-
Notifications
You must be signed in to change notification settings - Fork 12.9k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
16 changed files
with
2,249 additions
and
371 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
// check-pass | ||
// compile-flags: -Z span-debug --error-format human | ||
// aux-build:test-macros.rs | ||
|
||
#![feature(stmt_expr_attributes)] | ||
#![feature(custom_inner_attributes)] | ||
#![feature(rustc_attrs)] | ||
|
||
#![no_std] // Don't load unnecessary hygiene information from std | ||
extern crate std; | ||
|
||
#[macro_use] | ||
extern crate test_macros; | ||
|
||
trait MyTrait<T> {} | ||
struct MyStruct<const N: bool>; | ||
|
||
#[print_attr] | ||
fn foo<T: MyTrait<MyStruct<{ true }>>>() {} | ||
|
||
impl<T> MyTrait<T> for MyStruct<{true}> { | ||
#![print_attr] | ||
#![rustc_dummy] | ||
} | ||
|
||
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,171 @@ | ||
PRINT-ATTR INPUT (DISPLAY): fn foo < T : MyTrait < MyStruct < { true } >> > () { } | ||
PRINT-ATTR INPUT (DEBUG): TokenStream [ | ||
Ident { | ||
ident: "fn", | ||
span: $DIR/attr-complex-fn.rs:19:1: 19:3 (#0), | ||
}, | ||
Ident { | ||
ident: "foo", | ||
span: $DIR/attr-complex-fn.rs:19:4: 19:7 (#0), | ||
}, | ||
Punct { | ||
ch: '<', | ||
spacing: Alone, | ||
span: $DIR/attr-complex-fn.rs:19:7: 19:8 (#0), | ||
}, | ||
Ident { | ||
ident: "T", | ||
span: $DIR/attr-complex-fn.rs:19:8: 19:9 (#0), | ||
}, | ||
Punct { | ||
ch: ':', | ||
spacing: Alone, | ||
span: $DIR/attr-complex-fn.rs:19:9: 19:10 (#0), | ||
}, | ||
Ident { | ||
ident: "MyTrait", | ||
span: $DIR/attr-complex-fn.rs:19:11: 19:18 (#0), | ||
}, | ||
Punct { | ||
ch: '<', | ||
spacing: Alone, | ||
span: $DIR/attr-complex-fn.rs:19:18: 19:19 (#0), | ||
}, | ||
Ident { | ||
ident: "MyStruct", | ||
span: $DIR/attr-complex-fn.rs:19:19: 19:27 (#0), | ||
}, | ||
Punct { | ||
ch: '<', | ||
spacing: Alone, | ||
span: $DIR/attr-complex-fn.rs:19:27: 19:28 (#0), | ||
}, | ||
Group { | ||
delimiter: Brace, | ||
stream: TokenStream [ | ||
Ident { | ||
ident: "true", | ||
span: $DIR/attr-complex-fn.rs:19:30: 19:34 (#0), | ||
}, | ||
], | ||
span: $DIR/attr-complex-fn.rs:19:28: 19:36 (#0), | ||
}, | ||
Punct { | ||
ch: '>', | ||
spacing: Joint, | ||
span: $DIR/attr-complex-fn.rs:19:36: 19:38 (#0), | ||
}, | ||
Punct { | ||
ch: '>', | ||
spacing: Joint, | ||
span: $DIR/attr-complex-fn.rs:19:36: 19:38 (#0), | ||
}, | ||
Punct { | ||
ch: '>', | ||
spacing: Alone, | ||
span: $DIR/attr-complex-fn.rs:19:38: 19:39 (#0), | ||
}, | ||
Group { | ||
delimiter: Parenthesis, | ||
stream: TokenStream [], | ||
span: $DIR/attr-complex-fn.rs:19:39: 19:41 (#0), | ||
}, | ||
Group { | ||
delimiter: Brace, | ||
stream: TokenStream [], | ||
span: $DIR/attr-complex-fn.rs:19:42: 19:44 (#0), | ||
}, | ||
] | ||
PRINT-ATTR INPUT (DISPLAY): impl < T > MyTrait < T > for MyStruct < { true } > { # ! [rustc_dummy] } | ||
PRINT-ATTR INPUT (DEBUG): TokenStream [ | ||
Ident { | ||
ident: "impl", | ||
span: $DIR/attr-complex-fn.rs:21:1: 24:2 (#0), | ||
}, | ||
Punct { | ||
ch: '<', | ||
spacing: Alone, | ||
span: $DIR/attr-complex-fn.rs:21:1: 24:2 (#0), | ||
}, | ||
Ident { | ||
ident: "T", | ||
span: $DIR/attr-complex-fn.rs:21:1: 24:2 (#0), | ||
}, | ||
Punct { | ||
ch: '>', | ||
spacing: Alone, | ||
span: $DIR/attr-complex-fn.rs:21:1: 24:2 (#0), | ||
}, | ||
Ident { | ||
ident: "MyTrait", | ||
span: $DIR/attr-complex-fn.rs:21:1: 24:2 (#0), | ||
}, | ||
Punct { | ||
ch: '<', | ||
spacing: Alone, | ||
span: $DIR/attr-complex-fn.rs:21:1: 24:2 (#0), | ||
}, | ||
Ident { | ||
ident: "T", | ||
span: $DIR/attr-complex-fn.rs:21:1: 24:2 (#0), | ||
}, | ||
Punct { | ||
ch: '>', | ||
spacing: Alone, | ||
span: $DIR/attr-complex-fn.rs:21:1: 24:2 (#0), | ||
}, | ||
Ident { | ||
ident: "for", | ||
span: $DIR/attr-complex-fn.rs:21:1: 24:2 (#0), | ||
}, | ||
Ident { | ||
ident: "MyStruct", | ||
span: $DIR/attr-complex-fn.rs:21:1: 24:2 (#0), | ||
}, | ||
Punct { | ||
ch: '<', | ||
spacing: Alone, | ||
span: $DIR/attr-complex-fn.rs:21:1: 24:2 (#0), | ||
}, | ||
Group { | ||
delimiter: Brace, | ||
stream: TokenStream [ | ||
Ident { | ||
ident: "true", | ||
span: $DIR/attr-complex-fn.rs:21:1: 24:2 (#0), | ||
}, | ||
], | ||
span: $DIR/attr-complex-fn.rs:21:1: 24:2 (#0), | ||
}, | ||
Punct { | ||
ch: '>', | ||
spacing: Alone, | ||
span: $DIR/attr-complex-fn.rs:21:1: 24:2 (#0), | ||
}, | ||
Group { | ||
delimiter: Brace, | ||
stream: TokenStream [ | ||
Punct { | ||
ch: '#', | ||
spacing: Joint, | ||
span: $DIR/attr-complex-fn.rs:21:1: 24:2 (#0), | ||
}, | ||
Punct { | ||
ch: '!', | ||
spacing: Alone, | ||
span: $DIR/attr-complex-fn.rs:21:1: 24:2 (#0), | ||
}, | ||
Group { | ||
delimiter: Bracket, | ||
stream: TokenStream [ | ||
Ident { | ||
ident: "rustc_dummy", | ||
span: $DIR/attr-complex-fn.rs:21:1: 24:2 (#0), | ||
}, | ||
], | ||
span: $DIR/attr-complex-fn.rs:21:1: 24:2 (#0), | ||
}, | ||
], | ||
span: $DIR/attr-complex-fn.rs:21:1: 24: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
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,34 @@ | ||
// check-pass | ||
// compile-flags: -Z span-debug --error-format human | ||
// aux-build:test-macros.rs | ||
|
||
#![feature(rustc_attrs)] | ||
|
||
#![no_std] // Don't load unnecessary hygiene information from std | ||
extern crate std; | ||
|
||
#[macro_use] | ||
extern crate test_macros; | ||
|
||
macro_rules! expand_to_derive { | ||
($item:item) => { | ||
#[derive(Print)] | ||
struct Foo { | ||
#[cfg(FALSE)] removed: bool, | ||
field: [bool; { | ||
$item | ||
0 | ||
}] | ||
} | ||
}; | ||
} | ||
|
||
expand_to_derive! { | ||
#[cfg_attr(not(FALSE), rustc_dummy)] | ||
struct Inner { | ||
#[cfg(FALSE)] removed_inner_field: bool, | ||
other_inner_field: u8, | ||
} | ||
} | ||
|
||
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,109 @@ | ||
PRINT-DERIVE INPUT (DISPLAY): struct Foo | ||
{ | ||
field : | ||
[bool ; { #[rustc_dummy] struct Inner { other_inner_field : u8, } 0 }], | ||
} | ||
PRINT-DERIVE INPUT (DEBUG): TokenStream [ | ||
Ident { | ||
ident: "struct", | ||
span: $DIR/expand-to-derive.rs:16:9: 22:10 (#4), | ||
}, | ||
Ident { | ||
ident: "Foo", | ||
span: $DIR/expand-to-derive.rs:16:9: 22:10 (#4), | ||
}, | ||
Group { | ||
delimiter: Brace, | ||
stream: TokenStream [ | ||
Ident { | ||
ident: "field", | ||
span: $DIR/expand-to-derive.rs:16:9: 22:10 (#4), | ||
}, | ||
Punct { | ||
ch: ':', | ||
spacing: Alone, | ||
span: $DIR/expand-to-derive.rs:16:9: 22:10 (#4), | ||
}, | ||
Group { | ||
delimiter: Bracket, | ||
stream: TokenStream [ | ||
Ident { | ||
ident: "bool", | ||
span: $DIR/expand-to-derive.rs:16:9: 22:10 (#4), | ||
}, | ||
Punct { | ||
ch: ';', | ||
spacing: Alone, | ||
span: $DIR/expand-to-derive.rs:16:9: 22:10 (#4), | ||
}, | ||
Group { | ||
delimiter: Brace, | ||
stream: TokenStream [ | ||
Punct { | ||
ch: '#', | ||
spacing: Alone, | ||
span: $DIR/expand-to-derive.rs:16:9: 22:10 (#4), | ||
}, | ||
Group { | ||
delimiter: Bracket, | ||
stream: TokenStream [ | ||
Ident { | ||
ident: "rustc_dummy", | ||
span: $DIR/expand-to-derive.rs:16:9: 22:10 (#4), | ||
}, | ||
], | ||
span: $DIR/expand-to-derive.rs:16:9: 22:10 (#4), | ||
}, | ||
Ident { | ||
ident: "struct", | ||
span: $DIR/expand-to-derive.rs:16:9: 22:10 (#4), | ||
}, | ||
Ident { | ||
ident: "Inner", | ||
span: $DIR/expand-to-derive.rs:16:9: 22:10 (#4), | ||
}, | ||
Group { | ||
delimiter: Brace, | ||
stream: TokenStream [ | ||
Ident { | ||
ident: "other_inner_field", | ||
span: $DIR/expand-to-derive.rs:16:9: 22:10 (#4), | ||
}, | ||
Punct { | ||
ch: ':', | ||
spacing: Alone, | ||
span: $DIR/expand-to-derive.rs:16:9: 22:10 (#4), | ||
}, | ||
Ident { | ||
ident: "u8", | ||
span: $DIR/expand-to-derive.rs:16:9: 22:10 (#4), | ||
}, | ||
Punct { | ||
ch: ',', | ||
spacing: Alone, | ||
span: $DIR/expand-to-derive.rs:16:9: 22:10 (#4), | ||
}, | ||
], | ||
span: $DIR/expand-to-derive.rs:16:9: 22:10 (#4), | ||
}, | ||
Literal { | ||
kind: Integer, | ||
symbol: "0", | ||
suffix: None, | ||
span: $DIR/expand-to-derive.rs:16:9: 22:10 (#4), | ||
}, | ||
], | ||
span: $DIR/expand-to-derive.rs:16:9: 22:10 (#4), | ||
}, | ||
], | ||
span: $DIR/expand-to-derive.rs:16:9: 22:10 (#4), | ||
}, | ||
Punct { | ||
ch: ',', | ||
spacing: Alone, | ||
span: $DIR/expand-to-derive.rs:16:9: 22:10 (#4), | ||
}, | ||
], | ||
span: $DIR/expand-to-derive.rs:16:9: 22:10 (#4), | ||
}, | ||
] |
Oops, something went wrong.