Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion src/test/ui/proc-macro/auxiliary/test-macros.rs
Original file line number Diff line number Diff line change
Expand Up @@ -108,5 +108,6 @@ pub fn print_attr(_: TokenStream, input: TokenStream) -> TokenStream {

#[proc_macro_derive(Print, attributes(print_helper))]
pub fn print_derive(input: TokenStream) -> TokenStream {
print_helper(input, "DERIVE")
print_helper(input, "DERIVE");
TokenStream::new()
}
5 changes: 3 additions & 2 deletions src/test/ui/proc-macro/dollar-crate.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
// check-pass
// edition:2018
// aux-build:test-macros.rs
// aux-build:dollar-crate-external.rs
Expand All @@ -23,7 +24,7 @@ mod local {
struct A($crate::S);

#[derive(Print)]
struct D($crate::S); //~ ERROR the name `D` is defined multiple times
struct D($crate::S);
};
}

Expand All @@ -33,7 +34,7 @@ mod local {
mod external {
use crate::dollar_crate_external;

dollar_crate_external::external!(); //~ ERROR the name `D` is defined multiple times
dollar_crate_external::external!();
}

fn main() {}
30 changes: 0 additions & 30 deletions src/test/ui/proc-macro/dollar-crate.stderr

This file was deleted.

25 changes: 25 additions & 0 deletions src/test/ui/proc-macro/input-interpolated.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
// Check what token streams proc macros see when interpolated tokens are passed to them as input.

// check-pass
// aux-build:test-macros.rs

#[macro_use]
extern crate test_macros;

macro_rules! pass_ident {
($i:ident) => {
fn f() {
print_bang!($i);
}

#[print_attr]
const $i: u8 = 0;

#[derive(Print)]
struct $i {}
};
}

pass_ident!(A);

fn main() {}
69 changes: 69 additions & 0 deletions src/test/ui/proc-macro/input-interpolated.stdout
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
PRINT-BANG INPUT (DISPLAY): A
PRINT-BANG RE-COLLECTED (DISPLAY): A
PRINT-BANG INPUT (DEBUG): TokenStream [
Group {
delimiter: None,
stream: TokenStream [
Ident {
ident: "A",
span: #0 bytes(402..403),
},
],
span: #3 bytes(269..271),
},
]
PRINT-ATTR INPUT (DISPLAY): const A: u8 = 0;
PRINT-ATTR RE-COLLECTED (DISPLAY): const A : u8 = 0 ;
PRINT-ATTR INPUT (DEBUG): TokenStream [
Ident {
ident: "const",
span: #0 bytes(0..0),
},
Ident {
ident: "A",
span: #0 bytes(0..0),
},
Punct {
ch: ':',
spacing: Alone,
span: #0 bytes(0..0),
},
Ident {
ident: "u8",
span: #0 bytes(0..0),
},
Punct {
ch: '=',
spacing: Alone,
span: #0 bytes(0..0),
},
Literal {
kind: Integer,
symbol: "0",
suffix: None,
span: #0 bytes(0..0),
},
Punct {
ch: ';',
spacing: Alone,
span: #0 bytes(0..0),
},
]
PRINT-DERIVE INPUT (DISPLAY): struct A {
}
PRINT-DERIVE RE-COLLECTED (DISPLAY): struct A { }
PRINT-DERIVE INPUT (DEBUG): TokenStream [
Ident {
ident: "struct",
span: #0 bytes(0..0),
},
Ident {
ident: "A",
span: #0 bytes(0..0),
},
Group {
delimiter: Brace,
stream: TokenStream [],
span: #0 bytes(0..0),
},
]