-
Notifications
You must be signed in to change notification settings - Fork 13k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Handle
#[expect(unfulfilled_lint_expectations)]
with a lint message
- Loading branch information
Showing
6 changed files
with
119 additions
and
14 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
39 changes: 39 additions & 0 deletions
39
src/test/ui/lint/rfc-2383-lint-reason/expect_unfulfilled_expectation.rs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
// check-pass | ||
// ignore-tidy-linelength | ||
|
||
#![feature(lint_reasons)] | ||
#![warn(unused_mut)] | ||
|
||
#![expect(unfulfilled_lint_expectations, reason = "idk why you would expect this")] | ||
//~^ WARNING this lint expectation is unfulfilled | ||
//~| NOTE `#[warn(unfulfilled_lint_expectations)]` on by default | ||
//~| NOTE idk why you would expect this | ||
//~| NOTE the `unfulfilled_lint_expectations` lint can't be expected and will always produce this message | ||
|
||
#[expect(unfulfilled_lint_expectations, reason = "a local: idk why you would expect this")] | ||
//~^ WARNING this lint expectation is unfulfilled | ||
//~| NOTE a local: idk why you would expect this | ||
//~| NOTE the `unfulfilled_lint_expectations` lint can't be expected and will always produce this message | ||
pub fn normal_test_fn() { | ||
#[expect(unused_mut, reason = "this expectation will create a diagnostic with the default lint level")] | ||
//~^ WARNING this lint expectation is unfulfilled | ||
//~| NOTE this expectation will create a diagnostic with the default lint level | ||
let mut v = vec![1, 1, 2, 3, 5]; | ||
v.sort(); | ||
|
||
// Check that lint lists including `unfulfilled_lint_expectations` are also handled correctly | ||
#[expect(unused, unfulfilled_lint_expectations, reason = "the expectation for `unused` should be fulfilled")] | ||
//~^ WARNING this lint expectation is unfulfilled | ||
//~| NOTE the expectation for `unused` should be fulfilled | ||
//~| NOTE the `unfulfilled_lint_expectations` lint can't be expected and will always produce this message | ||
let value = "I'm unused"; | ||
} | ||
|
||
#[expect(warnings, reason = "this suppresses all warnings and also suppresses itself. No warning will be issued")] | ||
pub fn expect_warnings() { | ||
// This lint trigger will be suppressed | ||
#[warn(unused_mut)] | ||
let mut v = vec![1, 1, 2, 3, 5]; | ||
} | ||
|
||
fn main() {} |
38 changes: 38 additions & 0 deletions
38
src/test/ui/lint/rfc-2383-lint-reason/expect_unfulfilled_expectation.stderr
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
warning: this lint expectation is unfulfilled | ||
--> $DIR/expect_unfulfilled_expectation.rs:7:11 | ||
| | ||
LL | #![expect(unfulfilled_lint_expectations, reason = "idk why you would expect this")] | ||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | ||
| | ||
= note: `#[warn(unfulfilled_lint_expectations)]` on by default | ||
= note: idk why you would expect this | ||
= note: the `unfulfilled_lint_expectations` lint can't be expected and will always produce this message | ||
|
||
warning: this lint expectation is unfulfilled | ||
--> $DIR/expect_unfulfilled_expectation.rs:13:10 | ||
| | ||
LL | #[expect(unfulfilled_lint_expectations, reason = "a local: idk why you would expect this")] | ||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | ||
| | ||
= note: a local: idk why you would expect this | ||
= note: the `unfulfilled_lint_expectations` lint can't be expected and will always produce this message | ||
|
||
warning: this lint expectation is unfulfilled | ||
--> $DIR/expect_unfulfilled_expectation.rs:18:14 | ||
| | ||
LL | #[expect(unused_mut, reason = "this expectation will create a diagnostic with the default lint level")] | ||
| ^^^^^^^^^^ | ||
| | ||
= note: this expectation will create a diagnostic with the default lint level | ||
|
||
warning: this lint expectation is unfulfilled | ||
--> $DIR/expect_unfulfilled_expectation.rs:25:22 | ||
| | ||
LL | #[expect(unused, unfulfilled_lint_expectations, reason = "the expectation for `unused` should be fulfilled")] | ||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | ||
| | ||
= note: the expectation for `unused` should be fulfilled | ||
= note: the `unfulfilled_lint_expectations` lint can't be expected and will always produce this message | ||
|
||
warning: 4 warnings emitted | ||
|