Add a regression test for the duplicated crate keyword in path suggestions

This commit is contained in:
Jacob Adam
2026-04-02 23:55:05 +01:00
parent e6b64a2f4c
commit e2461cf2ad
2 changed files with 43 additions and 0 deletions
@@ -0,0 +1,20 @@
//! Regression test for <https://github.com/rust-lang/rust/issues/115858>.
//!
//! The compiler used to suggest `crate::crate::unix::linux::system::Y`
//! (duplicating the `crate` keyword) instead of `crate::unix::linux::system::Y`.
pub mod unix {
pub mod linux {
pub mod utils {
pub fn f() {
let _x = crate::linux::system::Y;
//~^ ERROR cannot find `linux` in `crate`
}
}
pub mod system {
pub const Y: u32 = 0;
}
}
}
fn main() {}
@@ -0,0 +1,23 @@
error[E0433]: cannot find `linux` in `crate`
--> $DIR/path-suggestion-duplicated-crate-keyword.rs:10:33
|
LL | let _x = crate::linux::system::Y;
| ^^^^^ unresolved import
|
help: a similar path exists
|
LL | let _x = crate::unix::linux::system::Y;
| ++++++
help: consider importing this module
|
LL + use unix::linux::system;
|
help: if you import `system`, refer to it directly
|
LL - let _x = crate::linux::system::Y;
LL + let _x = system::Y;
|
error: aborting due to 1 previous error
For more information about this error, try `rustc --explain E0433`.