Factor out tt
pushes.
This commit is contained in:
parent
e3df96cfda
commit
099e716502
1 changed files with 5 additions and 6 deletions
|
@ -250,26 +250,25 @@ pub(super) fn transcribe<'a>(
|
||||||
// the meta-var.
|
// the meta-var.
|
||||||
let ident = MacroRulesNormalizedIdent::new(original_ident);
|
let ident = MacroRulesNormalizedIdent::new(original_ident);
|
||||||
if let Some(cur_matched) = lookup_cur_matched(ident, interp, &repeats) {
|
if let Some(cur_matched) = lookup_cur_matched(ident, interp, &repeats) {
|
||||||
match cur_matched {
|
let tt = match cur_matched {
|
||||||
MatchedTokenTree(tt) => {
|
MatchedTokenTree(tt) => {
|
||||||
// `tt`s are emitted into the output stream directly as "raw tokens",
|
// `tt`s are emitted into the output stream directly as "raw tokens",
|
||||||
// without wrapping them into groups.
|
// without wrapping them into groups.
|
||||||
let tt = maybe_use_metavar_location(cx, &stack, sp, tt, &mut marker);
|
maybe_use_metavar_location(cx, &stack, sp, tt, &mut marker)
|
||||||
result.push(tt);
|
|
||||||
}
|
}
|
||||||
MatchedNonterminal(nt) => {
|
MatchedNonterminal(nt) => {
|
||||||
// Other variables are emitted into the output stream as groups with
|
// Other variables are emitted into the output stream as groups with
|
||||||
// `Delimiter::Invisible` to maintain parsing priorities.
|
// `Delimiter::Invisible` to maintain parsing priorities.
|
||||||
// `Interpolated` is currently used for such groups in rustc parser.
|
// `Interpolated` is currently used for such groups in rustc parser.
|
||||||
marker.visit_span(&mut sp);
|
marker.visit_span(&mut sp);
|
||||||
result
|
TokenTree::token_alone(token::Interpolated(nt.clone()), sp)
|
||||||
.push(TokenTree::token_alone(token::Interpolated(nt.clone()), sp));
|
|
||||||
}
|
}
|
||||||
MatchedSeq(..) => {
|
MatchedSeq(..) => {
|
||||||
// We were unable to descend far enough. This is an error.
|
// We were unable to descend far enough. This is an error.
|
||||||
return Err(cx.dcx().create_err(VarStillRepeating { span: sp, ident }));
|
return Err(cx.dcx().create_err(VarStillRepeating { span: sp, ident }));
|
||||||
}
|
}
|
||||||
}
|
};
|
||||||
|
result.push(tt)
|
||||||
} else {
|
} else {
|
||||||
// If we aren't able to match the meta-var, we push it back into the result but
|
// If we aren't able to match the meta-var, we push it back into the result but
|
||||||
// with modified syntax context. (I believe this supports nested macros).
|
// with modified syntax context. (I believe this supports nested macros).
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue