]> git.lizzy.rs Git - rust.git/blob - tests/ui/lint/rfc-2383-lint-reason/expect_nested_lint_levels.rs
Auto merge of #106884 - clubby789:fieldless-enum-debug, r=michaelwoerister
[rust.git] / tests / ui / lint / rfc-2383-lint-reason / expect_nested_lint_levels.rs
1 // ignore-tidy-linelength
2
3 #![feature(lint_reasons)]
4 #![warn(unused_mut)]
5
6 #[expect(
7     unused_mut,
8     //~^ WARNING this lint expectation is unfulfilled [unfulfilled_lint_expectations]
9     //~| NOTE `#[warn(unfulfilled_lint_expectations)]` on by default
10     //~| NOTE this `expect` is overridden by a `allow` attribute before the `unused_mut` lint is triggered
11     reason = "this `expect` is overridden by a `allow` attribute before the `unused_mut` lint is triggered"
12 )]
13 mod foo {
14     fn bar() {
15         #[allow(
16             unused_mut,
17             reason = "this overrides the previous `expect` lint level and allows the `unused_mut` lint here"
18         )]
19         let mut v = 0;
20     }
21 }
22
23 #[expect(
24     unused_mut,
25     //~^ WARNING this lint expectation is unfulfilled [unfulfilled_lint_expectations]
26     //~| NOTE this `expect` is overridden by a `warn` attribute before the `unused_mut` lint is triggered
27     reason = "this `expect` is overridden by a `warn` attribute before the `unused_mut` lint is triggered"
28 )]
29 mod oof {
30     #[warn(
31         unused_mut,
32         //~^ NOTE the lint level is defined here
33         reason = "this overrides the previous `expect` lint level and warns about the `unused_mut` lint here"
34     )]
35     fn bar() {
36         let mut v = 0;
37         //~^ WARNING variable does not need to be mutable [unused_mut]
38         //~| NOTE this overrides the previous `expect` lint level and warns about the `unused_mut` lint here
39         //~| HELP remove this `mut`
40     }
41 }
42
43 #[expect(unused_variables)]
44 //~^ WARNING this lint expectation is unfulfilled
45 #[forbid(unused_variables)]
46 //~^ NOTE the lint level is defined here
47 fn check_expect_then_forbid() {
48     let this_is_my_function = 3;
49     //~^ ERROR unused variable: `this_is_my_function` [unused_variables]
50     //~| HELP if this is intentional, prefix it with an underscore
51 }
52
53 fn main() {}