From 0dab0763586bdcc131d775033d010495a7bacc60 Mon Sep 17 00:00:00 2001 From: Vadim Petrochenkov Date: Thu, 7 Jan 2021 16:43:22 +0300 Subject: [PATCH] rustc_parse: Better spans for synthesized token streams --- compiler/rustc_ast/src/token.rs | 2 +- compiler/rustc_ast_lowering/src/lib.rs | 10 +- compiler/rustc_expand/src/base.rs | 2 +- compiler/rustc_expand/src/expand.rs | 1 - compiler/rustc_expand/src/proc_macro.rs | 7 +- .../rustc_expand/src/proc_macro_server.rs | 2 +- compiler/rustc_parse/src/lib.rs | 20 +- .../proc-macro/issue-75930-derive-cfg.stdout | 256 +++++++++--------- .../issue-78675-captured-inner-attrs.stdout | 18 +- 9 files changed, 151 insertions(+), 167 deletions(-) diff --git a/compiler/rustc_ast/src/token.rs b/compiler/rustc_ast/src/token.rs index b311f9fdcb966..90bfb01d6c791 100644 --- a/compiler/rustc_ast/src/token.rs +++ b/compiler/rustc_ast/src/token.rs @@ -771,7 +771,7 @@ impl fmt::Display for NonterminalKind { } impl Nonterminal { - fn span(&self) -> Span { + pub fn span(&self) -> Span { match self { NtItem(item) => item.span, NtBlock(block) => block.span, diff --git a/compiler/rustc_ast_lowering/src/lib.rs b/compiler/rustc_ast_lowering/src/lib.rs index fe96e1c5c04e2..ab9861b85ab03 100644 --- a/compiler/rustc_ast_lowering/src/lib.rs +++ b/compiler/rustc_ast_lowering/src/lib.rs @@ -206,8 +206,7 @@ pub trait ResolverAstLowering { ) -> LocalDefId; } -type NtToTokenstream = - fn(&Nonterminal, &ParseSess, Span, CanSynthesizeMissingTokens) -> TokenStream; +type NtToTokenstream = fn(&Nonterminal, &ParseSess, CanSynthesizeMissingTokens) -> TokenStream; /// Context of `impl Trait` in code, which determines whether it is allowed in an HIR subtree, /// and if so, what meaning it has. @@ -417,12 +416,7 @@ impl<'a> TokenStreamLowering<'a> { fn lower_token(&mut self, token: Token) -> TokenStream { match token.kind { token::Interpolated(nt) => { - let tts = (self.nt_to_tokenstream)( - &nt, - self.parse_sess, - token.span, - self.synthesize_tokens, - ); + let tts = (self.nt_to_tokenstream)(&nt, self.parse_sess, self.synthesize_tokens); TokenTree::Delimited( DelimSpan::from_single(token.span), DelimToken::NoDelim, diff --git a/compiler/rustc_expand/src/base.rs b/compiler/rustc_expand/src/base.rs index 887e12b46f621..b2ba720e0d735 100644 --- a/compiler/rustc_expand/src/base.rs +++ b/compiler/rustc_expand/src/base.rs @@ -141,7 +141,7 @@ impl Annotatable { } crate fn into_tokens(self, sess: &ParseSess) -> TokenStream { - nt_to_tokenstream(&self.into_nonterminal(), sess, DUMMY_SP, CanSynthesizeMissingTokens::No) + nt_to_tokenstream(&self.into_nonterminal(), sess, CanSynthesizeMissingTokens::No) } pub fn expect_item(self) -> P { diff --git a/compiler/rustc_expand/src/expand.rs b/compiler/rustc_expand/src/expand.rs index 1453627f6e1b1..fa80a20dc8bb7 100644 --- a/compiler/rustc_expand/src/expand.rs +++ b/compiler/rustc_expand/src/expand.rs @@ -743,7 +743,6 @@ impl<'a, 'b> MacroExpander<'a, 'b> { AttrStyle::Inner => rustc_parse::fake_token_stream( &self.cx.sess.parse_sess, &item.into_nonterminal(), - span, ), }; let attr_item = attr.unwrap_normal_item(); diff --git a/compiler/rustc_expand/src/proc_macro.rs b/compiler/rustc_expand/src/proc_macro.rs index e8e098b621295..02129e9b5e548 100644 --- a/compiler/rustc_expand/src/proc_macro.rs +++ b/compiler/rustc_expand/src/proc_macro.rs @@ -94,12 +94,7 @@ impl MultiItemModifier for ProcMacroDerive { let input = if item.pretty_printing_compatibility_hack() { TokenTree::token(token::Interpolated(Lrc::new(item)), DUMMY_SP).into() } else { - nt_to_tokenstream( - &item, - &ecx.sess.parse_sess, - DUMMY_SP, - CanSynthesizeMissingTokens::Yes, - ) + nt_to_tokenstream(&item, &ecx.sess.parse_sess, CanSynthesizeMissingTokens::Yes) }; let server = proc_macro_server::Rustc::new(ecx); diff --git a/compiler/rustc_expand/src/proc_macro_server.rs b/compiler/rustc_expand/src/proc_macro_server.rs index 02ae842675f37..b6195d3bbc4a6 100644 --- a/compiler/rustc_expand/src/proc_macro_server.rs +++ b/compiler/rustc_expand/src/proc_macro_server.rs @@ -179,7 +179,7 @@ impl FromInternal<(TreeAndSpacing, &'_ ParseSess, &'_ mut Vec)> { TokenTree::Ident(Ident::new(sess, name.name, is_raw, name.span)) } else { - let stream = nt_to_tokenstream(&nt, sess, span, CanSynthesizeMissingTokens::No); + let stream = nt_to_tokenstream(&nt, sess, CanSynthesizeMissingTokens::No); TokenTree::Group(Group { delimiter: Delimiter::None, stream, diff --git a/compiler/rustc_parse/src/lib.rs b/compiler/rustc_parse/src/lib.rs index 9abffbacfc3b3..4fa9768febb36 100644 --- a/compiler/rustc_parse/src/lib.rs +++ b/compiler/rustc_parse/src/lib.rs @@ -236,7 +236,6 @@ pub fn parse_in<'a, T>( pub fn nt_to_tokenstream( nt: &Nonterminal, sess: &ParseSess, - span: Span, synthesize_tokens: CanSynthesizeMissingTokens, ) -> TokenStream { // A `Nonterminal` is often a parsed AST item. At this point we now @@ -256,11 +255,9 @@ pub fn nt_to_tokenstream( |tokens: Option<&LazyTokenStream>| tokens.as_ref().map(|t| t.create_token_stream()); let tokens = match *nt { - Nonterminal::NtItem(ref item) => { - prepend_attrs(sess, &item.attrs, nt, span, item.tokens.as_ref()) - } + Nonterminal::NtItem(ref item) => prepend_attrs(sess, &item.attrs, nt, item.tokens.as_ref()), Nonterminal::NtBlock(ref block) => convert_tokens(block.tokens.as_ref()), - Nonterminal::NtStmt(ref stmt) => prepend_attrs(sess, stmt.attrs(), nt, span, stmt.tokens()), + Nonterminal::NtStmt(ref stmt) => prepend_attrs(sess, stmt.attrs(), nt, stmt.tokens()), Nonterminal::NtPat(ref pat) => convert_tokens(pat.tokens.as_ref()), Nonterminal::NtTy(ref ty) => convert_tokens(ty.tokens.as_ref()), Nonterminal::NtIdent(ident, is_raw) => { @@ -277,31 +274,30 @@ pub fn nt_to_tokenstream( if expr.tokens.is_none() { debug!("missing tokens for expr {:?}", expr); } - prepend_attrs(sess, &expr.attrs, nt, span, expr.tokens.as_ref()) + prepend_attrs(sess, &expr.attrs, nt, expr.tokens.as_ref()) } }; if let Some(tokens) = tokens { return tokens; } else if matches!(synthesize_tokens, CanSynthesizeMissingTokens::Yes) { - return fake_token_stream(sess, nt, span); + return fake_token_stream(sess, nt); } else { let pretty = rustc_ast_pretty::pprust::nonterminal_to_string_no_extra_parens(&nt); - panic!("Missing tokens at {:?} for nt {:?}", span, pretty); + panic!("Missing tokens for nt {:?}", pretty); } } -pub fn fake_token_stream(sess: &ParseSess, nt: &Nonterminal, span: Span) -> TokenStream { +pub fn fake_token_stream(sess: &ParseSess, nt: &Nonterminal) -> TokenStream { let source = pprust::nonterminal_to_string(nt); let filename = FileName::macro_expansion_source_code(&source); - parse_stream_from_source_str(filename, source, sess, Some(span)) + parse_stream_from_source_str(filename, source, sess, Some(nt.span())) } fn prepend_attrs( sess: &ParseSess, attrs: &[ast::Attribute], nt: &Nonterminal, - span: Span, tokens: Option<&tokenstream::LazyTokenStream>, ) -> Option { if attrs.is_empty() { @@ -312,7 +308,7 @@ fn prepend_attrs( // FIXME: Correctly handle tokens for inner attributes. // For now, we fall back to reparsing the original AST node if attr.style == ast::AttrStyle::Inner { - return Some(fake_token_stream(sess, nt, span)); + return Some(fake_token_stream(sess, nt)); } builder.push(attr.tokens()); } diff --git a/src/test/ui/proc-macro/issue-75930-derive-cfg.stdout b/src/test/ui/proc-macro/issue-75930-derive-cfg.stdout index 4c0810217bf33..5f513684cfa6f 100644 --- a/src/test/ui/proc-macro/issue-75930-derive-cfg.stdout +++ b/src/test/ui/proc-macro/issue-75930-derive-cfg.stdout @@ -1211,141 +1211,141 @@ PRINT-DERIVE INPUT (DEBUG): TokenStream [ Punct { ch: '#', spacing: Alone, - span: $DIR/issue-75930-derive-cfg.rs:1:1: 1:1 (#0), + span: $DIR/issue-75930-derive-cfg.rs:21:1: 64:2 (#0), }, Group { delimiter: Bracket, stream: TokenStream [ Ident { ident: "allow", - span: $DIR/issue-75930-derive-cfg.rs:1:1: 1:1 (#0), + span: $DIR/issue-75930-derive-cfg.rs:21:1: 64:2 (#0), }, Group { delimiter: Parenthesis, stream: TokenStream [ Ident { ident: "dead_code", - span: $DIR/issue-75930-derive-cfg.rs:1:1: 1:1 (#0), + span: $DIR/issue-75930-derive-cfg.rs:21:1: 64:2 (#0), }, ], - span: $DIR/issue-75930-derive-cfg.rs:1:1: 1:1 (#0), + span: $DIR/issue-75930-derive-cfg.rs:21:1: 64:2 (#0), }, ], - span: $DIR/issue-75930-derive-cfg.rs:1:1: 1:1 (#0), + span: $DIR/issue-75930-derive-cfg.rs:21:1: 64:2 (#0), }, Punct { ch: '#', spacing: Alone, - span: $DIR/issue-75930-derive-cfg.rs:1:1: 1:1 (#0), + span: $DIR/issue-75930-derive-cfg.rs:21:1: 64:2 (#0), }, Group { delimiter: Bracket, stream: TokenStream [ Ident { ident: "print_helper", - span: $DIR/issue-75930-derive-cfg.rs:1:1: 1:1 (#0), + span: $DIR/issue-75930-derive-cfg.rs:21:1: 64:2 (#0), }, Group { delimiter: Parenthesis, stream: TokenStream [ Ident { ident: "b", - span: $DIR/issue-75930-derive-cfg.rs:1:1: 1:1 (#0), + span: $DIR/issue-75930-derive-cfg.rs:21:1: 64:2 (#0), }, ], - span: $DIR/issue-75930-derive-cfg.rs:1:1: 1:1 (#0), + span: $DIR/issue-75930-derive-cfg.rs:21:1: 64:2 (#0), }, ], - span: $DIR/issue-75930-derive-cfg.rs:1:1: 1:1 (#0), + span: $DIR/issue-75930-derive-cfg.rs:21:1: 64:2 (#0), }, Punct { ch: '#', spacing: Alone, - span: $DIR/issue-75930-derive-cfg.rs:1:1: 1:1 (#0), + span: $DIR/issue-75930-derive-cfg.rs:21:1: 64:2 (#0), }, Group { delimiter: Bracket, stream: TokenStream [ Ident { ident: "print_helper", - span: $DIR/issue-75930-derive-cfg.rs:1:1: 1:1 (#0), + span: $DIR/issue-75930-derive-cfg.rs:21:1: 64:2 (#0), }, Group { delimiter: Parenthesis, stream: TokenStream [ Ident { ident: "a", - span: $DIR/issue-75930-derive-cfg.rs:1:1: 1:1 (#0), + span: $DIR/issue-75930-derive-cfg.rs:21:1: 64:2 (#0), }, ], - span: $DIR/issue-75930-derive-cfg.rs:1:1: 1:1 (#0), + span: $DIR/issue-75930-derive-cfg.rs:21:1: 64:2 (#0), }, ], - span: $DIR/issue-75930-derive-cfg.rs:1:1: 1:1 (#0), + span: $DIR/issue-75930-derive-cfg.rs:21:1: 64:2 (#0), }, Ident { ident: "struct", - span: $DIR/issue-75930-derive-cfg.rs:1:1: 1:1 (#0), + span: $DIR/issue-75930-derive-cfg.rs:21:1: 64:2 (#0), }, Ident { ident: "Foo", - span: $DIR/issue-75930-derive-cfg.rs:1:1: 1:1 (#0), + span: $DIR/issue-75930-derive-cfg.rs:21:1: 64:2 (#0), }, Punct { ch: '<', spacing: Alone, - span: $DIR/issue-75930-derive-cfg.rs:1:1: 1:1 (#0), + span: $DIR/issue-75930-derive-cfg.rs:21:1: 64:2 (#0), }, Ident { ident: "B", - span: $DIR/issue-75930-derive-cfg.rs:1:1: 1:1 (#0), + span: $DIR/issue-75930-derive-cfg.rs:21:1: 64:2 (#0), }, Punct { ch: '>', spacing: Alone, - span: $DIR/issue-75930-derive-cfg.rs:1:1: 1:1 (#0), + span: $DIR/issue-75930-derive-cfg.rs:21:1: 64:2 (#0), }, Group { delimiter: Brace, stream: TokenStream [ Ident { ident: "second", - span: $DIR/issue-75930-derive-cfg.rs:1:1: 1:1 (#0), + span: $DIR/issue-75930-derive-cfg.rs:21:1: 64:2 (#0), }, Punct { ch: ':', spacing: Alone, - span: $DIR/issue-75930-derive-cfg.rs:1:1: 1:1 (#0), + span: $DIR/issue-75930-derive-cfg.rs:21:1: 64:2 (#0), }, Ident { ident: "bool", - span: $DIR/issue-75930-derive-cfg.rs:1:1: 1:1 (#0), + span: $DIR/issue-75930-derive-cfg.rs:21:1: 64:2 (#0), }, Punct { ch: ',', spacing: Alone, - span: $DIR/issue-75930-derive-cfg.rs:1:1: 1:1 (#0), + span: $DIR/issue-75930-derive-cfg.rs:21:1: 64:2 (#0), }, Ident { ident: "third", - span: $DIR/issue-75930-derive-cfg.rs:1:1: 1:1 (#0), + span: $DIR/issue-75930-derive-cfg.rs:21:1: 64:2 (#0), }, Punct { ch: ':', spacing: Alone, - span: $DIR/issue-75930-derive-cfg.rs:1:1: 1:1 (#0), + span: $DIR/issue-75930-derive-cfg.rs:21:1: 64:2 (#0), }, Group { delimiter: Bracket, stream: TokenStream [ Ident { ident: "u8", - span: $DIR/issue-75930-derive-cfg.rs:1:1: 1:1 (#0), + span: $DIR/issue-75930-derive-cfg.rs:21:1: 64:2 (#0), }, Punct { ch: ';', spacing: Alone, - span: $DIR/issue-75930-derive-cfg.rs:1:1: 1:1 (#0), + span: $DIR/issue-75930-derive-cfg.rs:21:1: 64:2 (#0), }, Group { delimiter: Brace, @@ -1353,58 +1353,58 @@ PRINT-DERIVE INPUT (DEBUG): TokenStream [ Punct { ch: '#', spacing: Alone, - span: $DIR/issue-75930-derive-cfg.rs:1:1: 1:1 (#0), + span: $DIR/issue-75930-derive-cfg.rs:21:1: 64:2 (#0), }, Group { delimiter: Bracket, stream: TokenStream [ Ident { ident: "cfg", - span: $DIR/issue-75930-derive-cfg.rs:1:1: 1:1 (#0), + span: $DIR/issue-75930-derive-cfg.rs:21:1: 64:2 (#0), }, Group { delimiter: Parenthesis, stream: TokenStream [ Ident { ident: "not", - span: $DIR/issue-75930-derive-cfg.rs:1:1: 1:1 (#0), + span: $DIR/issue-75930-derive-cfg.rs:21:1: 64:2 (#0), }, Group { delimiter: Parenthesis, stream: TokenStream [ Ident { ident: "FALSE", - span: $DIR/issue-75930-derive-cfg.rs:1:1: 1:1 (#0), + span: $DIR/issue-75930-derive-cfg.rs:21:1: 64:2 (#0), }, ], - span: $DIR/issue-75930-derive-cfg.rs:1:1: 1:1 (#0), + span: $DIR/issue-75930-derive-cfg.rs:21:1: 64:2 (#0), }, ], - span: $DIR/issue-75930-derive-cfg.rs:1:1: 1:1 (#0), + span: $DIR/issue-75930-derive-cfg.rs:21:1: 64:2 (#0), }, ], - span: $DIR/issue-75930-derive-cfg.rs:1:1: 1:1 (#0), + span: $DIR/issue-75930-derive-cfg.rs:21:1: 64:2 (#0), }, Ident { ident: "struct", - span: $DIR/issue-75930-derive-cfg.rs:1:1: 1:1 (#0), + span: $DIR/issue-75930-derive-cfg.rs:21:1: 64:2 (#0), }, Ident { ident: "Inner", - span: $DIR/issue-75930-derive-cfg.rs:1:1: 1:1 (#0), + span: $DIR/issue-75930-derive-cfg.rs:21:1: 64:2 (#0), }, Punct { ch: ';', spacing: Alone, - span: $DIR/issue-75930-derive-cfg.rs:1:1: 1:1 (#0), + span: $DIR/issue-75930-derive-cfg.rs:21:1: 64:2 (#0), }, Ident { ident: "match", - span: $DIR/issue-75930-derive-cfg.rs:1:1: 1:1 (#0), + span: $DIR/issue-75930-derive-cfg.rs:21:1: 64:2 (#0), }, Ident { ident: "true", - span: $DIR/issue-75930-derive-cfg.rs:1:1: 1:1 (#0), + span: $DIR/issue-75930-derive-cfg.rs:21:1: 64:2 (#0), }, Group { delimiter: Brace, @@ -1412,146 +1412,146 @@ PRINT-DERIVE INPUT (DEBUG): TokenStream [ Punct { ch: '#', spacing: Alone, - span: $DIR/issue-75930-derive-cfg.rs:1:1: 1:1 (#0), + span: $DIR/issue-75930-derive-cfg.rs:21:1: 64:2 (#0), }, Group { delimiter: Bracket, stream: TokenStream [ Ident { ident: "allow", - span: $DIR/issue-75930-derive-cfg.rs:1:1: 1:1 (#0), + span: $DIR/issue-75930-derive-cfg.rs:21:1: 64:2 (#0), }, Group { delimiter: Parenthesis, stream: TokenStream [ Ident { ident: "warnings", - span: $DIR/issue-75930-derive-cfg.rs:1:1: 1:1 (#0), + span: $DIR/issue-75930-derive-cfg.rs:21:1: 64:2 (#0), }, ], - span: $DIR/issue-75930-derive-cfg.rs:1:1: 1:1 (#0), + span: $DIR/issue-75930-derive-cfg.rs:21:1: 64:2 (#0), }, ], - span: $DIR/issue-75930-derive-cfg.rs:1:1: 1:1 (#0), + span: $DIR/issue-75930-derive-cfg.rs:21:1: 64:2 (#0), }, Ident { ident: "false", - span: $DIR/issue-75930-derive-cfg.rs:1:1: 1:1 (#0), + span: $DIR/issue-75930-derive-cfg.rs:21:1: 64:2 (#0), }, Punct { ch: '=', spacing: Joint, - span: $DIR/issue-75930-derive-cfg.rs:1:1: 1:1 (#0), + span: $DIR/issue-75930-derive-cfg.rs:21:1: 64:2 (#0), }, Punct { ch: '>', spacing: Alone, - span: $DIR/issue-75930-derive-cfg.rs:1:1: 1:1 (#0), + span: $DIR/issue-75930-derive-cfg.rs:21:1: 64:2 (#0), }, Group { delimiter: Brace, stream: TokenStream [], - span: $DIR/issue-75930-derive-cfg.rs:1:1: 1:1 (#0), + span: $DIR/issue-75930-derive-cfg.rs:21:1: 64:2 (#0), }, Ident { ident: "_", - span: $DIR/issue-75930-derive-cfg.rs:1:1: 1:1 (#0), + span: $DIR/issue-75930-derive-cfg.rs:21:1: 64:2 (#0), }, Punct { ch: '=', spacing: Joint, - span: $DIR/issue-75930-derive-cfg.rs:1:1: 1:1 (#0), + span: $DIR/issue-75930-derive-cfg.rs:21:1: 64:2 (#0), }, Punct { ch: '>', spacing: Alone, - span: $DIR/issue-75930-derive-cfg.rs:1:1: 1:1 (#0), + span: $DIR/issue-75930-derive-cfg.rs:21:1: 64:2 (#0), }, Group { delimiter: Brace, stream: TokenStream [], - span: $DIR/issue-75930-derive-cfg.rs:1:1: 1:1 (#0), + span: $DIR/issue-75930-derive-cfg.rs:21:1: 64:2 (#0), }, ], - span: $DIR/issue-75930-derive-cfg.rs:1:1: 1:1 (#0), + span: $DIR/issue-75930-derive-cfg.rs:21:1: 64:2 (#0), }, Punct { ch: ';', spacing: Alone, - span: $DIR/issue-75930-derive-cfg.rs:1:1: 1:1 (#0), + span: $DIR/issue-75930-derive-cfg.rs:21:1: 64:2 (#0), }, Punct { ch: '#', spacing: Alone, - span: $DIR/issue-75930-derive-cfg.rs:1:1: 1:1 (#0), + span: $DIR/issue-75930-derive-cfg.rs:21:1: 64:2 (#0), }, Group { delimiter: Bracket, stream: TokenStream [ Ident { ident: "print_helper", - span: $DIR/issue-75930-derive-cfg.rs:1:1: 1:1 (#0), + span: $DIR/issue-75930-derive-cfg.rs:21:1: 64:2 (#0), }, Group { delimiter: Parenthesis, stream: TokenStream [ Ident { ident: "c", - span: $DIR/issue-75930-derive-cfg.rs:1:1: 1:1 (#0), + span: $DIR/issue-75930-derive-cfg.rs:21:1: 64:2 (#0), }, ], - span: $DIR/issue-75930-derive-cfg.rs:1:1: 1:1 (#0), + span: $DIR/issue-75930-derive-cfg.rs:21:1: 64:2 (#0), }, ], - span: $DIR/issue-75930-derive-cfg.rs:1:1: 1:1 (#0), + span: $DIR/issue-75930-derive-cfg.rs:21:1: 64:2 (#0), }, Punct { ch: '#', spacing: Alone, - span: $DIR/issue-75930-derive-cfg.rs:1:1: 1:1 (#0), + span: $DIR/issue-75930-derive-cfg.rs:21:1: 64:2 (#0), }, Group { delimiter: Bracket, stream: TokenStream [ Ident { ident: "cfg", - span: $DIR/issue-75930-derive-cfg.rs:1:1: 1:1 (#0), + span: $DIR/issue-75930-derive-cfg.rs:21:1: 64:2 (#0), }, Group { delimiter: Parenthesis, stream: TokenStream [ Ident { ident: "not", - span: $DIR/issue-75930-derive-cfg.rs:1:1: 1:1 (#0), + span: $DIR/issue-75930-derive-cfg.rs:21:1: 64:2 (#0), }, Group { delimiter: Parenthesis, stream: TokenStream [ Ident { ident: "FALSE", - span: $DIR/issue-75930-derive-cfg.rs:1:1: 1:1 (#0), + span: $DIR/issue-75930-derive-cfg.rs:21:1: 64:2 (#0), }, ], - span: $DIR/issue-75930-derive-cfg.rs:1:1: 1:1 (#0), + span: $DIR/issue-75930-derive-cfg.rs:21:1: 64:2 (#0), }, ], - span: $DIR/issue-75930-derive-cfg.rs:1:1: 1:1 (#0), + span: $DIR/issue-75930-derive-cfg.rs:21:1: 64:2 (#0), }, ], - span: $DIR/issue-75930-derive-cfg.rs:1:1: 1:1 (#0), + span: $DIR/issue-75930-derive-cfg.rs:21:1: 64:2 (#0), }, Ident { ident: "fn", - span: $DIR/issue-75930-derive-cfg.rs:1:1: 1:1 (#0), + span: $DIR/issue-75930-derive-cfg.rs:21:1: 64:2 (#0), }, Ident { ident: "kept_fn", - span: $DIR/issue-75930-derive-cfg.rs:1:1: 1:1 (#0), + span: $DIR/issue-75930-derive-cfg.rs:21:1: 64:2 (#0), }, Group { delimiter: Parenthesis, stream: TokenStream [], - span: $DIR/issue-75930-derive-cfg.rs:1:1: 1:1 (#0), + span: $DIR/issue-75930-derive-cfg.rs:21:1: 64:2 (#0), }, Group { delimiter: Brace, @@ -1559,82 +1559,82 @@ PRINT-DERIVE INPUT (DEBUG): TokenStream [ Punct { ch: '#', spacing: Joint, - span: $DIR/issue-75930-derive-cfg.rs:1:1: 1:1 (#0), + span: $DIR/issue-75930-derive-cfg.rs:21:1: 64:2 (#0), }, Punct { ch: '!', spacing: Alone, - span: $DIR/issue-75930-derive-cfg.rs:1:1: 1:1 (#0), + span: $DIR/issue-75930-derive-cfg.rs:21:1: 64:2 (#0), }, Group { delimiter: Bracket, stream: TokenStream [ Ident { ident: "cfg", - span: $DIR/issue-75930-derive-cfg.rs:1:1: 1:1 (#0), + span: $DIR/issue-75930-derive-cfg.rs:21:1: 64:2 (#0), }, Group { delimiter: Parenthesis, stream: TokenStream [ Ident { ident: "not", - span: $DIR/issue-75930-derive-cfg.rs:1:1: 1:1 (#0), + span: $DIR/issue-75930-derive-cfg.rs:21:1: 64:2 (#0), }, Group { delimiter: Parenthesis, stream: TokenStream [ Ident { ident: "FALSE", - span: $DIR/issue-75930-derive-cfg.rs:1:1: 1:1 (#0), + span: $DIR/issue-75930-derive-cfg.rs:21:1: 64:2 (#0), }, ], - span: $DIR/issue-75930-derive-cfg.rs:1:1: 1:1 (#0), + span: $DIR/issue-75930-derive-cfg.rs:21:1: 64:2 (#0), }, ], - span: $DIR/issue-75930-derive-cfg.rs:1:1: 1:1 (#0), + span: $DIR/issue-75930-derive-cfg.rs:21:1: 64:2 (#0), }, ], - span: $DIR/issue-75930-derive-cfg.rs:1:1: 1:1 (#0), + span: $DIR/issue-75930-derive-cfg.rs:21:1: 64:2 (#0), }, Ident { ident: "let", - span: $DIR/issue-75930-derive-cfg.rs:1:1: 1:1 (#0), + span: $DIR/issue-75930-derive-cfg.rs:21:1: 64:2 (#0), }, Ident { ident: "my_val", - span: $DIR/issue-75930-derive-cfg.rs:1:1: 1:1 (#0), + span: $DIR/issue-75930-derive-cfg.rs:21:1: 64:2 (#0), }, Punct { ch: '=', spacing: Alone, - span: $DIR/issue-75930-derive-cfg.rs:1:1: 1:1 (#0), + span: $DIR/issue-75930-derive-cfg.rs:21:1: 64:2 (#0), }, Ident { ident: "true", - span: $DIR/issue-75930-derive-cfg.rs:1:1: 1:1 (#0), + span: $DIR/issue-75930-derive-cfg.rs:21:1: 64:2 (#0), }, Punct { ch: ';', spacing: Alone, - span: $DIR/issue-75930-derive-cfg.rs:1:1: 1:1 (#0), + span: $DIR/issue-75930-derive-cfg.rs:21:1: 64:2 (#0), }, ], - span: $DIR/issue-75930-derive-cfg.rs:1:1: 1:1 (#0), + span: $DIR/issue-75930-derive-cfg.rs:21:1: 64:2 (#0), }, Ident { ident: "enum", - span: $DIR/issue-75930-derive-cfg.rs:1:1: 1:1 (#0), + span: $DIR/issue-75930-derive-cfg.rs:21:1: 64:2 (#0), }, Ident { ident: "TupleEnum", - span: $DIR/issue-75930-derive-cfg.rs:1:1: 1:1 (#0), + span: $DIR/issue-75930-derive-cfg.rs:21:1: 64:2 (#0), }, Group { delimiter: Brace, stream: TokenStream [ Ident { ident: "Foo", - span: $DIR/issue-75930-derive-cfg.rs:1:1: 1:1 (#0), + span: $DIR/issue-75930-derive-cfg.rs:21:1: 64:2 (#0), }, Group { delimiter: Parenthesis, @@ -1642,69 +1642,69 @@ PRINT-DERIVE INPUT (DEBUG): TokenStream [ Punct { ch: '#', spacing: Alone, - span: $DIR/issue-75930-derive-cfg.rs:1:1: 1:1 (#0), + span: $DIR/issue-75930-derive-cfg.rs:21:1: 64:2 (#0), }, Group { delimiter: Bracket, stream: TokenStream [ Ident { ident: "cfg", - span: $DIR/issue-75930-derive-cfg.rs:1:1: 1:1 (#0), + span: $DIR/issue-75930-derive-cfg.rs:21:1: 64:2 (#0), }, Group { delimiter: Parenthesis, stream: TokenStream [ Ident { ident: "not", - span: $DIR/issue-75930-derive-cfg.rs:1:1: 1:1 (#0), + span: $DIR/issue-75930-derive-cfg.rs:21:1: 64:2 (#0), }, Group { delimiter: Parenthesis, stream: TokenStream [ Ident { ident: "FALSE", - span: $DIR/issue-75930-derive-cfg.rs:1:1: 1:1 (#0), + span: $DIR/issue-75930-derive-cfg.rs:21:1: 64:2 (#0), }, ], - span: $DIR/issue-75930-derive-cfg.rs:1:1: 1:1 (#0), + span: $DIR/issue-75930-derive-cfg.rs:21:1: 64:2 (#0), }, ], - span: $DIR/issue-75930-derive-cfg.rs:1:1: 1:1 (#0), + span: $DIR/issue-75930-derive-cfg.rs:21:1: 64:2 (#0), }, ], - span: $DIR/issue-75930-derive-cfg.rs:1:1: 1:1 (#0), + span: $DIR/issue-75930-derive-cfg.rs:21:1: 64:2 (#0), }, Ident { ident: "i32", - span: $DIR/issue-75930-derive-cfg.rs:1:1: 1:1 (#0), + span: $DIR/issue-75930-derive-cfg.rs:21:1: 64:2 (#0), }, Punct { ch: ',', spacing: Alone, - span: $DIR/issue-75930-derive-cfg.rs:1:1: 1:1 (#0), + span: $DIR/issue-75930-derive-cfg.rs:21:1: 64:2 (#0), }, Ident { ident: "u8", - span: $DIR/issue-75930-derive-cfg.rs:1:1: 1:1 (#0), + span: $DIR/issue-75930-derive-cfg.rs:21:1: 64:2 (#0), }, ], - span: $DIR/issue-75930-derive-cfg.rs:1:1: 1:1 (#0), + span: $DIR/issue-75930-derive-cfg.rs:21:1: 64:2 (#0), }, Punct { ch: ',', spacing: Alone, - span: $DIR/issue-75930-derive-cfg.rs:1:1: 1:1 (#0), + span: $DIR/issue-75930-derive-cfg.rs:21:1: 64:2 (#0), }, ], - span: $DIR/issue-75930-derive-cfg.rs:1:1: 1:1 (#0), + span: $DIR/issue-75930-derive-cfg.rs:21:1: 64:2 (#0), }, Ident { ident: "struct", - span: $DIR/issue-75930-derive-cfg.rs:1:1: 1:1 (#0), + span: $DIR/issue-75930-derive-cfg.rs:21:1: 64:2 (#0), }, Ident { ident: "TupleStruct", - span: $DIR/issue-75930-derive-cfg.rs:1:1: 1:1 (#0), + span: $DIR/issue-75930-derive-cfg.rs:21:1: 64:2 (#0), }, Group { delimiter: Parenthesis, @@ -1712,120 +1712,120 @@ PRINT-DERIVE INPUT (DEBUG): TokenStream [ Punct { ch: '#', spacing: Alone, - span: $DIR/issue-75930-derive-cfg.rs:1:1: 1:1 (#0), + span: $DIR/issue-75930-derive-cfg.rs:21:1: 64:2 (#0), }, Group { delimiter: Bracket, stream: TokenStream [ Ident { ident: "cfg", - span: $DIR/issue-75930-derive-cfg.rs:1:1: 1:1 (#0), + span: $DIR/issue-75930-derive-cfg.rs:21:1: 64:2 (#0), }, Group { delimiter: Parenthesis, stream: TokenStream [ Ident { ident: "not", - span: $DIR/issue-75930-derive-cfg.rs:1:1: 1:1 (#0), + span: $DIR/issue-75930-derive-cfg.rs:21:1: 64:2 (#0), }, Group { delimiter: Parenthesis, stream: TokenStream [ Ident { ident: "FALSE", - span: $DIR/issue-75930-derive-cfg.rs:1:1: 1:1 (#0), + span: $DIR/issue-75930-derive-cfg.rs:21:1: 64:2 (#0), }, ], - span: $DIR/issue-75930-derive-cfg.rs:1:1: 1:1 (#0), + span: $DIR/issue-75930-derive-cfg.rs:21:1: 64:2 (#0), }, ], - span: $DIR/issue-75930-derive-cfg.rs:1:1: 1:1 (#0), + span: $DIR/issue-75930-derive-cfg.rs:21:1: 64:2 (#0), }, ], - span: $DIR/issue-75930-derive-cfg.rs:1:1: 1:1 (#0), + span: $DIR/issue-75930-derive-cfg.rs:21:1: 64:2 (#0), }, Ident { ident: "i32", - span: $DIR/issue-75930-derive-cfg.rs:1:1: 1:1 (#0), + span: $DIR/issue-75930-derive-cfg.rs:21:1: 64:2 (#0), }, Punct { ch: ',', spacing: Alone, - span: $DIR/issue-75930-derive-cfg.rs:1:1: 1:1 (#0), + span: $DIR/issue-75930-derive-cfg.rs:21:1: 64:2 (#0), }, Ident { ident: "u8", - span: $DIR/issue-75930-derive-cfg.rs:1:1: 1:1 (#0), + span: $DIR/issue-75930-derive-cfg.rs:21:1: 64:2 (#0), }, ], - span: $DIR/issue-75930-derive-cfg.rs:1:1: 1:1 (#0), + span: $DIR/issue-75930-derive-cfg.rs:21:1: 64:2 (#0), }, Punct { ch: ';', spacing: Alone, - span: $DIR/issue-75930-derive-cfg.rs:1:1: 1:1 (#0), + span: $DIR/issue-75930-derive-cfg.rs:21:1: 64:2 (#0), }, Literal { kind: Integer, symbol: "0", suffix: None, - span: $DIR/issue-75930-derive-cfg.rs:1:1: 1:1 (#0), + span: $DIR/issue-75930-derive-cfg.rs:21:1: 64:2 (#0), }, ], - span: $DIR/issue-75930-derive-cfg.rs:1:1: 1:1 (#0), + span: $DIR/issue-75930-derive-cfg.rs:21:1: 64:2 (#0), }, ], - span: $DIR/issue-75930-derive-cfg.rs:1:1: 1:1 (#0), + span: $DIR/issue-75930-derive-cfg.rs:21:1: 64:2 (#0), }, Punct { ch: ',', spacing: Alone, - span: $DIR/issue-75930-derive-cfg.rs:1:1: 1:1 (#0), + span: $DIR/issue-75930-derive-cfg.rs:21:1: 64:2 (#0), }, Punct { ch: '#', spacing: Alone, - span: $DIR/issue-75930-derive-cfg.rs:1:1: 1:1 (#0), + span: $DIR/issue-75930-derive-cfg.rs:21:1: 64:2 (#0), }, Group { delimiter: Bracket, stream: TokenStream [ Ident { ident: "print_helper", - span: $DIR/issue-75930-derive-cfg.rs:1:1: 1:1 (#0), + span: $DIR/issue-75930-derive-cfg.rs:21:1: 64:2 (#0), }, Group { delimiter: Parenthesis, stream: TokenStream [ Ident { ident: "d", - span: $DIR/issue-75930-derive-cfg.rs:1:1: 1:1 (#0), + span: $DIR/issue-75930-derive-cfg.rs:21:1: 64:2 (#0), }, ], - span: $DIR/issue-75930-derive-cfg.rs:1:1: 1:1 (#0), + span: $DIR/issue-75930-derive-cfg.rs:21:1: 64:2 (#0), }, ], - span: $DIR/issue-75930-derive-cfg.rs:1:1: 1:1 (#0), + span: $DIR/issue-75930-derive-cfg.rs:21:1: 64:2 (#0), }, Ident { ident: "fourth", - span: $DIR/issue-75930-derive-cfg.rs:1:1: 1:1 (#0), + span: $DIR/issue-75930-derive-cfg.rs:21:1: 64:2 (#0), }, Punct { ch: ':', spacing: Alone, - span: $DIR/issue-75930-derive-cfg.rs:1:1: 1:1 (#0), + span: $DIR/issue-75930-derive-cfg.rs:21:1: 64:2 (#0), }, Ident { ident: "B", - span: $DIR/issue-75930-derive-cfg.rs:1:1: 1:1 (#0), + span: $DIR/issue-75930-derive-cfg.rs:21:1: 64:2 (#0), }, Punct { ch: ',', spacing: Alone, - span: $DIR/issue-75930-derive-cfg.rs:1:1: 1:1 (#0), + span: $DIR/issue-75930-derive-cfg.rs:21:1: 64:2 (#0), }, ], - span: $DIR/issue-75930-derive-cfg.rs:1:1: 1:1 (#0), + span: $DIR/issue-75930-derive-cfg.rs:21:1: 64:2 (#0), }, ] diff --git a/src/test/ui/proc-macro/issue-78675-captured-inner-attrs.stdout b/src/test/ui/proc-macro/issue-78675-captured-inner-attrs.stdout index c4ee44f654149..40da5aa93bfa8 100644 --- a/src/test/ui/proc-macro/issue-78675-captured-inner-attrs.stdout +++ b/src/test/ui/proc-macro/issue-78675-captured-inner-attrs.stdout @@ -34,11 +34,11 @@ PRINT-BANG INPUT (DEBUG): TokenStream [ stream: TokenStream [ Ident { ident: "mod", - span: $DIR/issue-78675-captured-inner-attrs.rs:22:13: 22:18 (#4), + span: $DIR/issue-78675-captured-inner-attrs.rs:27:5: 29:6 (#0), }, Ident { ident: "bar", - span: $DIR/issue-78675-captured-inner-attrs.rs:22:13: 22:18 (#4), + span: $DIR/issue-78675-captured-inner-attrs.rs:27:5: 29:6 (#0), }, Group { delimiter: Brace, @@ -46,36 +46,36 @@ PRINT-BANG INPUT (DEBUG): TokenStream [ Punct { ch: '#', spacing: Joint, - span: $DIR/issue-78675-captured-inner-attrs.rs:22:13: 22:18 (#4), + span: $DIR/issue-78675-captured-inner-attrs.rs:27:5: 29:6 (#0), }, Punct { ch: '!', spacing: Alone, - span: $DIR/issue-78675-captured-inner-attrs.rs:22:13: 22:18 (#4), + span: $DIR/issue-78675-captured-inner-attrs.rs:27:5: 29:6 (#0), }, Group { delimiter: Bracket, stream: TokenStream [ Ident { ident: "doc", - span: $DIR/issue-78675-captured-inner-attrs.rs:22:13: 22:18 (#4), + span: $DIR/issue-78675-captured-inner-attrs.rs:27:5: 29:6 (#0), }, Punct { ch: '=', spacing: Alone, - span: $DIR/issue-78675-captured-inner-attrs.rs:22:13: 22:18 (#4), + span: $DIR/issue-78675-captured-inner-attrs.rs:27:5: 29:6 (#0), }, Literal { kind: StrRaw(0), symbol: " Foo", suffix: None, - span: $DIR/issue-78675-captured-inner-attrs.rs:22:13: 22:18 (#4), + span: $DIR/issue-78675-captured-inner-attrs.rs:27:5: 29:6 (#0), }, ], - span: $DIR/issue-78675-captured-inner-attrs.rs:22:13: 22:18 (#4), + span: $DIR/issue-78675-captured-inner-attrs.rs:27:5: 29:6 (#0), }, ], - span: $DIR/issue-78675-captured-inner-attrs.rs:22:13: 22:18 (#4), + span: $DIR/issue-78675-captured-inner-attrs.rs:27:5: 29:6 (#0), }, ], span: $DIR/issue-78675-captured-inner-attrs.rs:22:13: 22:18 (#4),