Skip to content

Commit 2e423c7

Browse files
committed
Remove MatcherPos::match_lo.
It's redundant w.r.t. other fields.
1 parent 21699c4 commit 2e423c7

File tree

1 file changed

+4
-10
lines changed

1 file changed

+4
-10
lines changed

compiler/rustc_expand/src/mbe/macro_parser.rs

Lines changed: 4 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -134,10 +134,6 @@ struct MatcherPos<'tt> {
134134
/// The number of sequences this mp is within.
135135
seq_depth: usize,
136136

137-
/// The position in `matches` of the first metavar in this (sub)matcher. Zero if there are
138-
/// no metavars.
139-
match_lo: usize,
140-
141137
/// The position in `matches` of the next metavar to be matched against the source token
142138
/// stream. Should not be used if there are no metavars.
143139
match_cur: usize,
@@ -152,7 +148,7 @@ struct MatcherPos<'tt> {
152148

153149
// This type is used a lot. Make sure it doesn't unintentionally get bigger.
154150
#[cfg(all(target_arch = "x86_64", target_pointer_width = "64"))]
155-
rustc_data_structures::static_assert_size!(MatcherPos<'_>, 104);
151+
rustc_data_structures::static_assert_size!(MatcherPos<'_>, 96);
156152

157153
impl<'tt> MatcherPos<'tt> {
158154
fn top_level(matcher: &'tt [TokenTree], empty_matches: Lrc<NamedMatchVec>) -> Self {
@@ -161,7 +157,6 @@ impl<'tt> MatcherPos<'tt> {
161157
idx: 0,
162158
matches: empty_matches,
163159
seq_depth: 0,
164-
match_lo: 0,
165160
match_cur: 0,
166161
stack: smallvec![],
167162
sequence: None,
@@ -178,14 +173,13 @@ impl<'tt> MatcherPos<'tt> {
178173
idx: 0,
179174
matches: parent.matches.clone(),
180175
seq_depth: parent.seq_depth,
181-
match_lo: parent.match_cur,
182176
match_cur: parent.match_cur,
183177
sequence: Some(MatcherPosSequence { parent, seq }),
184178
stack: smallvec![],
185179
};
186180
// Start with an empty vec for each metavar within the sequence. Note that `mp.seq_depth`
187181
// must have the parent's depth at this point for these `push_match` calls to work.
188-
for idx in mp.match_lo..mp.match_lo + seq.num_captures {
182+
for idx in mp.match_cur..mp.match_cur + seq.num_captures {
189183
mp.push_match(idx, MatchedSeq(empty_matches.clone()));
190184
}
191185
mp.seq_depth += 1;
@@ -554,7 +548,7 @@ impl<'tt> TtParser<'tt> {
554548
// is finished.
555549
let mut new_mp = sequence.parent.clone();
556550
new_mp.matches = mp.matches.clone();
557-
new_mp.match_cur = mp.match_lo + sequence.seq.num_captures;
551+
new_mp.match_cur = mp.match_cur;
558552
new_mp.idx += 1;
559553
self.cur_mps.push(new_mp);
560554
}
@@ -575,7 +569,7 @@ impl<'tt> TtParser<'tt> {
575569
// We don't need a separator. Move the "dot" back to the beginning of the
576570
// matcher and try to match again UNLESS we are only allowed to have _one_
577571
// repetition.
578-
mp.match_cur = mp.match_lo;
572+
mp.match_cur -= sequence.seq.num_captures;
579573
mp.idx = 0;
580574
self.cur_mps.push(mp);
581575
}

0 commit comments

Comments
 (0)