New example for E0536
This commit is contained in:
@@ -3,22 +3,20 @@ The `not` cfg-predicate was malformed.
|
|||||||
Erroneous code example:
|
Erroneous code example:
|
||||||
|
|
||||||
```compile_fail,E0536
|
```compile_fail,E0536
|
||||||
#[cfg(not())] // error: expected 1 cfg-pattern
|
pub fn main() {
|
||||||
pub fn something() {}
|
if cfg!(not()) { }
|
||||||
|
}
|
||||||
pub fn main() {}
|
|
||||||
```
|
```
|
||||||
|
|
||||||
The `not` predicate expects one cfg-pattern. Example:
|
The `not` predicate expects one cfg-pattern. Example:
|
||||||
|
|
||||||
```
|
```
|
||||||
#[cfg(not(target_os = "linux"))] // ok!
|
pub fn main() {
|
||||||
pub fn something() {}
|
if cfg!(not(target_os = "linux")) { } // ok!
|
||||||
|
}
|
||||||
pub fn main() {}
|
|
||||||
```
|
```
|
||||||
|
|
||||||
For more information about the `cfg` attribute, read the section on
|
For more information about the `cfg` macro, read the section on
|
||||||
[Conditional Compilation][conditional-compilation] in the Reference.
|
[Conditional Compilation][conditional-compilation] in the Reference.
|
||||||
|
|
||||||
[conditional-compilation]: https://doc.rust-lang.org/reference/conditional-compilation.html
|
[conditional-compilation]: https://doc.rust-lang.org/reference/conditional-compilation.html
|
||||||
|
|||||||
@@ -1,4 +1,3 @@
|
|||||||
#[cfg(not())] //~ ERROR E0536
|
pub fn main() {
|
||||||
pub fn something() {}
|
if cfg!(not()) { } //~ ERROR E0536
|
||||||
|
}
|
||||||
pub fn main() {}
|
|
||||||
|
|||||||
@@ -1,8 +1,8 @@
|
|||||||
error[E0536]: expected 1 cfg-pattern
|
error[E0536]: expected 1 cfg-pattern
|
||||||
--> $DIR/E0536.rs:1:7
|
--> $DIR/E0536.rs:2:13
|
||||||
|
|
|
|
||||||
LL | #[cfg(not())]
|
LL | if cfg!(not()) { }
|
||||||
| ^^^^^
|
| ^^^^^
|
||||||
|
|
||||||
error: aborting due to 1 previous error
|
error: aborting due to 1 previous error
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user