Skip to content

Commit 85e02bd

Browse files
committed
Add tests.
1 parent 839c286 commit 85e02bd

File tree

6 files changed

+15
-7
lines changed

6 files changed

+15
-7
lines changed

Diff for: src/test/compile-fail-fulldeps/proc-macro/proc-macro-attributes.rs

+1
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ extern crate derive_b;
2020
#[C] //~ ERROR: The attribute `C` is currently unknown to the compiler
2121
#[B(D)]
2222
#[B(E = "foo")]
23+
#[B arbitrary tokens] //~ expected one of `(` or `=`, found `arbitrary`
2324
struct B;
2425

2526
fn main() {}

Diff for: src/test/compile-fail/macro-with-seps-err-msg.rs

+1
Original file line numberDiff line numberDiff line change
@@ -14,4 +14,5 @@ fn main() {
1414
globnar::brotz!(); //~ ERROR non-ident macro paths are experimental
1515
::foo!(); //~ ERROR non-ident macro paths are experimental
1616
foo::<T>!(); //~ ERROR type parameters are not allowed on macros
17+
#[derive(foo::Bar)] struct T; //~ ERROR non-ident macro paths are experimental
1718
}

Diff for: src/test/run-pass-fulldeps/proc-macro/attr-args.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,6 @@ use attr_args::attr_with_args;
1919
#[attr_with_args(text = "Hello, world!")]
2020
fn foo() {}
2121

22-
fn main() {
23-
assert_eq!(foo(), "Hello, world!");
24-
}
22+
#[::attr_args::identity
23+
fn main() { assert_eq!(foo(), "Hello, world!"); }]
24+
struct Dummy;

Diff for: src/test/run-pass-fulldeps/proc-macro/auxiliary/attr-args.rs

+5
Original file line numberDiff line numberDiff line change
@@ -30,3 +30,8 @@ pub fn attr_with_args(args: TokenStream, input: TokenStream) -> TokenStream {
3030
fn foo() -> &'static str { "Hello, world!" }
3131
"#.parse().unwrap()
3232
}
33+
34+
#[proc_macro_attribute]
35+
pub fn identity(attr_args: TokenStream, _: TokenStream) -> TokenStream {
36+
attr_args
37+
}

Diff for: src/test/run-pass-fulldeps/proc-macro/auxiliary/derive-b.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ use proc_macro::TokenStream;
1919
#[proc_macro_derive(B, attributes(B, C))]
2020
pub fn derive(input: TokenStream) -> TokenStream {
2121
let input = input.to_string();
22-
assert!(input.contains("#[B]"));
22+
assert!(input.contains("#[B arbitrary tokens]"));
2323
assert!(input.contains("struct B {"));
2424
assert!(input.contains("#[C]"));
2525
"".parse().unwrap()

Diff for: src/test/run-pass-fulldeps/proc-macro/derive-b.rs

+4-3
Original file line numberDiff line numberDiff line change
@@ -11,11 +11,12 @@
1111
// aux-build:derive-b.rs
1212
// ignore-stage1
1313

14-
#[macro_use]
14+
#![feature(proc_macro)]
15+
1516
extern crate derive_b;
1617

17-
#[derive(Debug, PartialEq, B, Eq, Copy, Clone)]
18-
#[B]
18+
#[derive(Debug, PartialEq, derive_b::B, Eq, Copy, Clone)]
19+
#[cfg_attr(all(), B arbitrary tokens)]
1920
struct B {
2021
#[C]
2122
a: u64

0 commit comments

Comments
 (0)