Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions compiler/rustc_resolve/src/diagnostics.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1610,6 +1610,7 @@ impl<'ra, 'tcx> Resolver<'ra, 'tcx> {
}
}

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

Expand Down
6 changes: 6 additions & 0 deletions tests/run-make/issue-149402-suggest-unresolve/foo.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
fn foo() {
let x = Vec::new();
x.push(Complete::Item { name: "hello" });
}

fn main() {}
18 changes: 18 additions & 0 deletions tests/run-make/issue-149402-suggest-unresolve/nightly.err
Original file line number Diff line number Diff line change
@@ -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`.
16 changes: 16 additions & 0 deletions tests/run-make/issue-149402-suggest-unresolve/output.diff
Original file line number Diff line number Diff line change
@@ -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

29 changes: 29 additions & 0 deletions tests/run-make/issue-149402-suggest-unresolve/rmake.rs
Original file line number Diff line number Diff line change
@@ -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();
}
9 changes: 9 additions & 0 deletions tests/run-make/issue-149402-suggest-unresolve/stable.err
Original file line number Diff line number Diff line change
@@ -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`.
Loading