Skip to content

Commit f0fa136

Browse files
committed
Fix tests
1 parent 923693d commit f0fa136

6 files changed

Lines changed: 33 additions & 87 deletions

File tree

tests/ui/proc-macro/auxiliary/custom-quote.rs

Lines changed: 0 additions & 29 deletions
This file was deleted.

tests/ui/proc-macro/auxiliary/span-from-proc-macro.rs

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,6 @@
11
#![feature(proc_macro_quote)]
2-
#![feature(proc_macro_internals)] // FIXME - this shouldn't be necessary
32

43
extern crate proc_macro;
5-
extern crate custom_quote;
64

75
use proc_macro::{quote, TokenStream};
86

@@ -19,13 +17,6 @@ pub fn error_from_bang(_input: TokenStream) -> TokenStream {
1917
expand_to_quote!()
2018
}
2119

22-
#[proc_macro]
23-
pub fn other_error_from_bang(_input: TokenStream) -> TokenStream {
24-
custom_quote::custom_quote! {
25-
my_ident
26-
}
27-
}
28-
2920
#[proc_macro_attribute]
3021
pub fn error_from_attribute(_args: TokenStream, _input: TokenStream) -> TokenStream {
3122
quote! {

tests/ui/proc-macro/mixed-site-span.stderr

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -130,10 +130,11 @@ LL | invoke_with_ident!{krate input TokenItem}
130130
|
131131
= note: this error originates in the macro `with_crate` which comes from the expansion of the macro `invoke_with_ident` (in Nightly builds, run with -Z macro-backtrace for more info)
132132
help: consider importing this struct instead
133-
--> $DIR/auxiliary/mixed-site-span.rs:60:34
133+
--> $DIR/auxiliary/mixed-site-span.rs:41:1
134+
|
135+
LL - pub fn with_crate(input: TokenStream) -> TokenStream {
136+
LL + token_site_span::TokenItem as _ {
134137
|
135-
LL | quote!(use $krate::$ident as token_site_span::TokenItem as _;)
136-
| +++++++++++++++++++++++++++++
137138

138139
error[E0432]: unresolved import `$crate::TokenItem`
139140
--> $DIR/mixed-site-span.rs:90:5
@@ -143,10 +144,11 @@ LL | with_crate!{krate input TokenItem}
143144
|
144145
= note: this error originates in the macro `with_crate` (in Nightly builds, run with -Z macro-backtrace for more info)
145146
help: consider importing this struct instead
146-
--> $DIR/auxiliary/mixed-site-span.rs:60:34
147+
--> $DIR/auxiliary/mixed-site-span.rs:41:1
148+
|
149+
LL - pub fn with_crate(input: TokenStream) -> TokenStream {
150+
LL + token_site_span::TokenItem as _ {
147151
|
148-
LL | quote!(use $krate::$ident as token_site_span::TokenItem as _;)
149-
| +++++++++++++++++++++++++++++
150152

151153
error[E0432]: unresolved import `$crate`
152154
--> $DIR/mixed-site-span.rs:91:5

tests/ui/proc-macro/quote/debug.stdout

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -22,17 +22,17 @@ fn main() {
2222
{
2323
let mut ts = crate::TokenStream::new();
2424
crate::ToTokens::to_tokens(&crate::TokenTree::Ident(crate::Ident::new("let",
25-
crate::Span::recover_proc_macro_span(0))), &mut ts);
25+
crate::Span::def_site())), &mut ts);
2626
crate::ToTokens::to_tokens(&crate::TokenTree::Ident(crate::Ident::new("hello",
27-
crate::Span::recover_proc_macro_span(1))), &mut ts);
27+
crate::Span::def_site())), &mut ts);
2828
crate::ToTokens::to_tokens(&crate::TokenTree::Punct(crate::Punct::new('=',
2929
crate::Spacing::Alone)), &mut ts);
3030
crate::ToTokens::to_tokens(&crate::TokenTree::Literal({
3131
let mut iter =
3232
"\"world\"".parse::<crate::TokenStream>().unwrap().into_iter();
3333
if let (Some(crate::TokenTree::Literal(mut lit)), None) =
3434
(iter.next(), iter.next()) {
35-
lit.set_span(crate::Span::recover_proc_macro_span(2));
35+
lit.set_span(crate::Span::def_site());
3636
lit
3737
} else {
3838
::core::panicking::panic("internal error: entered unreachable code")
@@ -41,17 +41,17 @@ fn main() {
4141
crate::ToTokens::to_tokens(&crate::TokenTree::Punct(crate::Punct::new(';',
4242
crate::Spacing::Alone)), &mut ts);
4343
crate::ToTokens::to_tokens(&crate::TokenTree::Ident(crate::Ident::new("let",
44-
crate::Span::recover_proc_macro_span(3))), &mut ts);
44+
crate::Span::def_site())), &mut ts);
4545
crate::ToTokens::to_tokens(&crate::TokenTree::Ident(crate::Ident::new_raw("raw_ident",
46-
crate::Span::recover_proc_macro_span(4))), &mut ts);
46+
crate::Span::def_site())), &mut ts);
4747
crate::ToTokens::to_tokens(&crate::TokenTree::Punct(crate::Punct::new('=',
4848
crate::Spacing::Alone)), &mut ts);
4949
crate::ToTokens::to_tokens(&crate::TokenTree::Literal({
5050
let mut iter =
5151
"r#\"raw\"literal\"#".parse::<crate::TokenStream>().unwrap().into_iter();
5252
if let (Some(crate::TokenTree::Literal(mut lit)), None) =
5353
(iter.next(), iter.next()) {
54-
lit.set_span(crate::Span::recover_proc_macro_span(5));
54+
lit.set_span(crate::Span::def_site());
5555
lit
5656
} else {
5757
::core::panicking::panic("internal error: entered unreachable code")

tests/ui/proc-macro/span-from-proc-macro.rs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
//@ proc-macro: custom-quote.rs
21
//@ proc-macro: span-from-proc-macro.rs
32
//@ compile-flags: -Z macro-backtrace
43
//@ ignore-backends: gcc
@@ -14,5 +13,4 @@ struct Kept;
1413

1514
fn main() {
1615
error_from_bang!(); //~ ERROR mismatched types
17-
other_error_from_bang!(); //~ ERROR cannot find value `my_ident`
1816
}
Lines changed: 19 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -1,62 +1,46 @@
11
error[E0425]: cannot find type `MissingType` in this scope
2-
--> $DIR/auxiliary/span-from-proc-macro.rs:33:20
2+
--> $DIR/auxiliary/span-from-proc-macro.rs:21:1
33
|
44
LL | pub fn error_from_attribute(_args: TokenStream, _input: TokenStream) -> TokenStream {
5-
| ----------------------------------------------------------------------------------- in this expansion of `#[error_from_attribute]`
6-
...
7-
LL | field: MissingType
8-
| ^^^^^^^^^^^ not found in this scope
5+
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
6+
| |
7+
| not found in this scope
8+
| in this expansion of `#[error_from_attribute]`
99
|
10-
::: $DIR/span-from-proc-macro.rs:9:1
10+
::: $DIR/span-from-proc-macro.rs:8:1
1111
|
1212
LL | #[error_from_attribute]
1313
| ----------------------- in this attribute macro expansion
1414

1515
error[E0425]: cannot find type `OtherMissingType` in this scope
16-
--> $DIR/auxiliary/span-from-proc-macro.rs:42:21
16+
--> $DIR/auxiliary/span-from-proc-macro.rs:30:1
1717
|
1818
LL | pub fn error_from_derive(_input: TokenStream) -> TokenStream {
19-
| ------------------------------------------------------------ in this expansion of `#[derive(ErrorFromDerive)]`
20-
...
21-
LL | Variant(OtherMissingType)
22-
| ^^^^^^^^^^^^^^^^ not found in this scope
19+
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
20+
| |
21+
| not found in this scope
22+
| in this expansion of `#[derive(ErrorFromDerive)]`
2323
|
24-
::: $DIR/span-from-proc-macro.rs:12:10
24+
::: $DIR/span-from-proc-macro.rs:11:10
2525
|
2626
LL | #[derive(ErrorFromDerive)]
2727
| --------------- in this derive macro expansion
2828

29-
error[E0425]: cannot find value `my_ident` in this scope
30-
--> $DIR/auxiliary/span-from-proc-macro.rs:25:9
31-
|
32-
LL | pub fn other_error_from_bang(_input: TokenStream) -> TokenStream {
33-
| ---------------------------------------------------------------- in this expansion of `other_error_from_bang!`
34-
LL | custom_quote::custom_quote! {
35-
LL | my_ident
36-
| ^^^^^^^^ not found in this scope
37-
|
38-
::: $DIR/span-from-proc-macro.rs:17:5
39-
|
40-
LL | other_error_from_bang!();
41-
| ------------------------ in this macro invocation
42-
4329
error[E0308]: mismatched types
44-
--> $DIR/auxiliary/span-from-proc-macro.rs:12:36
30+
--> $DIR/auxiliary/span-from-proc-macro.rs:16:1
4531
|
46-
LL | let bang_error: bool = 25;
47-
| ---- ^^ expected `bool`, found integer
48-
| |
49-
| expected due to this
50-
...
5132
LL | pub fn error_from_bang(_input: TokenStream) -> TokenStream {
52-
| ---------------------------------------------------------- in this expansion of `error_from_bang!`
33+
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
34+
| |
35+
| expected `bool`, found integer
36+
| in this expansion of `error_from_bang!`
5337
|
54-
::: $DIR/span-from-proc-macro.rs:16:5
38+
::: $DIR/span-from-proc-macro.rs:15:5
5539
|
5640
LL | error_from_bang!();
5741
| ------------------ in this macro invocation
5842

59-
error: aborting due to 4 previous errors
43+
error: aborting due to 3 previous errors
6044

6145
Some errors have detailed explanations: E0308, E0425.
6246
For more information about an error, try `rustc --explain E0308`.

0 commit comments

Comments
 (0)