-
Notifications
You must be signed in to change notification settings - Fork 13.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Implement basic input validation for built-in attributes #57321
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Large diffs are not rendered by default.
This file was deleted.
This file was deleted.
This file was deleted.
This file was deleted.
This file was deleted.
This file was deleted.
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,20 +1,26 @@ | ||
error: arguments to macro_use are not allowed here | ||
--> $DIR/issue-43106-gating-of-macro_use.rs:6:1 | ||
| | ||
LL | #![macro_use = "4900"] //~ ERROR arguments to macro_use are not allowed here | ||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | ||
LL | #![macro_use(my_macro)] | ||
| ^^^^^^^^^^^^^^^^^^^^^^^ | ||
|
||
error: arguments to macro_use are not allowed here | ||
--> $DIR/issue-43106-gating-of-macro_use.rs:8:1 | ||
--> $DIR/issue-43106-gating-of-macro_use.rs:9:1 | ||
| | ||
LL | #[macro_use = "2700"] | ||
| ^^^^^^^^^^^^^^^^^^^^^ | ||
LL | #[macro_use(my_macro)] | ||
| ^^^^^^^^^^^^^^^^^^^^^^ | ||
|
||
error: arguments to macro_use are not allowed here | ||
--> $DIR/issue-43106-gating-of-macro_use.rs:11:17 | ||
--> $DIR/issue-43106-gating-of-macro_use.rs:12:17 | ||
| | ||
LL | mod inner { #![macro_use="2700"] } | ||
| ^^^^^^^^^^^^^^^^^^^^ | ||
LL | mod inner { #![macro_use(my_macro)] } | ||
| ^^^^^^^^^^^^^^^^^^^^^^^ | ||
|
||
error: aborting due to 3 previous errors | ||
error: attribute must be of the form `#[macro_use]` or `#[macro_use(name1, name2, ...)]` | ||
--> $DIR/issue-43106-gating-of-macro_use.rs:15:5 | ||
| | ||
LL | #[macro_use = "2700"] struct S; | ||
| ^^^^^^^^^^^^^^^^^^^^^ | ||
|
||
error: aborting due to 4 previous errors | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,38 +1,38 @@ | ||
error: the `#[proc_macro_derive]` attribute may only be used on bare functions | ||
--> $DIR/issue-43106-gating-of-proc_macro_derive.rs:10:1 | ||
| | ||
LL | #[proc_macro_derive = "2500"] | ||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | ||
LL | #[proc_macro_derive()] | ||
| ^^^^^^^^^^^^^^^^^^^^^^ | ||
|
||
error: the `#[proc_macro_derive]` attribute may only be used on bare functions | ||
--> $DIR/issue-43106-gating-of-proc_macro_derive.rs:18:17 | ||
| | ||
LL | mod inner { #![proc_macro_derive="2500"] } | ||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | ||
LL | mod inner { #![proc_macro_derive()] } | ||
| ^^^^^^^^^^^^^^^^^^^^^^^ | ||
|
||
error: the `#[proc_macro_derive]` attribute is only usable with crates of the `proc-macro` crate type | ||
--> $DIR/issue-43106-gating-of-proc_macro_derive.rs:21:5 | ||
| | ||
LL | #[proc_macro_derive = "2500"] fn f() { } | ||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | ||
LL | #[proc_macro_derive()] fn f() { } | ||
| ^^^^^^^^^^^^^^^^^^^^^^ | ||
|
||
error: the `#[proc_macro_derive]` attribute may only be used on bare functions | ||
--> $DIR/issue-43106-gating-of-proc_macro_derive.rs:24:5 | ||
| | ||
LL | #[proc_macro_derive = "2500"] struct S; | ||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | ||
LL | #[proc_macro_derive()] struct S; | ||
| ^^^^^^^^^^^^^^^^^^^^^^ | ||
|
||
error: the `#[proc_macro_derive]` attribute may only be used on bare functions | ||
--> $DIR/issue-43106-gating-of-proc_macro_derive.rs:27:5 | ||
| | ||
LL | #[proc_macro_derive = "2500"] type T = S; | ||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | ||
LL | #[proc_macro_derive()] type T = S; | ||
| ^^^^^^^^^^^^^^^^^^^^^^ | ||
|
||
error: the `#[proc_macro_derive]` attribute may only be used on bare functions | ||
--> $DIR/issue-43106-gating-of-proc_macro_derive.rs:30:5 | ||
| | ||
LL | #[proc_macro_derive = "2500"] impl S { } | ||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | ||
LL | #[proc_macro_derive()] impl S { } | ||
| ^^^^^^^^^^^^^^^^^^^^^^ | ||
|
||
error: aborting due to 6 previous errors | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,44 +1,44 @@ | ||
error: stability attributes may not be used outside of the standard library | ||
--> $DIR/issue-43106-gating-of-rustc_deprecated.rs:7:1 | ||
| | ||
LL | #![rustc_deprecated = "1500"] | ||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | ||
LL | #![rustc_deprecated()] | ||
| ^^^^^^^^^^^^^^^^^^^^^^ | ||
|
||
error: stability attributes may not be used outside of the standard library | ||
--> $DIR/issue-43106-gating-of-rustc_deprecated.rs:10:1 | ||
| | ||
LL | #[rustc_deprecated = "1500"] | ||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | ||
LL | #[rustc_deprecated()] | ||
| ^^^^^^^^^^^^^^^^^^^^^ | ||
|
||
error: stability attributes may not be used outside of the standard library | ||
--> $DIR/issue-43106-gating-of-rustc_deprecated.rs:13:17 | ||
| | ||
LL | mod inner { #![rustc_deprecated="1500"] } | ||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^ | ||
LL | mod inner { #![rustc_deprecated()] } | ||
| ^^^^^^^^^^^^^^^^^^^^^^ | ||
|
||
error: stability attributes may not be used outside of the standard library | ||
--> $DIR/issue-43106-gating-of-rustc_deprecated.rs:16:5 | ||
| | ||
LL | #[rustc_deprecated = "1500"] fn f() { } | ||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | ||
LL | #[rustc_deprecated()] fn f() { } | ||
| ^^^^^^^^^^^^^^^^^^^^^ | ||
|
||
error: stability attributes may not be used outside of the standard library | ||
--> $DIR/issue-43106-gating-of-rustc_deprecated.rs:19:5 | ||
| | ||
LL | #[rustc_deprecated = "1500"] struct S; | ||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | ||
LL | #[rustc_deprecated()] struct S; | ||
| ^^^^^^^^^^^^^^^^^^^^^ | ||
|
||
error: stability attributes may not be used outside of the standard library | ||
--> $DIR/issue-43106-gating-of-rustc_deprecated.rs:22:5 | ||
| | ||
LL | #[rustc_deprecated = "1500"] type T = S; | ||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | ||
LL | #[rustc_deprecated()] type T = S; | ||
| ^^^^^^^^^^^^^^^^^^^^^ | ||
|
||
error: stability attributes may not be used outside of the standard library | ||
--> $DIR/issue-43106-gating-of-rustc_deprecated.rs:25:5 | ||
| | ||
LL | #[rustc_deprecated = "1500"] impl S { } | ||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | ||
LL | #[rustc_deprecated()] impl S { } | ||
| ^^^^^^^^^^^^^^^^^^^^^ | ||
|
||
error: aborting due to 7 previous errors | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,44 +1,44 @@ | ||
error: stability attributes may not be used outside of the standard library | ||
--> $DIR/issue-43106-gating-of-stable.rs:7:1 | ||
| | ||
LL | #![stable = "1300"] | ||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | ||
LL | #![stable()] | ||
| ^^^^^^^^^^^^ | ||
|
||
error: stability attributes may not be used outside of the standard library | ||
--> $DIR/issue-43106-gating-of-stable.rs:10:1 | ||
| | ||
LL | #[stable = "1300"] | ||
| ^^^^^^^^^^^^^^^^^^ | ||
LL | #[stable()] | ||
| ^^^^^^^^^^^ | ||
|
||
error: stability attributes may not be used outside of the standard library | ||
--> $DIR/issue-43106-gating-of-stable.rs:13:17 | ||
| | ||
LL | mod inner { #![stable="1300"] } | ||
| ^^^^^^^^^^^^^^^^^ | ||
LL | mod inner { #![stable()] } | ||
| ^^^^^^^^^^^^ | ||
|
||
error: stability attributes may not be used outside of the standard library | ||
--> $DIR/issue-43106-gating-of-stable.rs:16:5 | ||
| | ||
LL | #[stable = "1300"] fn f() { } | ||
| ^^^^^^^^^^^^^^^^^^ | ||
LL | #[stable()] fn f() { } | ||
| ^^^^^^^^^^^ | ||
|
||
error: stability attributes may not be used outside of the standard library | ||
--> $DIR/issue-43106-gating-of-stable.rs:19:5 | ||
| | ||
LL | #[stable = "1300"] struct S; | ||
| ^^^^^^^^^^^^^^^^^^ | ||
LL | #[stable()] struct S; | ||
| ^^^^^^^^^^^ | ||
|
||
error: stability attributes may not be used outside of the standard library | ||
--> $DIR/issue-43106-gating-of-stable.rs:22:5 | ||
| | ||
LL | #[stable = "1300"] type T = S; | ||
| ^^^^^^^^^^^^^^^^^^ | ||
LL | #[stable()] type T = S; | ||
| ^^^^^^^^^^^ | ||
|
||
error: stability attributes may not be used outside of the standard library | ||
--> $DIR/issue-43106-gating-of-stable.rs:25:5 | ||
| | ||
LL | #[stable = "1300"] impl S { } | ||
| ^^^^^^^^^^^^^^^^^^ | ||
LL | #[stable()] impl S { } | ||
| ^^^^^^^^^^^ | ||
|
||
error: aborting due to 7 previous errors | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,44 +1,44 @@ | ||
error: stability attributes may not be used outside of the standard library | ||
--> $DIR/issue-43106-gating-of-unstable.rs:7:1 | ||
| | ||
LL | #![unstable = "1200"] | ||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | ||
LL | #![unstable()] | ||
| ^^^^^^^^^^^^^^ | ||
|
||
error: stability attributes may not be used outside of the standard library | ||
--> $DIR/issue-43106-gating-of-unstable.rs:10:1 | ||
| | ||
LL | #[unstable = "1200"] | ||
| ^^^^^^^^^^^^^^^^^^^^ | ||
LL | #[unstable()] | ||
| ^^^^^^^^^^^^^ | ||
|
||
error: stability attributes may not be used outside of the standard library | ||
--> $DIR/issue-43106-gating-of-unstable.rs:13:17 | ||
| | ||
LL | mod inner { #![unstable="1200"] } | ||
| ^^^^^^^^^^^^^^^^^^^ | ||
LL | mod inner { #![unstable()] } | ||
| ^^^^^^^^^^^^^^ | ||
|
||
error: stability attributes may not be used outside of the standard library | ||
--> $DIR/issue-43106-gating-of-unstable.rs:16:5 | ||
| | ||
LL | #[unstable = "1200"] fn f() { } | ||
| ^^^^^^^^^^^^^^^^^^^^ | ||
LL | #[unstable()] fn f() { } | ||
| ^^^^^^^^^^^^^ | ||
|
||
error: stability attributes may not be used outside of the standard library | ||
--> $DIR/issue-43106-gating-of-unstable.rs:19:5 | ||
| | ||
LL | #[unstable = "1200"] struct S; | ||
| ^^^^^^^^^^^^^^^^^^^^ | ||
LL | #[unstable()] struct S; | ||
| ^^^^^^^^^^^^^ | ||
|
||
error: stability attributes may not be used outside of the standard library | ||
--> $DIR/issue-43106-gating-of-unstable.rs:22:5 | ||
| | ||
LL | #[unstable = "1200"] type T = S; | ||
| ^^^^^^^^^^^^^^^^^^^^ | ||
LL | #[unstable()] type T = S; | ||
| ^^^^^^^^^^^^^ | ||
|
||
error: stability attributes may not be used outside of the standard library | ||
--> $DIR/issue-43106-gating-of-unstable.rs:25:5 | ||
| | ||
LL | #[unstable = "1200"] impl S { } | ||
| ^^^^^^^^^^^^^^^^^^^^ | ||
LL | #[unstable()] impl S { } | ||
| ^^^^^^^^^^^^^ | ||
|
||
error: aborting due to 7 previous errors | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1,8 @@ | ||
error: `crate_type` requires a value | ||
error: attribute must be of the form `#[crate_type = "bin|lib|..."]` | ||
--> $DIR/invalid_crate_type_syntax.rs:2:1 | ||
| | ||
LL | #![crate_type(lib)] //~ ERROR `crate_type` requires a value | ||
LL | #![crate_type(lib)] //~ ERROR attribute must be of the form | ||
| ^^^^^^^^^^^^^^^^^^^ | ||
| | ||
= note: for example: `#![crate_type="lib"]` | ||
|
||
error: aborting due to previous error | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
#![deny = "foo"] //~ ERROR malformed lint attribute | ||
#![deny = "foo"] //~ ERROR attribute must be of the form | ||
#![allow(bar = "baz")] //~ ERROR malformed lint attribute | ||
|
||
fn main() { } |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,15 +1,15 @@ | ||
error[E0452]: malformed lint attribute | ||
--> $DIR/lint-malformed.rs:1:1 | ||
| | ||
LL | #![deny = "foo"] //~ ERROR malformed lint attribute | ||
| ^^^^^^^^^^^^^^^^ | ||
|
||
error[E0452]: malformed lint attribute | ||
--> $DIR/lint-malformed.rs:2:10 | ||
| | ||
LL | #![allow(bar = "baz")] //~ ERROR malformed lint attribute | ||
| ^^^^^^^^^^^ | ||
|
||
error: attribute must be of the form `#[deny(lint1, lint2, ..., /*opt*/ reason = "...")]` | ||
--> $DIR/lint-malformed.rs:1:1 | ||
| | ||
LL | #![deny = "foo"] //~ ERROR attribute must be of the form | ||
| ^^^^^^^^^^^^^^^^ | ||
|
||
error: aborting due to 2 previous errors | ||
|
||
For more information about this error, try `rustc --explain E0452`. |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
#[derive(::Absolute)] //~ ERROR failed to resolve | ||
struct S; | ||
|
||
fn main() {} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
error[E0433]: failed to resolve: maybe a missing `extern crate Absolute;`? | ||
--> $DIR/meta-item-absolute-path.rs:1:12 | ||
| | ||
LL | #[derive(::Absolute)] //~ ERROR failed to resolve | ||
| ^^^^^^^^ maybe a missing `extern crate Absolute;`? | ||
|
||
error: aborting due to previous error | ||
|
||
For more information about this error, try `rustc --explain E0433`. |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
#![feature(plugin)] | ||
#![plugin] //~ ERROR malformed plugin attribute | ||
#![plugin] //~ ERROR attribute must be of the form | ||
|
||
fn main() {} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,8 @@ | ||
error[E0498]: malformed plugin attribute | ||
error: attribute must be of the form `#[plugin(name|name(args))]` | ||
--> $DIR/malformed-plugin-1.rs:2:1 | ||
| | ||
LL | #![plugin] //~ ERROR malformed plugin attribute | ||
LL | #![plugin] //~ ERROR attribute must be of the form | ||
| ^^^^^^^^^^ | ||
|
||
error: aborting due to previous error | ||
|
||
For more information about this error, try `rustc --explain E0498`. |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
#![feature(plugin)] | ||
#![plugin="bleh"] //~ ERROR malformed plugin attribute | ||
#![plugin="bleh"] //~ ERROR attribute must be of the form | ||
|
||
fn main() {} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,8 @@ | ||
error[E0498]: malformed plugin attribute | ||
error: attribute must be of the form `#[plugin(name|name(args))]` | ||
--> $DIR/malformed-plugin-2.rs:2:1 | ||
| | ||
LL | #![plugin="bleh"] //~ ERROR malformed plugin attribute | ||
LL | #![plugin="bleh"] //~ ERROR attribute must be of the form | ||
| ^^^^^^^^^^^^^^^^^ | ||
|
||
error: aborting due to previous error | ||
|
||
For more information about this error, try `rustc --explain E0498`. |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
// compile-pass | ||
|
||
#[doc] //~ WARN attribute must be of the form | ||
#[ignore()] //~ WARN attribute must be of the form | ||
#[inline = ""] //~ WARN attribute must be of the form | ||
#[link] //~ WARN attribute must be of the form | ||
#[link = ""] //~ WARN attribute must be of the form | ||
fn main() {} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
warning: attribute must be of the form `#[doc(hidden|inline|...)]` or `#[doc = "string"]` | ||
--> $DIR/malformed-regressions.rs:3:1 | ||
| | ||
LL | #[doc] //~ WARN attribute must be of the form | ||
| ^^^^^^ | ||
| | ||
= note: #[warn(ill_formed_attribute_input)] on by default | ||
= warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! | ||
= note: for more information, see issue #57571 <https://github.com/rust-lang/rust/issues/57571> | ||
|
||
warning: attribute must be of the form `#[ignore]` or `#[ignore = "reason"]` | ||
--> $DIR/malformed-regressions.rs:4:1 | ||
| | ||
LL | #[ignore()] //~ WARN attribute must be of the form | ||
| ^^^^^^^^^^^ | ||
| | ||
= warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! | ||
= note: for more information, see issue #57571 <https://github.com/rust-lang/rust/issues/57571> | ||
|
||
warning: attribute must be of the form `#[inline]` or `#[inline(always|never)]` | ||
--> $DIR/malformed-regressions.rs:5:1 | ||
| | ||
LL | #[inline = ""] //~ WARN attribute must be of the form | ||
| ^^^^^^^^^^^^^^ | ||
| | ||
= warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! | ||
= note: for more information, see issue #57571 <https://github.com/rust-lang/rust/issues/57571> | ||
|
||
warning: attribute must be of the form `#[link(name = "...", /*opt*/ kind = "dylib|static|...", | ||
/*opt*/ cfg = "...")]` | ||
--> $DIR/malformed-regressions.rs:6:1 | ||
| | ||
LL | #[link] //~ WARN attribute must be of the form | ||
| ^^^^^^^ | ||
| | ||
= warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! | ||
= note: for more information, see issue #57571 <https://github.com/rust-lang/rust/issues/57571> | ||
|
||
warning: attribute must be of the form `#[link(name = "...", /*opt*/ kind = "dylib|static|...", | ||
/*opt*/ cfg = "...")]` | ||
--> $DIR/malformed-regressions.rs:7:1 | ||
| | ||
LL | #[link = ""] //~ WARN attribute must be of the form | ||
| ^^^^^^^^^^^^ | ||
| | ||
= warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! | ||
= note: for more information, see issue #57571 <https://github.com/rust-lang/rust/issues/57571> | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
#[cfg_attr] //~ ERROR expected `(`, found `<eof>` | ||
struct S1; | ||
|
||
#[cfg_attr = ""] //~ ERROR expected `(`, found `=` | ||
struct S2; | ||
|
||
#[derive] //~ ERROR attribute must be of the form | ||
struct S3; | ||
|
||
#[derive = ""] //~ ERROR attribute must be of the form | ||
struct S4; | ||
|
||
fn main() {} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
error: expected `(`, found `<eof>` | ||
|
||
error: expected `(`, found `=` | ||
--> $DIR/malformed-special-attrs.rs:4:12 | ||
| | ||
LL | #[cfg_attr] //~ ERROR expected `(`, found `<eof>` | ||
| - expected `(` | ||
... | ||
LL | #[cfg_attr = ""] //~ ERROR expected `(`, found `=` | ||
| ^ unexpected token | ||
|
||
error: attribute must be of the form `#[derive(Trait1, Trait2, ...)]` | ||
--> $DIR/malformed-special-attrs.rs:7:1 | ||
| | ||
LL | #[derive] //~ ERROR attribute must be of the form | ||
| ^^^^^^^^^ | ||
|
||
error: attribute must be of the form `#[derive(Trait1, Trait2, ...)]` | ||
--> $DIR/malformed-special-attrs.rs:10:1 | ||
| | ||
LL | #[derive = ""] //~ ERROR attribute must be of the form | ||
| ^^^^^^^^^^^^^^ | ||
|
||
error: aborting due to 4 previous errors | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,20 +1,20 @@ | ||
error: attribute should be empty | ||
error: attribute must be of the form `#[marker]` | ||
--> $DIR/marker-attribute-with-values.rs:4:1 | ||
| | ||
LL | #[marker(always)] | ||
| ^^^^^^^^^^^^^^^^^ | ||
|
||
error: attribute should be empty | ||
error: attribute must be of the form `#[marker]` | ||
--> $DIR/marker-attribute-with-values.rs:8:1 | ||
| | ||
LL | #[marker("never")] | ||
| ^^^^^^^^^^^^^^^^^^ | ||
|
||
error: attribute should be empty | ||
--> $DIR/marker-attribute-with-values.rs:12:1 | ||
error: expected unsuffixed literal or identifier, found value | ||
--> $DIR/marker-attribute-with-values.rs:12:10 | ||
| | ||
LL | #[marker(key = value)] | ||
| ^^^^^^^^^^^^^^^^^^^^^^ | ||
| ^^^ | ||
|
||
error: aborting due to 3 previous errors | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1,8 @@ | ||
error: `crate_type` requires a value | ||
error: attribute must be of the form `#[crate_type = "bin|lib|..."]` | ||
--> $DIR/no_crate_type.rs:2:1 | ||
| | ||
LL | #![crate_type] //~ ERROR `crate_type` requires a value | ||
LL | #![crate_type] //~ ERROR attribute must be of the form | ||
| ^^^^^^^^^^^^^^ | ||
| | ||
= note: for example: `#![crate_type="lib"]` | ||
|
||
error: aborting due to previous error | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1,17 @@ | ||
error: an inner attribute is not permitted in this context | ||
--> $DIR/attr.rs:5:3 | ||
| | ||
LL | #![lang(foo)] //~ ERROR an inner attribute is not permitted in this context | ||
LL | #![lang = "foo"] //~ ERROR an inner attribute is not permitted in this context | ||
| ^ | ||
| | ||
= note: inner attributes, like `#![no_std]`, annotate the item enclosing them, and are usually found at the beginning of source files. Outer attributes, like `#[test]`, annotate the item following them. | ||
|
||
error: aborting due to previous error | ||
error[E0522]: definition of an unknown language item: `foo` | ||
--> $DIR/attr.rs:5:1 | ||
| | ||
LL | #![lang = "foo"] //~ ERROR an inner attribute is not permitted in this context | ||
| ^^^^^^^^^^^^^^^^ definition of unknown language item `foo` | ||
|
||
error: aborting due to 2 previous errors | ||
|
||
For more information about this error, try `rustc --explain E0522`. |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,25 +1,20 @@ | ||
warning: `repr` attribute must have a hint | ||
--> $DIR/repr.rs:3:1 | ||
error: attribute must be of the form `#[repr(C, packed, ...)]` | ||
--> $DIR/repr.rs:1:1 | ||
| | ||
LL | #[repr] | ||
| ^^^^^^^ needs a hint | ||
| | ||
= note: #[warn(bad_repr)] on by default | ||
= help: valid hints include `#[repr(C)]`, `#[repr(packed)]`, `#[repr(rust)]` and `#[repr(transparent)]` | ||
= note: for more information, visit <https://doc.rust-lang.org/reference/type-layout.html> | ||
| ^^^^^^^ | ||
|
||
warning: `repr` attribute isn't configurable with a literal | ||
--> $DIR/repr.rs:7:1 | ||
error: attribute must be of the form `#[repr(C, packed, ...)]` | ||
--> $DIR/repr.rs:5:1 | ||
| | ||
LL | #[repr = "B"] | ||
| ^^^^^^^^^^^^^ needs a hint | ||
| | ||
= help: valid hints include `#[repr(C)]`, `#[repr(packed)]`, `#[repr(rust)]` and `#[repr(transparent)]` | ||
= note: for more information, visit <https://doc.rust-lang.org/reference/type-layout.html> | ||
| ^^^^^^^^^^^^^ | ||
|
||
warning: `repr` attribute isn't configurable with a literal | ||
--> $DIR/repr.rs:11:1 | ||
error: attribute must be of the form `#[repr(C, packed, ...)]` | ||
--> $DIR/repr.rs:9:1 | ||
| | ||
LL | #[repr = "C"] | ||
| ^^^^^^^^^^^^^ help: give `repr` a hint: `#[repr(C)]` | ||
| ^^^^^^^^^^^^^ | ||
|
||
error: aborting due to 3 previous errors | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,6 @@ | ||
// compile-flags:-Zforce-unstable-if-unmarked | ||
|
||
#[unstable] //~ ERROR: stability attributes may not be used | ||
#[stable] //~ ERROR: stability attributes may not be used | ||
#[rustc_deprecated] //~ ERROR: stability attributes may not be used | ||
#[unstable()] //~ ERROR: stability attributes may not be used | ||
#[stable()] //~ ERROR: stability attributes may not be used | ||
#[rustc_deprecated()] //~ ERROR: stability attributes may not be used | ||
fn main() { } |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,20 +1,20 @@ | ||
error: stability attributes may not be used outside of the standard library | ||
--> $DIR/stability-attribute-non-staged-force-unstable.rs:3:1 | ||
| | ||
LL | #[unstable] //~ ERROR: stability attributes may not be used | ||
| ^^^^^^^^^^^ | ||
LL | #[unstable()] //~ ERROR: stability attributes may not be used | ||
| ^^^^^^^^^^^^^ | ||
|
||
error: stability attributes may not be used outside of the standard library | ||
--> $DIR/stability-attribute-non-staged-force-unstable.rs:4:1 | ||
| | ||
LL | #[stable] //~ ERROR: stability attributes may not be used | ||
| ^^^^^^^^^ | ||
LL | #[stable()] //~ ERROR: stability attributes may not be used | ||
| ^^^^^^^^^^^ | ||
|
||
error: stability attributes may not be used outside of the standard library | ||
--> $DIR/stability-attribute-non-staged-force-unstable.rs:5:1 | ||
| | ||
LL | #[rustc_deprecated] //~ ERROR: stability attributes may not be used | ||
| ^^^^^^^^^^^^^^^^^^^ | ||
LL | #[rustc_deprecated()] //~ ERROR: stability attributes may not be used | ||
| ^^^^^^^^^^^^^^^^^^^^^ | ||
|
||
error: aborting due to 3 previous errors | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
#[unstable] //~ ERROR: stability attributes may not be used | ||
#[stable] //~ ERROR: stability attributes may not be used | ||
#[rustc_deprecated] //~ ERROR: stability attributes may not be used | ||
#[unstable()] //~ ERROR: stability attributes may not be used | ||
#[stable()] //~ ERROR: stability attributes may not be used | ||
#[rustc_deprecated()] //~ ERROR: stability attributes may not be used | ||
fn main() { } |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,20 +1,20 @@ | ||
error: stability attributes may not be used outside of the standard library | ||
--> $DIR/stability-attribute-non-staged.rs:1:1 | ||
| | ||
LL | #[unstable] //~ ERROR: stability attributes may not be used | ||
| ^^^^^^^^^^^ | ||
LL | #[unstable()] //~ ERROR: stability attributes may not be used | ||
| ^^^^^^^^^^^^^ | ||
|
||
error: stability attributes may not be used outside of the standard library | ||
--> $DIR/stability-attribute-non-staged.rs:2:1 | ||
| | ||
LL | #[stable] //~ ERROR: stability attributes may not be used | ||
| ^^^^^^^^^ | ||
LL | #[stable()] //~ ERROR: stability attributes may not be used | ||
| ^^^^^^^^^^^ | ||
|
||
error: stability attributes may not be used outside of the standard library | ||
--> $DIR/stability-attribute-non-staged.rs:3:1 | ||
| | ||
LL | #[rustc_deprecated] //~ ERROR: stability attributes may not be used | ||
| ^^^^^^^^^^^^^^^^^^^ | ||
LL | #[rustc_deprecated()] //~ ERROR: stability attributes may not be used | ||
| ^^^^^^^^^^^^^^^^^^^^^ | ||
|
||
error: aborting due to 3 previous errors | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
// Various checks that stability attributes are used correctly, per RFC 507 | ||
|
||
#![feature(staged_api)] | ||
|
||
#![stable(feature = "rust1", since = "1.0.0")] | ||
|
||
mod bogus_attribute_types_2 { | ||
#[unstable] //~ ERROR attribute must be of the form | ||
fn f1() { } | ||
|
||
#[unstable = "b"] //~ ERROR attribute must be of the form | ||
fn f2() { } | ||
|
||
#[stable] //~ ERROR attribute must be of the form | ||
fn f3() { } | ||
|
||
#[stable = "a"] //~ ERROR attribute must be of the form | ||
fn f4() { } | ||
|
||
#[stable(feature = "a", since = "b")] | ||
#[rustc_deprecated] //~ ERROR attribute must be of the form | ||
fn f5() { } | ||
|
||
#[stable(feature = "a", since = "b")] | ||
#[rustc_deprecated = "a"] //~ ERROR attribute must be of the form | ||
fn f6() { } | ||
} | ||
|
||
fn main() { } |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
error: attribute must be of the form `#[unstable(feature = "name", reason = "...", issue = "N")]` | ||
--> $DIR/stability-attribute-sanity-4.rs:8:5 | ||
| | ||
LL | #[unstable] //~ ERROR attribute must be of the form | ||
| ^^^^^^^^^^^ | ||
|
||
error: attribute must be of the form `#[unstable(feature = "name", reason = "...", issue = "N")]` | ||
--> $DIR/stability-attribute-sanity-4.rs:11:5 | ||
| | ||
LL | #[unstable = "b"] //~ ERROR attribute must be of the form | ||
| ^^^^^^^^^^^^^^^^^ | ||
|
||
error: attribute must be of the form `#[stable(feature = "name", since = "version")]` | ||
--> $DIR/stability-attribute-sanity-4.rs:14:5 | ||
| | ||
LL | #[stable] //~ ERROR attribute must be of the form | ||
| ^^^^^^^^^ | ||
|
||
error: attribute must be of the form `#[stable(feature = "name", since = "version")]` | ||
--> $DIR/stability-attribute-sanity-4.rs:17:5 | ||
| | ||
LL | #[stable = "a"] //~ ERROR attribute must be of the form | ||
| ^^^^^^^^^^^^^^^ | ||
|
||
error: attribute must be of the form `#[rustc_deprecated(since = "version", reason = "...")]` | ||
--> $DIR/stability-attribute-sanity-4.rs:21:5 | ||
| | ||
LL | #[rustc_deprecated] //~ ERROR attribute must be of the form | ||
| ^^^^^^^^^^^^^^^^^^^ | ||
|
||
error: attribute must be of the form `#[rustc_deprecated(since = "version", reason = "...")]` | ||
--> $DIR/stability-attribute-sanity-4.rs:25:5 | ||
| | ||
LL | #[rustc_deprecated = "a"] //~ ERROR attribute must be of the form | ||
| ^^^^^^^^^^^^^^^^^^^^^^^^^ | ||
|
||
error: aborting due to 6 previous errors | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,13 +1,15 @@ | ||
#[path = 1usize] //~ ERROR: suffixed literals are not allowed in attributes | ||
#[path = 1u8] //~ ERROR: suffixed literals are not allowed in attributes | ||
#[path = 1u16] //~ ERROR: suffixed literals are not allowed in attributes | ||
#[path = 1u32] //~ ERROR: suffixed literals are not allowed in attributes | ||
#[path = 1u64] //~ ERROR: suffixed literals are not allowed in attributes | ||
#[path = 1isize] //~ ERROR: suffixed literals are not allowed in attributes | ||
#[path = 1i8] //~ ERROR: suffixed literals are not allowed in attributes | ||
#[path = 1i16] //~ ERROR: suffixed literals are not allowed in attributes | ||
#[path = 1i32] //~ ERROR: suffixed literals are not allowed in attributes | ||
#[path = 1i64] //~ ERROR: suffixed literals are not allowed in attributes | ||
#[path = 1.0f32] //~ ERROR: suffixed literals are not allowed in attributes | ||
#[path = 1.0f64] //~ ERROR: suffixed literals are not allowed in attributes | ||
#![feature(custom_attribute)] | ||
|
||
#[my_attr = 1usize] //~ ERROR: suffixed literals are not allowed in attributes | ||
#[my_attr = 1u8] //~ ERROR: suffixed literals are not allowed in attributes | ||
#[my_attr = 1u16] //~ ERROR: suffixed literals are not allowed in attributes | ||
#[my_attr = 1u32] //~ ERROR: suffixed literals are not allowed in attributes | ||
#[my_attr = 1u64] //~ ERROR: suffixed literals are not allowed in attributes | ||
#[my_attr = 1isize] //~ ERROR: suffixed literals are not allowed in attributes | ||
#[my_attr = 1i8] //~ ERROR: suffixed literals are not allowed in attributes | ||
#[my_attr = 1i16] //~ ERROR: suffixed literals are not allowed in attributes | ||
#[my_attr = 1i32] //~ ERROR: suffixed literals are not allowed in attributes | ||
#[my_attr = 1i64] //~ ERROR: suffixed literals are not allowed in attributes | ||
#[my_attr = 1.0f32] //~ ERROR: suffixed literals are not allowed in attributes | ||
#[my_attr = 1.0f64] //~ ERROR: suffixed literals are not allowed in attributes | ||
fn main() { } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Btw... I tried to look for the reason why this happens instead of unused_attributes but got lost... (cc #54651).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is a hardcoded warning in
libsyntax/ext/derive.rs
.derive
is removed during expansion currently (rust/src/libsyntax/ext/expand.rs
Lines 373 to 374 in d6d32ac
Expansion should degrade
#[derive(Macro1, Macro2, ...)]
into#[derive()]
instead with derive attribute itself marked as used when it applies a macro.