diff --git a/tests/ui/macros/same-sequence-span.stderr b/tests/ui/macros/same-sequence-span.stderr index 3242a32e2f4dd..6408522f0789c 100644 --- a/tests/ui/macros/same-sequence-span.stderr +++ b/tests/ui/macros/same-sequence-span.stderr @@ -17,9 +17,9 @@ 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 | | } - | |_________________________________^ not allowed after `expr` fragments -LL | +LL | | (1 $x:expr $($y:tt,)* + | |______________________________________________^ 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 88800596ce562..0000000000000 --- a/tests/ui/proc-macro/auxiliary/custom-quote.rs +++ /dev/null @@ -1,32 +0,0 @@ -//@ force-host -//@ no-prefer-dynamic -// ignore-tidy-linelength - -#![feature(proc_macro_quote)] -#![crate_type = "proc-macro"] - -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 fdcca29e177bc..13e800dbcdcef 100644 --- a/tests/ui/proc-macro/auxiliary/span-from-proc-macro.rs +++ b/tests/ui/proc-macro/auxiliary/span-from-proc-macro.rs @@ -6,7 +6,6 @@ #![crate_type = "proc-macro"] extern crate proc_macro; -extern crate custom_quote; use proc_macro::{quote, TokenStream}; @@ -15,7 +14,7 @@ macro_rules! expand_to_quote { quote! { let bang_error: bool = 25; } - } + }; } #[proc_macro] @@ -23,13 +22,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/quote-debug.stdout b/tests/ui/proc-macro/quote-debug.stdout index d84b4e051e872..5199fd771e32e 100644 --- a/tests/ui/proc-macro/quote-debug.stdout +++ b/tests/ui/proc-macro/quote-debug.stdout @@ -20,9 +20,9 @@ extern crate proc_macro; fn main() { [crate::TokenStream::from(crate::TokenTree::Ident(crate::Ident::new("let", - crate::Span::recover_proc_macro_span(0)))), + crate::Span::def_site()))), crate::TokenStream::from(crate::TokenTree::Ident(crate::Ident::new("hello", - crate::Span::recover_proc_macro_span(1)))), + crate::Span::def_site()))), crate::TokenStream::from(crate::TokenTree::Punct(crate::Punct::new('=', crate::Spacing::Alone))), crate::TokenStream::from(crate::TokenTree::Literal({ @@ -30,7 +30,7 @@ fn main() { "\"world\"".parse::().unwrap().into_iter(); if let (Some(crate::TokenTree::Literal(mut lit)), None) = (iter.next(), iter.next()) { - lit.set_span(crate::Span::recover_proc_macro_span(2)); + lit.set_span(crate::Span::def_site()); lit } else { ::core::panicking::panic("internal error: entered unreachable code") diff --git a/tests/ui/proc-macro/span-from-proc-macro.rs b/tests/ui/proc-macro/span-from-proc-macro.rs index 9d851d62d1269..8174c598da8d2 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 @@ -//@ aux-build:custom-quote.rs //@ aux-build: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 7beed505a7efa..7478662e3a7b5 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:37:20 + --> $DIR/auxiliary/span-from-proc-macro.rs:26: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:46:21 + --> $DIR/auxiliary/span-from-proc-macro.rs:35: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:29: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:16:36 + --> $DIR/auxiliary/span-from-proc-macro.rs:21: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`.