]> git.proxmox.com Git - rustc.git/blob - src/test/ui/lint/rfc-2383-lint-reason/expect_with_forbid.rs
New upstream version 1.67.1+dfsg1
[rustc.git] / src / test / ui / lint / rfc-2383-lint-reason / expect_with_forbid.rs
1 #![feature(lint_reasons)]
2
3 #[forbid(unused_variables)]
4 //~^ NOTE `forbid` level set here
5 //~| NOTE `forbid` level set here
6 #[expect(unused_variables)]
7 //~^ ERROR incompatible with previous forbid [E0453]
8 //~| NOTE overruled by previous forbid
9 //~| ERROR incompatible with previous forbid [E0453]
10 //~| NOTE overruled by previous forbid
11 fn expect_forbidden_lint_1() {}
12
13 #[forbid(while_true)]
14 //~^ NOTE `forbid` level set here
15 //~| NOTE `forbid` level set here
16 //~| NOTE the lint level is defined here
17 #[expect(while_true)]
18 //~^ ERROR incompatible with previous forbid [E0453]
19 //~| NOTE overruled by previous forbid
20 //~| ERROR incompatible with previous forbid [E0453]
21 //~| NOTE overruled by previous forbid
22 fn expect_forbidden_lint_2() {
23 // This while loop will produce a `while_true` lint as the lint level
24 // at this node is still `forbid` and the `while_true` check happens
25 // before the compilation terminates due to `E0453`
26 while true {}
27 //~^ ERROR denote infinite loops with `loop { ... }`
28 //~| HELP use `loop`
29 }
30
31 fn main() {
32 expect_forbidden_lint_1();
33 expect_forbidden_lint_2();
34 }