-
Notifications
You must be signed in to change notification settings - Fork 12.7k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Auto merge of #84016 - Aaron1011:new-preexp-tests, r=petrochenkov
Add some proc-macro attribute token handling tests Split out from #82608 r? `@petrochenkov`
- Loading branch information
Showing
10 changed files
with
1,199 additions
and
66 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
// compile-flags: -Z span-debug | ||
// aux-build:test-macros.rs | ||
// check-pass | ||
|
||
#![feature(cfg_eval)] | ||
#![feature(custom_inner_attributes)] | ||
#![feature(stmt_expr_attributes)] | ||
#![feature(rustc_attrs)] | ||
|
||
#![no_std] // Don't load unnecessary hygiene information from std | ||
extern crate std; | ||
|
||
#[macro_use] | ||
extern crate test_macros; | ||
|
||
struct Foo<T>(T); | ||
|
||
impl Foo<[u8; { | ||
#![cfg_attr(not(FALSE), rustc_dummy(cursed_inner))] | ||
#![allow(unused)] | ||
struct Inner { | ||
field: [u8; { | ||
#![cfg_attr(not(FALSE), rustc_dummy(another_cursed_inner))] | ||
1 | ||
}] | ||
} | ||
|
||
0 | ||
}]> { | ||
#![cfg_eval] | ||
#![print_attr] | ||
#![cfg_attr(not(FALSE), rustc_dummy(evaluated_attr))] | ||
|
||
fn bar() { | ||
#[cfg(FALSE)] let a = 1; | ||
} | ||
} | ||
|
||
fn main() {} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,252 @@ | ||
PRINT-ATTR INPUT (DISPLAY): impl Foo < | ||
[u8 ; | ||
{ | ||
# ! [rustc_dummy(cursed_inner)] # ! [allow(unused)] struct Inner | ||
{ field : [u8 ; { # ! [rustc_dummy(another_cursed_inner)] 1 }], } 0 | ||
}] > { # ! [rustc_dummy(evaluated_attr)] fn bar() { } } | ||
PRINT-ATTR INPUT (DEBUG): TokenStream [ | ||
Ident { | ||
ident: "impl", | ||
span: $DIR/cfg-eval-inner.rs:18:1: 37:2 (#0), | ||
}, | ||
Ident { | ||
ident: "Foo", | ||
span: $DIR/cfg-eval-inner.rs:18:1: 37:2 (#0), | ||
}, | ||
Punct { | ||
ch: '<', | ||
spacing: Alone, | ||
span: $DIR/cfg-eval-inner.rs:18:1: 37:2 (#0), | ||
}, | ||
Group { | ||
delimiter: Bracket, | ||
stream: TokenStream [ | ||
Ident { | ||
ident: "u8", | ||
span: $DIR/cfg-eval-inner.rs:18:1: 37:2 (#0), | ||
}, | ||
Punct { | ||
ch: ';', | ||
spacing: Alone, | ||
span: $DIR/cfg-eval-inner.rs:18:1: 37:2 (#0), | ||
}, | ||
Group { | ||
delimiter: Brace, | ||
stream: TokenStream [ | ||
Punct { | ||
ch: '#', | ||
spacing: Joint, | ||
span: $DIR/cfg-eval-inner.rs:18:1: 37:2 (#0), | ||
}, | ||
Punct { | ||
ch: '!', | ||
spacing: Alone, | ||
span: $DIR/cfg-eval-inner.rs:18:1: 37:2 (#0), | ||
}, | ||
Group { | ||
delimiter: Bracket, | ||
stream: TokenStream [ | ||
Ident { | ||
ident: "rustc_dummy", | ||
span: $DIR/cfg-eval-inner.rs:18:1: 37:2 (#0), | ||
}, | ||
Group { | ||
delimiter: Parenthesis, | ||
stream: TokenStream [ | ||
Ident { | ||
ident: "cursed_inner", | ||
span: $DIR/cfg-eval-inner.rs:18:1: 37:2 (#0), | ||
}, | ||
], | ||
span: $DIR/cfg-eval-inner.rs:18:1: 37:2 (#0), | ||
}, | ||
], | ||
span: $DIR/cfg-eval-inner.rs:18:1: 37:2 (#0), | ||
}, | ||
Punct { | ||
ch: '#', | ||
spacing: Joint, | ||
span: $DIR/cfg-eval-inner.rs:18:1: 37:2 (#0), | ||
}, | ||
Punct { | ||
ch: '!', | ||
spacing: Alone, | ||
span: $DIR/cfg-eval-inner.rs:18:1: 37:2 (#0), | ||
}, | ||
Group { | ||
delimiter: Bracket, | ||
stream: TokenStream [ | ||
Ident { | ||
ident: "allow", | ||
span: $DIR/cfg-eval-inner.rs:18:1: 37:2 (#0), | ||
}, | ||
Group { | ||
delimiter: Parenthesis, | ||
stream: TokenStream [ | ||
Ident { | ||
ident: "unused", | ||
span: $DIR/cfg-eval-inner.rs:18:1: 37:2 (#0), | ||
}, | ||
], | ||
span: $DIR/cfg-eval-inner.rs:18:1: 37:2 (#0), | ||
}, | ||
], | ||
span: $DIR/cfg-eval-inner.rs:18:1: 37:2 (#0), | ||
}, | ||
Ident { | ||
ident: "struct", | ||
span: $DIR/cfg-eval-inner.rs:18:1: 37:2 (#0), | ||
}, | ||
Ident { | ||
ident: "Inner", | ||
span: $DIR/cfg-eval-inner.rs:18:1: 37:2 (#0), | ||
}, | ||
Group { | ||
delimiter: Brace, | ||
stream: TokenStream [ | ||
Ident { | ||
ident: "field", | ||
span: $DIR/cfg-eval-inner.rs:18:1: 37:2 (#0), | ||
}, | ||
Punct { | ||
ch: ':', | ||
spacing: Alone, | ||
span: $DIR/cfg-eval-inner.rs:18:1: 37:2 (#0), | ||
}, | ||
Group { | ||
delimiter: Bracket, | ||
stream: TokenStream [ | ||
Ident { | ||
ident: "u8", | ||
span: $DIR/cfg-eval-inner.rs:18:1: 37:2 (#0), | ||
}, | ||
Punct { | ||
ch: ';', | ||
spacing: Alone, | ||
span: $DIR/cfg-eval-inner.rs:18:1: 37:2 (#0), | ||
}, | ||
Group { | ||
delimiter: Brace, | ||
stream: TokenStream [ | ||
Punct { | ||
ch: '#', | ||
spacing: Joint, | ||
span: $DIR/cfg-eval-inner.rs:18:1: 37:2 (#0), | ||
}, | ||
Punct { | ||
ch: '!', | ||
spacing: Alone, | ||
span: $DIR/cfg-eval-inner.rs:18:1: 37:2 (#0), | ||
}, | ||
Group { | ||
delimiter: Bracket, | ||
stream: TokenStream [ | ||
Ident { | ||
ident: "rustc_dummy", | ||
span: $DIR/cfg-eval-inner.rs:18:1: 37:2 (#0), | ||
}, | ||
Group { | ||
delimiter: Parenthesis, | ||
stream: TokenStream [ | ||
Ident { | ||
ident: "another_cursed_inner", | ||
span: $DIR/cfg-eval-inner.rs:18:1: 37:2 (#0), | ||
}, | ||
], | ||
span: $DIR/cfg-eval-inner.rs:18:1: 37:2 (#0), | ||
}, | ||
], | ||
span: $DIR/cfg-eval-inner.rs:18:1: 37:2 (#0), | ||
}, | ||
Literal { | ||
kind: Integer, | ||
symbol: "1", | ||
suffix: None, | ||
span: $DIR/cfg-eval-inner.rs:18:1: 37:2 (#0), | ||
}, | ||
], | ||
span: $DIR/cfg-eval-inner.rs:18:1: 37:2 (#0), | ||
}, | ||
], | ||
span: $DIR/cfg-eval-inner.rs:18:1: 37:2 (#0), | ||
}, | ||
Punct { | ||
ch: ',', | ||
spacing: Alone, | ||
span: $DIR/cfg-eval-inner.rs:18:1: 37:2 (#0), | ||
}, | ||
], | ||
span: $DIR/cfg-eval-inner.rs:18:1: 37:2 (#0), | ||
}, | ||
Literal { | ||
kind: Integer, | ||
symbol: "0", | ||
suffix: None, | ||
span: $DIR/cfg-eval-inner.rs:18:1: 37:2 (#0), | ||
}, | ||
], | ||
span: $DIR/cfg-eval-inner.rs:18:1: 37:2 (#0), | ||
}, | ||
], | ||
span: $DIR/cfg-eval-inner.rs:18:1: 37:2 (#0), | ||
}, | ||
Punct { | ||
ch: '>', | ||
spacing: Alone, | ||
span: $DIR/cfg-eval-inner.rs:18:1: 37:2 (#0), | ||
}, | ||
Group { | ||
delimiter: Brace, | ||
stream: TokenStream [ | ||
Punct { | ||
ch: '#', | ||
spacing: Joint, | ||
span: $DIR/cfg-eval-inner.rs:18:1: 37:2 (#0), | ||
}, | ||
Punct { | ||
ch: '!', | ||
spacing: Alone, | ||
span: $DIR/cfg-eval-inner.rs:18:1: 37:2 (#0), | ||
}, | ||
Group { | ||
delimiter: Bracket, | ||
stream: TokenStream [ | ||
Ident { | ||
ident: "rustc_dummy", | ||
span: $DIR/cfg-eval-inner.rs:18:1: 37:2 (#0), | ||
}, | ||
Group { | ||
delimiter: Parenthesis, | ||
stream: TokenStream [ | ||
Ident { | ||
ident: "evaluated_attr", | ||
span: $DIR/cfg-eval-inner.rs:18:1: 37:2 (#0), | ||
}, | ||
], | ||
span: $DIR/cfg-eval-inner.rs:18:1: 37:2 (#0), | ||
}, | ||
], | ||
span: $DIR/cfg-eval-inner.rs:18:1: 37:2 (#0), | ||
}, | ||
Ident { | ||
ident: "fn", | ||
span: $DIR/cfg-eval-inner.rs:18:1: 37:2 (#0), | ||
}, | ||
Ident { | ||
ident: "bar", | ||
span: $DIR/cfg-eval-inner.rs:18:1: 37:2 (#0), | ||
}, | ||
Group { | ||
delimiter: Parenthesis, | ||
stream: TokenStream [], | ||
span: $DIR/cfg-eval-inner.rs:18:1: 37:2 (#0), | ||
}, | ||
Group { | ||
delimiter: Brace, | ||
stream: TokenStream [], | ||
span: $DIR/cfg-eval-inner.rs:18:1: 37:2 (#0), | ||
}, | ||
], | ||
span: $DIR/cfg-eval-inner.rs:18:1: 37:2 (#0), | ||
}, | ||
] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.