@@ -232,17 +232,19 @@ pub(super) fn transcribe<'a>(
232232 // the meta-var.
233233 let ident = MacroRulesNormalizedIdent :: new ( orignal_ident) ;
234234 if let Some ( cur_matched) = lookup_cur_matched ( ident, interp, & repeats) {
235- if let MatchedNonterminal ( ref nt) = cur_matched {
236- // FIXME #2887: why do we apply a mark when matching a token tree meta-var
237- // (e.g. `$x:tt`), but not when we are matching any other type of token
238- // tree?
239- if let NtTT ( ref tt) = * * nt {
240- result. push ( tt. clone ( ) . into ( ) ) ;
235+ if let MatchedNonterminal ( nt) = cur_matched {
236+ let token = if let NtTT ( tt) = & * * nt {
237+ // `tt`s are emitted into the output stream directly as "raw tokens",
238+ // without wrapping them into groups.
239+ tt. clone ( )
241240 } else {
241+ // Other variables are emitted into the output stream as groups with
242+ // `Delimiter::None` to maintain parsing priorities.
243+ // `Interpolated` is currenty used for such groups in rustc parser.
242244 marker. visit_span ( & mut sp) ;
243- let token = TokenTree :: token ( token:: Interpolated ( nt. clone ( ) ) , sp) ;
244- result . push ( token . into ( ) ) ;
245- }
245+ TokenTree :: token ( token:: Interpolated ( nt. clone ( ) ) , sp)
246+ } ;
247+ result . push ( token . into ( ) ) ;
246248 } else {
247249 // We were unable to descend far enough. This is an error.
248250 return Err ( cx. struct_span_err (
0 commit comments