#[C] //~ ERROR: The attribute `C` is currently unknown to the compiler
#[B(D)]
#[B(E = "foo")]
+#[B arbitrary tokens] //~ expected one of `(` or `=`, found `arbitrary`
struct B;
fn main() {}
globnar::brotz!(); //~ ERROR non-ident macro paths are experimental
::foo!(); //~ ERROR non-ident macro paths are experimental
foo::<T>!(); //~ ERROR type parameters are not allowed on macros
+ #[derive(foo::Bar)] struct T; //~ ERROR non-ident macro paths are experimental
}
#[attr_with_args(text = "Hello, world!")]
fn foo() {}
-fn main() {
- assert_eq!(foo(), "Hello, world!");
-}
+#[::attr_args::identity
+ fn main() { assert_eq!(foo(), "Hello, world!"); }]
+struct Dummy;
fn foo() -> &'static str { "Hello, world!" }
"#.parse().unwrap()
}
+
+#[proc_macro_attribute]
+pub fn identity(attr_args: TokenStream, _: TokenStream) -> TokenStream {
+ attr_args
+}
#[proc_macro_derive(B, attributes(B, C))]
pub fn derive(input: TokenStream) -> TokenStream {
let input = input.to_string();
- assert!(input.contains("#[B]"));
+ assert!(input.contains("#[B arbitrary tokens]"));
assert!(input.contains("struct B {"));
assert!(input.contains("#[C]"));
"".parse().unwrap()
// aux-build:derive-b.rs
// ignore-stage1
-#[macro_use]
+#![feature(proc_macro)]
+
extern crate derive_b;
-#[derive(Debug, PartialEq, B, Eq, Copy, Clone)]
-#[B]
+#[derive(Debug, PartialEq, derive_b::B, Eq, Copy, Clone)]
+#[cfg_attr(all(), B arbitrary tokens)]
struct B {
#[C]
a: u64