Auto merge of #54929 - csmoe:cfg_lint, r=petrochenkov

Suggest to remove prefix `b` in cfg attribute lint string

Closes #54926
r? @estebank
This commit is contained in:
bors 2018-10-26 21:46:13 +00:00
commit fa45602b71
15 changed files with 221 additions and 78 deletions

View file

@ -22,11 +22,14 @@ struct S7;
#[cfg(a = 10)] //~ ERROR literal in `cfg` predicate value must be a string
struct S8;
macro_rules! generate_s9 {
#[cfg(a = b"hi")] //~ ERROR literal in `cfg` predicate value must be a string
struct S9;
macro_rules! generate_s10 {
($expr: expr) => {
#[cfg(feature = $expr)] //~ ERROR `cfg` is not a well-formed meta-item
struct S9;
struct S10;
}
}
generate_s9!(concat!("nonexistent"));
generate_s10!(concat!("nonexistent"));

View file

@ -40,21 +40,28 @@ error[E0537]: invalid predicate `a`
LL | #[cfg(a())] //~ ERROR invalid predicate `a`
| ^^^
error: literal in `cfg` predicate value must be a string
error[E0565]: literal in `cfg` predicate value must be a string
--> $DIR/cfg-attr-syntax-validation.rs:22:11
|
LL | #[cfg(a = 10)] //~ ERROR literal in `cfg` predicate value must be a string
| ^^
error[E0565]: literal in `cfg` predicate value must be a string
--> $DIR/cfg-attr-syntax-validation.rs:25:11
|
LL | #[cfg(a = b"hi")] //~ ERROR literal in `cfg` predicate value must be a string
| ^^^^^ help: consider removing the prefix: `"hi"`
error: `cfg` is not a well-formed meta-item
--> $DIR/cfg-attr-syntax-validation.rs:27:9
--> $DIR/cfg-attr-syntax-validation.rs:30:9
|
LL | #[cfg(feature = $expr)] //~ ERROR `cfg` is not a well-formed meta-item
| ^^^^^^^^^^^^^^^^^^^^^^^ help: expected syntax is: `#[cfg(/* predicate */)]`
...
LL | generate_s9!(concat!("nonexistent"));
| ------------------------------------- in this macro invocation
LL | generate_s10!(concat!("nonexistent"));
| -------------------------------------- in this macro invocation
error: aborting due to 9 previous errors
error: aborting due to 10 previous errors
For more information about this error, try `rustc --explain E0537`.
Some errors occurred: E0537, E0565.
For more information about an error, try `rustc --explain E0537`.

View file

@ -1,4 +1,4 @@
error[E0565]: unsupported literal
error[E0565]: item in `deprecated` must be a key/value pair
--> $DIR/E0565-1.rs:12:14
|
LL | #[deprecated("since")] //~ ERROR E0565

View file

@ -0,0 +1,15 @@
// Copyright 2018 The Rust Project Developers. See the COPYRIGHT
// file at the top-level directory of this distribution and at
// http://rust-lang.org/COPYRIGHT.
//
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
// option. This file may not be copied, modified, or distributed
// except according to those terms.
// repr currently doesn't support literals
#[deprecated(since = b"1.29", note = "hi")] //~ ERROR E0565
struct A { }
fn main() { }

View file

@ -0,0 +1,9 @@
error[E0565]: literal in `deprecated` value must be a string
--> $DIR/E0565-2.rs:12:22
|
LL | #[deprecated(since = b"1.29", note = "hi")] //~ ERROR E0565
| ^^^^^^^ help: consider removing the prefix: `"1.29"`
error: aborting due to previous error
For more information about this error, try `rustc --explain E0565`.

View file

@ -1,4 +1,4 @@
error[E0565]: unsupported literal
error[E0565]: meta item in `repr` must be an identifier
--> $DIR/E0565.rs:12:8
|
LL | #[repr("C")] //~ ERROR E0565