Auto merge of #149440 - chenyukang:yukang/issue-149402, r=fee1-dead

Remove suggestion from importing unstable items on stable channel

Fixes rust-lang/rust#149402
This commit is contained in:
bors 2026-01-22 18:09:51 +00:00
commit 39052daf93
6 changed files with 79 additions and 0 deletions

View file

@ -0,0 +1,6 @@
fn foo() {
let x = Vec::new();
x.push(Complete::Item { name: "hello" });
}
fn main() {}

View file

@ -0,0 +1,18 @@
error[E0433]: failed to resolve: use of undeclared type `Complete`
--> foo.rs:3:12
|
3 | x.push(Complete::Item { name: "hello" });
| ^^^^^^^^ use of undeclared type `Complete`
|
help: there is an enum variant `core::ops::CoroutineState::Complete` and 1 other; try using the variant's enum
|
3 - x.push(Complete::Item { name: "hello" });
3 + x.push(core::ops::CoroutineState::Item { name: "hello" });
|
3 - x.push(Complete::Item { name: "hello" });
3 + x.push(std::ops::CoroutineState::Item { name: "hello" });
|
error: aborting due to 1 previous error
For more information about this error, try `rustc --explain E0433`.

View file

@ -0,0 +1,16 @@
@@ -3,6 +3,15 @@
|
3 | x.push(Complete::Item { name: "hello" });
| ^^^^^^^^ use of undeclared type `Complete`
+ |
+help: there is an enum variant `core::ops::CoroutineState::Complete` and 1 other; try using the variant's enum
+ |
+3 - x.push(Complete::Item { name: "hello" });
+3 + x.push(core::ops::CoroutineState::Item { name: "hello" });
+ |
+3 - x.push(Complete::Item { name: "hello" });
+3 + x.push(std::ops::CoroutineState::Item { name: "hello" });
+ |
error: aborting due to 1 previous error

View file

@ -0,0 +1,29 @@
//! Check that unstable name-resolution suggestions are omitted on stable.
//!
//! Regression test for <https://github.com/rust-lang/rust/issues/149402>.
//!
//@ only-nightly
//@ needs-target-std
use run_make_support::{diff, rustc, similar};
fn main() {
let stable_like = rustc()
.env("RUSTC_BOOTSTRAP", "-1")
.edition("2024")
.input("foo.rs")
.run_fail()
.stderr_utf8();
assert!(!stable_like.contains("CoroutineState::Complete"));
diff().expected_file("stable.err").actual_text("stable_like", &stable_like).run();
let nightly = rustc().edition("2024").input("foo.rs").run_fail().stderr_utf8();
assert!(nightly.contains("CoroutineState::Complete"));
diff().expected_file("nightly.err").actual_text("nightly", &nightly).run();
let stderr_diff =
similar::TextDiff::from_lines(&stable_like, &nightly).unified_diff().to_string();
diff().expected_file("output.diff").actual_text("diff", stderr_diff).run();
}

View file

@ -0,0 +1,9 @@
error[E0433]: failed to resolve: use of undeclared type `Complete`
--> foo.rs:3:12
|
3 | x.push(Complete::Item { name: "hello" });
| ^^^^^^^^ use of undeclared type `Complete`
error: aborting due to 1 previous error
For more information about this error, try `rustc --explain E0433`.