Skip to content

fix: emit diagnostic for useless #[path] attribute on inline modules#158835

Open
ravlynd wants to merge 1 commit into
rust-lang:mainfrom
ravlynd:fix/warn-path-attribute
Open

fix: emit diagnostic for useless #[path] attribute on inline modules#158835
ravlynd wants to merge 1 commit into
rust-lang:mainfrom
ravlynd:fix/warn-path-attribute

Conversation

@ravlynd

@ravlynd ravlynd commented Jul 6, 2026

Copy link
Copy Markdown

Closes #157260.

This PR adds a warning for #[path] attributes on inline modules when the attribute has no effect.

It also adds UI tests covering both warning and non-warning 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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

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.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Nonsensical #[path] attributes are allowed.

4 participants