Auto merge of #130050 - cjgillot:expect-attr-id, r=fee1-dead
Enumerate lint expectations using AttrId This PR implements the idea I outlined in https://github.com/rust-lang/rust/issues/127884#issuecomment-2240338547 We can uniquely identify a lint expectation `#[expect(lint0, lint1...)]` using the `AttrId` and the index of the lint inside the attribute. This PR uses this property in `check_expectations`. In addition, this PR stops stashing expected diagnostics to wait for the unstable -> stable `LintExpectationId` mapping: if the lint is emitted with an unstable attribute, it must have been emitted by an `eval_always` query (like inside the resolver), so won't be loaded from cache. Decoding an `AttrId` from the on-disk cache ICEs, so we have no risk of accidentally checking an expectation. Fixes https://github.com/rust-lang/rust/issues/127884 cc `@xFrednet`
This commit is contained in:
commit
4c5fc2c334
6 changed files with 72 additions and 167 deletions
9
tests/ui/lint/expect-unused-imports.rs
Normal file
9
tests/ui/lint/expect-unused-imports.rs
Normal file
|
|
@ -0,0 +1,9 @@
|
|||
//@ check-pass
|
||||
|
||||
#![deny(unused_imports)]
|
||||
#![deny(unfulfilled_lint_expectations)]
|
||||
|
||||
#[expect(unused_imports)]
|
||||
use std::{io, fs};
|
||||
|
||||
fn main() {}
|
||||
6
tests/ui/lint/rfc-2383-lint-reason/expect_warnings.rs
Normal file
6
tests/ui/lint/rfc-2383-lint-reason/expect_warnings.rs
Normal file
|
|
@ -0,0 +1,6 @@
|
|||
//@ check-pass
|
||||
|
||||
#![expect(warnings)]
|
||||
|
||||
#[expect(unused)]
|
||||
fn main() {}
|
||||
|
|
@ -1,3 +1,11 @@
|
|||
warning: denote infinite loops with `loop { ... }`
|
||||
--> $DIR/force_warn_expected_lints_fulfilled.rs:8:5
|
||||
|
|
||||
LL | while true {
|
||||
| ^^^^^^^^^^ help: use `loop`
|
||||
|
|
||||
= note: requested on the command line with `--force-warn while-true`
|
||||
|
||||
warning: unused variable: `x`
|
||||
--> $DIR/force_warn_expected_lints_fulfilled.rs:18:9
|
||||
|
|
||||
|
|
@ -28,13 +36,5 @@ warning: unused variable: `this_should_fulfill_the_expectation`
|
|||
LL | let this_should_fulfill_the_expectation = "The `#[allow]` has no power here";
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: if this is intentional, prefix it with an underscore: `_this_should_fulfill_the_expectation`
|
||||
|
||||
warning: denote infinite loops with `loop { ... }`
|
||||
--> $DIR/force_warn_expected_lints_fulfilled.rs:8:5
|
||||
|
|
||||
LL | while true {
|
||||
| ^^^^^^^^^^ help: use `loop`
|
||||
|
|
||||
= note: requested on the command line with `--force-warn while-true`
|
||||
|
||||
warning: 5 warnings emitted
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue