Changes to diagnostics

This commit is contained in:
Jonathan Brouwer
2025-07-07 09:10:38 +02:00
parent 6133c676d7
commit c7f5ddc098
15 changed files with 162 additions and 97 deletions

View File

@@ -593,7 +593,13 @@ impl<'a, G: EmissionGuarantee> Diagnostic<'a, G> for AttributeParseError {
diag.code(E0565); diag.code(E0565);
} }
AttributeParseErrorReason::ExpectedNameValue(None) => { AttributeParseErrorReason::ExpectedNameValue(None) => {
// The suggestion we add below this match already contains enough information // If the span is the entire attribute, the suggestion we add below this match already contains enough information
if self.span != self.attr_span {
diag.span_label(
self.span,
format!("expected this to be of the form `... = \"...\"`"),
);
}
} }
AttributeParseErrorReason::ExpectedNameValue(Some(name)) => { AttributeParseErrorReason::ExpectedNameValue(Some(name)) => {
diag.span_label( diag.span_label(

View File

@@ -100,7 +100,7 @@
//~^ ERROR malformed //~^ ERROR malformed
//~| ERROR the `#[proc_macro]` attribute is only usable with crates of the `proc-macro` crate type //~| ERROR the `#[proc_macro]` attribute is only usable with crates of the `proc-macro` crate type
#[cfg] #[cfg]
//~^ ERROR is not followed by parentheses //~^ ERROR malformed
#[cfg_attr] #[cfg_attr]
//~^ ERROR malformed //~^ ERROR malformed
#[instruction_set] #[instruction_set]

View File

@@ -1,8 +1,11 @@
error: `cfg` is not followed by parentheses error[E0539]: malformed `cfg` attribute input
--> $DIR/malformed-attrs.rs:102:1 --> $DIR/malformed-attrs.rs:102:1
| |
LL | #[cfg] LL | #[cfg]
| ^^^^^^ help: expected syntax is: `cfg(/* predicate */)` | ^^^^^^
| |
| expected this to be a list
| help: must be of the form: `#[cfg(predicate)]`
error: malformed `cfg_attr` attribute input error: malformed `cfg_attr` attribute input
--> $DIR/malformed-attrs.rs:104:1 --> $DIR/malformed-attrs.rs:104:1

View File

@@ -3,19 +3,23 @@
#![feature(cfg_target_compact)] #![feature(cfg_target_compact)]
#[cfg(target(o::o))] #[cfg(target(o::o))]
//~^ ERROR `cfg` predicate key must be an identifier //~^ ERROR malformed `cfg` attribute input
fn one() {} fn one() {}
#[cfg(target(os = 8))] #[cfg(target(os = 8))]
//~^ ERROR literal in `cfg` predicate value must be a string //~^ ERROR malformed `cfg` attribute input
fn two() {} fn two() {}
#[cfg(target(os = "linux", pointer(width = "64")))] #[cfg(target(os = "linux", pointer(width = "64")))]
//~^ ERROR invalid predicate `target_pointer` //~^ ERROR malformed `cfg` attribute input
fn three() {} fn three() {}
#[cfg(target(true))] #[cfg(target(true))]
//~^ ERROR `cfg` predicate key must be an identifier //~^ ERROR malformed `cfg` attribute input
fn four() {} fn four() {}
#[cfg(target(clippy::os = "linux"))]
//~^ ERROR `cfg` predicate key must be an identifier
fn five() {}
fn main() {} fn main() {}

View File

@@ -1,28 +1,45 @@
error: `cfg` predicate key must be an identifier error[E0539]: malformed `cfg` attribute input
--> $DIR/cfg-target-compact-errors.rs:5:14 --> $DIR/cfg-target-compact-errors.rs:5:1
| |
LL | #[cfg(target(o::o))] LL | #[cfg(target(o::o))]
| ^^^^ | ^^^^^^^^^^^^^----^^^
| | |
| | expected this to be of the form `... = "..."`
| help: must be of the form: `#[cfg(predicate)]`
error[E0565]: literal in `cfg` predicate value must be a string error[E0539]: malformed `cfg` attribute input
--> $DIR/cfg-target-compact-errors.rs:9:19 --> $DIR/cfg-target-compact-errors.rs:9:1
| |
LL | #[cfg(target(os = 8))] LL | #[cfg(target(os = 8))]
| ^ | ^^^^^^^^^^^^^^^^^^-^^^
| | |
| | expected a string literal here
| help: must be of the form: `#[cfg(predicate)]`
error[E0537]: invalid predicate `target_pointer` error[E0539]: malformed `cfg` attribute input
--> $DIR/cfg-target-compact-errors.rs:13:28 --> $DIR/cfg-target-compact-errors.rs:13:1
| |
LL | #[cfg(target(os = "linux", pointer(width = "64")))] LL | #[cfg(target(os = "linux", pointer(width = "64")))]
| ^^^^^^^^^^^^^^^^^^^^^ | ^^^^^^^^^^^^^^^^^^^^^^^^^^^---------------------^^^
| | |
| | expected this to be of the form `... = "..."`
| help: must be of the form: `#[cfg(predicate)]`
error: `cfg` predicate key must be an identifier error[E0539]: malformed `cfg` attribute input
--> $DIR/cfg-target-compact-errors.rs:17:14 --> $DIR/cfg-target-compact-errors.rs:17:1
| |
LL | #[cfg(target(true))] LL | #[cfg(target(true))]
| ^^^^ | ^^^^^^^^^^^^^----^^^
| | |
| | expected this to be of the form `... = "..."`
| help: must be of the form: `#[cfg(predicate)]`
error: aborting due to 4 previous errors error: `cfg` predicate key must be an identifier
--> $DIR/cfg-target-compact-errors.rs:21:14
|
LL | #[cfg(target(clippy::os = "linux"))]
| ^^^^^^^^^^
Some errors have detailed explanations: E0537, E0565. error: aborting due to 5 previous errors
For more information about an error, try `rustc --explain E0537`.
For more information about this error, try `rustc --explain E0539`.

View File

@@ -17,10 +17,10 @@ LL | #[cfg(version(false))]
| ^^^^^ | ^^^^^
error: expected single version literal error: expected single version literal
--> $DIR/syntax.rs:23:7 --> $DIR/syntax.rs:23:14
| |
LL | #[cfg(version("1.43", "1.44", "1.45"))] LL | #[cfg(version("1.43", "1.44", "1.45"))]
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | ^^^^^^^^^^^^^^^^^^^^^^^^
warning: unknown version literal format, assuming it refers to a future version warning: unknown version literal format, assuming it refers to a future version
--> $DIR/syntax.rs:51:15 --> $DIR/syntax.rs:51:15

View File

@@ -10,10 +10,10 @@ note: found an item that was configured out
LL | pub mod doesnt_exist { LL | pub mod doesnt_exist {
| ^^^^^^^^^^^^ | ^^^^^^^^^^^^
note: the item is gated here note: the item is gated here
--> $DIR/auxiliary/cfged_out.rs:5:5 --> $DIR/auxiliary/cfged_out.rs:5:11
| |
LL | #[cfg(false)] LL | #[cfg(false)]
| ^^^^^^^^^^^^^ | ^^^^^
error[E0425]: cannot find function `uwu` in crate `cfged_out` error[E0425]: cannot find function `uwu` in crate `cfged_out`
--> $DIR/diagnostics-cross-crate.rs:7:16 --> $DIR/diagnostics-cross-crate.rs:7:16
@@ -33,10 +33,10 @@ note: found an item that was configured out
LL | pub fn uwu() {} LL | pub fn uwu() {}
| ^^^ | ^^^
note: the item is gated here note: the item is gated here
--> $DIR/auxiliary/cfged_out.rs:2:5 --> $DIR/auxiliary/cfged_out.rs:2:11
| |
LL | #[cfg(false)] LL | #[cfg(false)]
| ^^^^^^^^^^^^^ | ^^^^^
error[E0425]: cannot find function `meow` in module `cfged_out::inner::right` error[E0425]: cannot find function `meow` in module `cfged_out::inner::right`
--> $DIR/diagnostics-cross-crate.rs:24:30 --> $DIR/diagnostics-cross-crate.rs:24:30
@@ -67,10 +67,10 @@ note: found an item that was configured out
LL | pub fn vanished() {} LL | pub fn vanished() {}
| ^^^^^^^^ | ^^^^^^^^
note: the item is gated here note: the item is gated here
--> $DIR/auxiliary/cfged_out.rs:21:1 --> $DIR/auxiliary/cfged_out.rs:21:7
| |
LL | #[cfg(i_dont_exist_and_you_can_do_nothing_about_it)] LL | #[cfg(i_dont_exist_and_you_can_do_nothing_about_it)]
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
error: aborting due to 5 previous errors error: aborting due to 5 previous errors

View File

@@ -10,10 +10,10 @@ note: found an item that was configured out
LL | pub mod gated { LL | pub mod gated {
| ^^^^^ | ^^^^^
note: the item is gated here note: the item is gated here
--> $DIR/diagnostics-reexport-2.rs:4:5 --> $DIR/diagnostics-reexport-2.rs:4:11
| |
LL | #[cfg(false)] LL | #[cfg(false)]
| ^^^^^^^^^^^^^ | ^^^^^
error[E0433]: failed to resolve: could not find `gated` in `reexport2` error[E0433]: failed to resolve: could not find `gated` in `reexport2`
--> $DIR/diagnostics-reexport-2.rs:46:16 --> $DIR/diagnostics-reexport-2.rs:46:16
@@ -27,10 +27,10 @@ note: found an item that was configured out
LL | pub mod gated { LL | pub mod gated {
| ^^^^^ | ^^^^^
note: the item is gated here note: the item is gated here
--> $DIR/diagnostics-reexport-2.rs:4:5 --> $DIR/diagnostics-reexport-2.rs:4:11
| |
LL | #[cfg(false)] LL | #[cfg(false)]
| ^^^^^^^^^^^^^ | ^^^^^
error[E0433]: failed to resolve: could not find `gated` in `reexport30` error[E0433]: failed to resolve: could not find `gated` in `reexport30`
--> $DIR/diagnostics-reexport-2.rs:50:17 --> $DIR/diagnostics-reexport-2.rs:50:17
@@ -44,10 +44,10 @@ note: found an item that was configured out
LL | pub mod gated { LL | pub mod gated {
| ^^^^^ | ^^^^^
note: the item is gated here note: the item is gated here
--> $DIR/diagnostics-reexport-2.rs:4:5 --> $DIR/diagnostics-reexport-2.rs:4:11
| |
LL | #[cfg(false)] LL | #[cfg(false)]
| ^^^^^^^^^^^^^ | ^^^^^
error[E0433]: failed to resolve: could not find `gated` in `reexport31` error[E0433]: failed to resolve: could not find `gated` in `reexport31`
--> $DIR/diagnostics-reexport-2.rs:54:17 --> $DIR/diagnostics-reexport-2.rs:54:17
@@ -61,10 +61,10 @@ note: found an item that was configured out
LL | pub mod gated { LL | pub mod gated {
| ^^^^^ | ^^^^^
note: the item is gated here note: the item is gated here
--> $DIR/diagnostics-reexport-2.rs:4:5 --> $DIR/diagnostics-reexport-2.rs:4:11
| |
LL | #[cfg(false)] LL | #[cfg(false)]
| ^^^^^^^^^^^^^ | ^^^^^
error[E0433]: failed to resolve: could not find `gated` in `reexport32` error[E0433]: failed to resolve: could not find `gated` in `reexport32`
--> $DIR/diagnostics-reexport-2.rs:58:17 --> $DIR/diagnostics-reexport-2.rs:58:17
@@ -78,10 +78,10 @@ note: found an item that was configured out
LL | pub mod gated { LL | pub mod gated {
| ^^^^^ | ^^^^^
note: the item is gated here note: the item is gated here
--> $DIR/diagnostics-reexport-2.rs:4:5 --> $DIR/diagnostics-reexport-2.rs:4:11
| |
LL | #[cfg(false)] LL | #[cfg(false)]
| ^^^^^^^^^^^^^ | ^^^^^
error: aborting due to 5 previous errors error: aborting due to 5 previous errors

View File

@@ -10,10 +10,10 @@ note: found an item that was configured out
LL | pub fn x() {} LL | pub fn x() {}
| ^ | ^
note: the item is gated here note: the item is gated here
--> $DIR/diagnostics-reexport.rs:17:5 --> $DIR/diagnostics-reexport.rs:17:11
| |
LL | #[cfg(false)] LL | #[cfg(false)]
| ^^^^^^^^^^^^^ | ^^^^^
error[E0432]: unresolved imports `b::x`, `b::y` error[E0432]: unresolved imports `b::x`, `b::y`
--> $DIR/diagnostics-reexport.rs:22:13 --> $DIR/diagnostics-reexport.rs:22:13
@@ -29,20 +29,20 @@ note: found an item that was configured out
LL | pub fn x() {} LL | pub fn x() {}
| ^ | ^
note: the item is gated here note: the item is gated here
--> $DIR/diagnostics-reexport.rs:28:5 --> $DIR/diagnostics-reexport.rs:28:11
| |
LL | #[cfg(false)] LL | #[cfg(false)]
| ^^^^^^^^^^^^^ | ^^^^^
note: found an item that was configured out note: found an item that was configured out
--> $DIR/diagnostics-reexport.rs:32:12 --> $DIR/diagnostics-reexport.rs:32:12
| |
LL | pub fn y() {} LL | pub fn y() {}
| ^ | ^
note: the item is gated here note: the item is gated here
--> $DIR/diagnostics-reexport.rs:31:5 --> $DIR/diagnostics-reexport.rs:31:11
| |
LL | #[cfg(false)] LL | #[cfg(false)]
| ^^^^^^^^^^^^^ | ^^^^^
error[E0425]: cannot find function `uwu` in module `inner` error[E0425]: cannot find function `uwu` in module `inner`
--> $DIR/diagnostics-reexport.rs:38:12 --> $DIR/diagnostics-reexport.rs:38:12
@@ -56,10 +56,10 @@ note: found an item that was configured out
LL | pub use super::uwu; LL | pub use super::uwu;
| ^^^ | ^^^
note: the item is gated here note: the item is gated here
--> $DIR/diagnostics-reexport.rs:7:5 --> $DIR/diagnostics-reexport.rs:7:11
| |
LL | #[cfg(false)] LL | #[cfg(false)]
| ^^^^^^^^^^^^^ | ^^^^^
error: aborting due to 3 previous errors error: aborting due to 3 previous errors

View File

@@ -10,10 +10,10 @@ note: found an item that was configured out
LL | pub mod doesnt_exist { LL | pub mod doesnt_exist {
| ^^^^^^^^^^^^ | ^^^^^^^^^^^^
note: the item is gated here note: the item is gated here
--> $DIR/diagnostics-same-crate.rs:8:5 --> $DIR/diagnostics-same-crate.rs:8:11
| |
LL | #[cfg(false)] LL | #[cfg(false)]
| ^^^^^^^^^^^^^ | ^^^^^
error[E0432]: unresolved import `super::inner::doesnt_exist` error[E0432]: unresolved import `super::inner::doesnt_exist`
--> $DIR/diagnostics-same-crate.rs:35:23 --> $DIR/diagnostics-same-crate.rs:35:23
@@ -27,10 +27,10 @@ note: found an item that was configured out
LL | pub mod doesnt_exist { LL | pub mod doesnt_exist {
| ^^^^^^^^^^^^ | ^^^^^^^^^^^^
note: the item is gated here note: the item is gated here
--> $DIR/diagnostics-same-crate.rs:8:5 --> $DIR/diagnostics-same-crate.rs:8:11
| |
LL | #[cfg(false)] LL | #[cfg(false)]
| ^^^^^^^^^^^^^ | ^^^^^
error[E0433]: failed to resolve: could not find `doesnt_exist` in `inner` error[E0433]: failed to resolve: could not find `doesnt_exist` in `inner`
--> $DIR/diagnostics-same-crate.rs:54:12 --> $DIR/diagnostics-same-crate.rs:54:12
@@ -44,10 +44,10 @@ note: found an item that was configured out
LL | pub mod doesnt_exist { LL | pub mod doesnt_exist {
| ^^^^^^^^^^^^ | ^^^^^^^^^^^^
note: the item is gated here note: the item is gated here
--> $DIR/diagnostics-same-crate.rs:8:5 --> $DIR/diagnostics-same-crate.rs:8:11
| |
LL | #[cfg(false)] LL | #[cfg(false)]
| ^^^^^^^^^^^^^ | ^^^^^
error[E0425]: cannot find function `uwu` in module `inner` error[E0425]: cannot find function `uwu` in module `inner`
--> $DIR/diagnostics-same-crate.rs:49:12 --> $DIR/diagnostics-same-crate.rs:49:12
@@ -61,10 +61,10 @@ note: found an item that was configured out
LL | pub fn uwu() {} LL | pub fn uwu() {}
| ^^^ | ^^^
note: the item is gated here note: the item is gated here
--> $DIR/diagnostics-same-crate.rs:4:5 --> $DIR/diagnostics-same-crate.rs:4:11
| |
LL | #[cfg(false)] LL | #[cfg(false)]
| ^^^^^^^^^^^^^ | ^^^^^
error[E0425]: cannot find function `meow` in module `inner::right` error[E0425]: cannot find function `meow` in module `inner::right`
--> $DIR/diagnostics-same-crate.rs:58:19 --> $DIR/diagnostics-same-crate.rs:58:19

View File

@@ -13,4 +13,8 @@ pub fn expected() {}
//~^ WARNING unexpected `cfg` condition name //~^ WARNING unexpected `cfg` condition name
pub fn unexpected() {} pub fn unexpected() {}
#[cfg(target(os = "windows", architecture = "arm"))]
//~^ WARNING unexpected `cfg` condition name
pub fn unexpected2() {}
fn main() {} fn main() {}

View File

@@ -8,5 +8,14 @@ LL | #[cfg(target(os = "linux", architecture = "arm"))]
= note: see <https://doc.rust-lang.org/nightly/rustc/check-cfg.html> for more information about checking conditional configuration = note: see <https://doc.rust-lang.org/nightly/rustc/check-cfg.html> for more information about checking conditional configuration
= note: `#[warn(unexpected_cfgs)]` on by default = note: `#[warn(unexpected_cfgs)]` on by default
warning: 1 warning emitted warning: unexpected `cfg` condition name: `target_architecture`
--> $DIR/compact-names.rs:16:30
|
LL | #[cfg(target(os = "windows", architecture = "arm"))]
| ^^^^^^^^^^^^^^^^^^^^
|
= help: to expect this configuration use `--check-cfg=cfg(target_architecture, values("arm"))`
= note: see <https://doc.rust-lang.org/nightly/rustc/check-cfg.html> for more information about checking conditional configuration
warning: 2 warnings emitted

View File

@@ -1,16 +1,24 @@
#[cfg] //~ ERROR `cfg` is not followed by parentheses #[cfg]
//~^ ERROR malformed `cfg` attribute
//~| NOTE expected this to be a list
struct S1; struct S1;
#[cfg = 10] //~ ERROR `cfg` is not followed by parentheses #[cfg = 10]
//~^ ERROR malformed `cfg` attribute
//~| NOTE expected this to be a list
struct S2; struct S2;
#[cfg()] //~ ERROR `cfg` predicate is not specified #[cfg()]
//~^ ERROR malformed `cfg` attribute
//~| NOTE expected a single argument here
struct S3; struct S3;
#[cfg(a, b)] //~ ERROR multiple `cfg` predicates are specified #[cfg(a, b)]
//~^ ERROR malformed `cfg` attribute
//~| NOTE expected a single argument here
struct S4; struct S4;
#[cfg("str")] //~ ERROR `cfg` predicate key cannot be a literal #[cfg("str")] //~ ERROR `cfg` predicate key must be an identifier
struct S5; struct S5;
#[cfg(a::b)] //~ ERROR `cfg` predicate key must be an identifier #[cfg(a::b)] //~ ERROR `cfg` predicate key must be an identifier
@@ -19,10 +27,12 @@ struct S6;
#[cfg(a())] //~ ERROR invalid predicate `a` #[cfg(a())] //~ ERROR invalid predicate `a`
struct S7; struct S7;
#[cfg(a = 10)] //~ ERROR literal in `cfg` predicate value must be a string #[cfg(a = 10)] //~ ERROR malformed `cfg` attribute input
//~^ NOTE expected a string literal here
struct S8; struct S8;
#[cfg(a = b"hi")] //~ ERROR literal in `cfg` predicate value must be a string #[cfg(a = b"hi")] //~ ERROR malformed `cfg` attribute input
//~^ NOTE expected a normal string literal, not a byte string literal
struct S9; struct S9;
macro_rules! generate_s10 { macro_rules! generate_s10 {
@@ -34,5 +44,6 @@ macro_rules! generate_s10 {
} }
generate_s10!(concat!("nonexistent")); generate_s10!(concat!("nonexistent"));
//~^ NOTE in this expansion of generate_s10!
fn main() {} fn main() {}

View File

@@ -1,61 +1,78 @@
error: `cfg` is not followed by parentheses error[E0539]: malformed `cfg` attribute input
--> $DIR/cfg-attr-syntax-validation.rs:1:1 --> $DIR/cfg-attr-syntax-validation.rs:1:1
| |
LL | #[cfg] LL | #[cfg]
| ^^^^^^ help: expected syntax is: `cfg(/* predicate */)` | ^^^^^^
| |
| expected this to be a list
| help: must be of the form: `#[cfg(predicate)]`
error: `cfg` is not followed by parentheses error[E0539]: malformed `cfg` attribute input
--> $DIR/cfg-attr-syntax-validation.rs:4:1 --> $DIR/cfg-attr-syntax-validation.rs:6:1
| |
LL | #[cfg = 10] LL | #[cfg = 10]
| ^^^^^^^^^^^ help: expected syntax is: `cfg(/* predicate */)` | ^^^^^^^^^^^
| |
| expected this to be a list
| help: must be of the form: `#[cfg(predicate)]`
error: `cfg` predicate is not specified error[E0805]: malformed `cfg` attribute input
--> $DIR/cfg-attr-syntax-validation.rs:7:1 --> $DIR/cfg-attr-syntax-validation.rs:11:1
| |
LL | #[cfg()] LL | #[cfg()]
| ^^^^^^^^ help: expected syntax is: `cfg(/* predicate */)` | ^^^^^--^
| | |
| | expected a single argument here
| help: must be of the form: `#[cfg(predicate)]`
error: multiple `cfg` predicates are specified error[E0805]: malformed `cfg` attribute input
--> $DIR/cfg-attr-syntax-validation.rs:10:10 --> $DIR/cfg-attr-syntax-validation.rs:16:1
| |
LL | #[cfg(a, b)] LL | #[cfg(a, b)]
| ^ | ^^^^^------^
| | |
| | expected a single argument here
| help: must be of the form: `#[cfg(predicate)]`
error: `cfg` predicate key cannot be a literal error: `cfg` predicate key must be an identifier
--> $DIR/cfg-attr-syntax-validation.rs:13:7 --> $DIR/cfg-attr-syntax-validation.rs:21:7
| |
LL | #[cfg("str")] LL | #[cfg("str")]
| ^^^^^ | ^^^^^
error: `cfg` predicate key must be an identifier error: `cfg` predicate key must be an identifier
--> $DIR/cfg-attr-syntax-validation.rs:16:7 --> $DIR/cfg-attr-syntax-validation.rs:24:7
| |
LL | #[cfg(a::b)] LL | #[cfg(a::b)]
| ^^^^ | ^^^^
error[E0537]: invalid predicate `a` error[E0537]: invalid predicate `a`
--> $DIR/cfg-attr-syntax-validation.rs:19:7 --> $DIR/cfg-attr-syntax-validation.rs:27:7
| |
LL | #[cfg(a())] LL | #[cfg(a())]
| ^^^ | ^^^
error[E0565]: literal in `cfg` predicate value must be a string error[E0539]: malformed `cfg` attribute input
--> $DIR/cfg-attr-syntax-validation.rs:22:11 --> $DIR/cfg-attr-syntax-validation.rs:30:1
| |
LL | #[cfg(a = 10)] LL | #[cfg(a = 10)]
| ^^ | ^^^^^^^^^^--^^
| | |
| | expected a string literal here
| help: must be of the form: `#[cfg(predicate)]`
error[E0565]: literal in `cfg` predicate value must be a string error[E0539]: malformed `cfg` attribute input
--> $DIR/cfg-attr-syntax-validation.rs:25:11 --> $DIR/cfg-attr-syntax-validation.rs:34:1
| |
LL | #[cfg(a = b"hi")] LL | #[cfg(a = b"hi")]
| -^^^^ | ^^^^^^^^^^-^^^^^^
| | | |
| help: consider removing the prefix | help: consider removing the prefix
|
= note: expected a normal string literal, not a byte string literal
error: expected unsuffixed literal, found `expr` metavariable error: expected unsuffixed literal, found `expr` metavariable
--> $DIR/cfg-attr-syntax-validation.rs:30:25 --> $DIR/cfg-attr-syntax-validation.rs:40:25
| |
LL | #[cfg(feature = $expr)] LL | #[cfg(feature = $expr)]
| ^^^^^ | ^^^^^
@@ -67,5 +84,5 @@ LL | generate_s10!(concat!("nonexistent"));
error: aborting due to 10 previous errors error: aborting due to 10 previous errors
Some errors have detailed explanations: E0537, E0565. Some errors have detailed explanations: E0537, E0539, E0805.
For more information about an error, try `rustc --explain E0537`. For more information about an error, try `rustc --explain E0537`.

View File

@@ -10,16 +10,10 @@ note: found an item that was configured out
LL | pub fn bar() { }); LL | pub fn bar() { });
| ^^^ | ^^^
note: the item is gated here note: the item is gated here
--> $DIR/macro-outer-attributes.rs:5:45 --> $DIR/macro-outer-attributes.rs:8:13
| |
LL | $i:item) => (mod $nm { #[$a] $i }); } LL | #[cfg(false)],
| ^^^^^ | ^^^^^
LL |
LL | / test!(a,
LL | | #[cfg(false)],
LL | | pub fn bar() { });
| |_______________________- in this macro invocation
= note: this error originates in the macro `test` (in Nightly builds, run with -Z macro-backtrace for more info)
help: consider importing this function help: consider importing this function
| |
LL + use b::bar; LL + use b::bar;