Function rustc_expand::mbe::transcribe::lockstep_iter_size
source · [−]fn lockstep_iter_size(
tree: &TokenTree,
interpolations: &FxHashMap<MacroRulesNormalizedIdent, NamedMatch>,
repeats: &[(usize, usize)]
) -> LockstepIterSize
Expand description
Given a tree
, make sure that all sequences have the same length as the matches for the
appropriate meta-vars in interpolations
.
Note that if repeats
does not match the exact correct depth of a meta-var,
lookup_cur_matched
will return None
, which is why this still works even in the presence of
multiple nested matcher sequences.
Example: $($($x $y)+*);+
– we need to make sure that x
and y
repeat the same amount as
each other at the given depth when the macro was invoked. If they don’t it might mean they were
declared at unequal depths or there was a compile bug. For example, if we have 3 repetitions of
the outer sequence and 4 repetitions of the inner sequence for x
, we should have the same for
y
; otherwise, we can’t transcribe them both at the given depth.