]> git.lizzy.rs Git - rust.git/commitdiff
Add tests.
authorJeffrey Seyfried <jeffrey.seyfried@gmail.com>
Wed, 8 Mar 2017 23:13:43 +0000 (23:13 +0000)
committerJeffrey Seyfried <jeffrey.seyfried@gmail.com>
Tue, 14 Mar 2017 04:39:23 +0000 (04:39 +0000)
src/test/compile-fail-fulldeps/proc-macro/proc-macro-attributes.rs
src/test/compile-fail/macro-with-seps-err-msg.rs
src/test/run-pass-fulldeps/proc-macro/attr-args.rs
src/test/run-pass-fulldeps/proc-macro/auxiliary/attr-args.rs
src/test/run-pass-fulldeps/proc-macro/auxiliary/derive-b.rs
src/test/run-pass-fulldeps/proc-macro/derive-b.rs

index 4ad1cf79d61c6fbf71475fbfa56dc479caf1f41d..df881bedec1bbf5202dfd618eefe913c658c13fc 100644 (file)
@@ -20,6 +20,7 @@
 #[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() {}
index 6cc682bde997f123ebfaa2fd78da40bc2d9aad9d..c28e22d58f9db8f6adc2f1a104903e9a47112cac 100644 (file)
@@ -14,4 +14,5 @@ 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
 }
index d28d75d81a2fb7ca5f35d42d60afdc0d49e0a792..8a9fdd7536770dc07fdd3357f63e0893e08654c9 100644 (file)
@@ -19,6 +19,6 @@
 #[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;
index 6e1eb395a0a1923f6a215cbaf6400060a8462dd6..989c77f1089cfbe913b11adb77663bc3d194c429 100644 (file)
@@ -30,3 +30,8 @@ pub fn attr_with_args(args: TokenStream, input: TokenStream) -> TokenStream {
         fn foo() -> &'static str { "Hello, world!" }
     "#.parse().unwrap()
 }
+
+#[proc_macro_attribute]
+pub fn identity(attr_args: TokenStream, _: TokenStream) -> TokenStream {
+    attr_args
+}
index bf793534d50c960a1beb6ed5a023a7d6738e8363..7b521f2b9138a21bb01c40d2ae9ea1d7ff0ebdb5 100644 (file)
@@ -19,7 +19,7 @@
 #[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()
index f1e1626ddf8ca4340fd1eb292456a47c6196ad85..995dc65729a5059f8719c88ee9b3f7380886cc02 100644 (file)
 // 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