Skip to content

rustc_passes: lint unused #[path] attributes on inline modules - #158835

Merged
rust-bors[bot] merged 1 commit into
rust-lang:mainfrom
ravlynd:fix/warn-path-attribute
Aug 9, 2026
Merged

rustc_passes: lint unused #[path] attributes on inline modules#158835
rust-bors[bot] merged 1 commit into
rust-lang:mainfrom
ravlynd:fix/warn-path-attribute

Conversation

@ravlynd

@ravlynd ravlynd commented Jul 6, 2026

Copy link
Copy Markdown
Contributor

View all comments

Closes #157260.

This PR emits the unused_attributes lint for #[path] attributes on inline modules when the attribute is unused.

It also adds UI tests covering both linted and non-linted cases.

r? @theemathas

@rustbot

rustbot commented Jul 6, 2026

Copy link
Copy Markdown
Collaborator

Some changes occurred in compiler/rustc_passes/src/check_attr.rs

cc @jdonszelmann, @JonathanBrouwer

Some changes occurred in compiler/rustc_attr_parsing

cc @jdonszelmann, @JonathanBrouwer

Some changes occurred in compiler/rustc_hir/src/attrs

cc @jdonszelmann, @JonathanBrouwer

@rustbot rustbot added A-attributes Area: Attributes (`#[…]`, `#![…]`) S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. labels Jul 6, 2026
@rustbot

rustbot commented Jul 6, 2026

Copy link
Copy Markdown
Collaborator

Thanks for the pull request, and welcome! The Rust Project is excited to review your changes, and you should hear from @theemathas (or someone else) some time within the next two weeks.

Please see the contribution instructions for more information. Namely, in order to ensure the minimum review times lag, PR authors and assigned reviewers should ensure that the review label (S-waiting-on-review and S-waiting-on-author) stays updated, invoking these commands when appropriate:

  • @rustbot author: the review is finished, PR author should check the comments and take action accordingly
  • @rustbot review: the author is ready for a review, this PR will be queued again in the reviewer's queue

@theemathas

Copy link
Copy Markdown
Contributor

r? compiler

@rustbot rustbot assigned hanna-kruppe and unassigned theemathas Jul 6, 2026
@hanna-kruppe

Copy link
Copy Markdown
Contributor

This feels similar-ish to other warnings about misapplied attributes, at least some of which were treated more as FCW than regular warning. Maybe there's a reason I'm missing why this one should be different. @JonathanBrouwer what do you think?

Comment thread compiler/rustc_passes/src/diagnostics.rs Outdated
@rustbot rustbot removed the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. label Jul 7, 2026
@rustbot

rustbot commented Jul 7, 2026

Copy link
Copy Markdown
Collaborator

Reminder, once the PR becomes ready for a review, use @rustbot ready.

@rustbot rustbot added the S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. label Jul 7, 2026
@hanna-kruppe

Copy link
Copy Markdown
Contributor

r? @JonathanBrouwer

@rustbot

rustbot commented Jul 7, 2026

Copy link
Copy Markdown
Collaborator

JonathanBrouwer is currently at their maximum review capacity.
They may take a while to respond.

@ravlynd
ravlynd force-pushed the fix/warn-path-attribute branch from c397ba1 to 37c3b37 Compare July 8, 2026 04:51
@rustbot

This comment has been minimized.

@ravlynd ravlynd changed the title fix: emit diagnostic for useless #[path] attribute on inline modules rustc_passes: lint unused #[path] attributes on inline modules Jul 8, 2026
@ravlynd
ravlynd force-pushed the fix/warn-path-attribute branch from 37c3b37 to 56dd0c2 Compare July 8, 2026 04:59
@ravlynd

ravlynd commented Jul 8, 2026

Copy link
Copy Markdown
Contributor Author

@rustbot ready

@rustbot rustbot added S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. and removed S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. labels Jul 8, 2026
@ravlynd
ravlynd requested a review from JonathanBrouwer July 8, 2026 05:11
@JonathanBrouwer JonathanBrouwer added I-lang-nominated Nominated for discussion during a lang team meeting. needs-fcp This change is insta-stable, or significant enough to need a team FCP to proceed. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Jul 10, 2026
@rust-bors rust-bors Bot removed the S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. label Jul 31, 2026
@rust-bors

rust-bors Bot commented Jul 31, 2026

Copy link
Copy Markdown
Contributor

This pull request was unapproved.

View changes since this unapproval

@ravlynd
ravlynd force-pushed the fix/warn-path-attribute branch from d468a2b to 6d83fae Compare August 5, 2026 01:18
@rustbot

This comment has been minimized.

