diff --git a/tests/ui/resolve/path-suggestion-duplicated-crate-keyword.rs b/tests/ui/resolve/path-suggestion-duplicated-crate-keyword.rs new file mode 100644 index 0000000000000..294885b997da3 --- /dev/null +++ b/tests/ui/resolve/path-suggestion-duplicated-crate-keyword.rs @@ -0,0 +1,20 @@ +//! Regression test for . +//! +//! 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() {} diff --git a/tests/ui/resolve/path-suggestion-duplicated-crate-keyword.stderr b/tests/ui/resolve/path-suggestion-duplicated-crate-keyword.stderr new file mode 100644 index 0000000000000..49c2db34d2b4d --- /dev/null +++ b/tests/ui/resolve/path-suggestion-duplicated-crate-keyword.stderr @@ -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`.