diff --git a/tests/ui/imports/remove-unused-private-import-errors.remove.stderr b/tests/ui/imports/remove-unused-private-import-errors.remove.stderr new file mode 100644 index 0000000000000..b5c11af17c1bb --- /dev/null +++ b/tests/ui/imports/remove-unused-private-import-errors.remove.stderr @@ -0,0 +1,9 @@ +error[E0433]: cannot find module `Ident` in this scope + --> $DIR/remove-unused-private-import-errors.rs:16:5 + | +LL | Ident::x(); + | ^^^^^ `Ident` is a variant, not a module + +error: aborting due to 1 previous error + +For more information about this error, try `rustc --explain E0433`. diff --git a/tests/ui/imports/remove-unused-private-import-errors.rs b/tests/ui/imports/remove-unused-private-import-errors.rs new file mode 100644 index 0000000000000..a51305327d7fa --- /dev/null +++ b/tests/ui/imports/remove-unused-private-import-errors.rs @@ -0,0 +1,40 @@ +//! Removing a private import that triggers `hidden_glob_reexports` can +//! break upstream code! +//! +//! Also see + +//@revisions: keep remove +//@[keep]check-pass + +#![crate_type = "lib"] + +use rustc_span::Ident; + +pub fn foo() { + use rustc_ast::*; // Must be inside the function scope + let _ /* fn(_,_) -> _*/ = Ident; + Ident::x(); + //[remove]~^ ERROR cannot find module `Ident` in this scope +} + +pub mod rustc_ast { + pub use self::TokenKind::*; + + #[cfg(keep)] // Compile error if false + #[expect(hidden_glob_reexports, unused_imports)] + use super::rustc_span::Ident; + + pub enum TokenKind { + Ident(u8, u8), + } +} + +pub mod rustc_span { + pub struct Ident {} + + impl Ident { + pub fn x() -> bool { + true + } + } +}