Skip to content

internal: remove dead #[allow] attributes - #22906

Open
weiscadence wants to merge 1 commit into
rust-lang:masterfrom
weiscadence:internal/remove-dead-allow-attrs
Open

internal: remove dead #[allow] attributes#22906
weiscadence wants to merge 1 commit into
rust-lang:masterfrom
weiscadence:internal/remove-dead-allow-attrs

Conversation

@weiscadence

Copy link
Copy Markdown

Each of these 20 #[allow(..)] attributes suppresses a lint that no longer
fires at that site, so the attribute currently has no effect. The change is
purely subtractive — 20 deletions, no statement, signature or behaviour change.

How they were found

  1. Rewrote every #[allow(..)] under crates/ to #[expect(..)] and collected
    unfulfilled_lint_expectations.
  2. Discarded every diagnostic whose span came from a macro expansion. Those are
    not dead: the suppression is still needed by other expansions of the same
    macro. This was the large majority (134 of 153 sites).
  3. Confirmed each remaining candidate by actually deleting the attribute and
    rebuilding.

Step 3 was not redundant. One candidate that step 1 reported as unfulfilled —
#[allow(unused_mut)] in crates/hir-def/src/expr_store/lower/path.rs — makes
unused_mut fire when removed, because that binding is only mutated under
#[cfg(test)]. It is left untouched here. An unfulfilled expectation is not by
itself proof that an allow is dead.

Verification

  • cargo check --workspace --all-targets — clean, no diagnostics.
  • Same under CI's RUSTFLAGS="-W unreachable-pub --cfg no_salsa_async_drops".
  • Cargo.lock is deliberately untouched. (It does churn locally on a pristine
    checkout too — salsa-macros — so that is unrelated to this change.)

Not covered

I could not build the in-rust-tree feature (needs a nightly toolchain), so
these were not checked under it. As far as I can tell CI only builds that
feature for proc-macro-srv, proc-macro-srv-cli and proc-macro-api, none of
which are touched here — but flagging it rather than implying coverage I don't
have.

Happy to split this per-crate if that is easier to review.

@rustbot rustbot added the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. label Jul 25, 2026
@ChayimFriedman2

Copy link
Copy Markdown
Contributor

Please note that our AI policy disallows using AI to write GitHub comments, including PR descriptions.

@ChayimFriedman2 ChayimFriedman2 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please switch all other allows to expects, or a comment explaining why they can't be.

View changes since this review

Comment thread crates/hir-ty/src/infer.rs Outdated
@@ -111,9 +111,7 @@ use crate::{
// This lint has a false positive here. See the link below for details.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please remove this comment as well.

};
let arg_id = MacroCallId::new(db, loc);
#[allow(deprecated)] // builtin eager macros are never derives
let (_, _, span) = arg_id.macro_arg(db);

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is incorrect, the #[deprecated] was just lost during the Salsa transition, we should add it back.

/// This is not connected to the database so it does not cache the result. However, the inner [macro_arg] query is
///
/// [macro_arg]: Self::macro_arg
#[allow(deprecated)] // we are macro_arg_considering_derives

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Here too.

@weiscadence

Copy link
Copy Markdown
Author

infer.rs - I removed the comment

eager.rs + lib.rs - you’re right they aren’t dead but your fix doesn’t compile. #[salsa::tracked] expand the method into a trait impl. I tried both attribute orders and got the same error. So the depreciation wasn’t dropped by oversight in the salsa transition, it stopped being expressable.

rustc rejects it:
“error: #[deprecated] attribute cannot be used on trait methods in impl blocks”

There is a workaround:

rename the tracked query to macro_arg_ and put #[deprecated] on a thin wrapper. The same _-suffix pattern already in cli/flags.rs. I confirmed it compiles and that the warning genuinely fires (stripped the allow back out and the deprecation warning appeared). But it renames a salsa query so do you want that or leave those two allows deleted?

Allow-expect - for the whole codebase or just the touched files? 134 of 153 allow sites sit inside macro expansions where expect breaks because other expansions of the same macro still need the suppression.

@ChayimFriedman2 ChayimFriedman2 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

eager.rs + lib.rs - you’re right they aren’t dead but your fix doesn’t compile. #[salsa::tracked] expand the method into a trait impl. I tried both attribute orders and got the same error. So the depreciation wasn’t dropped by oversight in the salsa transition, it stopped being expressable.

Ugh. Okay then I guess a comment above the function to not remove it will be enough, you don't need to insert an inner function.

Allow-expect - for the whole codebase or just the touched files? 134 of 153 allow sites sit inside macro expansions where expect breaks because other expansions of the same macro still need the suppression.

For the whole codebases, but only outside of macros. You can do that in a separate PR if you want.

Please also squash.

View changes since this review

The suppressions at the `macro_arg` call sites are kept: the
`#[deprecated]` they suppress was lost in the Salsa transition and is no
longer expressible, since `#[salsa::tracked]` expands the method into a
trait impl and rustc rejects `#[deprecated]` on trait methods in impl
blocks. A comment on the query records that intent instead.

Assisted-by: Claude (see AI_POLICY.md)
@weiscadence
weiscadence force-pushed the internal/remove-dead-allow-attrs branch from 456a5a2 to 6c66805 Compare July 27, 2026 18:18
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

S-waiting-on-review Status: Awaiting review from the assignee but also interested parties.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants