diff options
| author | Vadim Petrochenkov <vadim.petrochenkov@gmail.com> | 2018-09-11 00:30:21 +0300 |
|---|---|---|
| committer | Vadim Petrochenkov <vadim.petrochenkov@gmail.com> | 2018-09-11 01:13:55 +0300 |
| commit | de153d61f5a4ef8681fc64fc55de2bcfe449c8c4 (patch) | |
| tree | 82780bd162d339bc56a11dee53e2a4e42f04458d /src/test | |
| parent | 65c8c97bc7151809db58756182c22032379585d9 (diff) | |
| download | rust-de153d61f5a4ef8681fc64fc55de2bcfe449c8c4.tar.gz rust-de153d61f5a4ef8681fc64fc55de2bcfe449c8c4.zip | |
resolve: Reserve a few very special names in macro namespace
Diffstat (limited to 'src/test')
5 files changed, 48 insertions, 52 deletions
diff --git a/src/test/ui-fulldeps/proc-macro/ambiguous-builtin-attrs.rs b/src/test/ui-fulldeps/proc-macro/ambiguous-builtin-attrs.rs index b3a50e8fb7c..9f4f0abf324 100644 --- a/src/test/ui-fulldeps/proc-macro/ambiguous-builtin-attrs.rs +++ b/src/test/ui-fulldeps/proc-macro/ambiguous-builtin-attrs.rs @@ -11,19 +11,6 @@ struct S; #[cfg_attr(all(), repr(C))] //~ ERROR `repr` is ambiguous struct SCond; -#[cfg(all())] //~ ERROR `cfg` is ambiguous -struct A; -#[cfg(any())] // ERROR FIXME -struct A; - -#[cfg_attr(all(), cold)] // ERROR FIXME -fn g() {} -#[cfg_attr(any(), cold)] // ERROR FIXME -fn h() {} - -#[derive(Clone)] // ERROR FIXME -struct B; - #[test] // OK, shadowed fn test() {} diff --git a/src/test/ui-fulldeps/proc-macro/ambiguous-builtin-attrs.stderr b/src/test/ui-fulldeps/proc-macro/ambiguous-builtin-attrs.stderr index 2bf3082aa42..ea867faf47b 100644 --- a/src/test/ui-fulldeps/proc-macro/ambiguous-builtin-attrs.stderr +++ b/src/test/ui-fulldeps/proc-macro/ambiguous-builtin-attrs.stderr @@ -34,26 +34,8 @@ LL | #[cfg_attr(all(), repr(C))] //~ ERROR `repr` is ambiguous | ^^^^ = note: consider adding an explicit import of `repr` to disambiguate -error[E0659]: `cfg` is ambiguous - --> $DIR/ambiguous-builtin-attrs.rs:14:3 - | -LL | #[cfg(all())] //~ ERROR `cfg` is ambiguous - | ^^^ ambiguous name - | -note: `cfg` could refer to the name imported here - --> $DIR/ambiguous-builtin-attrs.rs:7:5 - | -LL | use builtin_attrs::*; - | ^^^^^^^^^^^^^^^^ -note: `cfg` could also refer to the name defined here - --> $DIR/ambiguous-builtin-attrs.rs:14:3 - | -LL | #[cfg(all())] //~ ERROR `cfg` is ambiguous - | ^^^ - = note: consider adding an explicit import of `cfg` to disambiguate - error[E0659]: `repr` is ambiguous - --> $DIR/ambiguous-builtin-attrs.rs:33:34 + --> $DIR/ambiguous-builtin-attrs.rs:20:34 | LL | fn non_macro_expanded_location<#[repr(C)] T>() { //~ ERROR `repr` is ambiguous | ^^^^ ambiguous name @@ -64,14 +46,14 @@ note: `repr` could refer to the name imported here LL | use builtin_attrs::*; | ^^^^^^^^^^^^^^^^ note: `repr` could also refer to the name defined here - --> $DIR/ambiguous-builtin-attrs.rs:33:34 + --> $DIR/ambiguous-builtin-attrs.rs:20:34 | LL | fn non_macro_expanded_location<#[repr(C)] T>() { //~ ERROR `repr` is ambiguous | ^^^^ = note: consider adding an explicit import of `repr` to disambiguate error[E0659]: `repr` is ambiguous - --> $DIR/ambiguous-builtin-attrs.rs:35:11 + --> $DIR/ambiguous-builtin-attrs.rs:22:11 | LL | #[repr(C)] //~ ERROR `repr` is ambiguous | ^^^^ ambiguous name @@ -82,7 +64,7 @@ note: `repr` could refer to the name imported here LL | use builtin_attrs::*; | ^^^^^^^^^^^^^^^^ note: `repr` could also refer to the name defined here - --> $DIR/ambiguous-builtin-attrs.rs:35:11 + --> $DIR/ambiguous-builtin-attrs.rs:22:11 | LL | #[repr(C)] //~ ERROR `repr` is ambiguous | ^^^^ @@ -107,12 +89,12 @@ LL | #![feature(decl_macro)] //~ ERROR `feature` is ambiguous = note: consider adding an explicit import of `feature` to disambiguate error[E0425]: cannot find value `NonExistent` in this scope - --> $DIR/ambiguous-builtin-attrs.rs:43:5 + --> $DIR/ambiguous-builtin-attrs.rs:30:5 | LL | NonExistent; //~ ERROR cannot find value `NonExistent` in this scope | ^^^^^^^^^^^ not found in this scope -error: aborting due to 7 previous errors +error: aborting due to 6 previous errors Some errors occurred: E0425, E0659. For more information about an error, try `rustc --explain E0425`. diff --git a/src/test/ui-fulldeps/proc-macro/auxiliary/builtin-attrs.rs b/src/test/ui-fulldeps/proc-macro/auxiliary/builtin-attrs.rs index 332df815b19..e18ca57aab1 100644 --- a/src/test/ui-fulldeps/proc-macro/auxiliary/builtin-attrs.rs +++ b/src/test/ui-fulldeps/proc-macro/auxiliary/builtin-attrs.rs @@ -26,21 +26,6 @@ pub fn repr(_: TokenStream, input: TokenStream) -> TokenStream { } #[proc_macro_attribute] -pub fn cfg(_: TokenStream, input: TokenStream) -> TokenStream { - input -} - -#[proc_macro_attribute] -pub fn cfg_attr(_: TokenStream, input: TokenStream) -> TokenStream { - input -} - -#[proc_macro_attribute] -pub fn derive(_: TokenStream, input: TokenStream) -> TokenStream { - input -} - -#[proc_macro_attribute] pub fn test(_: TokenStream, input: TokenStream) -> TokenStream { "struct Test;".parse().unwrap() } diff --git a/src/test/ui-fulldeps/proc-macro/reserved-macro-names.rs b/src/test/ui-fulldeps/proc-macro/reserved-macro-names.rs new file mode 100644 index 00000000000..ff5984aa67c --- /dev/null +++ b/src/test/ui-fulldeps/proc-macro/reserved-macro-names.rs @@ -0,0 +1,22 @@ +#![crate_type = "proc-macro"] + +extern crate proc_macro; +use proc_macro::*; + +#[proc_macro_attribute] +pub fn cfg(_: TokenStream, input: TokenStream) -> TokenStream { + //~^ ERROR name `cfg` is reserved in macro namespace + input +} + +#[proc_macro_attribute] +pub fn cfg_attr(_: TokenStream, input: TokenStream) -> TokenStream { + //~^ ERROR name `cfg_attr` is reserved in macro namespace + input +} + +#[proc_macro_attribute] +pub fn derive(_: TokenStream, input: TokenStream) -> TokenStream { + //~^ ERROR name `derive` is reserved in macro namespace + input +} diff --git a/src/test/ui-fulldeps/proc-macro/reserved-macro-names.stderr b/src/test/ui-fulldeps/proc-macro/reserved-macro-names.stderr new file mode 100644 index 00000000000..be6e80c3878 --- /dev/null +++ b/src/test/ui-fulldeps/proc-macro/reserved-macro-names.stderr @@ -0,0 +1,20 @@ +error: name `cfg` is reserved in macro namespace + --> $DIR/reserved-macro-names.rs:7:8 + | +LL | pub fn cfg(_: TokenStream, input: TokenStream) -> TokenStream { + | ^^^ + +error: name `cfg_attr` is reserved in macro namespace + --> $DIR/reserved-macro-names.rs:13:8 + | +LL | pub fn cfg_attr(_: TokenStream, input: TokenStream) -> TokenStream { + | ^^^^^^^^ + +error: name `derive` is reserved in macro namespace + --> $DIR/reserved-macro-names.rs:19:8 + | +LL | pub fn derive(_: TokenStream, input: TokenStream) -> TokenStream { + | ^^^^^^ + +error: aborting due to 3 previous errors + |
