Skip to content

Improve cross-namespace name diagnostics#159307

Merged
rust-bors[bot] merged 1 commit into
rust-lang:mainfrom
TorinAsakura:fix/builtin-attribute-value-diagnostics
Jul 21, 2026
Merged

Improve cross-namespace name diagnostics#159307
rust-bors[bot] merged 1 commit into
rust-lang:mainfrom
TorinAsakura:fix/builtin-attribute-value-diagnostics

Conversation

@TorinAsakura

@TorinAsakura TorinAsakura commented Jul 14, 2026

Copy link
Copy Markdown
Contributor

Close #86290

Cross-namespace name matches now use the ordinary missing-name diagnostic while preserving its error code and suggestions. The diagnostic adds a note identifying the item found in another namespace, while same-namespace wrong-kind diagnostics remain unchanged.

The UI expectations cover cross-namespace combinations across the resolver suite, including preservation of existing suggestions.

@rustbot rustbot added 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 14, 2026
@rustbot

rustbot commented Jul 14, 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 @petrochenkov (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
Why was this reviewer chosen?

The reviewer was selected based on:

  • Owners of files modified in this PR: compiler
  • compiler expanded to 75 candidates
  • Random selection from 21 candidates

@TorinAsakura
TorinAsakura force-pushed the fix/builtin-attribute-value-diagnostics branch from 4e36c58 to 92d8373 Compare July 14, 2026 21:29
@petrochenkov

Copy link
Copy Markdown
Contributor

I don't think we should do this - #86290 (comment).
@rustbot blocked

@rustbot rustbot added S-blocked Status: Blocked on something else such as an RFC or other implementation work. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Jul 15, 2026
@TorinAsakura

Copy link
Copy Markdown
Contributor Author

@petrochenkov Makes sense, the resolver fallback should stay as-is.

Looking at where the error is built, changing make_base_error unconditionally would also affect wrong-kind errors from the same namespace. Would it make sense to limit the wording change to expression paths whose resolved item comes from another namespace, and apply it consistently to attributes, macros, and enums?

For example: “expected value, but a built-in attribute with the same name exists”.

@petrochenkov

Copy link
Copy Markdown
Contributor

Would it make sense to limit the wording change to expression paths whose resolved item comes from another namespace, and apply it consistently to attributes, macros, and enums?

Yes, I think the wording for the same-namespace case is already good, and the wording for the cross-namespace case is better changed consistently for all the namespace combinations.

It may also be better to discuss the details on the issue thread #86290.

@rustbot

rustbot commented Jul 16, 2026

Copy link
Copy Markdown
Collaborator

This PR modifies tests/ui/issues/. If this PR is adding new tests to tests/ui/issues/,
please refrain from doing so, and instead add it to more descriptive subdirectories.

@TorinAsakura TorinAsakura changed the title Improve missing value diagnostics for built-in attributes Improve cross-namespace name diagnostics Jul 16, 2026
@TorinAsakura

Copy link
Copy Markdown
Contributor Author

@rustbot review

@rustbot rustbot added S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. and removed S-blocked Status: Blocked on something else such as an RFC or other implementation work. labels Jul 16, 2026
@rust-log-analyzer

This comment has been minimized.

Comment thread compiler/rustc_resolve/src/late/diagnostics.rs Outdated
@petrochenkov

Copy link
Copy Markdown
Contributor

Some tests are also failing.
Otherwise looks ok to me.
@rustbot author

@rustbot rustbot 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-review Status: Awaiting review from the assignee but also interested parties. labels Jul 17, 2026
@rustbot

rustbot commented Jul 17, 2026

Copy link
Copy Markdown
Collaborator

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

@TorinAsakura

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 17, 2026
@rust-log-analyzer

This comment has been minimized.

@rustbot

rustbot commented Jul 17, 2026

Copy link
Copy Markdown
Collaborator

miri is developed in its own repository. If possible, consider making this change to rust-lang/miri instead.

cc @rust-lang/miri

@TorinAsakura

Copy link
Copy Markdown
Contributor Author

miri is developed in its own repository. If possible, consider making this change to rust-lang/miri instead.

cc @rust-lang/miri

rust-lang/miri#5214

@petrochenkov

Copy link
Copy Markdown
Contributor

r=me after squashing commits.
@rustbot author

@rustbot rustbot 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-review Status: Awaiting review from the assignee but also interested parties. labels Jul 20, 2026
@TorinAsakura
TorinAsakura force-pushed the fix/builtin-attribute-value-diagnostics branch from 61730f7 to 30bc6d2 Compare July 20, 2026 22:03
@TorinAsakura

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 20, 2026
@petrochenkov

Copy link
Copy Markdown
Contributor

@bors r+

@rust-bors

rust-bors Bot commented Jul 20, 2026

Copy link
Copy Markdown
Contributor

📌 Commit 30bc6d2 has been approved by petrochenkov

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 Jul 20, 2026
rust-bors Bot pushed a commit that referenced this pull request Jul 21, 2026
Rollup of 14 pull requests

Successful merges:

 - #159307 (Improve cross-namespace name diagnostics)
 - #159543 (Remove extra semicolons in parsing item lists)
 - #157270 (ergonomic_clones_dotuse_capture_by_ref: Capture upvar by ref for `.use` in non-move closures)
 - #158496 (Move `check_rustc_pub_transparent` into the attribute parser)
 - #158547 (Move `std::io::buffered` to `alloc::io`)
 - #158808 (Filter host libstdc++ ABI flag in rustc_llvm cross builds)
 - #159362 (Add regression test for #120328)
 - #159472 (Support creating float constants in rustc_public mir)
 - #159505 (make rustdoc::bare_urls strip trailing periods from url)
 - #159568 (Suggest close compiler options)
 - #159578 (Extract coroutine closure helper functions)
 - #159601 (Make `TokenTreeCursor` private)
 - #159613 (Set the rustc lib path for unstable-book-gen)
 - #159616 (Clarify the comment about stage1/stage2 discrepancy in input-stats test)
@rust-bors
rust-bors Bot merged commit e1d8ba6 into rust-lang:main Jul 21, 2026
13 checks passed
rust-timer added a commit that referenced this pull request Jul 21, 2026
Rollup merge of #159307 - TorinAsakura:fix/builtin-attribute-value-diagnostics, r=petrochenkov

Improve cross-namespace name diagnostics

Close #86290

Cross-namespace name matches now use the ordinary missing-name diagnostic while preserving its error code and suggestions. The diagnostic adds a note identifying the item found in another namespace, while same-namespace wrong-kind diagnostics remain unchanged.

The UI expectations cover cross-namespace combinations across the resolver suite, including preservation of existing suggestions.
@rustbot rustbot added this to the 1.99.0 milestone Jul 21, 2026
@TorinAsakura
TorinAsakura deleted the fix/builtin-attribute-value-diagnostics branch July 21, 2026 15:38
pull Bot pushed a commit to xtqqczze/rust-lang-miri that referenced this pull request Jul 22, 2026
Rollup of 14 pull requests

Successful merges:

 - rust-lang/rust#159307 (Improve cross-namespace name diagnostics)
 - rust-lang/rust#159543 (Remove extra semicolons in parsing item lists)
 - rust-lang/rust#157270 (ergonomic_clones_dotuse_capture_by_ref: Capture upvar by ref for `.use` in non-move closures)
 - rust-lang/rust#158496 (Move `check_rustc_pub_transparent` into the attribute parser)
 - rust-lang/rust#158547 (Move `std::io::buffered` to `alloc::io`)
 - rust-lang/rust#158808 (Filter host libstdc++ ABI flag in rustc_llvm cross builds)
 - rust-lang/rust#159362 (Add regression test for rust-lang/rust#120328)
 - rust-lang/rust#159472 (Support creating float constants in rustc_public mir)
 - rust-lang/rust#159505 (make rustdoc::bare_urls strip trailing periods from url)
 - rust-lang/rust#159568 (Suggest close compiler options)
 - rust-lang/rust#159578 (Extract coroutine closure helper functions)
 - rust-lang/rust#159601 (Make `TokenTreeCursor` private)
 - rust-lang/rust#159613 (Set the rustc lib path for unstable-book-gen)
 - rust-lang/rust#159616 (Clarify the comment about stage1/stage2 discrepancy in input-stats test)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

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.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Missing variables/fields give confusing error when name is the same as a built-in attribute like start or path

4 participants