Skip to content

Add regression test for unstable path suggestions - #161540

Open
KevinA-cpu wants to merge 1 commit into
rust-lang:mainfrom
KevinA-cpu:regression-test-78130
Open

KevinA-cpu wants to merge 1 commit into
rust-lang:mainfrom
KevinA-cpu:regression-test-78130

Conversation

@KevinA-cpu

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

Copy link
Copy Markdown
Contributor

closes #78130

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

rustbot commented Aug 22, 2026

Copy link
Copy Markdown
Collaborator

r? @dingxiangfei2009

rustbot has assigned @dingxiangfei2009.
They will have a look at your PR within the next two weeks and either review your PR or reassign to another reviewer.

Use r? to explicitly pick a reviewer

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

|
help: consider importing this function
|
LL + use std::intrinsics::assert_zero_valid;

@JonathanBrouwer JonathanBrouwer Aug 22, 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.

Hmmm wel it seems like rust is suggesting an unstable path, so it is not fixed

View changes since the review

@KevinA-cpu KevinA-cpu Aug 23, 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.

Hi @JonathanBrouwer , would it be acceptable to add a note for unstable features in nightly builds?

let note = if !is_stable {
    this.tcx.lookup_stability(did).and_then(|stab| match stab.level {
        StabilityLevel::Unstable { .. } => Some(format!(
            "'{}' is unstable in nightly Rust and is only available with the `#![feature({})]` attribute",
            path_names_to_string(&path),
            stab.feature
        )),
        _ => None,
    })
}

or should this be addressed in a different item for nightly builds?

@JonathanBrouwer JonathanBrouwer Aug 28, 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.

From taking a look at the current code:

suggestions.retain(|suggestion| suggestion.is_stable || self.tcx.sess.is_nightly_build());

It seems that showing unstable suggestions on nightly is intentional, and I like this.

I think there are two things I'd like to change here:

  • IMO We should never be suggesting intrinsics to be imported, unless the core_intrinsics feature is already enabled. The current implementation still suggests them if there is nothing else to suggest, I don't see the point of this as nobody outside of the stdlib should be using these. This is implemented here
    let intrinsic_candidates: Vec<_> = candidates

    This was discussed previously here E0425: Don't recommend the use of intrinsics first #97618
    cc @compiler-errors @oli-obk if you have opinions as people who were previously involved in this issue
  • As you mentioned, adding an extra note when a suggestion is unstable is a good idea to prevent people from adding the import and then immediately removing it again if they don't want to use features. Make sure to only add this note if the feature is not already enabled.

@KevinA-cpu Do you feel like implementing these two points? Preferably in separate PRs as they are mostly unrelated. Feel free to assign me as a reviewer

@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.

Hi @JonathanBrouwer , thank you for the suggestion. I'd love to try my hand at implementing those two points. As I am still new, let's hope it does not take 10 years 🤣

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

rustbot commented Aug 22, 2026

Copy link
Copy Markdown
Collaborator

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

@JonathanBrouwer JonathanBrouwer 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 24, 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 Aug 28, 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.

Rust suggests unstable paths for non-imported item

4 participants