@rust-log-analyzer

This comment has been minimized.

@ravlynd
ravlynd force-pushed the fix/warn-path-attribute branch from 6d83fae to a7636e9 Compare August 8, 2026 01:19
@rustbot

This comment has been minimized.

@ravlynd

ravlynd commented Aug 8, 2026

Copy link
Copy Markdown
Contributor Author

@rustbot ready

@rustbot rustbot added S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. and removed S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. labels Aug 8, 2026
@JonathanBrouwer

Copy link
Copy Markdown
Contributor

@bors r+
Thanks <3

@rust-bors

rust-bors Bot commented Aug 8, 2026

Copy link
Copy Markdown
Contributor

📌 Commit a7636e9 has been approved by JonathanBrouwer

It is now in the queue for this repository.

@rust-bors rust-bors Bot added S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Aug 8, 2026
rust-bors Bot pushed a commit that referenced this pull request Aug 8, 2026
…uwer

Rollup of 12 pull requests

Successful merges:

 - #160336 (Move attributes out of rustc_hir)
 - #160715 (ignore tests with the GCC backend if we can't find `libgccjit.so` for the target)
 - #157609 (fix: build-std on 32 bit arm with 64 bit time)
 - #160613 (Add regression test for unsized non-last struct field with overlapping impls)
 - #160658 (miri: implement more restrictive trivial-ABI checks)
 - #160704 (sort lint names in lint pass declarations)
 - #160707 (Add regression test for higher ranked fn pointer impl not general enough)
 - #160713 (Add regression test for #135287)
 - #160720 (triagebot: add ubiratan to infra-ci)
 - #160747 (rustc_errors: remove unused code)
 - #160751 (Add regression test for incremental borrowck ICE with generic const exprs)
 - #160753 (rustc_lint: remove unused rustc_attrs feature)

Failed merges:

 - #158835 (rustc_passes: lint unused `#[path]` attributes on inline modules)
@rust-bors rust-bors Bot added S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. and removed S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. labels Aug 8, 2026
@rust-bors

This comment has been minimized.

@JonathanBrouwer
JonathanBrouwer force-pushed the fix/warn-path-attribute branch from a7636e9 to 7b1731b Compare August 8, 2026 20:16
@rustbot

rustbot commented Aug 8, 2026

Copy link
Copy Markdown
Collaborator

Some changes occurred in compiler/rustc_attr_ir

cc @jdonszelmann, @JonathanBrouwer

@rustbot

rustbot commented Aug 8, 2026

Copy link
Copy Markdown
Collaborator

This PR was rebased onto a different main commit. Here's a range-diff highlighting what actually changed.

Rebasing is a normal part of keeping PRs up to date, so no action is needed—this note is just to help reviewers.

@JonathanBrouwer

Copy link
Copy Markdown
Contributor

^ Rebased
@bors r+

@rust-bors

rust-bors Bot commented Aug 8, 2026

Copy link
Copy Markdown
Contributor

📌 Commit 7b1731b has been approved by JonathanBrouwer

It is now in the queue for this repository.

@rust-bors rust-bors Bot added S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. and removed S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. labels Aug 8, 2026
rust-bors Bot pushed a commit that referenced this pull request Aug 8, 2026
…uwer

Rollup of 9 pull requests

Successful merges:

 - #156935 (Introduce a `PinSafePointer` trait that generalizes `PinCoerceUnsized`)
 - #159834 (Apply str debugger visualizer to `*const str`, `*mut str` and `Box<str>`)
 - #160663 (Suggest add async for function sig with return expr in body)
 - #160732 (Optimize slice::contains for one-byte BytewiseEq types)
 - #157944 (Make `char::is_default_ignorable` unstably public)
 - #158835 (rustc_passes: lint unused `#[path]` attributes on inline modules)
 - #160754 (Rename more diagnostic files to `diagnostics.rs`)
 - #160755 (Merge `rustc_lint/lints.rs` into `diagnostics.rs`)
 - #160757 (Merge `rustc_attr_parsing/session_diagnostics.rs` into `diagnostics.rs`)
@rust-bors
rust-bors Bot merged commit 2a8d31a into rust-lang:main Aug 9, 2026
13 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

A-attributes Area: Attributes (`#[…]`, `#![…]`) disposition-merge This issue / PR is in PFCP or FCP with a disposition to merge it. finished-final-comment-period The final comment period is finished for this PR / Issue. I-lang-radar Items that are on lang's radar and will need eventual work or consideration. S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. T-lang Relevant to the language team to-announce Announce this issue on triage meeting

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Nonsensical #[path] attributes are allowed.