Skip to content

Commit

Permalink
Fix tests
Browse files Browse the repository at this point in the history
  • Loading branch information
bjorn3 committed May 29, 2024
1 parent 1fee709 commit 9e60ab3
Show file tree
Hide file tree
Showing 5 changed files with 25 additions and 82 deletions.
32 changes: 0 additions & 32 deletions tests/ui/proc-macro/auxiliary/custom-quote.rs

This file was deleted.

10 changes: 1 addition & 9 deletions tests/ui/proc-macro/auxiliary/span-from-proc-macro.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
#![crate_type = "proc-macro"]

extern crate proc_macro;
extern crate custom_quote;

use proc_macro::{quote, TokenStream};

Expand All @@ -15,21 +14,14 @@ macro_rules! expand_to_quote {
quote! {
let bang_error: bool = 25;
}
}
};
}

#[proc_macro]
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! {
Expand Down
6 changes: 3 additions & 3 deletions tests/ui/proc-macro/quote-debug.stdout
Original file line number Diff line number Diff line change
Expand Up @@ -20,17 +20,17 @@ 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({
let mut iter =
"\"world\"".parse::<crate::TokenStream>().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")
Expand Down
2 changes: 0 additions & 2 deletions tests/ui/proc-macro/span-from-proc-macro.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
//@ aux-build:custom-quote.rs
//@ aux-build:span-from-proc-macro.rs
//@ compile-flags: -Z macro-backtrace

Expand All @@ -13,5 +12,4 @@ struct Kept;

fn main() {
error_from_bang!(); //~ ERROR mismatched types
other_error_from_bang!(); //~ ERROR cannot find value `my_ident`
}
57 changes: 21 additions & 36 deletions tests/ui/proc-macro/span-from-proc-macro.stderr
Original file line number Diff line number Diff line change
@@ -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`.

0 comments on commit 9e60ab3

Please sign in to comment.