Skip to content

Commit c0df447

Browse files
authored
Auto merge of #34242 - zackmdavis:explain_E0453, r=GuillaumeGomez
add long explanation for E0453, lint attribute overruled by outer forbid This is a subtask of #32777. ----- r? @GuillaumeGomez
2 parents 5e3136d + e4c566c commit c0df447

File tree

1 file changed

+45
-1
lines changed

1 file changed

+45
-1
lines changed

src/librustc/diagnostics.rs

Lines changed: 45 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1444,6 +1444,51 @@ lint name). Ensure the attribute is of this form:
14441444
```
14451445
"##,
14461446

1447+
E0453: r##"
1448+
A lint check attribute was overruled by a `forbid` directive set as an
1449+
attribute on an enclosing scope, or on the command line with the `-F` option.
1450+
1451+
Example of erroneous code:
1452+
1453+
```compile_fail
1454+
#![forbid(non_snake_case)]
1455+
1456+
#[allow(non_snake_case)]
1457+
fn main() {
1458+
let MyNumber = 2; // error: allow(non_snake_case) overruled by outer
1459+
// forbid(non_snake_case)
1460+
}
1461+
```
1462+
1463+
The `forbid` lint setting, like `deny`, turns the corresponding compiler
1464+
warning into a hard error. Unlike `deny`, `forbid` prevents itself from being
1465+
overridden by inner attributes.
1466+
1467+
If you're sure you want to override the lint check, you can change `forbid` to
1468+
`deny` (or use `-D` instead of `-F` if the `forbid` setting was given as a
1469+
command-line option) to allow the inner lint check attribute:
1470+
1471+
```
1472+
#![deny(non_snake_case)]
1473+
1474+
#[allow(non_snake_case)]
1475+
fn main() {
1476+
let MyNumber = 2; // ok!
1477+
}
1478+
```
1479+
1480+
Otherwise, edit the code to pass the lint check, and remove the overruled
1481+
attribute:
1482+
1483+
```
1484+
#![forbid(non_snake_case)]
1485+
1486+
fn main() {
1487+
let my_number = 2;
1488+
}
1489+
```
1490+
"##,
1491+
14471492
E0496: r##"
14481493
A lifetime name is shadowing another lifetime name. Erroneous code example:
14491494
@@ -1628,7 +1673,6 @@ register_diagnostics! {
16281673
E0314, // closure outlives stack frame
16291674
E0315, // cannot invoke closure outside of its lifetime
16301675
E0316, // nested quantification of lifetimes
1631-
E0453, // overruled by outer forbid
16321676
E0473, // dereference of reference outside its lifetime
16331677
E0474, // captured variable `..` does not outlive the enclosing closure
16341678
E0475, // index of slice outside its lifetime

0 commit comments

Comments
 (0)