Skip to content

Commit 60e69b8

Browse files
New example for E0536
1 parent 70be30b commit 60e69b8

File tree

3 files changed

+13
-16
lines changed

3 files changed

+13
-16
lines changed

compiler/rustc_error_codes/src/error_codes/E0536.md

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -3,22 +3,20 @@ The `not` cfg-predicate was malformed.
33
Erroneous code example:
44

55
```compile_fail,E0536
6-
#[cfg(not())] // error: expected 1 cfg-pattern
7-
pub fn something() {}
8-
9-
pub fn main() {}
6+
pub fn main() {
7+
if cfg!(not()) { }
8+
}
109
```
1110

1211
The `not` predicate expects one cfg-pattern. Example:
1312

1413
```
15-
#[cfg(not(target_os = "linux"))] // ok!
16-
pub fn something() {}
17-
18-
pub fn main() {}
14+
pub fn main() {
15+
if cfg!(not(target_os = "linux")) { } // ok!
16+
}
1917
```
2018

21-
For more information about the `cfg` attribute, read the section on
19+
For more information about the `cfg` macro, read the section on
2220
[Conditional Compilation][conditional-compilation] in the Reference.
2321

2422
[conditional-compilation]: https://doc.rust-lang.org/reference/conditional-compilation.html

tests/ui/span/E0536.rs

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
#[cfg(not())] //~ ERROR E0536
2-
pub fn something() {}
3-
4-
pub fn main() {}
1+
pub fn main() {
2+
if cfg!(not()) { } //~ ERROR E0536
3+
}

tests/ui/span/E0536.stderr

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
error[E0536]: expected 1 cfg-pattern
2-
--> $DIR/E0536.rs:1:7
2+
--> $DIR/E0536.rs:2:13
33
|
4-
LL | #[cfg(not())]
5-
| ^^^^^
4+
LL | if cfg!(not()) { }
5+
| ^^^^^
66

77
error: aborting due to 1 previous error
88

0 commit comments

Comments
 (0)