]> git.lizzy.rs Git - rust.git/blob - src/test/ui/lint/rfc-2383-lint-reason/expect_unfulfilled_expectation.rs
Handle `#[expect(unfulfilled_lint_expectations)]` with a lint message
[rust.git] / src / test / ui / lint / rfc-2383-lint-reason / expect_unfulfilled_expectation.rs
1 // check-pass
2 // ignore-tidy-linelength
3
4 #![feature(lint_reasons)]
5 #![warn(unused_mut)]
6
7 #![expect(unfulfilled_lint_expectations, reason = "idk why you would expect this")]
8 //~^ WARNING this lint expectation is unfulfilled
9 //~| NOTE `#[warn(unfulfilled_lint_expectations)]` on by default
10 //~| NOTE idk why you would expect this
11 //~| NOTE the `unfulfilled_lint_expectations` lint can't be expected and will always produce this message
12
13 #[expect(unfulfilled_lint_expectations, reason = "a local: idk why you would expect this")]
14 //~^ WARNING this lint expectation is unfulfilled
15 //~| NOTE a local: idk why you would expect this
16 //~| NOTE the `unfulfilled_lint_expectations` lint can't be expected and will always produce this message
17 pub fn normal_test_fn() {
18     #[expect(unused_mut, reason = "this expectation will create a diagnostic with the default lint level")]
19     //~^ WARNING this lint expectation is unfulfilled
20     //~| NOTE this expectation will create a diagnostic with the default lint level
21     let mut v = vec![1, 1, 2, 3, 5];
22     v.sort();
23
24     // Check that lint lists including `unfulfilled_lint_expectations` are also handled correctly
25     #[expect(unused, unfulfilled_lint_expectations, reason = "the expectation for `unused` should be fulfilled")]
26     //~^ WARNING this lint expectation is unfulfilled
27     //~| NOTE the expectation for `unused` should be fulfilled
28     //~| NOTE the `unfulfilled_lint_expectations` lint can't be expected and will always produce this message
29     let value = "I'm unused";
30 }
31
32 #[expect(warnings, reason = "this suppresses all warnings and also suppresses itself. No warning will be issued")]
33 pub fn expect_warnings() {
34     // This lint trigger will be suppressed
35     #[warn(unused_mut)]
36     let mut v = vec![1, 1, 2, 3, 5];
37 }
38
39 fn main() {}