Skip to content
This repository was archived by the owner on May 28, 2025. It is now read-only.

Commit 099e716

Browse files
committed
Factor out tt pushes.
1 parent e3df96c commit 099e716

File tree

1 file changed

+5
-6
lines changed

1 file changed

+5
-6
lines changed

compiler/rustc_expand/src/mbe/transcribe.rs

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -250,26 +250,25 @@ pub(super) fn transcribe<'a>(
250250
// the meta-var.
251251
let ident = MacroRulesNormalizedIdent::new(original_ident);
252252
if let Some(cur_matched) = lookup_cur_matched(ident, interp, &repeats) {
253-
match cur_matched {
253+
let tt = match cur_matched {
254254
MatchedTokenTree(tt) => {
255255
// `tt`s are emitted into the output stream directly as "raw tokens",
256256
// without wrapping them into groups.
257-
let tt = maybe_use_metavar_location(cx, &stack, sp, tt, &mut marker);
258-
result.push(tt);
257+
maybe_use_metavar_location(cx, &stack, sp, tt, &mut marker)
259258
}
260259
MatchedNonterminal(nt) => {
261260
// Other variables are emitted into the output stream as groups with
262261
// `Delimiter::Invisible` to maintain parsing priorities.
263262
// `Interpolated` is currently used for such groups in rustc parser.
264263
marker.visit_span(&mut sp);
265-
result
266-
.push(TokenTree::token_alone(token::Interpolated(nt.clone()), sp));
264+
TokenTree::token_alone(token::Interpolated(nt.clone()), sp)
267265
}
268266
MatchedSeq(..) => {
269267
// We were unable to descend far enough. This is an error.
270268
return Err(cx.dcx().create_err(VarStillRepeating { span: sp, ident }));
271269
}
272-
}
270+
};
271+
result.push(tt)
273272
} else {
274273
// If we aren't able to match the meta-var, we push it back into the result but
275274
// with modified syntax context. (I believe this supports nested macros).

0 commit comments

Comments
 (0)