Skip to content

Improve diagnostics for suggestions of unstable items - #161943

Open
KevinA-cpu wants to merge 7 commits into
rust-lang:mainfrom
KevinA-cpu:rustc-diagnostics-unstable-and-intrinsics-suggestions
Open

KevinA-cpu wants to merge 7 commits into
rust-lang:mainfrom
KevinA-cpu:rustc-diagnostics-unstable-and-intrinsics-suggestions

Conversation

@KevinA-cpu

@KevinA-cpu KevinA-cpu commented Aug 28, 2026 •

Copy link
Copy Markdown
Contributor

View all comments

  • Add a note for unstable suggestions
  • Only suggest intrinsics when the core_intrinsics feature is enabled

r? @JonathanBrouwer

Related:
Started from issue #78130
Created PR #161540 for regression tests
Then move to this PR for improvement points

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

This comment has been minimized.

@rust-log-analyzer

This comment has been minimized.

@JonathanBrouwer

Copy link
Copy Markdown
Member

@bors try jobs=x86_64-gnu-stable

@rust-bors

This comment has been minimized.

rust-bors Bot pushed a commit that referenced this pull request Aug 31, 2026
…rinsics-suggestions, r=<try>

Improve rustc diagnostics


try-job: x86_64-gnu-stable
Comment thread tests/ui/const-generics/issues/issue-82956.stderr Outdated
LL | let _: BorrowedBuf;
| ^^^^^^^^^^^ not found in this scope
|
= note: 'std::io::BorrowedBuf' is unstable in nightly Rust and is only available with the `#![feature(core_io_borrowed_buf)]` attribute

@JonathanBrouwer JonathanBrouwer Aug 31, 2026 •

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Could you place the note below the help: consider importing this struct? That improves the reading order

View changes since the review

@KevinA-cpu KevinA-cpu Sep 1, 2026 •

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

I want to clarify @JonathanBrouwer, do you want to reorder so that the note is below the help universally, or do you only want this particular new note we're adding to be below the help?

Below is an example where a note above the help might be more useful:

= note: 'std::convert::TryFrom' is included in the prelude starting in Edition 2021
help: consider importing this trait

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

I mean I want the note to be under the help universally.
The idea being that we first tell the user "you might have meant x" then "by the way, x is unstable". If you start with "x is unstable" its not obvious why the compiler is telling us that until you read the next sentence

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Updated

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

The note is still above the help.

That is, I want

error[E0425]: cannot find type `BorrowedBuf` in this scope
  --> $DIR/import-suggestion-unstable-feature-note.rs:9:12
   |
LL |     let _: BorrowedBuf;
   |            ^^^^^^^^^^^ not found in this scope
   |
   = note: 'std::io::BorrowedBuf' is unstable, add `#![feature(core_io_borrowed_buf)]` to the crate attributes to enable
help: consider importing this struct
   |
LL + use std::io::BorrowedBuf;
   |

To change to (approximately)

error[E0425]: cannot find type `BorrowedBuf` in this scope
  --> $DIR/import-suggestion-unstable-feature-note.rs:9:12
   |
LL |     let _: BorrowedBuf;
   |            ^^^^^^^^^^^ not found in this scope
   |
help: consider importing this struct
   |
LL + use std::io::BorrowedBuf;
   |
note: 'std::io::BorrowedBuf' is unstable, add `#![feature(core_io_borrowed_buf)]` to the crate attributes to enable

@JonathanBrouwer JonathanBrouwer Oct 24, 2026 •

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Sorry for the late review! Due to a mix of conferences and illness I didn't get around to it earlier
@rustbot author

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

@JonathanBrouwer no worries, I actually have to thank you for taking the time to review and help me grow. Like there's no financial incentive for you right?

I myself wants to be like you and many others in the rust contributors team - getting a chance to attends conferences and all that 😆

I'm actually also going through some career transition as well, it's exhausting, I'll get on to address your comments as soon as thing stabilizes!

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Like there's no financial incentive for you right

Since a few weeks maintaining the rust compiler is now my full-time job, through the RustNL maintainers team. Before that I was indeed fully unpaid, so many thanks to them :)

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

I'm actually also going through some career transition as well, it's exhausting, I'll get on to address your comments as soon as thing stabilizes!

No worries, take as long as you need, you're volunteering your time here after all. And good luck with the career transition <3

Comment thread compiler/rustc_resolve/src/diagnostics/impls.rs Outdated
@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 Aug 31, 2026
@rustbot

rustbot commented Aug 31, 2026

Copy link
Copy Markdown
Collaborator

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

@JonathanBrouwer JonathanBrouwer changed the title Improve rustc diagnostics Improve diagnostics for suggestions of unstable items Aug 31, 2026
@rust-bors

rust-bors Bot commented Aug 31, 2026

Copy link
Copy Markdown
Contributor

☀️ Try build successful (CI)
Build commit: c00b75b (c00b75bd88d2b929fd91c696b206b37c632003e0)
Base parent: 0dfb098 (0dfb098f3aeecbe38c2566ca090193280e7349e7)

@JonathanBrouwer

Copy link
Copy Markdown
Member

@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 Oct 6, 2026
@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 Oct 7, 2026
@rustbot

This comment has been minimized.

@rust-log-analyzer

This comment has been minimized.

@rust-log-analyzer

This comment has been minimized.

- Add a note for unstable suggestions
- Only suggest intrinsics when `core_intrinsics` feature is enabled
@KevinA-cpu
KevinA-cpu force-pushed the rustc-diagnostics-unstable-and-intrinsics-suggestions branch from a7202d8 to df6364a Compare October 12, 2026 09:21
@rustbot

rustbot commented Oct 12, 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.

@rustbot

rustbot commented Oct 12, 2026

Copy link
Copy Markdown
Collaborator

⚠️ Warning ⚠️

@rust-log-analyzer

This comment has been minimized.

@JonathanBrouwer

Copy link
Copy Markdown
Member

Fyi I'm on holidays (at Eurorust) this week I'll get to any review next week

@KevinA-cpu

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 Oct 14, 2026
@rust-bors

rust-bors Bot commented Oct 23, 2026

Copy link
Copy Markdown
Contributor

☔ The latest upstream changes (presumably #164804) made this pull request unmergeable. Please resolve the merge conflicts by rebasing.

@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 Oct 24, 2026

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. 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.

4 participants