From d0f18de5b848ef861537d5c5b753ca2cbbebfe6e Mon Sep 17 00:00:00 2001 From: bjorn3 <17426603+bjorn3@users.noreply.github.com> Date: Wed, 29 May 2024 12:13:19 +0000 Subject: [PATCH 1/3] Stop emitting spans from proc macro compile time in quote expansion Before this commit if the proc_macro::quote!{} macro was used, the span of each token as written in the source of the proc macro itself would be saved in the crate metadata of the proc macro and then recovered at proc macro runtime to forward this to the macro expansion of the proc macro. This commit stops doing this and instead generates def-site spans for each token. This removes the only case where spans from the proc macro source have a semantic effect on the compilation of crates that use the proc macro. This makes it easier to stop requiring all dependencies of proc macros to be present when using the proc macro. And will make it easier to stop requiring a proc macro to be present when using a crate that used this proc macro internally but doesn't expose it as part of it's public api. The latter is necessary to be able to cross-compile tools that link against rustc internals without requiring to be built as part of rustc with the -Zdual-proc-macro hack. It may also enable using proc macros inside the standard library or it's dependencies without breaking cross-compilation. --- compiler/rustc_expand/src/base.rs | 6 +-- .../rustc_expand/src/proc_macro_server.rs | 43 ------------------- compiler/rustc_metadata/src/rmeta/decoder.rs | 9 ---- .../src/rmeta/decoder/cstore_impl.rs | 9 ---- compiler/rustc_metadata/src/rmeta/encoder.rs | 4 -- compiler/rustc_metadata/src/rmeta/mod.rs | 1 - compiler/rustc_resolve/src/macros.rs | 6 +-- compiler/rustc_session/src/parse.rs | 14 ------ library/proc_macro/src/bridge/mod.rs | 2 - library/proc_macro/src/lib.rs | 16 +------ library/proc_macro/src/quote.rs | 13 +----- 11 files changed, 5 insertions(+), 118 deletions(-) diff --git a/compiler/rustc_expand/src/base.rs b/compiler/rustc_expand/src/base.rs index 1928cfd90482b..6ef4655beebe2 100644 --- a/compiler/rustc_expand/src/base.rs +++ b/compiler/rustc_expand/src/base.rs @@ -23,7 +23,7 @@ use rustc_parse::parser::{ForceCollect, Parser}; use rustc_session::config::CollapseMacroDebuginfo; use rustc_session::parse::ParseSess; use rustc_session::{Limit, Session}; -use rustc_span::def_id::{CrateNum, DefId, LocalDefId}; +use rustc_span::def_id::{DefId, LocalDefId}; use rustc_span::edition::Edition; use rustc_span::hygiene::{AstPass, ExpnData, ExpnKind, LocalExpnId, MacroKind}; use rustc_span::source_map::SourceMap; @@ -1116,10 +1116,6 @@ pub trait ResolverExpand { path: &ast::Path, ) -> Result; - /// Decodes the proc-macro quoted span in the specified crate, with the specified id. - /// No caching is performed. - fn get_proc_macro_quoted_span(&self, krate: CrateNum, id: usize) -> Span; - /// The order of items in the HIR is unrelated to the order of /// items in the AST. However, we generate proc macro harnesses /// based on the AST order, and later refer to these harnesses diff --git a/compiler/rustc_expand/src/proc_macro_server.rs b/compiler/rustc_expand/src/proc_macro_server.rs index fd71f2ce948c8..316de163dd203 100644 --- a/compiler/rustc_expand/src/proc_macro_server.rs +++ b/compiler/rustc_expand/src/proc_macro_server.rs @@ -6,7 +6,6 @@ use rustc_ast::token; use rustc_ast::tokenstream::{self, DelimSpacing, Spacing, TokenStream}; use rustc_ast::util::literal::escape_byte_str_symbol; use rustc_ast_pretty::pprust; -use rustc_data_structures::fx::FxHashMap; use rustc_errors::{Diag, ErrorGuaranteed, MultiSpan, PResult}; use rustc_parse::lexer::nfc_normalize; use rustc_parse::parser::Parser; @@ -16,7 +15,6 @@ use rustc_proc_macro::bridge::{ }; use rustc_proc_macro::{Delimiter, Level}; use rustc_session::parse::ParseSess; -use rustc_span::def_id::CrateNum; use rustc_span::{BytePos, FileName, Pos, Span, Symbol, sym}; use smallvec::{SmallVec, smallvec}; @@ -432,8 +430,6 @@ pub(crate) struct Rustc<'a, 'b> { def_site: Span, call_site: Span, mixed_site: Span, - krate: CrateNum, - rebased_spans: FxHashMap, } impl<'a, 'b> Rustc<'a, 'b> { @@ -443,8 +439,6 @@ impl<'a, 'b> Rustc<'a, 'b> { def_site: ecx.with_def_site_ctxt(expn_data.def_site), call_site: ecx.with_call_site_ctxt(expn_data.call_site), mixed_site: ecx.with_mixed_site_ctxt(expn_data.call_site), - krate: expn_data.macro_def_id.unwrap().krate, - rebased_spans: FxHashMap::default(), ecx, } } @@ -788,43 +782,6 @@ impl server::Span for Rustc<'_, '_> { fn source_text(&mut self, span: Self::Span) -> Option { self.psess().source_map().span_to_snippet(span).ok() } - - /// Saves the provided span into the metadata of - /// *the crate we are currently compiling*, which must - /// be a proc-macro crate. This id can be passed to - /// `recover_proc_macro_span` when our current crate - /// is *run* as a proc-macro. - /// - /// Let's suppose that we have two crates - `my_client` - /// and `my_proc_macro`. The `my_proc_macro` crate - /// contains a procedural macro `my_macro`, which - /// is implemented as: `quote! { "hello" }` - /// - /// When we *compile* `my_proc_macro`, we will execute - /// the `quote` proc-macro. This will save the span of - /// "hello" into the metadata of `my_proc_macro`. As a result, - /// the body of `my_proc_macro` (after expansion) will end - /// up containing a call that looks like this: - /// `proc_macro::Ident::new("hello", proc_macro::Span::recover_proc_macro_span(0))` - /// - /// where `0` is the id returned by this function. - /// When `my_proc_macro` *executes* (during the compilation of `my_client`), - /// the call to `recover_proc_macro_span` will load the corresponding - /// span from the metadata of `my_proc_macro` (which we have access to, - /// since we've loaded `my_proc_macro` from disk in order to execute it). - /// In this way, we have obtained a span pointing into `my_proc_macro` - fn save_span(&mut self, span: Self::Span) -> usize { - self.psess().save_proc_macro_span(span) - } - - fn recover_proc_macro_span(&mut self, id: usize) -> Self::Span { - let (resolver, krate, def_site) = (&*self.ecx.resolver, self.krate, self.def_site); - *self.rebased_spans.entry(id).or_insert_with(|| { - // FIXME: `SyntaxContext` for spans from proc macro crates is lost during encoding, - // replace it with a def-site context until we are encoding it properly. - resolver.get_proc_macro_quoted_span(krate, id).with_ctxt(def_site.ctxt()) - }) - } } impl server::Symbol for Rustc<'_, '_> { diff --git a/compiler/rustc_metadata/src/rmeta/decoder.rs b/compiler/rustc_metadata/src/rmeta/decoder.rs index e6aedc61338bd..e39489925609c 100644 --- a/compiler/rustc_metadata/src/rmeta/decoder.rs +++ b/compiler/rustc_metadata/src/rmeta/decoder.rs @@ -1470,15 +1470,6 @@ impl<'a> CrateMetadataRef<'a> { self.root.native_libraries.decode((self, sess)) } - fn get_proc_macro_quoted_span(self, index: usize, sess: &Session) -> Span { - self.root - .tables - .proc_macro_quoted_spans - .get(self, index) - .unwrap_or_else(|| panic!("Missing proc macro quoted span: {index:?}")) - .decode((self, sess)) - } - fn get_foreign_modules(self, sess: &'a Session) -> impl Iterator { self.root.foreign_modules.decode((self, sess)) } diff --git a/compiler/rustc_metadata/src/rmeta/decoder/cstore_impl.rs b/compiler/rustc_metadata/src/rmeta/decoder/cstore_impl.rs index 57a672c45f7bc..f37f813a99e72 100644 --- a/compiler/rustc_metadata/src/rmeta/decoder/cstore_impl.rs +++ b/compiler/rustc_metadata/src/rmeta/decoder/cstore_impl.rs @@ -606,15 +606,6 @@ impl CStore { self.get_crate_data(cnum).num_def_ids() } - pub fn get_proc_macro_quoted_span_untracked( - &self, - cnum: CrateNum, - id: usize, - sess: &Session, - ) -> Span { - self.get_crate_data(cnum).get_proc_macro_quoted_span(id, sess) - } - pub fn set_used_recursively(&mut self, cnum: CrateNum) { let cmeta = self.get_crate_data_mut(cnum); if !cmeta.used { diff --git a/compiler/rustc_metadata/src/rmeta/encoder.rs b/compiler/rustc_metadata/src/rmeta/encoder.rs index 5cd98038fc6d3..c8f504e9c6a4c 100644 --- a/compiler/rustc_metadata/src/rmeta/encoder.rs +++ b/compiler/rustc_metadata/src/rmeta/encoder.rs @@ -1933,10 +1933,6 @@ impl<'a, 'tcx> EncodeContext<'a, 'tcx> { let stability = tcx.lookup_stability(CRATE_DEF_ID); let macros = self.lazy_array(tcx.resolutions(()).proc_macros.iter().map(|p| p.local_def_index)); - for (i, span) in self.tcx.sess.psess.proc_macro_quoted_spans() { - let span = self.lazy(span); - self.tables.proc_macro_quoted_spans.set_some(i, span); - } self.tables.def_kind.set_some(LOCAL_CRATE.as_def_id().index, DefKind::Mod); record!(self.tables.def_span[LOCAL_CRATE.as_def_id()] <- tcx.def_span(LOCAL_CRATE.as_def_id())); diff --git a/compiler/rustc_metadata/src/rmeta/mod.rs b/compiler/rustc_metadata/src/rmeta/mod.rs index 915c973168802..90d9fcc165817 100644 --- a/compiler/rustc_metadata/src/rmeta/mod.rs +++ b/compiler/rustc_metadata/src/rmeta/mod.rs @@ -469,7 +469,6 @@ define_tables! { // `DefPathTable` up front, since we may only ever use a few // definitions from any given crate. def_keys: Table>, - proc_macro_quoted_spans: Table>, variant_data: Table>, assoc_container: Table, macro_definition: Table>, diff --git a/compiler/rustc_resolve/src/macros.rs b/compiler/rustc_resolve/src/macros.rs index 77ef7f56c094c..9927f572ee626 100644 --- a/compiler/rustc_resolve/src/macros.rs +++ b/compiler/rustc_resolve/src/macros.rs @@ -18,7 +18,7 @@ use rustc_expand::expand::{ AstFragment, AstFragmentKind, Invocation, InvocationKind, SupportsMacroExpansion, }; use rustc_hir::def::{self, DefKind, Namespace, NonMacroAttrKind}; -use rustc_hir::def_id::{CrateNum, DefId, LocalDefId}; +use rustc_hir::def_id::{DefId, LocalDefId}; use rustc_middle::middle::stability; use rustc_middle::ty::{RegisteredTools, TyCtxt}; use rustc_session::lint::BuiltinLintDiag; @@ -475,10 +475,6 @@ impl<'ra, 'tcx> ResolverExpand for Resolver<'ra, 'tcx> { self.path_accessible(expn_id, path, &[MacroNS]) } - fn get_proc_macro_quoted_span(&self, krate: CrateNum, id: usize) -> Span { - self.cstore().get_proc_macro_quoted_span_untracked(krate, id, self.tcx.sess) - } - fn declare_proc_macro(&mut self, id: NodeId) { self.proc_macros.push(self.local_def_id(id)) } diff --git a/compiler/rustc_session/src/parse.rs b/compiler/rustc_session/src/parse.rs index 9097b27b86c4c..fe98fd01260ee 100644 --- a/compiler/rustc_session/src/parse.rs +++ b/compiler/rustc_session/src/parse.rs @@ -273,9 +273,6 @@ pub struct ParseSess { pub file_depinfo: Lock>, /// Whether cfg(version) should treat the current release as incomplete pub assume_incomplete_release: bool, - /// Spans passed to `proc_macro::quote_span`. Each span has a numerical - /// identifier represented by its position in the vector. - proc_macro_quoted_spans: AppendOnlyVec, /// Used to generate new `AttrId`s. Every `AttrId` is unique. pub attr_id_generator: AttrIdGenerator, } @@ -310,7 +307,6 @@ impl ParseSess { env_depinfo: Default::default(), file_depinfo: Default::default(), assume_incomplete_release: false, - proc_macro_quoted_spans: Default::default(), attr_id_generator: AttrIdGenerator::new(), } } @@ -364,16 +360,6 @@ impl ParseSess { }); } - pub fn save_proc_macro_span(&self, span: Span) -> usize { - self.proc_macro_quoted_spans.push(span) - } - - pub fn proc_macro_quoted_spans(&self) -> impl Iterator { - // This is equivalent to `.iter().copied().enumerate()`, but that isn't possible for - // AppendOnlyVec, so we resort to this scheme. - self.proc_macro_quoted_spans.iter_enumerated() - } - pub fn dcx(&self) -> DiagCtxtHandle<'_> { self.dcx.handle() } diff --git a/library/proc_macro/src/bridge/mod.rs b/library/proc_macro/src/bridge/mod.rs index d60a76fff5dc5..f02feac0a3d65 100644 --- a/library/proc_macro/src/bridge/mod.rs +++ b/library/proc_macro/src/bridge/mod.rs @@ -93,8 +93,6 @@ macro_rules! with_api { fn subspan($self: $S::Span, start: Bound, end: Bound) -> Option<$S::Span>; fn resolved_at($self: $S::Span, at: $S::Span) -> $S::Span; fn source_text($self: $S::Span) -> Option; - fn save_span($self: $S::Span) -> usize; - fn recover_proc_macro_span(id: usize) -> $S::Span; }, Symbol { fn normalize_and_validate_ident(string: &str) -> Result<$S::Symbol, ()>; diff --git a/library/proc_macro/src/lib.rs b/library/proc_macro/src/lib.rs index 162b4fdcc8ae2..3b7e98f482ebe 100644 --- a/library/proc_macro/src/lib.rs +++ b/library/proc_macro/src/lib.rs @@ -238,7 +238,7 @@ impl Default for TokenStream { } #[unstable(feature = "proc_macro_quote", issue = "54722")] -pub use quote::{HasIterator, RepInterp, ThereIsNoIteratorInRepetition, ext, quote, quote_span}; +pub use quote::{HasIterator, RepInterp, ThereIsNoIteratorInRepetition, ext, quote}; fn tree_to_bridge_tree( tree: TokenTree, @@ -601,20 +601,6 @@ impl Span { self.0.source_text() } - // Used by the implementation of `Span::quote` - #[doc(hidden)] - #[unstable(feature = "proc_macro_internals", issue = "27812")] - pub fn save_span(&self) -> usize { - self.0.save_span() - } - - // Used by the implementation of `Span::quote` - #[doc(hidden)] - #[unstable(feature = "proc_macro_internals", issue = "27812")] - pub fn recover_proc_macro_span(id: usize) -> Span { - Span(bridge::client::Span::recover_proc_macro_span(id)) - } - diagnostic_method!(error, Level::Error); diagnostic_method!(warning, Level::Warning); diagnostic_method!(note, Level::Note); diff --git a/library/proc_macro/src/quote.rs b/library/proc_macro/src/quote.rs index dbb55cd9fb300..a7a78fb0dc000 100644 --- a/library/proc_macro/src/quote.rs +++ b/library/proc_macro/src/quote.rs @@ -280,7 +280,6 @@ pub fn quote(stream: TokenStream) -> TokenStream { if stream.is_empty() { return minimal_quote!(crate::TokenStream::new()); } - let proc_macro_crate = minimal_quote!(crate); let mut after_dollar = false; let mut tokens = crate::TokenStream::new(); @@ -415,7 +414,7 @@ pub fn quote(stream: TokenStream) -> TokenStream { }; minimal_quote!(crate::ToTokens::to_tokens(&crate::TokenTree::Ident((@ ctor)( (@ TokenTree::from(Literal::string(literal))), - (@ quote_span(proc_macro_crate.clone(), tt.span())), + crate::Span::def_site(), )), &mut ts);) } TokenTree::Literal(tt) => { @@ -427,7 +426,7 @@ pub fn quote(stream: TokenStream) -> TokenStream { if let (Some(crate::TokenTree::Literal(mut lit)), None) = (iter.next(), iter.next()) { - lit.set_span((@ quote_span(proc_macro_crate.clone(), tt.span()))); + lit.set_span(crate::Span::def_site()); lit } else { unreachable!() @@ -476,11 +475,3 @@ fn collect_meta_vars(content_stream: TokenStream) -> Vec { helper(content_stream, &mut vars); vars } - -/// Quote a `Span` into a `TokenStream`. -/// This is needed to implement a custom quoter. -#[unstable(feature = "proc_macro_quote", issue = "54722")] -pub fn quote_span(proc_macro_crate: TokenStream, span: Span) -> TokenStream { - let id = span.save_span(); - minimal_quote!((@ proc_macro_crate ) ::Span::recover_proc_macro_span((@ TokenTree::from(Literal::usize_unsuffixed(id))))) -} From 309af5da43758ca804250d473e9db625e9cf67f4 Mon Sep 17 00:00:00 2001 From: bjorn3 <17426603+bjorn3@users.noreply.github.com> Date: Wed, 29 May 2024 13:55:51 +0000 Subject: [PATCH 2/3] Fix the proc-macro-srv --- .../src/server_impl/rust_analyzer_span.rs | 12 ------------ .../proc-macro-srv/src/server_impl/token_id.rs | 6 ------ 2 files changed, 18 deletions(-) diff --git a/src/tools/rust-analyzer/crates/proc-macro-srv/src/server_impl/rust_analyzer_span.rs b/src/tools/rust-analyzer/crates/proc-macro-srv/src/server_impl/rust_analyzer_span.rs index a1863efafbb76..d51df95b25632 100644 --- a/src/tools/rust-analyzer/crates/proc-macro-srv/src/server_impl/rust_analyzer_span.rs +++ b/src/tools/rust-analyzer/crates/proc-macro-srv/src/server_impl/rust_analyzer_span.rs @@ -145,18 +145,6 @@ impl server::Span for RaSpanServer { // FIXME None } - fn save_span(&mut self, _span: Self::Span) -> usize { - // FIXME, quote is incompatible with third-party tools - // This is called by the quote proc-macro which is expanded when the proc-macro is compiled - // As such, r-a will never observe this - 0 - } - fn recover_proc_macro_span(&mut self, _id: usize) -> Self::Span { - // FIXME, quote is incompatible with third-party tools - // This is called by the expansion of quote!, r-a will observe this, but we don't have - // access to the spans that were encoded - self.call_site - } /// Recent feature, not yet in the proc_macro /// /// See PR: diff --git a/src/tools/rust-analyzer/crates/proc-macro-srv/src/server_impl/token_id.rs b/src/tools/rust-analyzer/crates/proc-macro-srv/src/server_impl/token_id.rs index b493b325e830f..73f6c1b1ac4fc 100644 --- a/src/tools/rust-analyzer/crates/proc-macro-srv/src/server_impl/token_id.rs +++ b/src/tools/rust-analyzer/crates/proc-macro-srv/src/server_impl/token_id.rs @@ -117,12 +117,6 @@ impl server::Span for TokenIdServer { fn local_file(&mut self, _span: Self::Span) -> Option { None } - fn save_span(&mut self, _span: Self::Span) -> usize { - 0 - } - fn recover_proc_macro_span(&mut self, _id: usize) -> Self::Span { - self.call_site - } /// Recent feature, not yet in the proc_macro /// /// See PR: From 7d9f4e6c9aa63d73cf194dc5e9e4620faf5097a4 Mon Sep 17 00:00:00 2001 From: bjorn3 <17426603+bjorn3@users.noreply.github.com> Date: Wed, 29 May 2024 18:33:13 +0000 Subject: [PATCH 3/3] Fix tests --- tests/ui/macros/same-sequence-span.stderr | 4 +- tests/ui/proc-macro/auxiliary/custom-quote.rs | 29 ---------- .../auxiliary/span-from-proc-macro.rs | 9 --- tests/ui/proc-macro/span-from-proc-macro.rs | 2 - .../ui/proc-macro/span-from-proc-macro.stderr | 57 +++++++------------ 5 files changed, 23 insertions(+), 78 deletions(-) delete mode 100644 tests/ui/proc-macro/auxiliary/custom-quote.rs diff --git a/tests/ui/macros/same-sequence-span.stderr b/tests/ui/macros/same-sequence-span.stderr index 34df201f5a5c7..24275bcee99c8 100644 --- a/tests/ui/macros/same-sequence-span.stderr +++ b/tests/ui/macros/same-sequence-span.stderr @@ -17,8 +17,8 @@ LL | $(= $z:tt)* error: `$x:expr` may be followed by `$y:tt`, which is not allowed for `expr` fragments --> $DIR/same-sequence-span.rs:19:1 | -LL | | macro_rules! manual_foo { - | |__________________________^not allowed after `expr` fragments +LL | | + | |_^not allowed after `expr` fragments ... LL | proc_macro_sequence::make_foo!(); | ^------------------------------- diff --git a/tests/ui/proc-macro/auxiliary/custom-quote.rs b/tests/ui/proc-macro/auxiliary/custom-quote.rs deleted file mode 100644 index bccbed8a6b492..0000000000000 --- a/tests/ui/proc-macro/auxiliary/custom-quote.rs +++ /dev/null @@ -1,29 +0,0 @@ -// ignore-tidy-linelength - -#![feature(proc_macro_quote)] - -extern crate proc_macro; -use std::iter::FromIterator; -use std::str::FromStr; -use proc_macro::*; - -#[proc_macro] -pub fn custom_quote(input: TokenStream) -> TokenStream { - let mut tokens: Vec<_> = input.into_iter().collect(); - assert_eq!(tokens.len(), 1, "Unexpected input: {:?}", tokens); - match tokens.pop() { - Some(TokenTree::Ident(ident)) => { - assert_eq!(ident.to_string(), "my_ident"); - - let proc_macro_crate = TokenStream::from_str("::proc_macro").unwrap(); - let quoted_span = proc_macro::quote_span(proc_macro_crate, ident.span()); - let prefix = TokenStream::from_str(r#"let mut ident = proc_macro::Ident::new("my_ident", proc_macro::Span::call_site());"#).unwrap(); - let set_span_method = TokenStream::from_str("ident.set_span").unwrap(); - let set_span_arg = TokenStream::from(TokenTree::Group(Group::new(Delimiter::Parenthesis, quoted_span))); - let suffix = TokenStream::from_str(";proc_macro::TokenStream::from(proc_macro::TokenTree::Ident(ident))").unwrap(); - let full_stream = TokenStream::from_iter([prefix, set_span_method, set_span_arg, suffix]); - full_stream - } - _ => unreachable!() - } -} diff --git a/tests/ui/proc-macro/auxiliary/span-from-proc-macro.rs b/tests/ui/proc-macro/auxiliary/span-from-proc-macro.rs index 16ca5e3f9e2d1..98dd665984e26 100644 --- a/tests/ui/proc-macro/auxiliary/span-from-proc-macro.rs +++ b/tests/ui/proc-macro/auxiliary/span-from-proc-macro.rs @@ -1,8 +1,6 @@ #![feature(proc_macro_quote)] -#![feature(proc_macro_internals)] // FIXME - this shouldn't be necessary extern crate proc_macro; -extern crate custom_quote; use proc_macro::{quote, TokenStream}; @@ -19,13 +17,6 @@ pub fn error_from_bang(_input: TokenStream) -> TokenStream { expand_to_quote!() } -#[proc_macro] -pub fn other_error_from_bang(_input: TokenStream) -> TokenStream { - custom_quote::custom_quote! { - my_ident - } -} - #[proc_macro_attribute] pub fn error_from_attribute(_args: TokenStream, _input: TokenStream) -> TokenStream { quote! { diff --git a/tests/ui/proc-macro/span-from-proc-macro.rs b/tests/ui/proc-macro/span-from-proc-macro.rs index 4e12a695a5c09..7f2901c2c7a54 100644 --- a/tests/ui/proc-macro/span-from-proc-macro.rs +++ b/tests/ui/proc-macro/span-from-proc-macro.rs @@ -1,4 +1,3 @@ -//@ proc-macro: custom-quote.rs //@ proc-macro: span-from-proc-macro.rs //@ compile-flags: -Z macro-backtrace @@ -13,5 +12,4 @@ struct Kept; fn main() { error_from_bang!(); //~ ERROR mismatched types - other_error_from_bang!(); //~ ERROR cannot find value `my_ident` } diff --git a/tests/ui/proc-macro/span-from-proc-macro.stderr b/tests/ui/proc-macro/span-from-proc-macro.stderr index 452c04df8779e..32e41a4543a0e 100644 --- a/tests/ui/proc-macro/span-from-proc-macro.stderr +++ b/tests/ui/proc-macro/span-from-proc-macro.stderr @@ -1,62 +1,47 @@ error[E0412]: cannot find type `MissingType` in this scope - --> $DIR/auxiliary/span-from-proc-macro.rs:33:20 + --> $DIR/auxiliary/span-from-proc-macro.rs:21:1 | LL | pub fn error_from_attribute(_args: TokenStream, _input: TokenStream) -> TokenStream { - | ----------------------------------------------------------------------------------- in this expansion of `#[error_from_attribute]` -... -LL | field: MissingType - | ^^^^^^^^^^^ not found in this scope + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + | | + | not found in this scope + | in this expansion of `#[error_from_attribute]` | - ::: $DIR/span-from-proc-macro.rs:8:1 + ::: $DIR/span-from-proc-macro.rs:7:1 | LL | #[error_from_attribute] | ----------------------- in this procedural macro expansion error[E0412]: cannot find type `OtherMissingType` in this scope - --> $DIR/auxiliary/span-from-proc-macro.rs:42:21 + --> $DIR/auxiliary/span-from-proc-macro.rs:30:1 | LL | pub fn error_from_derive(_input: TokenStream) -> TokenStream { - | ------------------------------------------------------------ in this expansion of `#[derive(ErrorFromDerive)]` -... -LL | Variant(OtherMissingType) - | ^^^^^^^^^^^^^^^^ not found in this scope + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + | | + | not found in this scope + | in this expansion of `#[derive(ErrorFromDerive)]` | - ::: $DIR/span-from-proc-macro.rs:11:10 + ::: $DIR/span-from-proc-macro.rs:10:10 | LL | #[derive(ErrorFromDerive)] | --------------- in this derive macro expansion -error[E0425]: cannot find value `my_ident` in this scope - --> $DIR/auxiliary/span-from-proc-macro.rs:25:9 - | -LL | pub fn other_error_from_bang(_input: TokenStream) -> TokenStream { - | ---------------------------------------------------------------- in this expansion of `other_error_from_bang!` -LL | custom_quote::custom_quote! { -LL | my_ident - | ^^^^^^^^ not found in this scope - | - ::: $DIR/span-from-proc-macro.rs:16:5 - | -LL | other_error_from_bang!(); - | ------------------------ in this macro invocation - error[E0308]: mismatched types - --> $DIR/auxiliary/span-from-proc-macro.rs:12:36 + --> $DIR/auxiliary/span-from-proc-macro.rs:16:1 | -LL | let bang_error: bool = 25; - | ---- ^^ expected `bool`, found integer - | | - | expected due to this -... LL | pub fn error_from_bang(_input: TokenStream) -> TokenStream { - | ---------------------------------------------------------- in this expansion of `error_from_bang!` + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + | | + | expected `bool`, found integer + | expected due to this + | in this expansion of `error_from_bang!` | - ::: $DIR/span-from-proc-macro.rs:15:5 + ::: $DIR/span-from-proc-macro.rs:14:5 | LL | error_from_bang!(); | ------------------ in this macro invocation -error: aborting due to 4 previous errors +error: aborting due to 3 previous errors -Some errors have detailed explanations: E0308, E0412, E0425. +Some errors have detailed explanations: E0308, E0412. For more information about an error, try `rustc --explain E0308`.