From 89bf3ed6501f3a65d697de5d8e139ecad249aa19 Mon Sep 17 00:00:00 2001 From: LorrensP-2158466 Date: Fri, 8 Aug 2025 17:47:25 +0200 Subject: [PATCH 1/5] Resolver: Batched import resolution. Collect side effects from the current set of undetermined imports and only apply them at the end. --- compiler/rustc_hir/src/def.rs | 18 ++ compiler/rustc_resolve/src/imports.rs | 200 ++++++++++++------ compiler/rustc_resolve/src/lib.rs | 6 - fail.rs | 30 +++ tests/ui/imports/ambiguous-9.rs | 8 +- tests/ui/imports/ambiguous-9.stderr | 52 ++--- .../ui/imports/glob-conflict-cross-crate-1.rs | 2 +- .../glob-conflict-cross-crate-1.stderr | 16 +- tests/ui/imports/reexports.stderr | 20 +- .../shadowed/shadowed-use-visibility.stderr | 32 +-- 10 files changed, 244 insertions(+), 140 deletions(-) create mode 100644 fail.rs diff --git a/compiler/rustc_hir/src/def.rs b/compiler/rustc_hir/src/def.rs index 8af4740f376b6..cb06d8165c58d 100644 --- a/compiler/rustc_hir/src/def.rs +++ b/compiler/rustc_hir/src/def.rs @@ -722,6 +722,24 @@ impl PerNS { pub fn iter(&self) -> IntoIter<&T, 3> { [&self.value_ns, &self.type_ns, &self.macro_ns].into_iter() } + + pub fn into_iter_with(self) -> IntoIter<(Namespace, T), 3> { + [ + (Namespace::TypeNS, self.type_ns), + (Namespace::ValueNS, self.value_ns), + (Namespace::MacroNS, self.macro_ns), + ] + .into_iter() + } + + pub fn iter_with(&self) -> IntoIter<(Namespace, &T), 3> { + [ + (Namespace::TypeNS, &self.type_ns), + (Namespace::ValueNS, &self.value_ns), + (Namespace::MacroNS, &self.macro_ns), + ] + .into_iter() + } } impl ::std::ops::Index for PerNS { diff --git a/compiler/rustc_resolve/src/imports.rs b/compiler/rustc_resolve/src/imports.rs index d7fc028287ff5..e2d4d2ddb2917 100644 --- a/compiler/rustc_resolve/src/imports.rs +++ b/compiler/rustc_resolve/src/imports.rs @@ -2,6 +2,7 @@ use std::cell::Cell; use std::mem; +use std::ops::Deref; use rustc_ast::NodeId; use rustc_data_structures::fx::{FxHashSet, FxIndexSet}; @@ -41,6 +42,96 @@ use crate::{ type Res = def::Res; +struct ImportResolver<'r, 'ra, 'tcx> { + r: CmResolver<'r, 'ra, 'tcx>, // always immutable + outputs: ImportResolutionOutputs<'ra>, +} + +enum SideEffect<'ra> { + None, + Single { import_bindings: PerNS> }, + Glob { import_bindings: Vec<(NameBinding<'ra>, BindingKey, bool /* warn_ambiguity */)> }, +} + +#[derive(Default)] +struct ImportResolutionOutputs<'ra> { + indeterminate_imports: Vec>, + determined_imports: Vec<(Import<'ra>, SideEffect<'ra>)>, +} + +impl<'ra> ImportResolutionOutputs<'ra> { + fn commit<'tcx>(self, r: &mut Resolver<'ra, 'tcx>) { + r.indeterminate_imports = self.indeterminate_imports; + r.determined_imports.reserve(self.determined_imports.len()); + + for (import, side_effect) in self.determined_imports { + r.determined_imports.push(import); + + let parent = import.parent_scope.module; + match (&import.kind, side_effect) { + ( + ImportKind::Single { target, bindings, .. }, + SideEffect::Single { import_bindings }, + ) => { + for (ns, pending_binding) in import_bindings.into_iter_with() { + match pending_binding { + PendingBinding::Ready(Some(binding)) => { + r.define_binding_local(parent, *target, ns, binding); + } + PendingBinding::Ready(None) => { + let key = BindingKey::new(*target, ns); + r.update_local_resolution(parent, key, false, |_, resolution| { + resolution.single_imports.swap_remove(&import); + }); + } + _ => {} + } + bindings[ns].set(pending_binding); + } + } + (ImportKind::Glob { id, .. }, SideEffect::Glob { import_bindings }) => { + let ModuleOrUniformRoot::Module(module) = import.imported_module.get().unwrap() + else { + unreachable!(); + }; + + module.glob_importers.borrow_mut().push(import); + + for (binding, key, warn_ambiguity) in import_bindings { + let _ = r.try_define_local( + parent, + key.ident.0, + key.ns, + binding, + warn_ambiguity, + ); + } + + r.record_partial_res(*id, PartialRes::new(module.res().unwrap())); + } + + (_, SideEffect::None) => {} + // Something weird happened, which shouldn't have happened. + _ => unreachable!("Mismatched import kind and side effect"), + } + } + } +} + +impl<'r, 'ra, 'tcx> Deref for ImportResolver<'r, 'ra, 'tcx> { + type Target = Resolver<'ra, 'tcx>; + + fn deref(&self) -> &Self::Target { + self.r.deref() + } +} + +impl<'r, 'ra, 'tcx> AsRef> for ImportResolver<'r, 'ra, 'tcx> { + fn as_ref(&self) -> &Resolver<'ra, 'tcx> { + self.r.as_ref() + } +} + /// A [`NameBinding`] in the process of being resolved. #[derive(Clone, Copy, Default, PartialEq)] pub(crate) enum PendingBinding<'ra> { @@ -551,22 +642,34 @@ impl<'ra, 'tcx> Resolver<'ra, 'tcx> { /// Resolves all imports for the crate. This method performs the fixed- /// point iteration. pub(crate) fn resolve_imports(&mut self) { - self.assert_speculative = true; let mut prev_indeterminate_count = usize::MAX; let mut indeterminate_count = self.indeterminate_imports.len() * 3; while indeterminate_count < prev_indeterminate_count { prev_indeterminate_count = indeterminate_count; - indeterminate_count = 0; - for import in mem::take(&mut self.indeterminate_imports) { - let import_indeterminate_count = self.cm().resolve_import(import); - indeterminate_count += import_indeterminate_count; - match import_indeterminate_count { - 0 => self.determined_imports.push(import), - _ => self.indeterminate_imports.push(import), - } + let batch = mem::take(&mut self.indeterminate_imports); + self.assert_speculative = true; + let (outputs, count) = + ImportResolver { r: self.cm(), outputs: Default::default() }.resolve_batch(batch); + self.assert_speculative = false; + indeterminate_count = count; + outputs.commit(self); + } + } + + fn resolve_batch<'r>( + mut self: ImportResolver<'r, 'ra, 'tcx>, + batch: Vec>, + ) -> (ImportResolutionOutputs<'ra>, usize) { + let mut indeterminate_count = 0; + for import in batch { + let (side_effect, import_indeterminate_count) = self.resolve_import(import); + indeterminate_count += import_indeterminate_count; + match import_indeterminate_count { + 0 => self.outputs.determined_imports.push((import, side_effect)), + _ => self.outputs.indeterminate_imports.push(import), } } - self.assert_speculative = false; + (self.outputs, indeterminate_count) } pub(crate) fn finalize_imports(&mut self) { @@ -839,7 +942,10 @@ impl<'ra, 'tcx> Resolver<'ra, 'tcx> { /// /// Meanwhile, if resolve successful, the resolved bindings are written /// into the module. - fn resolve_import<'r>(mut self: CmResolver<'r, 'ra, 'tcx>, import: Import<'ra>) -> usize { + fn resolve_import<'r>( + self: &mut ImportResolver<'r, 'ra, 'tcx>, + import: Import<'ra>, + ) -> (SideEffect<'ra>, usize) { debug!( "(resolving import for module) resolving import `{}::...` in `{}`", Segment::names_to_string(&import.module_path), @@ -848,7 +954,7 @@ impl<'ra, 'tcx> Resolver<'ra, 'tcx> { let module = if let Some(module) = import.imported_module.get() { module } else { - let path_res = self.reborrow().maybe_resolve_path( + let path_res = self.r.reborrow().maybe_resolve_path( &import.module_path, None, &import.parent_scope, @@ -857,8 +963,10 @@ impl<'ra, 'tcx> Resolver<'ra, 'tcx> { match path_res { PathResult::Module(module) => module, - PathResult::Indeterminate => return 3, - PathResult::NonModule(..) | PathResult::Failed { .. } => return 0, + PathResult::Indeterminate => return (SideEffect::None, 3), + PathResult::NonModule(..) | PathResult::Failed { .. } => { + return (SideEffect::None, 0); + } } }; @@ -868,16 +976,14 @@ impl<'ra, 'tcx> Resolver<'ra, 'tcx> { (source, target, bindings, type_ns_only) } ImportKind::Glob { .. } => { - // FIXME: Use mutable resolver directly as a hack, this should be an output of - // speculative resolution. - self.get_mut_unchecked().resolve_glob_import(import); - return 0; + return (self.resolve_glob_import(import), 0); } _ => unreachable!(), }; + let mut import_bindings = PerNS::default(); let mut indeterminate_count = 0; - self.per_ns_cm(|this, ns| { + self.r.reborrow().per_ns_cm(|this, ns| { if !type_ns_only || ns == TypeNS { if bindings[ns].get() != PendingBinding::Pending { return; @@ -889,8 +995,7 @@ impl<'ra, 'tcx> Resolver<'ra, 'tcx> { &import.parent_scope, Some(import), ); - let parent = import.parent_scope.module; - let binding = match binding_result { + let pending_binding = match binding_result { Ok(binding) => { if binding.is_assoc_item() && !this.tcx.features().import_trait_associated_functions() @@ -905,43 +1010,25 @@ impl<'ra, 'tcx> Resolver<'ra, 'tcx> { } // We need the `target`, `source` can be extracted. let imported_binding = this.import(binding, import); - // FIXME: Use mutable resolver directly as a hack, this should be an output of - // speculative resolution. - this.get_mut_unchecked().define_binding_local( - parent, - target, - ns, - imported_binding, - ); PendingBinding::Ready(Some(imported_binding)) } Err(Determinacy::Determined) => { // Don't remove underscores from `single_imports`, they were never added. - if target.name != kw::Underscore { - let key = BindingKey::new(target, ns); - // FIXME: Use mutable resolver directly as a hack, this should be an output of - // speculative resolution. - this.get_mut_unchecked().update_local_resolution( - parent, - key, - false, - |_, resolution| { - resolution.single_imports.swap_remove(&import); - }, - ); + if target.name == kw::Underscore { + return; } PendingBinding::Ready(None) } Err(Determinacy::Undetermined) => { indeterminate_count += 1; - PendingBinding::Pending + return; } }; - bindings[ns].set(binding); + import_bindings[ns] = pending_binding; } }); - indeterminate_count + (SideEffect::Single { import_bindings }, indeterminate_count) } /// Performs final import resolution, consistency checks and error reporting. @@ -1484,13 +1571,16 @@ impl<'ra, 'tcx> Resolver<'ra, 'tcx> { false } - fn resolve_glob_import(&mut self, import: Import<'ra>) { + fn resolve_glob_import<'r>( + self: &mut ImportResolver<'r, 'ra, 'tcx>, + import: Import<'ra>, + ) -> SideEffect<'ra> { // This function is only called for glob imports. - let ImportKind::Glob { id, .. } = import.kind else { unreachable!() }; + let ImportKind::Glob { .. } = import.kind else { unreachable!() }; let ModuleOrUniformRoot::Module(module) = import.imported_module.get().unwrap() else { self.dcx().emit_err(CannotGlobImportAllCrates { span: import.span }); - return; + return SideEffect::None; }; if module.is_trait() && !self.tcx.features().import_trait_associated_functions() { @@ -1504,12 +1594,9 @@ impl<'ra, 'tcx> Resolver<'ra, 'tcx> { } if module == import.parent_scope.module { - return; + return SideEffect::None; } - // Add to module's glob_importers - module.glob_importers.borrow_mut().push(import); - // Ensure that `resolutions` isn't borrowed during `try_define`, // since it might get updated via a glob cycle. let bindings = self @@ -1520,6 +1607,7 @@ impl<'ra, 'tcx> Resolver<'ra, 'tcx> { resolution.borrow().binding().map(|binding| (*key, binding)) }) .collect::>(); + let mut import_bindings = Vec::with_capacity(bindings.len()); for (mut key, binding) in bindings { let scope = match key.ident.0.span.reverse_glob_adjust(module.expansion, import.span) { Some(Some(def)) => self.expn_def_scope(def), @@ -1532,18 +1620,12 @@ impl<'ra, 'tcx> Resolver<'ra, 'tcx> { .resolution(import.parent_scope.module, key) .and_then(|r| r.binding()) .is_some_and(|binding| binding.warn_ambiguity_recursive()); - let _ = self.try_define_local( - import.parent_scope.module, - key.ident.0, - key.ns, - imported_binding, - warn_ambiguity, - ); + import_bindings.push((imported_binding, key, warn_ambiguity)); } } // Record the destination of this import - self.record_partial_res(id, PartialRes::new(module.res().unwrap())); + SideEffect::Glob { import_bindings } } // Miscellaneous post-processing, including recording re-exports, diff --git a/compiler/rustc_resolve/src/lib.rs b/compiler/rustc_resolve/src/lib.rs index 2afb52ef4d4be..6d42ec7b4aba4 100644 --- a/compiler/rustc_resolve/src/lib.rs +++ b/compiler/rustc_resolve/src/lib.rs @@ -2541,12 +2541,6 @@ mod ref_mut { true => self.p, } } - - /// Returns a mutable reference to the inner value without checking if - /// it's in a mutable state. - pub(crate) fn get_mut_unchecked(&mut self) -> &mut T { - self.p - } } } diff --git a/fail.rs b/fail.rs new file mode 100644 index 0000000000000..114e05ed76072 --- /dev/null +++ b/fail.rs @@ -0,0 +1,30 @@ +#![no_core] +#![feature(no_core)] +#![allow(internal_features)] +#![feature(lang_items)] + +#[lang = "sized"] +pub trait Sized: MetaSized {} + +#[lang = "meta_sized"] +pub trait MetaSized: PointeeSized {} + +#[lang = "pointee_sized"] +pub trait PointeeSized {} + +mod core_simd { + mod vector { + pub struct Simd {} + } + pub mod simd { + pub use crate::core_simd::vector::*; + } +} + +pub mod simd { + pub use crate::core_simd::simd::*; +} + +mod fail { + use crate::simd::Simd; +} diff --git a/tests/ui/imports/ambiguous-9.rs b/tests/ui/imports/ambiguous-9.rs index c10b1268060ce..cb352668e7599 100644 --- a/tests/ui/imports/ambiguous-9.rs +++ b/tests/ui/imports/ambiguous-9.rs @@ -4,7 +4,7 @@ pub mod dsl { mod range { pub fn date_range() {} } - pub use self::range::*; //~ WARNING ambiguous glob re-exports + pub use self::range::*; use super::prelude::*; } @@ -12,8 +12,8 @@ pub mod prelude { mod t { pub fn date_range() {} } - pub use self::t::*; //~ WARNING ambiguous glob re-exports - pub use super::dsl::*; + pub use self::t::*; + pub use super::dsl::*; //~ WARNING ambiguous glob re-exports } use dsl::*; @@ -23,6 +23,4 @@ fn main() { date_range(); //~^ ERROR `date_range` is ambiguous //~| WARNING this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! - //~| ERROR `date_range` is ambiguous - //~| WARNING this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! } diff --git a/tests/ui/imports/ambiguous-9.stderr b/tests/ui/imports/ambiguous-9.stderr index 800a2e10c9d78..9222f3f99c1e3 100644 --- a/tests/ui/imports/ambiguous-9.stderr +++ b/tests/ui/imports/ambiguous-9.stderr @@ -1,10 +1,10 @@ warning: ambiguous glob re-exports - --> $DIR/ambiguous-9.rs:7:13 + --> $DIR/ambiguous-9.rs:16:13 | -LL | pub use self::range::*; - | ^^^^^^^^^^^^^^ the name `date_range` in the value namespace is first re-exported here -LL | use super::prelude::*; - | ----------------- but the name `date_range` in the value namespace is also re-exported here +LL | pub use self::t::*; + | ---------- but the name `date_range` in the value namespace is also re-exported here +LL | pub use super::dsl::*; + | ^^^^^^^^^^^^^ the name `date_range` in the value namespace is first re-exported here | = note: `#[warn(ambiguous_glob_reexports)]` on by default @@ -18,10 +18,10 @@ LL | date_range(); = note: for more information, see issue #114095 = note: ambiguous because of multiple glob imports of a name in the same module note: `date_range` could refer to the function imported here - --> $DIR/ambiguous-9.rs:7:13 + --> $DIR/ambiguous-9.rs:16:13 | -LL | pub use self::range::*; - | ^^^^^^^^^^^^^^ +LL | pub use super::dsl::*; + | ^^^^^^^^^^^^^ = help: consider adding an explicit import of `date_range` to disambiguate note: `date_range` could also refer to the function imported here --> $DIR/ambiguous-9.rs:8:9 @@ -35,33 +35,11 @@ warning: ambiguous glob re-exports --> $DIR/ambiguous-9.rs:15:13 | LL | pub use self::t::*; - | ^^^^^^^^^^ the name `date_range` in the value namespace is first re-exported here -LL | pub use super::dsl::*; - | ------------- but the name `date_range` in the value namespace is also re-exported here - -error: `date_range` is ambiguous - --> $DIR/ambiguous-9.rs:23:5 - | -LL | date_range(); - | ^^^^^^^^^^ ambiguous name - | - = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! - = note: for more information, see issue #114095 - = note: ambiguous because of multiple glob imports of a name in the same module -note: `date_range` could refer to the function imported here - --> $DIR/ambiguous-9.rs:19:5 - | -LL | use dsl::*; - | ^^^^^^ - = help: consider adding an explicit import of `date_range` to disambiguate -note: `date_range` could also refer to the function imported here - --> $DIR/ambiguous-9.rs:20:5 - | -LL | use prelude::*; - | ^^^^^^^^^^ + | ^^^^^^^^^^ = help: consider adding an explicit import of `date_range` to disambiguate + = note: `#[deny(ambiguous_glob_imports)]` on by default -error: aborting due to 2 previous errors; 2 warnings emitted +error: aborting due to 1 previous error; 1 warning emitted Future incompatibility report: Future breakage diagnostic: error: `date_range` is ambiguous @@ -74,13 +52,13 @@ LL | date_range(); = note: for more information, see issue #114095 = note: ambiguous because of multiple glob imports of a name in the same module note: `date_range` could refer to the function imported here - --> $DIR/ambiguous-9.rs:7:13 + --> $DIR/ambiguous-9.rs:16:13 | -LL | pub use self::range::*; - | ^^^^^^^^^^^^^^ +LL | pub use super::dsl::*; + | ^^^^^^^^^^^^^ = help: consider adding an explicit import of `date_range` to disambiguate note: `date_range` could also refer to the function imported here - --> $DIR/ambiguous-9.rs:8:9 + --> $DIR/ambiguous-9.rs:15:13 | LL | use super::prelude::*; | ^^^^^^^^^^^^^^^^^ diff --git a/tests/ui/imports/glob-conflict-cross-crate-1.rs b/tests/ui/imports/glob-conflict-cross-crate-1.rs index 5f0433d13fcfd..4ea6e131d2400 100644 --- a/tests/ui/imports/glob-conflict-cross-crate-1.rs +++ b/tests/ui/imports/glob-conflict-cross-crate-1.rs @@ -6,7 +6,7 @@ fn main() { glob_conflict::f(); //~ ERROR cannot find function `f` in crate `glob_conflict` //^ FIXME: `glob_conflict::f` should raise an // ambiguity error instead of a not found error. - glob_conflict::glob::f(); //~ ERROR cannot find function `f` in module `glob_conflict::glob` + glob_conflict::glob::f(); //^ FIXME: `glob_conflict::glob::f` should raise an // ambiguity error instead of a not found error. } diff --git a/tests/ui/imports/glob-conflict-cross-crate-1.stderr b/tests/ui/imports/glob-conflict-cross-crate-1.stderr index 758087107f397..1f1217c25e626 100644 --- a/tests/ui/imports/glob-conflict-cross-crate-1.stderr +++ b/tests/ui/imports/glob-conflict-cross-crate-1.stderr @@ -3,13 +3,17 @@ error[E0425]: cannot find function `f` in crate `glob_conflict` | LL | glob_conflict::f(); | ^ not found in `glob_conflict` - -error[E0425]: cannot find function `f` in module `glob_conflict::glob` - --> $DIR/glob-conflict-cross-crate-1.rs:9:26 | -LL | glob_conflict::glob::f(); - | ^ not found in `glob_conflict::glob` +help: consider importing this function + | +LL + use glob_conflict::glob::f; + | +help: if you import `f`, refer to it directly + | +LL - glob_conflict::f(); +LL + f(); + | -error: aborting due to 2 previous errors +error: aborting due to 1 previous error For more information about this error, try `rustc --explain E0425`. diff --git a/tests/ui/imports/reexports.stderr b/tests/ui/imports/reexports.stderr index 0ebcf8e58d627..dec8a60f93ca0 100644 --- a/tests/ui/imports/reexports.stderr +++ b/tests/ui/imports/reexports.stderr @@ -11,16 +11,16 @@ LL | pub use super::foo; | ^^^^^^^^^^ error[E0603]: module import `foo` is private - --> $DIR/reexports.rs:36:22 + --> $DIR/reexports.rs:37:22 | -LL | use crate::b::a::foo::S; +LL | use crate::b::b::foo::S as T; | ^^^ private module import | note: the module import `foo` is defined here... - --> $DIR/reexports.rs:24:17 + --> $DIR/reexports.rs:29:17 | -LL | pub use super::foo; // This is OK since the value `foo` is visible enough. - | ^^^^^^^^^^ +LL | pub use super::*; // This is also OK since the value `foo` is visible enough. + | ^^^^^^^^ note: ...and refers to the module `foo` which is defined here --> $DIR/reexports.rs:19:5 | @@ -28,16 +28,16 @@ LL | mod foo { | ^^^^^^^ error[E0603]: module import `foo` is private - --> $DIR/reexports.rs:37:22 + --> $DIR/reexports.rs:36:22 | -LL | use crate::b::b::foo::S as T; +LL | use crate::b::a::foo::S; | ^^^ private module import | note: the module import `foo` is defined here... - --> $DIR/reexports.rs:29:17 + --> $DIR/reexports.rs:24:17 | -LL | pub use super::*; // This is also OK since the value `foo` is visible enough. - | ^^^^^^^^ +LL | pub use super::foo; // This is OK since the value `foo` is visible enough. + | ^^^^^^^^^^ note: ...and refers to the module `foo` which is defined here --> $DIR/reexports.rs:19:5 | diff --git a/tests/ui/shadowed/shadowed-use-visibility.stderr b/tests/ui/shadowed/shadowed-use-visibility.stderr index b062341dc8be8..f3b81fcac99e0 100644 --- a/tests/ui/shadowed/shadowed-use-visibility.stderr +++ b/tests/ui/shadowed/shadowed-use-visibility.stderr @@ -1,31 +1,31 @@ -error[E0603]: module import `bar` is private - --> $DIR/shadowed-use-visibility.rs:9:21 +error[E0603]: module import `f` is private + --> $DIR/shadowed-use-visibility.rs:15:10 | -LL | use crate::foo::bar::f as g; - | ^^^ private module import +LL | use bar::f::f; + | ^ private module import | -note: the module import `bar` is defined here... - --> $DIR/shadowed-use-visibility.rs:4:9 +note: the module import `f` is defined here... + --> $DIR/shadowed-use-visibility.rs:11:9 | -LL | use crate::foo as bar; - | ^^^^^^^^^^^^^^^^^ +LL | use crate::foo as f; + | ^^^^^^^^^^^^^^^ note: ...and refers to the module `foo` which is defined here --> $DIR/shadowed-use-visibility.rs:1:1 | LL | mod foo { | ^^^^^^^ -error[E0603]: module import `f` is private - --> $DIR/shadowed-use-visibility.rs:15:10 +error[E0603]: module import `bar` is private + --> $DIR/shadowed-use-visibility.rs:9:21 | -LL | use bar::f::f; - | ^ private module import +LL | use crate::foo::bar::f as g; + | ^^^ private module import | -note: the module import `f` is defined here... - --> $DIR/shadowed-use-visibility.rs:11:9 +note: the module import `bar` is defined here... + --> $DIR/shadowed-use-visibility.rs:4:9 | -LL | use crate::foo as f; - | ^^^^^^^^^^^^^^^ +LL | use crate::foo as bar; + | ^^^^^^^^^^^^^^^^^ note: ...and refers to the module `foo` which is defined here --> $DIR/shadowed-use-visibility.rs:1:1 | From 8499dd2e58a346834f34dadf5b37adb71df5d25e Mon Sep 17 00:00:00 2001 From: LorrensP-2158466 Date: Tue, 19 Aug 2025 12:14:06 +0200 Subject: [PATCH 2/5] Several logical changes. --- compiler/rustc_hir/src/def.rs | 18 -- compiler/rustc_resolve/src/imports.rs | 363 +++++++++++++------------- fail.rs | 30 --- 3 files changed, 184 insertions(+), 227 deletions(-) delete mode 100644 fail.rs diff --git a/compiler/rustc_hir/src/def.rs b/compiler/rustc_hir/src/def.rs index cb06d8165c58d..8af4740f376b6 100644 --- a/compiler/rustc_hir/src/def.rs +++ b/compiler/rustc_hir/src/def.rs @@ -722,24 +722,6 @@ impl PerNS { pub fn iter(&self) -> IntoIter<&T, 3> { [&self.value_ns, &self.type_ns, &self.macro_ns].into_iter() } - - pub fn into_iter_with(self) -> IntoIter<(Namespace, T), 3> { - [ - (Namespace::TypeNS, self.type_ns), - (Namespace::ValueNS, self.value_ns), - (Namespace::MacroNS, self.macro_ns), - ] - .into_iter() - } - - pub fn iter_with(&self) -> IntoIter<(Namespace, &T), 3> { - [ - (Namespace::TypeNS, &self.type_ns), - (Namespace::ValueNS, &self.value_ns), - (Namespace::MacroNS, &self.macro_ns), - ] - .into_iter() - } } impl ::std::ops::Index for PerNS { diff --git a/compiler/rustc_resolve/src/imports.rs b/compiler/rustc_resolve/src/imports.rs index e2d4d2ddb2917..06942851457a1 100644 --- a/compiler/rustc_resolve/src/imports.rs +++ b/compiler/rustc_resolve/src/imports.rs @@ -2,7 +2,6 @@ use std::cell::Cell; use std::mem; -use std::ops::Deref; use rustc_ast::NodeId; use rustc_data_structures::fx::{FxHashSet, FxIndexSet}; @@ -42,98 +41,30 @@ use crate::{ type Res = def::Res; -struct ImportResolver<'r, 'ra, 'tcx> { - r: CmResolver<'r, 'ra, 'tcx>, // always immutable - outputs: ImportResolutionOutputs<'ra>, -} - -enum SideEffect<'ra> { +/// The the side effect made when resolving the bindings for an underterminate import. +enum SideEffectBindings<'ra> { None, - Single { import_bindings: PerNS> }, - Glob { import_bindings: Vec<(NameBinding<'ra>, BindingKey, bool /* warn_ambiguity */)> }, -} - -#[derive(Default)] -struct ImportResolutionOutputs<'ra> { - indeterminate_imports: Vec>, - determined_imports: Vec<(Import<'ra>, SideEffect<'ra>)>, -} - -impl<'ra> ImportResolutionOutputs<'ra> { - fn commit<'tcx>(self, r: &mut Resolver<'ra, 'tcx>) { - r.indeterminate_imports = self.indeterminate_imports; - r.determined_imports.reserve(self.determined_imports.len()); - - for (import, side_effect) in self.determined_imports { - r.determined_imports.push(import); - - let parent = import.parent_scope.module; - match (&import.kind, side_effect) { - ( - ImportKind::Single { target, bindings, .. }, - SideEffect::Single { import_bindings }, - ) => { - for (ns, pending_binding) in import_bindings.into_iter_with() { - match pending_binding { - PendingBinding::Ready(Some(binding)) => { - r.define_binding_local(parent, *target, ns, binding); - } - PendingBinding::Ready(None) => { - let key = BindingKey::new(*target, ns); - r.update_local_resolution(parent, key, false, |_, resolution| { - resolution.single_imports.swap_remove(&import); - }); - } - _ => {} - } - bindings[ns].set(pending_binding); - } - } - (ImportKind::Glob { id, .. }, SideEffect::Glob { import_bindings }) => { - let ModuleOrUniformRoot::Module(module) = import.imported_module.get().unwrap() - else { - unreachable!(); - }; - - module.glob_importers.borrow_mut().push(import); - - for (binding, key, warn_ambiguity) in import_bindings { - let _ = r.try_define_local( - parent, - key.ident.0, - key.ns, - binding, - warn_ambiguity, - ); - } - - r.record_partial_res(*id, PartialRes::new(module.res().unwrap())); - } - - (_, SideEffect::None) => {} - // Something weird happened, which shouldn't have happened. - _ => unreachable!("Mismatched import kind and side effect"), - } - } - } -} - -impl<'r, 'ra, 'tcx> Deref for ImportResolver<'r, 'ra, 'tcx> { - type Target = Resolver<'ra, 'tcx>; - - fn deref(&self) -> &Self::Target { - self.r.deref() - } + /// Side effect that should be applied to the field `bindings` of `ImportKind::Single`. + /// + /// The inner `Option` is the actual side effect, it tells us whether we found a binding + /// when resolving the import in this particular namespace. + /// The outer `Option` tells us if this side effect is present. + Single { + import_bindings: PerNS>>>, + }, + Glob { + import_bindings: Vec<(NameBinding<'ra>, BindingKey, bool /* warn_ambiguity */)>, + }, } -impl<'r, 'ra, 'tcx> AsRef> for ImportResolver<'r, 'ra, 'tcx> { - fn as_ref(&self) -> &Resolver<'ra, 'tcx> { - self.r.as_ref() - } +/// The side effect made when resolving an undeterminate import. +struct SideEffect<'ra> { + imported_module: ModuleOrUniformRoot<'ra>, + bindings: SideEffectBindings<'ra>, } /// A [`NameBinding`] in the process of being resolved. -#[derive(Clone, Copy, Default, PartialEq)] +#[derive(Clone, Copy, Default, PartialEq, Debug)] pub(crate) enum PendingBinding<'ra> { Ready(Option>), #[default] @@ -633,11 +564,12 @@ impl<'ra, 'tcx> Resolver<'ra, 'tcx> { // Import resolution // - // This is a fixed-point algorithm. We resolve imports until our efforts - // are stymied by an unresolved import; then we bail out of the current - // module and continue. We terminate successfully once no more imports - // remain or unsuccessfully when no forward progress in resolving imports - // is made. + // This is a batched fixed-point algorithm. Each import is resolved in + // isolation, with any side effects collected for later. + // After a full pass over the current set of `indeterminate_imports`, + // the collected side effects are committed together. The process + // repeats until either no imports remain or no further progress can + // be made. /// Resolves all imports for the crate. This method performs the fixed- /// point iteration. @@ -646,30 +578,124 @@ impl<'ra, 'tcx> Resolver<'ra, 'tcx> { let mut indeterminate_count = self.indeterminate_imports.len() * 3; while indeterminate_count < prev_indeterminate_count { prev_indeterminate_count = indeterminate_count; - let batch = mem::take(&mut self.indeterminate_imports); + indeterminate_count = 0; + let mut side_effects = Vec::new(); self.assert_speculative = true; - let (outputs, count) = - ImportResolver { r: self.cm(), outputs: Default::default() }.resolve_batch(batch); + for import in mem::take(&mut self.indeterminate_imports) { + let (side_effect, import_indeterminate_count) = self.cm().resolve_import(import); + indeterminate_count += import_indeterminate_count; + match import_indeterminate_count { + 0 => self.determined_imports.push(import), + _ => self.indeterminate_imports.push(import), + } + if let Some(side_effect) = side_effect { + side_effects.push((import, side_effect)); + } + } self.assert_speculative = false; - indeterminate_count = count; - outputs.commit(self); + self.commit_import_resolutions(side_effects); } } - fn resolve_batch<'r>( - mut self: ImportResolver<'r, 'ra, 'tcx>, - batch: Vec>, - ) -> (ImportResolutionOutputs<'ra>, usize) { - let mut indeterminate_count = 0; - for import in batch { - let (side_effect, import_indeterminate_count) = self.resolve_import(import); - indeterminate_count += import_indeterminate_count; - match import_indeterminate_count { - 0 => self.outputs.determined_imports.push((import, side_effect)), - _ => self.outputs.indeterminate_imports.push(import), + fn commit_import_resolutions( + &mut self, + import_resolutions: Vec<(Import<'ra>, SideEffect<'ra>)>, + ) { + self.determined_imports.reserve(self.determined_imports.len()); + for (import, side_effect) in import_resolutions.iter() { + self.determined_imports.push(*import); + let SideEffect { imported_module, .. } = side_effect; + import.imported_module.set(Some(*imported_module)); + + if import.is_glob() + && let ModuleOrUniformRoot::Module(module) = imported_module + && import.parent_scope.module != *module + { + module.glob_importers.borrow_mut().push(*import); + } + } + + for (import, side_effect) in import_resolutions { + let SideEffect { imported_module, bindings: side_effect_bindings } = side_effect; + let parent = import.parent_scope.module; + + match (&import.kind, side_effect_bindings) { + ( + ImportKind::Single { target, bindings, .. }, + SideEffectBindings::Single { import_bindings }, + ) => { + self.per_ns(|this, ns| { + match import_bindings[ns] { + Some(Some(binding)) => { + if binding.is_assoc_item() + && !this.tcx.features().import_trait_associated_functions() + { + feature_err( + this.tcx.sess, + sym::import_trait_associated_functions, + import.span, + "`use` associated items of traits is unstable", + ) + .emit(); + } + this.define_binding_local(parent, *target, ns, binding); + bindings[ns].set(PendingBinding::Ready(Some(binding))); + } + Some(None) => { + // Don't remove underscores from `single_imports`, they were never added. + if target.name != kw::Underscore { + let key = BindingKey::new(*target, ns); + this.update_local_resolution( + parent, + key, + false, + |_, resolution| { + resolution.single_imports.swap_remove(&import); + }, + ); + } + bindings[ns].set(PendingBinding::Ready(None)); + } + None => {} + } + }); + } + (ImportKind::Glob { id, .. }, SideEffectBindings::Glob { import_bindings }) => { + let ModuleOrUniformRoot::Module(module) = imported_module else { + self.dcx().emit_err(CannotGlobImportAllCrates { span: import.span }); + continue; + }; + + if module.is_trait() && !self.tcx.features().import_trait_associated_functions() + { + feature_err( + self.tcx.sess, + sym::import_trait_associated_functions, + import.span, + "`use` associated items of traits is unstable", + ) + .emit(); + } + + for (binding, key, warn_ambiguity) in import_bindings { + let _ = self.try_define_local( + parent, + key.ident.0, + key.ns, + binding, + warn_ambiguity, + ); + } + + self.record_partial_res(*id, PartialRes::new(module.res().unwrap())); + } + + (_, SideEffectBindings::None) => {} + + // Something weird happened, which shouldn't have happened. + _ => unreachable!("Mismatched import kind and side effect"), } } - (self.outputs, indeterminate_count) } pub(crate) fn finalize_imports(&mut self) { @@ -940,12 +966,11 @@ impl<'ra, 'tcx> Resolver<'ra, 'tcx> { /// - `0` means its resolution is determined. /// - Other values mean that indeterminate exists under certain namespaces. /// - /// Meanwhile, if resolve successful, the resolved bindings are written - /// into the module. + /// Meanwhile, if resolution is successful, the side effect of the resolution is returned. fn resolve_import<'r>( - self: &mut ImportResolver<'r, 'ra, 'tcx>, + self: &mut CmResolver<'r, 'ra, 'tcx>, import: Import<'ra>, - ) -> (SideEffect<'ra>, usize) { + ) -> (Option>, usize) { debug!( "(resolving import for module) resolving import `{}::...` in `{}`", Segment::names_to_string(&import.module_path), @@ -954,7 +979,7 @@ impl<'ra, 'tcx> Resolver<'ra, 'tcx> { let module = if let Some(module) = import.imported_module.get() { module } else { - let path_res = self.r.reborrow().maybe_resolve_path( + let path_res = self.reborrow().maybe_resolve_path( &import.module_path, None, &import.parent_scope, @@ -963,27 +988,32 @@ impl<'ra, 'tcx> Resolver<'ra, 'tcx> { match path_res { PathResult::Module(module) => module, - PathResult::Indeterminate => return (SideEffect::None, 3), + PathResult::Indeterminate => return (None, 3), PathResult::NonModule(..) | PathResult::Failed { .. } => { - return (SideEffect::None, 0); + return (None, 0); } } }; - import.imported_module.set(Some(module)); - let (source, target, bindings, type_ns_only) = match import.kind { + let (source, _, bindings, type_ns_only) = match import.kind { ImportKind::Single { source, target, ref bindings, type_ns_only, .. } => { (source, target, bindings, type_ns_only) } ImportKind::Glob { .. } => { - return (self.resolve_glob_import(import), 0); + return ( + Some(SideEffect { + imported_module: module, + bindings: self.resolve_glob_import(import, module), + }), + 0, + ); } _ => unreachable!(), }; let mut import_bindings = PerNS::default(); let mut indeterminate_count = 0; - self.r.reborrow().per_ns_cm(|this, ns| { + self.reborrow().per_ns_cm(|this, ns| { if !type_ns_only || ns == TypeNS { if bindings[ns].get() != PendingBinding::Pending { return; @@ -997,38 +1027,27 @@ impl<'ra, 'tcx> Resolver<'ra, 'tcx> { ); let pending_binding = match binding_result { Ok(binding) => { - if binding.is_assoc_item() - && !this.tcx.features().import_trait_associated_functions() - { - feature_err( - this.tcx.sess, - sym::import_trait_associated_functions, - import.span, - "`use` associated items of traits is unstable", - ) - .emit(); - } // We need the `target`, `source` can be extracted. let imported_binding = this.import(binding, import); - PendingBinding::Ready(Some(imported_binding)) - } - Err(Determinacy::Determined) => { - // Don't remove underscores from `single_imports`, they were never added. - if target.name == kw::Underscore { - return; - } - PendingBinding::Ready(None) + Some(Some(imported_binding)) } + Err(Determinacy::Determined) => Some(None), Err(Determinacy::Undetermined) => { indeterminate_count += 1; - return; + None } }; import_bindings[ns] = pending_binding; } }); - (SideEffect::Single { import_bindings }, indeterminate_count) + ( + Some(SideEffect { + imported_module: module, + bindings: SideEffectBindings::Single { import_bindings }, + }), + indeterminate_count, + ) } /// Performs final import resolution, consistency checks and error reporting. @@ -1572,60 +1591,46 @@ impl<'ra, 'tcx> Resolver<'ra, 'tcx> { } fn resolve_glob_import<'r>( - self: &mut ImportResolver<'r, 'ra, 'tcx>, + self: &mut CmResolver<'r, 'ra, 'tcx>, import: Import<'ra>, - ) -> SideEffect<'ra> { + imported_module: ModuleOrUniformRoot<'ra>, + ) -> SideEffectBindings<'ra> { // This function is only called for glob imports. let ImportKind::Glob { .. } = import.kind else { unreachable!() }; - let ModuleOrUniformRoot::Module(module) = import.imported_module.get().unwrap() else { - self.dcx().emit_err(CannotGlobImportAllCrates { span: import.span }); - return SideEffect::None; + let ModuleOrUniformRoot::Module(module) = imported_module else { + return SideEffectBindings::None; }; - if module.is_trait() && !self.tcx.features().import_trait_associated_functions() { - feature_err( - self.tcx.sess, - sym::import_trait_associated_functions, - import.span, - "`use` associated items of traits is unstable", - ) - .emit(); - } - if module == import.parent_scope.module { - return SideEffect::None; + return SideEffectBindings::None; } - // Ensure that `resolutions` isn't borrowed during `try_define`, - // since it might get updated via a glob cycle. - let bindings = self + let import_bindings = self .resolutions(module) .borrow() .iter() .filter_map(|(key, resolution)| { - resolution.borrow().binding().map(|binding| (*key, binding)) + let binding = resolution.borrow().binding()?; + let mut key = *key; + let scope = + match key.ident.0.span.reverse_glob_adjust(module.expansion, import.span) { + Some(Some(def)) => self.expn_def_scope(def), + Some(None) => import.parent_scope.module, + None => return None, + }; + self.is_accessible_from(binding.vis, scope).then(|| { + let imported_binding = self.import(binding, import); + let warn_ambiguity = self + .resolution(import.parent_scope.module, key) + .and_then(|r| r.binding()) + .is_some_and(|binding| binding.warn_ambiguity_recursive()); + (imported_binding, key, warn_ambiguity) + }) }) .collect::>(); - let mut import_bindings = Vec::with_capacity(bindings.len()); - for (mut key, binding) in bindings { - let scope = match key.ident.0.span.reverse_glob_adjust(module.expansion, import.span) { - Some(Some(def)) => self.expn_def_scope(def), - Some(None) => import.parent_scope.module, - None => continue, - }; - if self.is_accessible_from(binding.vis, scope) { - let imported_binding = self.import(binding, import); - let warn_ambiguity = self - .resolution(import.parent_scope.module, key) - .and_then(|r| r.binding()) - .is_some_and(|binding| binding.warn_ambiguity_recursive()); - import_bindings.push((imported_binding, key, warn_ambiguity)); - } - } - // Record the destination of this import - SideEffect::Glob { import_bindings } + SideEffectBindings::Glob { import_bindings } } // Miscellaneous post-processing, including recording re-exports, diff --git a/fail.rs b/fail.rs deleted file mode 100644 index 114e05ed76072..0000000000000 --- a/fail.rs +++ /dev/null @@ -1,30 +0,0 @@ -#![no_core] -#![feature(no_core)] -#![allow(internal_features)] -#![feature(lang_items)] - -#[lang = "sized"] -pub trait Sized: MetaSized {} - -#[lang = "meta_sized"] -pub trait MetaSized: PointeeSized {} - -#[lang = "pointee_sized"] -pub trait PointeeSized {} - -mod core_simd { - mod vector { - pub struct Simd {} - } - pub mod simd { - pub use crate::core_simd::vector::*; - } -} - -pub mod simd { - pub use crate::core_simd::simd::*; -} - -mod fail { - use crate::simd::Simd; -} From 67df74b3eb18c0ea4d61115a5ddcc7d334e32654 Mon Sep 17 00:00:00 2001 From: LorrensP-2158466 Date: Tue, 26 Aug 2025 23:16:31 +0200 Subject: [PATCH 3/5] bless tests --- tests/ui/imports/ambiguous-9.stderr | 38 +------------ tests/ui/imports/import-loop-2.rs | 4 +- tests/ui/imports/import-loop-2.stderr | 8 +-- tests/ui/imports/import4.rs | 4 +- tests/ui/imports/import4.stderr | 8 +-- tests/ui/imports/issue-109148.rs | 4 +- tests/ui/imports/issue-109148.stderr | 41 +++++++++++++- tests/ui/imports/issue-56125.rs | 6 +- tests/ui/imports/issue-56125.stderr | 56 ++++++++++++++++++- tests/ui/imports/issue-57539.rs | 2 +- tests/ui/imports/issue-57539.stderr | 38 ++++++++++++- .../imports/no-pub-reexports-but-used.stderr | 16 +++++- tests/ui/imports/reexports.stderr | 49 ++++++++++++---- .../shadow-glob-module-resolution-1.stderr | 18 ++++-- 14 files changed, 220 insertions(+), 72 deletions(-) diff --git a/tests/ui/imports/ambiguous-9.stderr b/tests/ui/imports/ambiguous-9.stderr index 9222f3f99c1e3..6446f2129c60b 100644 --- a/tests/ui/imports/ambiguous-9.stderr +++ b/tests/ui/imports/ambiguous-9.stderr @@ -24,20 +24,12 @@ LL | pub use super::dsl::*; | ^^^^^^^^^^^^^ = help: consider adding an explicit import of `date_range` to disambiguate note: `date_range` could also refer to the function imported here - --> $DIR/ambiguous-9.rs:8:9 - | -LL | use super::prelude::*; - | ^^^^^^^^^^^^^^^^^ - = help: consider adding an explicit import of `date_range` to disambiguate - = note: `#[deny(ambiguous_glob_imports)]` (part of `#[deny(future_incompatible)]`) on by default - -warning: ambiguous glob re-exports --> $DIR/ambiguous-9.rs:15:13 | LL | pub use self::t::*; | ^^^^^^^^^^ = help: consider adding an explicit import of `date_range` to disambiguate - = note: `#[deny(ambiguous_glob_imports)]` on by default + = note: `#[deny(ambiguous_glob_imports)]` (part of `#[deny(future_incompatible)]`) on by default error: aborting due to 1 previous error; 1 warning emitted @@ -60,32 +52,8 @@ LL | pub use super::dsl::*; note: `date_range` could also refer to the function imported here --> $DIR/ambiguous-9.rs:15:13 | -LL | use super::prelude::*; - | ^^^^^^^^^^^^^^^^^ - = help: consider adding an explicit import of `date_range` to disambiguate - = note: `#[deny(ambiguous_glob_imports)]` (part of `#[deny(future_incompatible)]`) on by default - -Future breakage diagnostic: -error: `date_range` is ambiguous - --> $DIR/ambiguous-9.rs:23:5 - | -LL | date_range(); - | ^^^^^^^^^^ ambiguous name - | - = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! - = note: for more information, see issue #114095 - = note: ambiguous because of multiple glob imports of a name in the same module -note: `date_range` could refer to the function imported here - --> $DIR/ambiguous-9.rs:19:5 - | -LL | use dsl::*; - | ^^^^^^ - = help: consider adding an explicit import of `date_range` to disambiguate -note: `date_range` could also refer to the function imported here - --> $DIR/ambiguous-9.rs:20:5 - | -LL | use prelude::*; - | ^^^^^^^^^^ +LL | pub use self::t::*; + | ^^^^^^^^^^ = help: consider adding an explicit import of `date_range` to disambiguate = note: `#[deny(ambiguous_glob_imports)]` (part of `#[deny(future_incompatible)]`) on by default diff --git a/tests/ui/imports/import-loop-2.rs b/tests/ui/imports/import-loop-2.rs index 42f9a07fff389..7e4c4dbc8a951 100644 --- a/tests/ui/imports/import-loop-2.rs +++ b/tests/ui/imports/import-loop-2.rs @@ -1,9 +1,9 @@ mod a { - pub use crate::b::x; + pub use crate::b::x; //~ ERROR unresolved import `crate::b::x` [E0432] } mod b { - pub use crate::a::x; //~ ERROR unresolved import `crate::a::x` + pub use crate::a::x; fn main() { let y = x; } } diff --git a/tests/ui/imports/import-loop-2.stderr b/tests/ui/imports/import-loop-2.stderr index 2ef40c4e21829..dfa7cf35eaac2 100644 --- a/tests/ui/imports/import-loop-2.stderr +++ b/tests/ui/imports/import-loop-2.stderr @@ -1,8 +1,8 @@ -error[E0432]: unresolved import `crate::a::x` - --> $DIR/import-loop-2.rs:6:13 +error[E0432]: unresolved import `crate::b::x` + --> $DIR/import-loop-2.rs:2:13 | -LL | pub use crate::a::x; - | ^^^^^^^^^^^ no `x` in `a` +LL | pub use crate::b::x; + | ^^^^^^^^^^^ no `x` in `b` error: aborting due to 1 previous error diff --git a/tests/ui/imports/import4.rs b/tests/ui/imports/import4.rs index f670cc06201c0..76a9887534c34 100644 --- a/tests/ui/imports/import4.rs +++ b/tests/ui/imports/import4.rs @@ -1,4 +1,4 @@ -mod a { pub use crate::b::foo; } -mod b { pub use crate::a::foo; } //~ ERROR unresolved import `crate::a::foo` +mod a { pub use crate::b::foo; } //~ ERROR unresolved import `crate::b::foo` +mod b { pub use crate::a::foo; } fn main() { println!("loop"); } diff --git a/tests/ui/imports/import4.stderr b/tests/ui/imports/import4.stderr index 4faa5f0520a9d..07fdc6a3d0ced 100644 --- a/tests/ui/imports/import4.stderr +++ b/tests/ui/imports/import4.stderr @@ -1,8 +1,8 @@ -error[E0432]: unresolved import `crate::a::foo` - --> $DIR/import4.rs:2:17 +error[E0432]: unresolved import `crate::b::foo` + --> $DIR/import4.rs:1:17 | -LL | mod b { pub use crate::a::foo; } - | ^^^^^^^^^^^^^ no `foo` in `a` +LL | mod a { pub use crate::b::foo; } + | ^^^^^^^^^^^^^ no `foo` in `b` error: aborting due to 1 previous error diff --git a/tests/ui/imports/issue-109148.rs b/tests/ui/imports/issue-109148.rs index 49fc2fe0f5bc6..7d19917547146 100644 --- a/tests/ui/imports/issue-109148.rs +++ b/tests/ui/imports/issue-109148.rs @@ -10,7 +10,7 @@ macro_rules! m { m!(); -use std::mem; //~ ERROR `std` is ambiguous -use ::std::mem as _; //~ ERROR `std` is ambiguous +use std::mem; //~ ERROR `std` is ambiguous [E0659] +use ::std::mem as _; //~ ERROR `std` is ambiguous [E0659] fn main() {} diff --git a/tests/ui/imports/issue-109148.stderr b/tests/ui/imports/issue-109148.stderr index ee047385ae328..930903db0b772 100644 --- a/tests/ui/imports/issue-109148.stderr +++ b/tests/ui/imports/issue-109148.stderr @@ -46,6 +46,45 @@ LL | m!(); | ---- in this macro invocation = note: this error originates in the macro `m` (in Nightly builds, run with -Z macro-backtrace for more info) -error: aborting due to 3 previous errors +error[E0659]: `std` is ambiguous + --> $DIR/issue-109148.rs:13:5 + | +LL | use std::mem; + | ^^^ ambiguous name + | + = note: ambiguous because of a conflict between a macro-expanded name and a less macro-expanded name from outer scope during import or macro resolution + = note: `std` could refer to a built-in crate +note: `std` could also refer to the crate imported here + --> $DIR/issue-109148.rs:6:9 + | +LL | extern crate core as std; + | ^^^^^^^^^^^^^^^^^^^^^^^^^ +... +LL | m!(); + | ---- in this macro invocation + = help: use `crate::std` to refer to this crate unambiguously + = note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no` + = note: this error originates in the macro `m` (in Nightly builds, run with -Z macro-backtrace for more info) + +error[E0659]: `std` is ambiguous + --> $DIR/issue-109148.rs:14:7 + | +LL | use ::std::mem as _; + | ^^^ ambiguous name + | + = note: ambiguous because of a conflict between a macro-expanded name and a less macro-expanded name from outer scope during import or macro resolution + = note: `std` could refer to a built-in crate +note: `std` could also refer to the crate imported here + --> $DIR/issue-109148.rs:6:9 + | +LL | extern crate core as std; + | ^^^^^^^^^^^^^^^^^^^^^^^^^ +... +LL | m!(); + | ---- in this macro invocation + = note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no` + = note: this error originates in the macro `m` (in Nightly builds, run with -Z macro-backtrace for more info) + +error: aborting due to 5 previous errors For more information about this error, try `rustc --explain E0659`. diff --git a/tests/ui/imports/issue-56125.rs b/tests/ui/imports/issue-56125.rs index 4e7e7ac67c572..ca175d257a946 100644 --- a/tests/ui/imports/issue-56125.rs +++ b/tests/ui/imports/issue-56125.rs @@ -4,18 +4,18 @@ mod m1 { use issue_56125::last_segment::*; - //~^ ERROR `issue_56125` is ambiguous + //~^ ERROR `issue_56125` is ambiguous [E0659] } mod m2 { use issue_56125::non_last_segment::non_last_segment::*; - //~^ ERROR `issue_56125` is ambiguous + //~^ ERROR `issue_56125` is ambiguous [E0659] } mod m3 { mod empty {} use empty::issue_56125; //~ ERROR unresolved import `empty::issue_56125` - use issue_56125::*; //~ ERROR `issue_56125` is ambiguous + use issue_56125::*; //~ ERROR `issue_56125` is ambiguous [E0659] } fn main() {} diff --git a/tests/ui/imports/issue-56125.stderr b/tests/ui/imports/issue-56125.stderr index 371130facf9d3..b78d211104357 100644 --- a/tests/ui/imports/issue-56125.stderr +++ b/tests/ui/imports/issue-56125.stderr @@ -54,6 +54,59 @@ LL | use issue_56125::non_last_segment::non_last_segment::*; = help: consider adding an explicit import of `issue_56125` to disambiguate = help: or use `self::issue_56125` to refer to this module unambiguously +error[E0659]: `issue_56125` is ambiguous + --> $DIR/issue-56125.rs:6:9 + | +LL | use issue_56125::last_segment::*; + | ^^^^^^^^^^^ ambiguous name + | + = note: ambiguous because of a conflict between a name from a glob import and an outer scope during import or macro resolution + = note: `issue_56125` could refer to a crate passed with `--extern` + = help: use `::issue_56125` to refer to this crate unambiguously +note: `issue_56125` could also refer to the module imported here + --> $DIR/issue-56125.rs:6:9 + | +LL | use issue_56125::last_segment::*; + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + = help: consider adding an explicit import of `issue_56125` to disambiguate + = help: or use `self::issue_56125` to refer to this module unambiguously + = note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no` + +error[E0659]: `issue_56125` is ambiguous + --> $DIR/issue-56125.rs:11:9 + | +LL | use issue_56125::non_last_segment::non_last_segment::*; + | ^^^^^^^^^^^ ambiguous name + | + = note: ambiguous because of a conflict between a name from a glob import and an outer scope during import or macro resolution + = note: `issue_56125` could refer to a crate passed with `--extern` + = help: use `::issue_56125` to refer to this crate unambiguously +note: `issue_56125` could also refer to the module imported here + --> $DIR/issue-56125.rs:11:9 + | +LL | use issue_56125::non_last_segment::non_last_segment::*; + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + = help: consider adding an explicit import of `issue_56125` to disambiguate + = help: or use `self::issue_56125` to refer to this module unambiguously + = note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no` + +error[E0659]: `issue_56125` is ambiguous + --> $DIR/issue-56125.rs:18:9 + | +LL | use issue_56125::*; + | ^^^^^^^^^^^ ambiguous name + | + = note: ambiguous because of a conflict between a name from a glob import and an outer scope during import or macro resolution + = note: `issue_56125` could refer to a crate passed with `--extern` + = help: use `::issue_56125` to refer to this crate unambiguously +note: `issue_56125` could also refer to the module imported here + --> $DIR/issue-56125.rs:18:9 + | +LL | use issue_56125::*; + | ^^^^^^^^^^^^^^ + = help: consider adding an explicit import of `issue_56125` to disambiguate + = help: or use `self::issue_56125` to refer to this module unambiguously + error[E0659]: `issue_56125` is ambiguous --> $DIR/issue-56125.rs:18:9 | @@ -70,8 +123,9 @@ LL | use issue_56125::*; | ^^^^^^^^^^^^^^ = help: consider adding an explicit import of `issue_56125` to disambiguate = help: or use `self::issue_56125` to refer to this module unambiguously + = note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no` -error: aborting due to 4 previous errors +error: aborting due to 7 previous errors Some errors have detailed explanations: E0432, E0659. For more information about an error, try `rustc --explain E0432`. diff --git a/tests/ui/imports/issue-57539.rs b/tests/ui/imports/issue-57539.rs index d97a74291d39b..0abfb54e957b6 100644 --- a/tests/ui/imports/issue-57539.rs +++ b/tests/ui/imports/issue-57539.rs @@ -1,7 +1,7 @@ //@ edition:2018 mod core { - use core; //~ ERROR `core` is ambiguous + use core; //~ ERROR `core` is ambiguous [E0659] use crate::*; } diff --git a/tests/ui/imports/issue-57539.stderr b/tests/ui/imports/issue-57539.stderr index c8473cc85bdae..cdc9ccf853308 100644 --- a/tests/ui/imports/issue-57539.stderr +++ b/tests/ui/imports/issue-57539.stderr @@ -15,6 +15,42 @@ LL | use crate::*; = help: consider adding an explicit import of `core` to disambiguate = help: or use `self::core` to refer to this module unambiguously -error: aborting due to 1 previous error +error[E0659]: `core` is ambiguous + --> $DIR/issue-57539.rs:4:9 + | +LL | use core; + | ^^^^ ambiguous name + | + = note: ambiguous because of a conflict between a name from a glob import and an outer scope during import or macro resolution + = note: `core` could refer to a built-in crate + = help: use `::core` to refer to this crate unambiguously +note: `core` could also refer to the module imported here + --> $DIR/issue-57539.rs:5:9 + | +LL | use crate::*; + | ^^^^^^^^ + = help: consider adding an explicit import of `core` to disambiguate + = help: or use `self::core` to refer to this module unambiguously + = note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no` + +error[E0659]: `core` is ambiguous + --> $DIR/issue-57539.rs:4:9 + | +LL | use core; + | ^^^^ ambiguous name + | + = note: ambiguous because of a conflict between a name from a glob import and an outer scope during import or macro resolution + = note: `core` could refer to a built-in crate + = help: use `::core` to refer to this crate unambiguously +note: `core` could also refer to the module imported here + --> $DIR/issue-57539.rs:5:9 + | +LL | use crate::*; + | ^^^^^^^^ + = help: consider adding an explicit import of `core` to disambiguate + = help: or use `self::core` to refer to this module unambiguously + = note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no` + +error: aborting due to 3 previous errors For more information about this error, try `rustc --explain E0659`. diff --git a/tests/ui/imports/no-pub-reexports-but-used.stderr b/tests/ui/imports/no-pub-reexports-but-used.stderr index b693dea193579..585425c40ff4d 100644 --- a/tests/ui/imports/no-pub-reexports-but-used.stderr +++ b/tests/ui/imports/no-pub-reexports-but-used.stderr @@ -16,5 +16,19 @@ note: the lint level is defined here LL | #[warn(unused_imports)] | ^^^^^^^^^^^^^^ -warning: 1 warning emitted +warning: glob import doesn't reexport anything with visibility `pub` because no imported item is public enough + --> $DIR/no-pub-reexports-but-used.rs:9:9 + | +LL | pub use m::*; + | ^^^^ + | +note: the most public imported item is `pub(crate)` + --> $DIR/no-pub-reexports-but-used.rs:9:9 + | +LL | pub use m::*; + | ^^^^ + = help: reduce the glob import's visibility or increase visibility of imported items + = note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no` + +warning: 2 warnings emitted diff --git a/tests/ui/imports/reexports.stderr b/tests/ui/imports/reexports.stderr index dec8a60f93ca0..8abf6a918841b 100644 --- a/tests/ui/imports/reexports.stderr +++ b/tests/ui/imports/reexports.stderr @@ -10,17 +10,30 @@ note: consider marking `foo` as `pub` in the imported module LL | pub use super::foo; | ^^^^^^^^^^ +error[E0364]: `foo` is private, and cannot be re-exported + --> $DIR/reexports.rs:8:17 + | +LL | pub use super::foo; + | ^^^^^^^^^^ + | +note: consider marking `foo` as `pub` in the imported module + --> $DIR/reexports.rs:8:17 + | +LL | pub use super::foo; + | ^^^^^^^^^^ + = note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no` + error[E0603]: module import `foo` is private - --> $DIR/reexports.rs:37:22 + --> $DIR/reexports.rs:36:22 | -LL | use crate::b::b::foo::S as T; +LL | use crate::b::a::foo::S; | ^^^ private module import | note: the module import `foo` is defined here... - --> $DIR/reexports.rs:29:17 + --> $DIR/reexports.rs:24:17 | -LL | pub use super::*; // This is also OK since the value `foo` is visible enough. - | ^^^^^^^^ +LL | pub use super::foo; // This is OK since the value `foo` is visible enough. + | ^^^^^^^^^^ note: ...and refers to the module `foo` which is defined here --> $DIR/reexports.rs:19:5 | @@ -28,16 +41,16 @@ LL | mod foo { | ^^^^^^^ error[E0603]: module import `foo` is private - --> $DIR/reexports.rs:36:22 + --> $DIR/reexports.rs:37:22 | -LL | use crate::b::a::foo::S; +LL | use crate::b::b::foo::S as T; | ^^^ private module import | note: the module import `foo` is defined here... - --> $DIR/reexports.rs:24:17 + --> $DIR/reexports.rs:29:17 | -LL | pub use super::foo; // This is OK since the value `foo` is visible enough. - | ^^^^^^^^^^ +LL | pub use super::*; // This is also OK since the value `foo` is visible enough. + | ^^^^^^^^ note: ...and refers to the module `foo` which is defined here --> $DIR/reexports.rs:19:5 | @@ -69,13 +82,27 @@ LL | pub use super::*; | ^^^^^^^^ = help: reduce the glob import's visibility or increase visibility of imported items +warning: glob import doesn't reexport anything with visibility `pub` because no imported item is public enough + --> $DIR/reexports.rs:11:17 + | +LL | pub use super::*; + | ^^^^^^^^ + | +note: the most public imported item is `pub(in crate::a)` + --> $DIR/reexports.rs:11:17 + | +LL | pub use super::*; + | ^^^^^^^^ + = help: reduce the glob import's visibility or increase visibility of imported items + = note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no` + warning: unused import: `super::*` --> $DIR/reexports.rs:11:17 | LL | pub use super::*; | ^^^^^^^^ -error: aborting due to 3 previous errors; 3 warnings emitted +error: aborting due to 4 previous errors; 4 warnings emitted Some errors have detailed explanations: E0364, E0603. For more information about an error, try `rustc --explain E0364`. diff --git a/tests/ui/imports/shadow-glob-module-resolution-1.stderr b/tests/ui/imports/shadow-glob-module-resolution-1.stderr index f9135963fe99e..f309a96fd6a4c 100644 --- a/tests/ui/imports/shadow-glob-module-resolution-1.stderr +++ b/tests/ui/imports/shadow-glob-module-resolution-1.stderr @@ -12,11 +12,21 @@ LL | use b::c; | = note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no` -error[E0432]: unresolved import `b::c` - --> $DIR/shadow-glob-module-resolution-1.rs:11:5 +error[E0432]: unresolved import `c` + --> $DIR/shadow-glob-module-resolution-1.rs:15:5 | -LL | use b::c; - | ^^^^ +LL | use c as b; + | ^^^^^^ no `c` in the root + | +help: a similar name exists in the module + | +LL - use c as b; +LL + use a as b; + | +help: consider importing this module instead + | +LL | use b::c as b; + | +++ error: aborting due to 3 previous errors From 142f56157eb05cfbe0a7d312792e95369224eede Mon Sep 17 00:00:00 2001 From: LorrensP-2158466 Date: Wed, 27 Aug 2025 13:50:31 +0200 Subject: [PATCH 4/5] Report glob errors in first phase of commit. --- compiler/rustc_resolve/src/imports.rs | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/compiler/rustc_resolve/src/imports.rs b/compiler/rustc_resolve/src/imports.rs index 06942851457a1..b8a8a4a2f12b4 100644 --- a/compiler/rustc_resolve/src/imports.rs +++ b/compiler/rustc_resolve/src/imports.rs @@ -607,11 +607,14 @@ impl<'ra, 'tcx> Resolver<'ra, 'tcx> { let SideEffect { imported_module, .. } = side_effect; import.imported_module.set(Some(*imported_module)); - if import.is_glob() - && let ModuleOrUniformRoot::Module(module) = imported_module - && import.parent_scope.module != *module - { - module.glob_importers.borrow_mut().push(*import); + if import.is_glob() { + let ModuleOrUniformRoot::Module(module) = imported_module else { + self.dcx().emit_err(CannotGlobImportAllCrates { span: import.span }); + continue; + }; + if import.parent_scope.module != *module { + module.glob_importers.borrow_mut().push(*import); + } } } @@ -662,7 +665,6 @@ impl<'ra, 'tcx> Resolver<'ra, 'tcx> { } (ImportKind::Glob { id, .. }, SideEffectBindings::Glob { import_bindings }) => { let ModuleOrUniformRoot::Module(module) = imported_module else { - self.dcx().emit_err(CannotGlobImportAllCrates { span: import.span }); continue; }; From fe82c39664f311ad7e85419965cc0fbdfe72dd3b Mon Sep 17 00:00:00 2001 From: LorrensP-2158466 Date: Wed, 27 Aug 2025 13:51:04 +0200 Subject: [PATCH 5/5] Alter/Bless lots of tests of last CI failure. --- tests/ui/crate-loading/invalid-rlib.rs | 11 +- tests/ui/crate-loading/invalid-rlib.stderr | 20 +- tests/ui/error-codes/E0365.rs | 1 + tests/ui/error-codes/E0365.stderr | 11 +- tests/ui/hygiene/privacy-early.rs | 4 +- tests/ui/hygiene/privacy-early.stderr | 22 +- tests/ui/imports/issue-109148.rs | 8 +- tests/ui/imports/issue-109148.stderr | 4 +- tests/ui/imports/issue-56125.rs | 6 +- tests/ui/imports/issue-56125.stderr | 18 +- tests/ui/imports/issue-57539.rs | 5 +- tests/ui/imports/issue-57539.stderr | 6 +- tests/ui/imports/no-pub-reexports-but-used.rs | 3 + tests/ui/imports/reexports.rs | 2 + tests/ui/imports/reexports.stderr | 22 +- .../shadow-glob-module-resolution-1.rs | 2 +- .../shadow-glob-module-resolution-1.stderr | 2 +- tests/ui/lint/force-warn/ice-free.rs | 2 + tests/ui/lint/force-warn/ice-free.stderr | 31 ++- tests/ui/modules/issue-56411.rs | 1 + tests/ui/modules/issue-56411.stderr | 15 +- tests/ui/privacy/crate-private-reexport.rs | 71 +++-- .../ui/privacy/crate-private-reexport.stderr | 261 +++++++++++++++--- ...sue-46209-private-enum-variant-reexport.rs | 5 + ...46209-private-enum-variant-reexport.stderr | 92 +++++- tests/ui/privacy/macro-private-reexport.rs | 8 +- .../ui/privacy/macro-private-reexport.stderr | 38 ++- tests/ui/privacy/privacy1.stderr | 24 +- tests/ui/privacy/private-variant-reexport.rs | 13 +- .../privacy/private-variant-reexport.stderr | 65 ++++- tests/ui/privacy/restricted/test.rs | 6 +- tests/ui/privacy/restricted/test.stderr | 63 ++++- tests/ui/proc-macro/issue-79148.rs | 4 +- tests/ui/proc-macro/issue-79148.stderr | 16 +- .../ui/pub/pub-reexport-priv-extern-crate.rs | 7 +- .../pub/pub-reexport-priv-extern-crate.stderr | 39 ++- .../edition-lint-nested-empty-paths.fixed | 10 + .../edition-lint-nested-empty-paths.rs | 10 + .../edition-lint-nested-empty-paths.stderr | 60 +++- .../rust-2018/edition-lint-nested-paths.fixed | 8 + .../ui/rust-2018/edition-lint-nested-paths.rs | 8 + .../edition-lint-nested-paths.stderr | 46 ++- tests/ui/rust-2018/edition-lint-paths.fixed | 18 ++ tests/ui/rust-2018/edition-lint-paths.rs | 18 ++ tests/ui/rust-2018/edition-lint-paths.stderr | 108 +++++++- tests/ui/rust-2018/extern-crate-rename.fixed | 2 + tests/ui/rust-2018/extern-crate-rename.rs | 2 + tests/ui/rust-2018/extern-crate-rename.stderr | 12 +- tests/ui/rust-2018/extern-crate-submod.fixed | 2 + tests/ui/rust-2018/extern-crate-submod.rs | 2 + tests/ui/rust-2018/extern-crate-submod.stderr | 12 +- .../uniform-paths/ambiguity-macros-nested.rs | 1 + .../ambiguity-macros-nested.stderr | 27 +- .../uniform-paths/ambiguity-macros.rs | 1 + .../uniform-paths/ambiguity-macros.stderr | 27 +- .../ui/rust-2018/uniform-paths/issue-56596.rs | 5 +- .../uniform-paths/issue-56596.stderr | 38 ++- .../ui/rust-2018/uniform-paths/macro-rules.rs | 4 +- .../uniform-paths/macro-rules.stderr | 19 +- .../shadowed/shadowed-use-visibility.stderr | 32 +-- 60 files changed, 1186 insertions(+), 194 deletions(-) diff --git a/tests/ui/crate-loading/invalid-rlib.rs b/tests/ui/crate-loading/invalid-rlib.rs index 6b46352624452..9a84505b9c079 100644 --- a/tests/ui/crate-loading/invalid-rlib.rs +++ b/tests/ui/crate-loading/invalid-rlib.rs @@ -4,8 +4,15 @@ //@ rustc-env:RUSTC_LOG=error //@ edition:2018 #![no_std] -use ::foo; //~ ERROR invalid metadata files for crate `foo` +use ::foo; +//~^ ERROR invalid metadata files for crate `foo` //~| NOTE failed to mmap file -//~^^ ERROR invalid metadata files for crate `foo` +//~| ERROR invalid metadata files for crate `foo` //~| NOTE failed to mmap file +//~| ERROR invalid metadata files for crate `foo` +//~| NOTE failed to mmap file +//~| ERROR invalid metadata files for crate `foo` +//~| NOTE failed to mmap file +//~| NOTE duplicate diagnostic +//~| NOTE duplicate diagnostic //~| NOTE duplicate diagnostic diff --git a/tests/ui/crate-loading/invalid-rlib.stderr b/tests/ui/crate-loading/invalid-rlib.stderr index 63bb1b95cbb78..bfdd78c70ab0d 100644 --- a/tests/ui/crate-loading/invalid-rlib.stderr +++ b/tests/ui/crate-loading/invalid-rlib.stderr @@ -15,6 +15,24 @@ LL | use ::foo; = note: failed to mmap file 'auxiliary/libfoo.rlib' = note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no` -error: aborting due to 2 previous errors +error[E0786]: found invalid metadata files for crate `foo` + --> $DIR/invalid-rlib.rs:7:7 + | +LL | use ::foo; + | ^^^ + | + = note: failed to mmap file 'auxiliary/libfoo.rlib' + = note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no` + +error[E0786]: found invalid metadata files for crate `foo` + --> $DIR/invalid-rlib.rs:7:7 + | +LL | use ::foo; + | ^^^ + | + = note: failed to mmap file 'auxiliary/libfoo.rlib' + = note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no` + +error: aborting due to 4 previous errors For more information about this error, try `rustc --explain E0786`. diff --git a/tests/ui/error-codes/E0365.rs b/tests/ui/error-codes/E0365.rs index 464109247c9ba..21535fe57911c 100644 --- a/tests/ui/error-codes/E0365.rs +++ b/tests/ui/error-codes/E0365.rs @@ -4,5 +4,6 @@ mod foo { pub use foo as foo2; //~^ ERROR `foo` is only public within the crate, and cannot be re-exported outside [E0365] +//~| ERROR `foo` is only public within the crate, and cannot be re-exported outside [E0365] fn main() {} diff --git a/tests/ui/error-codes/E0365.stderr b/tests/ui/error-codes/E0365.stderr index d6eb9d6c38339..402e062ba7a9b 100644 --- a/tests/ui/error-codes/E0365.stderr +++ b/tests/ui/error-codes/E0365.stderr @@ -6,6 +6,15 @@ LL | pub use foo as foo2; | = note: consider declaring type or module `foo` with `pub` -error: aborting due to 1 previous error +error[E0365]: `foo` is only public within the crate, and cannot be re-exported outside + --> $DIR/E0365.rs:5:9 + | +LL | pub use foo as foo2; + | ^^^^^^^^^^^ re-export of crate public `foo` + | + = note: consider declaring type or module `foo` with `pub` + = note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no` + +error: aborting due to 2 previous errors For more information about this error, try `rustc --explain E0365`. diff --git a/tests/ui/hygiene/privacy-early.rs b/tests/ui/hygiene/privacy-early.rs index 07680a7b9b22d..f601f40807078 100644 --- a/tests/ui/hygiene/privacy-early.rs +++ b/tests/ui/hygiene/privacy-early.rs @@ -7,7 +7,9 @@ mod foo { macro f() {} pub macro m() { - use f as g; //~ ERROR `f` is private, and cannot be re-exported + use f as g; + //~^ ERROR `f` is private, and cannot be re-exported + //~| ERROR `f` is private, and cannot be re-exported f!(); } } diff --git a/tests/ui/hygiene/privacy-early.stderr b/tests/ui/hygiene/privacy-early.stderr index 1c2f9ff5405f4..556c6e3fe02ca 100644 --- a/tests/ui/hygiene/privacy-early.stderr +++ b/tests/ui/hygiene/privacy-early.stderr @@ -17,6 +17,26 @@ LL | foo::m!(); | --------- in this macro invocation = note: this error originates in the macro `foo::m` (in Nightly builds, run with -Z macro-backtrace for more info) -error: aborting due to 1 previous error +error[E0364]: `f` is private, and cannot be re-exported + --> $DIR/privacy-early.rs:10:13 + | +LL | use f as g; + | ^^^^^^ +... +LL | foo::m!(); + | --------- in this macro invocation + | +note: consider marking `f` as `pub` in the imported module + --> $DIR/privacy-early.rs:10:13 + | +LL | use f as g; + | ^^^^^^ +... +LL | foo::m!(); + | --------- in this macro invocation + = note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no` + = note: this error originates in the macro `foo::m` (in Nightly builds, run with -Z macro-backtrace for more info) + +error: aborting due to 2 previous errors For more information about this error, try `rustc --explain E0364`. diff --git a/tests/ui/imports/issue-109148.rs b/tests/ui/imports/issue-109148.rs index 7d19917547146..4be27d35da449 100644 --- a/tests/ui/imports/issue-109148.rs +++ b/tests/ui/imports/issue-109148.rs @@ -10,7 +10,11 @@ macro_rules! m { m!(); -use std::mem; //~ ERROR `std` is ambiguous [E0659] -use ::std::mem as _; //~ ERROR `std` is ambiguous [E0659] +use std::mem; +//~^ ERROR `std` is ambiguous [E0659] +//~| ERROR `std` is ambiguous [E0659] +use ::std::mem as _; +//~^ ERROR `std` is ambiguous [E0659] +//~| ERROR `std` is ambiguous [E0659] fn main() {} diff --git a/tests/ui/imports/issue-109148.stderr b/tests/ui/imports/issue-109148.stderr index 930903db0b772..8f06d8317620e 100644 --- a/tests/ui/imports/issue-109148.stderr +++ b/tests/ui/imports/issue-109148.stderr @@ -29,7 +29,7 @@ LL | m!(); = note: this error originates in the macro `m` (in Nightly builds, run with -Z macro-backtrace for more info) error[E0659]: `std` is ambiguous - --> $DIR/issue-109148.rs:14:7 + --> $DIR/issue-109148.rs:16:7 | LL | use ::std::mem as _; | ^^^ ambiguous name @@ -67,7 +67,7 @@ LL | m!(); = note: this error originates in the macro `m` (in Nightly builds, run with -Z macro-backtrace for more info) error[E0659]: `std` is ambiguous - --> $DIR/issue-109148.rs:14:7 + --> $DIR/issue-109148.rs:16:7 | LL | use ::std::mem as _; | ^^^ ambiguous name diff --git a/tests/ui/imports/issue-56125.rs b/tests/ui/imports/issue-56125.rs index ca175d257a946..76bf5ee9f5f27 100644 --- a/tests/ui/imports/issue-56125.rs +++ b/tests/ui/imports/issue-56125.rs @@ -5,17 +5,21 @@ mod m1 { use issue_56125::last_segment::*; //~^ ERROR `issue_56125` is ambiguous [E0659] + //~| ERROR `issue_56125` is ambiguous [E0659] } mod m2 { use issue_56125::non_last_segment::non_last_segment::*; //~^ ERROR `issue_56125` is ambiguous [E0659] + //~| ERROR `issue_56125` is ambiguous [E0659] } mod m3 { mod empty {} use empty::issue_56125; //~ ERROR unresolved import `empty::issue_56125` - use issue_56125::*; //~ ERROR `issue_56125` is ambiguous [E0659] + use issue_56125::*; + //~^ ERROR `issue_56125` is ambiguous [E0659] + //~| ERROR `issue_56125` is ambiguous [E0659] } fn main() {} diff --git a/tests/ui/imports/issue-56125.stderr b/tests/ui/imports/issue-56125.stderr index b78d211104357..107263103402a 100644 --- a/tests/ui/imports/issue-56125.stderr +++ b/tests/ui/imports/issue-56125.stderr @@ -1,5 +1,5 @@ error[E0432]: unresolved import `empty::issue_56125` - --> $DIR/issue-56125.rs:17:9 + --> $DIR/issue-56125.rs:19:9 | LL | use empty::issue_56125; | ^^^^^^^^^^^^^^^^^^ no `issue_56125` in `m3::empty` @@ -38,7 +38,7 @@ LL | use issue_56125::last_segment::*; = help: or use `self::issue_56125` to refer to this module unambiguously error[E0659]: `issue_56125` is ambiguous - --> $DIR/issue-56125.rs:11:9 + --> $DIR/issue-56125.rs:12:9 | LL | use issue_56125::non_last_segment::non_last_segment::*; | ^^^^^^^^^^^ ambiguous name @@ -47,7 +47,7 @@ LL | use issue_56125::non_last_segment::non_last_segment::*; = note: `issue_56125` could refer to a crate passed with `--extern` = help: use `::issue_56125` to refer to this crate unambiguously note: `issue_56125` could also refer to the module imported here - --> $DIR/issue-56125.rs:11:9 + --> $DIR/issue-56125.rs:12:9 | LL | use issue_56125::non_last_segment::non_last_segment::*; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -73,7 +73,7 @@ LL | use issue_56125::last_segment::*; = note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no` error[E0659]: `issue_56125` is ambiguous - --> $DIR/issue-56125.rs:11:9 + --> $DIR/issue-56125.rs:12:9 | LL | use issue_56125::non_last_segment::non_last_segment::*; | ^^^^^^^^^^^ ambiguous name @@ -82,7 +82,7 @@ LL | use issue_56125::non_last_segment::non_last_segment::*; = note: `issue_56125` could refer to a crate passed with `--extern` = help: use `::issue_56125` to refer to this crate unambiguously note: `issue_56125` could also refer to the module imported here - --> $DIR/issue-56125.rs:11:9 + --> $DIR/issue-56125.rs:12:9 | LL | use issue_56125::non_last_segment::non_last_segment::*; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -91,7 +91,7 @@ LL | use issue_56125::non_last_segment::non_last_segment::*; = note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no` error[E0659]: `issue_56125` is ambiguous - --> $DIR/issue-56125.rs:18:9 + --> $DIR/issue-56125.rs:20:9 | LL | use issue_56125::*; | ^^^^^^^^^^^ ambiguous name @@ -100,7 +100,7 @@ LL | use issue_56125::*; = note: `issue_56125` could refer to a crate passed with `--extern` = help: use `::issue_56125` to refer to this crate unambiguously note: `issue_56125` could also refer to the module imported here - --> $DIR/issue-56125.rs:18:9 + --> $DIR/issue-56125.rs:20:9 | LL | use issue_56125::*; | ^^^^^^^^^^^^^^ @@ -108,7 +108,7 @@ LL | use issue_56125::*; = help: or use `self::issue_56125` to refer to this module unambiguously error[E0659]: `issue_56125` is ambiguous - --> $DIR/issue-56125.rs:18:9 + --> $DIR/issue-56125.rs:20:9 | LL | use issue_56125::*; | ^^^^^^^^^^^ ambiguous name @@ -117,7 +117,7 @@ LL | use issue_56125::*; = note: `issue_56125` could refer to a crate passed with `--extern` = help: use `::issue_56125` to refer to this crate unambiguously note: `issue_56125` could also refer to the module imported here - --> $DIR/issue-56125.rs:18:9 + --> $DIR/issue-56125.rs:20:9 | LL | use issue_56125::*; | ^^^^^^^^^^^^^^ diff --git a/tests/ui/imports/issue-57539.rs b/tests/ui/imports/issue-57539.rs index 0abfb54e957b6..4b7d63ef8bea3 100644 --- a/tests/ui/imports/issue-57539.rs +++ b/tests/ui/imports/issue-57539.rs @@ -1,7 +1,10 @@ //@ edition:2018 mod core { - use core; //~ ERROR `core` is ambiguous [E0659] + use core; + //~^ ERROR `core` is ambiguous [E0659] + //~| ERROR `core` is ambiguous [E0659] + //~| ERROR `core` is ambiguous [E0659] use crate::*; } diff --git a/tests/ui/imports/issue-57539.stderr b/tests/ui/imports/issue-57539.stderr index cdc9ccf853308..5f86ba6ec228d 100644 --- a/tests/ui/imports/issue-57539.stderr +++ b/tests/ui/imports/issue-57539.stderr @@ -8,7 +8,7 @@ LL | use core; = note: `core` could refer to a built-in crate = help: use `::core` to refer to this crate unambiguously note: `core` could also refer to the module imported here - --> $DIR/issue-57539.rs:5:9 + --> $DIR/issue-57539.rs:8:9 | LL | use crate::*; | ^^^^^^^^ @@ -25,7 +25,7 @@ LL | use core; = note: `core` could refer to a built-in crate = help: use `::core` to refer to this crate unambiguously note: `core` could also refer to the module imported here - --> $DIR/issue-57539.rs:5:9 + --> $DIR/issue-57539.rs:8:9 | LL | use crate::*; | ^^^^^^^^ @@ -43,7 +43,7 @@ LL | use core; = note: `core` could refer to a built-in crate = help: use `::core` to refer to this crate unambiguously note: `core` could also refer to the module imported here - --> $DIR/issue-57539.rs:5:9 + --> $DIR/issue-57539.rs:8:9 | LL | use crate::*; | ^^^^^^^^ diff --git a/tests/ui/imports/no-pub-reexports-but-used.rs b/tests/ui/imports/no-pub-reexports-but-used.rs index c0d7964ea71e8..2788c99016764 100644 --- a/tests/ui/imports/no-pub-reexports-but-used.rs +++ b/tests/ui/imports/no-pub-reexports-but-used.rs @@ -8,7 +8,10 @@ mod m { #[warn(unused_imports)] //~ NOTE: the lint level is defined here pub use m::*; //~^ WARNING: glob import doesn't reexport anything with visibility `pub` because no imported item is public enough +//~| WARNING: glob import doesn't reexport anything with visibility `pub` because no imported item is public enough [unused_imports] //~| NOTE: the most public imported item is `pub(crate)` +//~| NOTE: the most public imported item is `pub(crate)` +//~| NOTE: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no` fn main() { let _: A; diff --git a/tests/ui/imports/reexports.rs b/tests/ui/imports/reexports.rs index 6ad704b53fce7..0a411967ccc85 100644 --- a/tests/ui/imports/reexports.rs +++ b/tests/ui/imports/reexports.rs @@ -8,9 +8,11 @@ mod a { pub use super::foo; //~^ ERROR cannot be re-exported //~| WARNING unused import: `super::foo` + //~| ERROR cannot be re-exported pub use super::*; //~^ WARNING glob import doesn't reexport anything with visibility `pub` because no imported item is public enough //~| WARNING unused import: `super::*` + //~| WARNING glob import doesn't reexport anything with visibility `pub` because no imported item is public enough [unused_imports] } } diff --git a/tests/ui/imports/reexports.stderr b/tests/ui/imports/reexports.stderr index 8abf6a918841b..e0c8da5820068 100644 --- a/tests/ui/imports/reexports.stderr +++ b/tests/ui/imports/reexports.stderr @@ -24,35 +24,35 @@ LL | pub use super::foo; = note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no` error[E0603]: module import `foo` is private - --> $DIR/reexports.rs:36:22 + --> $DIR/reexports.rs:38:22 | LL | use crate::b::a::foo::S; | ^^^ private module import | note: the module import `foo` is defined here... - --> $DIR/reexports.rs:24:17 + --> $DIR/reexports.rs:26:17 | LL | pub use super::foo; // This is OK since the value `foo` is visible enough. | ^^^^^^^^^^ note: ...and refers to the module `foo` which is defined here - --> $DIR/reexports.rs:19:5 + --> $DIR/reexports.rs:21:5 | LL | mod foo { | ^^^^^^^ error[E0603]: module import `foo` is private - --> $DIR/reexports.rs:37:22 + --> $DIR/reexports.rs:39:22 | LL | use crate::b::b::foo::S as T; | ^^^ private module import | note: the module import `foo` is defined here... - --> $DIR/reexports.rs:29:17 + --> $DIR/reexports.rs:31:17 | LL | pub use super::*; // This is also OK since the value `foo` is visible enough. | ^^^^^^^^ note: ...and refers to the module `foo` which is defined here - --> $DIR/reexports.rs:19:5 + --> $DIR/reexports.rs:21:5 | LL | mod foo { | ^^^^^^^ @@ -70,26 +70,26 @@ LL | #![warn(unused_imports)] | ^^^^^^^^^^^^^^ warning: glob import doesn't reexport anything with visibility `pub` because no imported item is public enough - --> $DIR/reexports.rs:11:17 + --> $DIR/reexports.rs:12:17 | LL | pub use super::*; | ^^^^^^^^ | note: the most public imported item is `pub(in crate::a)` - --> $DIR/reexports.rs:11:17 + --> $DIR/reexports.rs:12:17 | LL | pub use super::*; | ^^^^^^^^ = help: reduce the glob import's visibility or increase visibility of imported items warning: glob import doesn't reexport anything with visibility `pub` because no imported item is public enough - --> $DIR/reexports.rs:11:17 + --> $DIR/reexports.rs:12:17 | LL | pub use super::*; | ^^^^^^^^ | note: the most public imported item is `pub(in crate::a)` - --> $DIR/reexports.rs:11:17 + --> $DIR/reexports.rs:12:17 | LL | pub use super::*; | ^^^^^^^^ @@ -97,7 +97,7 @@ LL | pub use super::*; = note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no` warning: unused import: `super::*` - --> $DIR/reexports.rs:11:17 + --> $DIR/reexports.rs:12:17 | LL | pub use super::*; | ^^^^^^^^ diff --git a/tests/ui/imports/shadow-glob-module-resolution-1.rs b/tests/ui/imports/shadow-glob-module-resolution-1.rs index ba1e65cddc652..8b4aaa2e90b15 100644 --- a/tests/ui/imports/shadow-glob-module-resolution-1.rs +++ b/tests/ui/imports/shadow-glob-module-resolution-1.rs @@ -11,7 +11,7 @@ use a::*; use b::c; //~^ ERROR: cannot determine resolution for the import //~| ERROR: cannot determine resolution for the import -//~| ERROR: unresolved import `b::c` use c as b; +//~^ ERROR: unresolved import `c` [E0432] fn main() {} diff --git a/tests/ui/imports/shadow-glob-module-resolution-1.stderr b/tests/ui/imports/shadow-glob-module-resolution-1.stderr index f309a96fd6a4c..058a5839914f9 100644 --- a/tests/ui/imports/shadow-glob-module-resolution-1.stderr +++ b/tests/ui/imports/shadow-glob-module-resolution-1.stderr @@ -13,7 +13,7 @@ LL | use b::c; = note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no` error[E0432]: unresolved import `c` - --> $DIR/shadow-glob-module-resolution-1.rs:15:5 + --> $DIR/shadow-glob-module-resolution-1.rs:14:5 | LL | use c as b; | ^^^^^^ no `c` in the root diff --git a/tests/ui/lint/force-warn/ice-free.rs b/tests/ui/lint/force-warn/ice-free.rs index 99b79f44648b2..657351c10047b 100644 --- a/tests/ui/lint/force-warn/ice-free.rs +++ b/tests/ui/lint/force-warn/ice-free.rs @@ -5,5 +5,7 @@ extern crate core; pub use core as reexported_core; //~^ warning: extern crate `core` is private //~| warning: this was previously accepted by the compiler +//~| warning: extern crate `core` is private +//~| warning: this was previously accepted by the compiler fn main() {} diff --git a/tests/ui/lint/force-warn/ice-free.stderr b/tests/ui/lint/force-warn/ice-free.stderr index b64e3b138a265..93762578e22f5 100644 --- a/tests/ui/lint/force-warn/ice-free.stderr +++ b/tests/ui/lint/force-warn/ice-free.stderr @@ -12,7 +12,21 @@ help: consider making the `extern crate` item publicly accessible LL | pub extern crate core; | +++ -warning: 1 warning emitted +warning[E0365]: extern crate `core` is private and cannot be re-exported + --> $DIR/ice-free.rs:5:9 + | +LL | pub use core as reexported_core; + | ^^^^^^^^^^^^^^^^^^^^^^^ + | + = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! + = note: for more information, see issue #127909 + = note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no` +help: consider making the `extern crate` item publicly accessible + | +LL | pub extern crate core; + | +++ + +warning: 2 warnings emitted For more information about this error, try `rustc --explain E0365`. Future incompatibility report: Future breakage diagnostic: @@ -30,3 +44,18 @@ help: consider making the `extern crate` item publicly accessible LL | pub extern crate core; | +++ +Future breakage diagnostic: +warning[E0365]: extern crate `core` is private and cannot be re-exported + --> $DIR/ice-free.rs:5:9 + | +LL | pub use core as reexported_core; + | ^^^^^^^^^^^^^^^^^^^^^^^ + | + = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! + = note: for more information, see issue #127909 + = note: requested on the command line with `--force-warn pub-use-of-private-extern-crate` +help: consider making the `extern crate` item publicly accessible + | +LL | pub extern crate core; + | +++ + diff --git a/tests/ui/modules/issue-56411.rs b/tests/ui/modules/issue-56411.rs index 0a20f5fe98562..226d886336034 100644 --- a/tests/ui/modules/issue-56411.rs +++ b/tests/ui/modules/issue-56411.rs @@ -6,6 +6,7 @@ macro_rules! import { pub use self::$name; //~^ ERROR the name `issue_56411_aux` is defined multiple times //~| ERROR `issue_56411_aux` is only public within the crate, and cannot be re-exported outside + //~| ERROR `issue_56411_aux` is only public within the crate, and cannot be re-exported outside )* } diff --git a/tests/ui/modules/issue-56411.stderr b/tests/ui/modules/issue-56411.stderr index 6732a8a3d7324..980bbe120618e 100644 --- a/tests/ui/modules/issue-56411.stderr +++ b/tests/ui/modules/issue-56411.stderr @@ -27,7 +27,20 @@ LL | import!(("issue-56411-aux.rs", issue_56411_aux)); = note: consider declaring type or module `issue_56411_aux` with `pub` = note: this error originates in the macro `import` (in Nightly builds, run with -Z macro-backtrace for more info) -error: aborting due to 2 previous errors +error[E0365]: `issue_56411_aux` is only public within the crate, and cannot be re-exported outside + --> $DIR/issue-56411.rs:6:21 + | +LL | pub use self::$name; + | ^^^^^^^^^^^ re-export of crate public `issue_56411_aux` +... +LL | import!(("issue-56411-aux.rs", issue_56411_aux)); + | ------------------------------------------------ in this macro invocation + | + = note: consider declaring type or module `issue_56411_aux` with `pub` + = note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no` + = note: this error originates in the macro `import` (in Nightly builds, run with -Z macro-backtrace for more info) + +error: aborting due to 3 previous errors Some errors have detailed explanations: E0255, E0365. For more information about an error, try `rustc --explain E0255`. diff --git a/tests/ui/privacy/crate-private-reexport.rs b/tests/ui/privacy/crate-private-reexport.rs index db0314683a0da..8bd68983a3a40 100644 --- a/tests/ui/privacy/crate-private-reexport.rs +++ b/tests/ui/privacy/crate-private-reexport.rs @@ -5,10 +5,18 @@ struct S1 { bar: i32, } mod m1 { - pub use crate::f1; //~ ERROR `f1` is only public within the crate, and cannot be re-exported outside - pub use crate::S1; //~ ERROR `S1` is only public within the crate, and cannot be re-exported outside - pub use crate::E1; //~ ERROR `E1` is only public within the crate, and cannot be re-exported outside - pub use crate::E1::V; //~ ERROR `V` is only public within the crate, and cannot be re-exported outside + pub use crate::f1; + //~^ ERROR `f1` is only public within the crate, and cannot be re-exported outside + //~| ERROR `f1` is only public within the crate, and cannot be re-exported outside + pub use crate::S1; + //~^ ERROR `S1` is only public within the crate, and cannot be re-exported outside + //~| ERROR `S1` is only public within the crate, and cannot be re-exported outside + pub use crate::E1; + //~^ ERROR `E1` is only public within the crate, and cannot be re-exported outside + //~| ERROR `E1` is only public within the crate, and cannot be re-exported outside + pub use crate::E1::V; + //~^ ERROR `V` is only public within the crate, and cannot be re-exported outside + //~| ERROR `V` is only public within the crate, and cannot be re-exported outside } pub(crate) fn f2() {} @@ -20,10 +28,18 @@ pub(crate) struct S2 { bar: i32, } mod m2 { - pub use crate::f2; //~ ERROR `f2` is only public within the crate, and cannot be re-exported outside - pub use crate::S2; //~ ERROR `S2` is only public within the crate, and cannot be re-exported outside - pub use crate::E2; //~ ERROR `E2` is only public within the crate, and cannot be re-exported outside - pub use crate::E2::V; //~ ERROR `V` is only public within the crate, and cannot be re-exported outside + pub use crate::f2; + //~^ ERROR `f2` is only public within the crate, and cannot be re-exported outside + //~| ERROR `f2` is only public within the crate, and cannot be re-exported outside + pub use crate::S2; + //~^ ERROR `S2` is only public within the crate, and cannot be re-exported outside + //~| ERROR `S2` is only public within the crate, and cannot be re-exported outside + pub use crate::E2; + //~^ ERROR `E2` is only public within the crate, and cannot be re-exported outside + //~| ERROR `E2` is only public within the crate, and cannot be re-exported outside + pub use crate::E2::V; + //~^ ERROR `V` is only public within the crate, and cannot be re-exported outside + //~| ERROR `V` is only public within the crate, and cannot be re-exported outside } mod m3 { @@ -36,13 +52,23 @@ mod m3 { bar: i32, } } -pub use m3::f3; //~ ERROR `f3` is only public within the crate, and cannot be re-exported outside -pub use m3::S3; //~ ERROR `S3` is only public within the crate, and cannot be re-exported outside -pub use m3::E3; //~ ERROR `E3` is only public within the crate, and cannot be re-exported outside -pub use m3::E3::V; //~ ERROR `V` is only public within the crate, and cannot be re-exported outside +pub use m3::f3; +//~^ ERROR `f3` is only public within the crate, and cannot be re-exported outside +//~| ERROR `f3` is only public within the crate, and cannot be re-exported outside +pub use m3::S3; +//~^ ERROR `S3` is only public within the crate, and cannot be re-exported outside +//~| ERROR `S3` is only public within the crate, and cannot be re-exported outside +pub use m3::E3; +//~^ ERROR `E3` is only public within the crate, and cannot be re-exported outside +//~| ERROR `E3` is only public within the crate, and cannot be re-exported outside +pub use m3::E3::V; +//~^ ERROR `V` is only public within the crate, and cannot be re-exported outside +//~| ERROR `V` is only public within the crate, and cannot be re-exported outside pub(self) fn f4() {} -pub use crate::f4 as f5; //~ ERROR `f4` is only public within the crate, and cannot be re-exported outside +pub use crate::f4 as f5; +//~^ ERROR `f4` is only public within the crate, and cannot be re-exported outside +//~| ERROR `f4` is only public within the crate, and cannot be re-exported outside pub mod m10 { pub mod m { @@ -50,17 +76,26 @@ pub mod m10 { pub(crate) fn f7() {} pub(in crate::m10) fn f8() {} } - pub use self::m::f6; //~ ERROR `f6` is private, and cannot be re-exported - pub use self::m::f7; //~ ERROR `f7` is only public within the crate, and cannot be re-exported outside - pub use self::m::f8; //~ ERROR `f8` is private, and cannot be re-exported + pub use self::m::f6; + //~^ ERROR `f6` is private, and cannot be re-exported + //~| ERROR `f6` is private, and cannot be re-exported + pub use self::m::f7; + //~^ ERROR `f7` is only public within the crate, and cannot be re-exported outside + //~| ERROR `f7` is only public within the crate, and cannot be re-exported outside + pub use self::m::f8; + //~^ ERROR `f8` is private, and cannot be re-exported + //~| ERROR `f8` is private, and cannot be re-exported } pub use m10::m::f6; //~ ERROR function `f6` is private -pub use m10::m::f7; //~ ERROR `f7` is only public within the crate, and cannot be re-exported outside +pub use m10::m::f7; +//~^ ERROR `f7` is only public within the crate, and cannot be re-exported outside +//~| ERROR `f7` is only public within the crate, and cannot be re-exported outside pub use m10::m::f8; //~ ERROR function `f8` is private pub mod m11 { pub(self) fn f9() {} } -pub use m11::f9; //~ ERROR function `f9` is private +pub use m11::f9; +//~^ ERROR function `f9` is private fn main() {} diff --git a/tests/ui/privacy/crate-private-reexport.stderr b/tests/ui/privacy/crate-private-reexport.stderr index 9b2626efacd2d..b9cec6ee8fb51 100644 --- a/tests/ui/privacy/crate-private-reexport.stderr +++ b/tests/ui/privacy/crate-private-reexport.stderr @@ -11,7 +11,7 @@ LL | pub use crate::f1; | ^^^^^^^^^ error[E0365]: `S1` is only public within the crate, and cannot be re-exported outside - --> $DIR/crate-private-reexport.rs:9:13 + --> $DIR/crate-private-reexport.rs:11:13 | LL | pub use crate::S1; | ^^^^^^^^^ re-export of crate public `S1` @@ -19,7 +19,7 @@ LL | pub use crate::S1; = note: consider declaring type or module `S1` with `pub` error[E0365]: `E1` is only public within the crate, and cannot be re-exported outside - --> $DIR/crate-private-reexport.rs:10:13 + --> $DIR/crate-private-reexport.rs:14:13 | LL | pub use crate::E1; | ^^^^^^^^^ re-export of crate public `E1` @@ -27,31 +27,31 @@ LL | pub use crate::E1; = note: consider declaring type or module `E1` with `pub` error[E0364]: `V` is only public within the crate, and cannot be re-exported outside - --> $DIR/crate-private-reexport.rs:11:13 + --> $DIR/crate-private-reexport.rs:17:13 | LL | pub use crate::E1::V; | ^^^^^^^^^^^^ | note: consider marking `V` as `pub` in the imported module - --> $DIR/crate-private-reexport.rs:11:13 + --> $DIR/crate-private-reexport.rs:17:13 | LL | pub use crate::E1::V; | ^^^^^^^^^^^^ error[E0364]: `f2` is only public within the crate, and cannot be re-exported outside - --> $DIR/crate-private-reexport.rs:23:13 + --> $DIR/crate-private-reexport.rs:31:13 | LL | pub use crate::f2; | ^^^^^^^^^ | note: consider marking `f2` as `pub` in the imported module - --> $DIR/crate-private-reexport.rs:23:13 + --> $DIR/crate-private-reexport.rs:31:13 | LL | pub use crate::f2; | ^^^^^^^^^ error[E0365]: `S2` is only public within the crate, and cannot be re-exported outside - --> $DIR/crate-private-reexport.rs:24:13 + --> $DIR/crate-private-reexport.rs:34:13 | LL | pub use crate::S2; | ^^^^^^^^^ re-export of crate public `S2` @@ -59,7 +59,7 @@ LL | pub use crate::S2; = note: consider declaring type or module `S2` with `pub` error[E0365]: `E2` is only public within the crate, and cannot be re-exported outside - --> $DIR/crate-private-reexport.rs:25:13 + --> $DIR/crate-private-reexport.rs:37:13 | LL | pub use crate::E2; | ^^^^^^^^^ re-export of crate public `E2` @@ -67,31 +67,31 @@ LL | pub use crate::E2; = note: consider declaring type or module `E2` with `pub` error[E0364]: `V` is only public within the crate, and cannot be re-exported outside - --> $DIR/crate-private-reexport.rs:26:13 + --> $DIR/crate-private-reexport.rs:40:13 | LL | pub use crate::E2::V; | ^^^^^^^^^^^^ | note: consider marking `V` as `pub` in the imported module - --> $DIR/crate-private-reexport.rs:26:13 + --> $DIR/crate-private-reexport.rs:40:13 | LL | pub use crate::E2::V; | ^^^^^^^^^^^^ error[E0364]: `f3` is only public within the crate, and cannot be re-exported outside - --> $DIR/crate-private-reexport.rs:39:9 + --> $DIR/crate-private-reexport.rs:55:9 | LL | pub use m3::f3; | ^^^^^^ | note: consider marking `f3` as `pub` in the imported module - --> $DIR/crate-private-reexport.rs:39:9 + --> $DIR/crate-private-reexport.rs:55:9 | LL | pub use m3::f3; | ^^^^^^ error[E0365]: `S3` is only public within the crate, and cannot be re-exported outside - --> $DIR/crate-private-reexport.rs:40:9 + --> $DIR/crate-private-reexport.rs:58:9 | LL | pub use m3::S3; | ^^^^^^ re-export of crate public `S3` @@ -99,7 +99,7 @@ LL | pub use m3::S3; = note: consider declaring type or module `S3` with `pub` error[E0365]: `E3` is only public within the crate, and cannot be re-exported outside - --> $DIR/crate-private-reexport.rs:41:9 + --> $DIR/crate-private-reexport.rs:61:9 | LL | pub use m3::E3; | ^^^^^^ re-export of crate public `E3` @@ -107,114 +107,311 @@ LL | pub use m3::E3; = note: consider declaring type or module `E3` with `pub` error[E0364]: `V` is only public within the crate, and cannot be re-exported outside - --> $DIR/crate-private-reexport.rs:42:9 + --> $DIR/crate-private-reexport.rs:64:9 | LL | pub use m3::E3::V; | ^^^^^^^^^ | note: consider marking `V` as `pub` in the imported module - --> $DIR/crate-private-reexport.rs:42:9 + --> $DIR/crate-private-reexport.rs:64:9 | LL | pub use m3::E3::V; | ^^^^^^^^^ error[E0364]: `f4` is only public within the crate, and cannot be re-exported outside - --> $DIR/crate-private-reexport.rs:45:9 + --> $DIR/crate-private-reexport.rs:69:9 | LL | pub use crate::f4 as f5; | ^^^^^^^^^^^^^^^ | note: consider marking `f4` as `pub` in the imported module - --> $DIR/crate-private-reexport.rs:45:9 + --> $DIR/crate-private-reexport.rs:69:9 | LL | pub use crate::f4 as f5; | ^^^^^^^^^^^^^^^ error[E0364]: `f6` is private, and cannot be re-exported - --> $DIR/crate-private-reexport.rs:53:13 + --> $DIR/crate-private-reexport.rs:79:13 | LL | pub use self::m::f6; | ^^^^^^^^^^^ | note: consider marking `f6` as `pub` in the imported module - --> $DIR/crate-private-reexport.rs:53:13 + --> $DIR/crate-private-reexport.rs:79:13 | LL | pub use self::m::f6; | ^^^^^^^^^^^ error[E0364]: `f7` is only public within the crate, and cannot be re-exported outside - --> $DIR/crate-private-reexport.rs:54:13 + --> $DIR/crate-private-reexport.rs:82:13 | LL | pub use self::m::f7; | ^^^^^^^^^^^ | note: consider marking `f7` as `pub` in the imported module - --> $DIR/crate-private-reexport.rs:54:13 + --> $DIR/crate-private-reexport.rs:82:13 | LL | pub use self::m::f7; | ^^^^^^^^^^^ error[E0364]: `f8` is private, and cannot be re-exported - --> $DIR/crate-private-reexport.rs:55:13 + --> $DIR/crate-private-reexport.rs:85:13 | LL | pub use self::m::f8; | ^^^^^^^^^^^ | note: consider marking `f8` as `pub` in the imported module - --> $DIR/crate-private-reexport.rs:55:13 + --> $DIR/crate-private-reexport.rs:85:13 | LL | pub use self::m::f8; | ^^^^^^^^^^^ error[E0364]: `f7` is only public within the crate, and cannot be re-exported outside - --> $DIR/crate-private-reexport.rs:58:9 + --> $DIR/crate-private-reexport.rs:90:9 | LL | pub use m10::m::f7; | ^^^^^^^^^^ | note: consider marking `f7` as `pub` in the imported module + --> $DIR/crate-private-reexport.rs:90:9 + | +LL | pub use m10::m::f7; + | ^^^^^^^^^^ + +error[E0364]: `f1` is only public within the crate, and cannot be re-exported outside + --> $DIR/crate-private-reexport.rs:8:13 + | +LL | pub use crate::f1; + | ^^^^^^^^^ + | +note: consider marking `f1` as `pub` in the imported module + --> $DIR/crate-private-reexport.rs:8:13 + | +LL | pub use crate::f1; + | ^^^^^^^^^ + = note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no` + +error[E0365]: `S1` is only public within the crate, and cannot be re-exported outside + --> $DIR/crate-private-reexport.rs:11:13 + | +LL | pub use crate::S1; + | ^^^^^^^^^ re-export of crate public `S1` + | + = note: consider declaring type or module `S1` with `pub` + = note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no` + +error[E0365]: `E1` is only public within the crate, and cannot be re-exported outside + --> $DIR/crate-private-reexport.rs:14:13 + | +LL | pub use crate::E1; + | ^^^^^^^^^ re-export of crate public `E1` + | + = note: consider declaring type or module `E1` with `pub` + = note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no` + +error[E0364]: `V` is only public within the crate, and cannot be re-exported outside + --> $DIR/crate-private-reexport.rs:17:13 + | +LL | pub use crate::E1::V; + | ^^^^^^^^^^^^ + | +note: consider marking `V` as `pub` in the imported module + --> $DIR/crate-private-reexport.rs:17:13 + | +LL | pub use crate::E1::V; + | ^^^^^^^^^^^^ + = note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no` + +error[E0364]: `f2` is only public within the crate, and cannot be re-exported outside + --> $DIR/crate-private-reexport.rs:31:13 + | +LL | pub use crate::f2; + | ^^^^^^^^^ + | +note: consider marking `f2` as `pub` in the imported module + --> $DIR/crate-private-reexport.rs:31:13 + | +LL | pub use crate::f2; + | ^^^^^^^^^ + = note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no` + +error[E0365]: `S2` is only public within the crate, and cannot be re-exported outside + --> $DIR/crate-private-reexport.rs:34:13 + | +LL | pub use crate::S2; + | ^^^^^^^^^ re-export of crate public `S2` + | + = note: consider declaring type or module `S2` with `pub` + = note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no` + +error[E0365]: `E2` is only public within the crate, and cannot be re-exported outside + --> $DIR/crate-private-reexport.rs:37:13 + | +LL | pub use crate::E2; + | ^^^^^^^^^ re-export of crate public `E2` + | + = note: consider declaring type or module `E2` with `pub` + = note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no` + +error[E0364]: `V` is only public within the crate, and cannot be re-exported outside + --> $DIR/crate-private-reexport.rs:40:13 + | +LL | pub use crate::E2::V; + | ^^^^^^^^^^^^ + | +note: consider marking `V` as `pub` in the imported module + --> $DIR/crate-private-reexport.rs:40:13 + | +LL | pub use crate::E2::V; + | ^^^^^^^^^^^^ + = note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no` + +error[E0364]: `f3` is only public within the crate, and cannot be re-exported outside + --> $DIR/crate-private-reexport.rs:55:9 + | +LL | pub use m3::f3; + | ^^^^^^ + | +note: consider marking `f3` as `pub` in the imported module + --> $DIR/crate-private-reexport.rs:55:9 + | +LL | pub use m3::f3; + | ^^^^^^ + = note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no` + +error[E0365]: `S3` is only public within the crate, and cannot be re-exported outside --> $DIR/crate-private-reexport.rs:58:9 | +LL | pub use m3::S3; + | ^^^^^^ re-export of crate public `S3` + | + = note: consider declaring type or module `S3` with `pub` + = note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no` + +error[E0365]: `E3` is only public within the crate, and cannot be re-exported outside + --> $DIR/crate-private-reexport.rs:61:9 + | +LL | pub use m3::E3; + | ^^^^^^ re-export of crate public `E3` + | + = note: consider declaring type or module `E3` with `pub` + = note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no` + +error[E0364]: `V` is only public within the crate, and cannot be re-exported outside + --> $DIR/crate-private-reexport.rs:64:9 + | +LL | pub use m3::E3::V; + | ^^^^^^^^^ + | +note: consider marking `V` as `pub` in the imported module + --> $DIR/crate-private-reexport.rs:64:9 + | +LL | pub use m3::E3::V; + | ^^^^^^^^^ + = note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no` + +error[E0364]: `f4` is only public within the crate, and cannot be re-exported outside + --> $DIR/crate-private-reexport.rs:69:9 + | +LL | pub use crate::f4 as f5; + | ^^^^^^^^^^^^^^^ + | +note: consider marking `f4` as `pub` in the imported module + --> $DIR/crate-private-reexport.rs:69:9 + | +LL | pub use crate::f4 as f5; + | ^^^^^^^^^^^^^^^ + = note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no` + +error[E0364]: `f6` is private, and cannot be re-exported + --> $DIR/crate-private-reexport.rs:79:13 + | +LL | pub use self::m::f6; + | ^^^^^^^^^^^ + | +note: consider marking `f6` as `pub` in the imported module + --> $DIR/crate-private-reexport.rs:79:13 + | +LL | pub use self::m::f6; + | ^^^^^^^^^^^ + = note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no` + +error[E0364]: `f7` is only public within the crate, and cannot be re-exported outside + --> $DIR/crate-private-reexport.rs:82:13 + | +LL | pub use self::m::f7; + | ^^^^^^^^^^^ + | +note: consider marking `f7` as `pub` in the imported module + --> $DIR/crate-private-reexport.rs:82:13 + | +LL | pub use self::m::f7; + | ^^^^^^^^^^^ + = note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no` + +error[E0364]: `f8` is private, and cannot be re-exported + --> $DIR/crate-private-reexport.rs:85:13 + | +LL | pub use self::m::f8; + | ^^^^^^^^^^^ + | +note: consider marking `f8` as `pub` in the imported module + --> $DIR/crate-private-reexport.rs:85:13 + | +LL | pub use self::m::f8; + | ^^^^^^^^^^^ + = note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no` + +error[E0364]: `f7` is only public within the crate, and cannot be re-exported outside + --> $DIR/crate-private-reexport.rs:90:9 + | +LL | pub use m10::m::f7; + | ^^^^^^^^^^ + | +note: consider marking `f7` as `pub` in the imported module + --> $DIR/crate-private-reexport.rs:90:9 + | LL | pub use m10::m::f7; | ^^^^^^^^^^ + = note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no` error[E0603]: function `f6` is private - --> $DIR/crate-private-reexport.rs:57:17 + --> $DIR/crate-private-reexport.rs:89:17 | LL | pub use m10::m::f6; | ^^ private function | note: the function `f6` is defined here - --> $DIR/crate-private-reexport.rs:49:9 + --> $DIR/crate-private-reexport.rs:75:9 | LL | pub(super) fn f6() {} | ^^^^^^^^^^^^^^^^^^ error[E0603]: function `f8` is private - --> $DIR/crate-private-reexport.rs:59:17 + --> $DIR/crate-private-reexport.rs:93:17 | LL | pub use m10::m::f8; | ^^ private function | note: the function `f8` is defined here - --> $DIR/crate-private-reexport.rs:51:9 + --> $DIR/crate-private-reexport.rs:77:9 | LL | pub(in crate::m10) fn f8() {} | ^^^^^^^^^^^^^^^^^^^^^^^^^^ error[E0603]: function `f9` is private - --> $DIR/crate-private-reexport.rs:64:14 + --> $DIR/crate-private-reexport.rs:98:14 | LL | pub use m11::f9; | ^^ private function | note: the function `f9` is defined here - --> $DIR/crate-private-reexport.rs:62:5 + --> $DIR/crate-private-reexport.rs:96:5 | LL | pub(self) fn f9() {} | ^^^^^^^^^^^^^^^^^ -error: aborting due to 20 previous errors +error: aborting due to 37 previous errors Some errors have detailed explanations: E0364, E0365, E0603. For more information about an error, try `rustc --explain E0364`. diff --git a/tests/ui/privacy/issue-46209-private-enum-variant-reexport.rs b/tests/ui/privacy/issue-46209-private-enum-variant-reexport.rs index 1800648b9546a..9682034730756 100644 --- a/tests/ui/privacy/issue-46209-private-enum-variant-reexport.rs +++ b/tests/ui/privacy/issue-46209-private-enum-variant-reexport.rs @@ -2,16 +2,21 @@ mod rank { pub use self::Professor::*; //~^ ERROR glob import doesn't reexport anything + //~| ERROR glob import doesn't reexport anything //~| ERROR unused import: `self::Professor::*` pub use self::Lieutenant::{JuniorGrade, Full}; //~^ ERROR `JuniorGrade` is private, and cannot be re-exported //~| ERROR `Full` is private, and cannot be re-exported + //~| ERROR `JuniorGrade` is private, and cannot be re-exported + //~| ERROR `Full` is private, and cannot be re-exported //~| ERROR unused imports: `Full` and `JuniorGrade` pub use self::PettyOfficer::*; //~^ ERROR glob import doesn't reexport anything + //~| ERROR glob import doesn't reexport anything //~| ERROR unused import: `self::PettyOfficer::*` pub use self::Crewman::*; //~^ ERROR glob import doesn't reexport anything + //~| ERROR glob import doesn't reexport anything //~| ERROR unused import: `self::Crewman::*` enum Professor { diff --git a/tests/ui/privacy/issue-46209-private-enum-variant-reexport.stderr b/tests/ui/privacy/issue-46209-private-enum-variant-reexport.stderr index f1701d547a62f..832555e0e1263 100644 --- a/tests/ui/privacy/issue-46209-private-enum-variant-reexport.stderr +++ b/tests/ui/privacy/issue-46209-private-enum-variant-reexport.stderr @@ -1,27 +1,53 @@ error[E0364]: `JuniorGrade` is private, and cannot be re-exported - --> $DIR/issue-46209-private-enum-variant-reexport.rs:6:32 + --> $DIR/issue-46209-private-enum-variant-reexport.rs:7:32 | LL | pub use self::Lieutenant::{JuniorGrade, Full}; | ^^^^^^^^^^^ | note: consider marking `JuniorGrade` as `pub` in the imported module - --> $DIR/issue-46209-private-enum-variant-reexport.rs:6:32 + --> $DIR/issue-46209-private-enum-variant-reexport.rs:7:32 | LL | pub use self::Lieutenant::{JuniorGrade, Full}; | ^^^^^^^^^^^ error[E0364]: `Full` is private, and cannot be re-exported - --> $DIR/issue-46209-private-enum-variant-reexport.rs:6:45 + --> $DIR/issue-46209-private-enum-variant-reexport.rs:7:45 | LL | pub use self::Lieutenant::{JuniorGrade, Full}; | ^^^^ | note: consider marking `Full` as `pub` in the imported module - --> $DIR/issue-46209-private-enum-variant-reexport.rs:6:45 + --> $DIR/issue-46209-private-enum-variant-reexport.rs:7:45 | LL | pub use self::Lieutenant::{JuniorGrade, Full}; | ^^^^ +error[E0364]: `JuniorGrade` is private, and cannot be re-exported + --> $DIR/issue-46209-private-enum-variant-reexport.rs:7:32 + | +LL | pub use self::Lieutenant::{JuniorGrade, Full}; + | ^^^^^^^^^^^ + | +note: consider marking `JuniorGrade` as `pub` in the imported module + --> $DIR/issue-46209-private-enum-variant-reexport.rs:7:32 + | +LL | pub use self::Lieutenant::{JuniorGrade, Full}; + | ^^^^^^^^^^^ + = note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no` + +error[E0364]: `Full` is private, and cannot be re-exported + --> $DIR/issue-46209-private-enum-variant-reexport.rs:7:45 + | +LL | pub use self::Lieutenant::{JuniorGrade, Full}; + | ^^^^ + | +note: consider marking `Full` as `pub` in the imported module + --> $DIR/issue-46209-private-enum-variant-reexport.rs:7:45 + | +LL | pub use self::Lieutenant::{JuniorGrade, Full}; + | ^^^^ + = note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no` + error: glob import doesn't reexport anything with visibility `pub` because no imported item is public enough --> $DIR/issue-46209-private-enum-variant-reexport.rs:3:13 | @@ -40,6 +66,20 @@ note: the lint level is defined here LL | #[deny(unused_imports)] | ^^^^^^^^^^^^^^ +error: glob import doesn't reexport anything with visibility `pub` because no imported item is public enough + --> $DIR/issue-46209-private-enum-variant-reexport.rs:3:13 + | +LL | pub use self::Professor::*; + | ^^^^^^^^^^^^^^^^^^ + | +note: the most public imported item is `pub(self)` + --> $DIR/issue-46209-private-enum-variant-reexport.rs:3:13 + | +LL | pub use self::Professor::*; + | ^^^^^^^^^^^^^^^^^^ + = help: reduce the glob import's visibility or increase visibility of imported items + = note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no` + error: unused import: `self::Professor::*` --> $DIR/issue-46209-private-enum-variant-reexport.rs:3:13 | @@ -47,49 +87,77 @@ LL | pub use self::Professor::*; | ^^^^^^^^^^^^^^^^^^ error: unused imports: `Full` and `JuniorGrade` - --> $DIR/issue-46209-private-enum-variant-reexport.rs:6:32 + --> $DIR/issue-46209-private-enum-variant-reexport.rs:7:32 | LL | pub use self::Lieutenant::{JuniorGrade, Full}; | ^^^^^^^^^^^ ^^^^ error: glob import doesn't reexport anything with visibility `pub` because no imported item is public enough - --> $DIR/issue-46209-private-enum-variant-reexport.rs:10:13 + --> $DIR/issue-46209-private-enum-variant-reexport.rs:13:13 + | +LL | pub use self::PettyOfficer::*; + | ^^^^^^^^^^^^^^^^^^^^^ + | +note: the most public imported item is `pub(self)` + --> $DIR/issue-46209-private-enum-variant-reexport.rs:13:13 + | +LL | pub use self::PettyOfficer::*; + | ^^^^^^^^^^^^^^^^^^^^^ + = help: reduce the glob import's visibility or increase visibility of imported items + +error: glob import doesn't reexport anything with visibility `pub` because no imported item is public enough + --> $DIR/issue-46209-private-enum-variant-reexport.rs:13:13 | LL | pub use self::PettyOfficer::*; | ^^^^^^^^^^^^^^^^^^^^^ | note: the most public imported item is `pub(self)` - --> $DIR/issue-46209-private-enum-variant-reexport.rs:10:13 + --> $DIR/issue-46209-private-enum-variant-reexport.rs:13:13 | LL | pub use self::PettyOfficer::*; | ^^^^^^^^^^^^^^^^^^^^^ = help: reduce the glob import's visibility or increase visibility of imported items + = note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no` error: unused import: `self::PettyOfficer::*` - --> $DIR/issue-46209-private-enum-variant-reexport.rs:10:13 + --> $DIR/issue-46209-private-enum-variant-reexport.rs:13:13 | LL | pub use self::PettyOfficer::*; | ^^^^^^^^^^^^^^^^^^^^^ error: glob import doesn't reexport anything with visibility `pub` because no imported item is public enough - --> $DIR/issue-46209-private-enum-variant-reexport.rs:13:13 + --> $DIR/issue-46209-private-enum-variant-reexport.rs:17:13 | LL | pub use self::Crewman::*; | ^^^^^^^^^^^^^^^^ | note: the most public imported item is `pub(crate)` - --> $DIR/issue-46209-private-enum-variant-reexport.rs:13:13 + --> $DIR/issue-46209-private-enum-variant-reexport.rs:17:13 | LL | pub use self::Crewman::*; | ^^^^^^^^^^^^^^^^ = help: reduce the glob import's visibility or increase visibility of imported items +error: glob import doesn't reexport anything with visibility `pub` because no imported item is public enough + --> $DIR/issue-46209-private-enum-variant-reexport.rs:17:13 + | +LL | pub use self::Crewman::*; + | ^^^^^^^^^^^^^^^^ + | +note: the most public imported item is `pub(crate)` + --> $DIR/issue-46209-private-enum-variant-reexport.rs:17:13 + | +LL | pub use self::Crewman::*; + | ^^^^^^^^^^^^^^^^ + = help: reduce the glob import's visibility or increase visibility of imported items + = note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no` + error: unused import: `self::Crewman::*` - --> $DIR/issue-46209-private-enum-variant-reexport.rs:13:13 + --> $DIR/issue-46209-private-enum-variant-reexport.rs:17:13 | LL | pub use self::Crewman::*; | ^^^^^^^^^^^^^^^^ -error: aborting due to 9 previous errors +error: aborting due to 14 previous errors For more information about this error, try `rustc --explain E0364`. diff --git a/tests/ui/privacy/macro-private-reexport.rs b/tests/ui/privacy/macro-private-reexport.rs index ebefde18f1f4c..e87a5f4bff0e2 100644 --- a/tests/ui/privacy/macro-private-reexport.rs +++ b/tests/ui/privacy/macro-private-reexport.rs @@ -7,11 +7,15 @@ mod foo { () => {}; } - pub use bar as _; //~ ERROR `bar` is only public within the crate, and cannot be re-exported outside + pub use bar as _; + //~^ ERROR `bar` is only public within the crate, and cannot be re-exported outside + //~| ERROR `bar` is only public within the crate, and cannot be re-exported outside macro baz() {} - pub use baz as _; //~ ERROR `baz` is private, and cannot be re-exported + pub use baz as _; + //~^ ERROR `baz` is private, and cannot be re-exported + //~| ERROR `baz` is private, and cannot be re-exported } fn main() {} diff --git a/tests/ui/privacy/macro-private-reexport.stderr b/tests/ui/privacy/macro-private-reexport.stderr index aa02715c20298..b6e9d9760e34d 100644 --- a/tests/ui/privacy/macro-private-reexport.stderr +++ b/tests/ui/privacy/macro-private-reexport.stderr @@ -17,17 +17,49 @@ LL | pub(crate) use bar as _; | +++++++ error[E0364]: `baz` is private, and cannot be re-exported - --> $DIR/macro-private-reexport.rs:14:13 + --> $DIR/macro-private-reexport.rs:16:13 | LL | pub use baz as _; | ^^^^^^^^ | note: consider marking `baz` as `pub` in the imported module - --> $DIR/macro-private-reexport.rs:14:13 + --> $DIR/macro-private-reexport.rs:16:13 | LL | pub use baz as _; | ^^^^^^^^ -error: aborting due to 2 previous errors +error[E0364]: `bar` is only public within the crate, and cannot be re-exported outside + --> $DIR/macro-private-reexport.rs:10:13 + | +LL | pub use bar as _; + | ^^^^^^^^ + | +help: consider adding a `#[macro_export]` to the macro in the imported module + --> $DIR/macro-private-reexport.rs:6:5 + | +LL | / macro_rules! bar { +LL | | () => {}; +LL | | } + | |_____^ + = note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no` +help: in case you want to use the macro within this crate only, reduce the visibility to `pub(crate)` + | +LL | pub(crate) use bar as _; + | +++++++ + +error[E0364]: `baz` is private, and cannot be re-exported + --> $DIR/macro-private-reexport.rs:16:13 + | +LL | pub use baz as _; + | ^^^^^^^^ + | +note: consider marking `baz` as `pub` in the imported module + --> $DIR/macro-private-reexport.rs:16:13 + | +LL | pub use baz as _; + | ^^^^^^^^ + = note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no` + +error: aborting due to 4 previous errors For more information about this error, try `rustc --explain E0364`. diff --git a/tests/ui/privacy/privacy1.stderr b/tests/ui/privacy/privacy1.stderr index 98750cee610e4..3dd4d29f3da0e 100644 --- a/tests/ui/privacy/privacy1.stderr +++ b/tests/ui/privacy/privacy1.stderr @@ -23,18 +23,6 @@ LL | mod baz { | ^^^^^^^ = note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no` -error[E0603]: module `baz` is private - --> $DIR/privacy1.rs:147:18 - | -LL | use bar::baz; - | ^^^ private module - | -note: the module `baz` is defined here - --> $DIR/privacy1.rs:56:5 - | -LL | mod baz { - | ^^^^^^^ - error[E0603]: module `i` is private --> $DIR/privacy1.rs:171:20 | @@ -47,6 +35,18 @@ note: the module `i` is defined here LL | mod i { | ^^^^^ +error[E0603]: module `baz` is private + --> $DIR/privacy1.rs:147:18 + | +LL | use bar::baz; + | ^^^ private module + | +note: the module `baz` is defined here + --> $DIR/privacy1.rs:56:5 + | +LL | mod baz { + | ^^^^^^^ + error[E0603]: module `baz` is private --> $DIR/privacy1.rs:110:21 | diff --git a/tests/ui/privacy/private-variant-reexport.rs b/tests/ui/privacy/private-variant-reexport.rs index b59243af62067..ff0d5267e18f1 100644 --- a/tests/ui/privacy/private-variant-reexport.rs +++ b/tests/ui/privacy/private-variant-reexport.rs @@ -1,19 +1,26 @@ mod m1 { - pub use ::E::V; //~ ERROR `V` is only public within the crate, and cannot be re-exported outside + pub use ::E::V; + //~^ ERROR `V` is only public within the crate, and cannot be re-exported outside + //~| ERROR `V` is only public within the crate, and cannot be re-exported outside } mod m2 { - pub use ::E::{V}; //~ ERROR `V` is only public within the crate, and cannot be re-exported outside + pub use ::E::{V}; + //~^ ERROR `V` is only public within the crate, and cannot be re-exported outside + //~| ERROR `V` is only public within the crate, and cannot be re-exported outside } mod m3 { - pub use ::E::V::{self}; //~ ERROR `V` is only public within the crate, and cannot be re-exported outside + pub use ::E::V::{self}; + //~^ ERROR `V` is only public within the crate, and cannot be re-exported outside + //~| ERROR `V` is only public within the crate, and cannot be re-exported outside } #[deny(unused_imports)] mod m4 { pub use ::E::*; //~^ ERROR glob import doesn't reexport anything + //~| ERROR glob import doesn't reexport anything //~| ERROR unused import: `::E::*` } diff --git a/tests/ui/privacy/private-variant-reexport.stderr b/tests/ui/privacy/private-variant-reexport.stderr index d73bd1a8cc29f..77678c108f4d6 100644 --- a/tests/ui/privacy/private-variant-reexport.stderr +++ b/tests/ui/privacy/private-variant-reexport.stderr @@ -11,50 +11,99 @@ LL | pub use ::E::V; | ^^^^^^ error[E0364]: `V` is only public within the crate, and cannot be re-exported outside - --> $DIR/private-variant-reexport.rs:6:19 + --> $DIR/private-variant-reexport.rs:8:19 | LL | pub use ::E::{V}; | ^ | note: consider marking `V` as `pub` in the imported module - --> $DIR/private-variant-reexport.rs:6:19 + --> $DIR/private-variant-reexport.rs:8:19 | LL | pub use ::E::{V}; | ^ error[E0365]: `V` is only public within the crate, and cannot be re-exported outside - --> $DIR/private-variant-reexport.rs:10:22 + --> $DIR/private-variant-reexport.rs:14:22 | LL | pub use ::E::V::{self}; | ^^^^ re-export of crate public `V` | = note: consider declaring type or module `V` with `pub` +error[E0364]: `V` is only public within the crate, and cannot be re-exported outside + --> $DIR/private-variant-reexport.rs:2:13 + | +LL | pub use ::E::V; + | ^^^^^^ + | +note: consider marking `V` as `pub` in the imported module + --> $DIR/private-variant-reexport.rs:2:13 + | +LL | pub use ::E::V; + | ^^^^^^ + = note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no` + +error[E0364]: `V` is only public within the crate, and cannot be re-exported outside + --> $DIR/private-variant-reexport.rs:8:19 + | +LL | pub use ::E::{V}; + | ^ + | +note: consider marking `V` as `pub` in the imported module + --> $DIR/private-variant-reexport.rs:8:19 + | +LL | pub use ::E::{V}; + | ^ + = note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no` + +error[E0365]: `V` is only public within the crate, and cannot be re-exported outside + --> $DIR/private-variant-reexport.rs:14:22 + | +LL | pub use ::E::V::{self}; + | ^^^^ re-export of crate public `V` + | + = note: consider declaring type or module `V` with `pub` + = note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no` + error: glob import doesn't reexport anything with visibility `pub` because no imported item is public enough - --> $DIR/private-variant-reexport.rs:15:13 + --> $DIR/private-variant-reexport.rs:21:13 | LL | pub use ::E::*; | ^^^^^^ | note: the most public imported item is `pub(crate)` - --> $DIR/private-variant-reexport.rs:15:13 + --> $DIR/private-variant-reexport.rs:21:13 | LL | pub use ::E::*; | ^^^^^^ = help: reduce the glob import's visibility or increase visibility of imported items note: the lint level is defined here - --> $DIR/private-variant-reexport.rs:13:8 + --> $DIR/private-variant-reexport.rs:19:8 | LL | #[deny(unused_imports)] | ^^^^^^^^^^^^^^ +error: glob import doesn't reexport anything with visibility `pub` because no imported item is public enough + --> $DIR/private-variant-reexport.rs:21:13 + | +LL | pub use ::E::*; + | ^^^^^^ + | +note: the most public imported item is `pub(crate)` + --> $DIR/private-variant-reexport.rs:21:13 + | +LL | pub use ::E::*; + | ^^^^^^ + = help: reduce the glob import's visibility or increase visibility of imported items + = note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no` + error: unused import: `::E::*` - --> $DIR/private-variant-reexport.rs:15:13 + --> $DIR/private-variant-reexport.rs:21:13 | LL | pub use ::E::*; | ^^^^^^ -error: aborting due to 5 previous errors +error: aborting due to 9 previous errors Some errors have detailed explanations: E0364, E0365. For more information about an error, try `rustc --explain E0364`. diff --git a/tests/ui/privacy/restricted/test.rs b/tests/ui/privacy/restricted/test.rs index b32b9327f07ee..b87f8cdc047a8 100644 --- a/tests/ui/privacy/restricted/test.rs +++ b/tests/ui/privacy/restricted/test.rs @@ -18,7 +18,11 @@ mod foo { fn f() { use foo::bar::S; pub(self) use foo::bar::f; // ok - pub(super) use foo::bar::f as g; //~ ERROR cannot be re-exported + pub(super) use foo::bar::f as g; + //~^ ERROR `f` is private, and cannot be re-exported [E0364] + //~| ERROR `f` is private, and cannot be re-exported [E0364] + //~| ERROR `f` is private, and cannot be re-exported [E0364] + //~| ERROR `f` is private, and cannot be re-exported [E0364] S::default().x; // ok S::default().f(); // ok S::g(); // ok diff --git a/tests/ui/privacy/restricted/test.stderr b/tests/ui/privacy/restricted/test.stderr index 2744b3708a826..5e45172f94ffd 100644 --- a/tests/ui/privacy/restricted/test.stderr +++ b/tests/ui/privacy/restricted/test.stderr @@ -1,5 +1,5 @@ error[E0433]: failed to resolve: use of unresolved module or unlinked crate `bad` - --> $DIR/test.rs:50:12 + --> $DIR/test.rs:54:12 | LL | pub(in bad::path) mod m1 {} | ^^^ use of unresolved module or unlinked crate `bad` @@ -10,7 +10,7 @@ LL + extern crate bad; | error[E0742]: visibilities can only be restricted to ancestor modules - --> $DIR/test.rs:51:12 + --> $DIR/test.rs:55:12 | LL | pub(in foo) mod m2 {} | ^^^ @@ -27,8 +27,47 @@ note: consider marking `f` as `pub` in the imported module LL | pub(super) use foo::bar::f as g; | ^^^^^^^^^^^^^^^^ +error[E0364]: `f` is private, and cannot be re-exported + --> $DIR/test.rs:21:24 + | +LL | pub(super) use foo::bar::f as g; + | ^^^^^^^^^^^^^^^^ + | +note: consider marking `f` as `pub` in the imported module + --> $DIR/test.rs:21:24 + | +LL | pub(super) use foo::bar::f as g; + | ^^^^^^^^^^^^^^^^ + = note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no` + +error[E0364]: `f` is private, and cannot be re-exported + --> $DIR/test.rs:21:24 + | +LL | pub(super) use foo::bar::f as g; + | ^^^^^^^^^^^^^^^^ + | +note: consider marking `f` as `pub` in the imported module + --> $DIR/test.rs:21:24 + | +LL | pub(super) use foo::bar::f as g; + | ^^^^^^^^^^^^^^^^ + = note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no` + +error[E0364]: `f` is private, and cannot be re-exported + --> $DIR/test.rs:21:24 + | +LL | pub(super) use foo::bar::f as g; + | ^^^^^^^^^^^^^^^^ + | +note: consider marking `f` as `pub` in the imported module + --> $DIR/test.rs:21:24 + | +LL | pub(super) use foo::bar::f as g; + | ^^^^^^^^^^^^^^^^ + = note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no` + error[E0603]: struct `Crate` is private - --> $DIR/test.rs:38:25 + --> $DIR/test.rs:42:25 | LL | use pub_restricted::Crate; | ^^^^^ private struct @@ -40,7 +79,7 @@ LL | pub(crate) struct Crate; | ^^^^^^^^^^^^^^^^^^^^^^^ error[E0603]: function `f` is private - --> $DIR/test.rs:30:19 + --> $DIR/test.rs:34:19 | LL | use foo::bar::f; | ^ private function @@ -52,13 +91,13 @@ LL | pub(super) fn f() {} | ^^^^^^^^^^^^^^^^^ error[E0616]: field `x` of struct `S` is private - --> $DIR/test.rs:31:18 + --> $DIR/test.rs:35:18 | LL | S::default().x; | ^ private field error[E0624]: method `f` is private - --> $DIR/test.rs:32:18 + --> $DIR/test.rs:36:18 | LL | pub(super) fn f(&self) {} | ---------------------- private method defined here @@ -67,7 +106,7 @@ LL | S::default().f(); | ^ private method error[E0624]: associated function `g` is private - --> $DIR/test.rs:33:8 + --> $DIR/test.rs:37:8 | LL | pub(super) fn g() {} | ----------------- private associated function defined here @@ -76,19 +115,19 @@ LL | S::g(); | ^ private associated function error[E0616]: field `y` of struct `Universe` is private - --> $DIR/test.rs:42:15 + --> $DIR/test.rs:46:15 | LL | let _ = u.y; | ^ private field error[E0616]: field `z` of struct `Universe` is private - --> $DIR/test.rs:43:15 + --> $DIR/test.rs:47:15 | LL | let _ = u.z; | ^ private field error[E0624]: method `g` is private - --> $DIR/test.rs:45:7 + --> $DIR/test.rs:49:7 | LL | u.g(); | ^ private method @@ -99,7 +138,7 @@ LL | pub(crate) fn g(&self) {} | ---------------------- private method defined here error[E0624]: method `h` is private - --> $DIR/test.rs:46:7 + --> $DIR/test.rs:50:7 | LL | u.h(); | ^ private method @@ -109,7 +148,7 @@ LL | u.h(); LL | pub(crate) fn h(&self) {} | ---------------------- private method defined here -error: aborting due to 12 previous errors +error: aborting due to 15 previous errors Some errors have detailed explanations: E0364, E0433, E0603, E0616, E0624, E0742. For more information about an error, try `rustc --explain E0364`. diff --git a/tests/ui/proc-macro/issue-79148.rs b/tests/ui/proc-macro/issue-79148.rs index b2248759b5f8e..7fa3fb79715a4 100644 --- a/tests/ui/proc-macro/issue-79148.rs +++ b/tests/ui/proc-macro/issue-79148.rs @@ -5,6 +5,8 @@ extern crate re_export; use re_export::cause_ice; -cause_ice!(); //~ ERROR `Variant` is only public within the crate, and cannot be re-exported outside +cause_ice!(); +//~^ ERROR `Variant` is only public within the crate, and cannot be re-exported outside +//~| ERROR `Variant` is only public within the crate, and cannot be re-exported outside fn main() {} diff --git a/tests/ui/proc-macro/issue-79148.stderr b/tests/ui/proc-macro/issue-79148.stderr index 8adc4c6e0dbe4..c1c44744e60fa 100644 --- a/tests/ui/proc-macro/issue-79148.stderr +++ b/tests/ui/proc-macro/issue-79148.stderr @@ -11,6 +11,20 @@ LL | cause_ice!(); | ^^^^^^^^^^^^ = note: this error originates in the macro `cause_ice` (in Nightly builds, run with -Z macro-backtrace for more info) -error: aborting due to 1 previous error +error[E0364]: `Variant` is only public within the crate, and cannot be re-exported outside + --> $DIR/issue-79148.rs:8:1 + | +LL | cause_ice!(); + | ^^^^^^^^^^^^ + | +note: consider marking `Variant` as `pub` in the imported module + --> $DIR/issue-79148.rs:8:1 + | +LL | cause_ice!(); + | ^^^^^^^^^^^^ + = note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no` + = note: this error originates in the macro `cause_ice` (in Nightly builds, run with -Z macro-backtrace for more info) + +error: aborting due to 2 previous errors For more information about this error, try `rustc --explain E0364`. diff --git a/tests/ui/pub/pub-reexport-priv-extern-crate.rs b/tests/ui/pub/pub-reexport-priv-extern-crate.rs index 9d615be30f450..7df4405a60983 100644 --- a/tests/ui/pub/pub-reexport-priv-extern-crate.rs +++ b/tests/ui/pub/pub-reexport-priv-extern-crate.rs @@ -1,6 +1,9 @@ extern crate core; -pub use core as reexported_core; //~ ERROR `core` is private and cannot be re-exported - //~^ WARN this was previously accepted +pub use core as reexported_core; +//~^ ERROR `core` is private and cannot be re-exported +//~| WARN this was previously accepted +//~| ERROR `core` is private and cannot be re-exported +//~| WARN this was previously accepted mod foo1 { extern crate core; diff --git a/tests/ui/pub/pub-reexport-priv-extern-crate.stderr b/tests/ui/pub/pub-reexport-priv-extern-crate.stderr index dbb080e1b0940..6ba0b193eb241 100644 --- a/tests/ui/pub/pub-reexport-priv-extern-crate.stderr +++ b/tests/ui/pub/pub-reexport-priv-extern-crate.stderr @@ -1,23 +1,23 @@ error[E0603]: crate import `core` is private - --> $DIR/pub-reexport-priv-extern-crate.rs:10:22 + --> $DIR/pub-reexport-priv-extern-crate.rs:13:22 | LL | use crate::foo1::core; | ^^^^ private crate import | note: the crate import `core` is defined here - --> $DIR/pub-reexport-priv-extern-crate.rs:6:5 + --> $DIR/pub-reexport-priv-extern-crate.rs:9:5 | LL | extern crate core; | ^^^^^^^^^^^^^^^^^^ error[E0603]: crate import `core` is private - --> $DIR/pub-reexport-priv-extern-crate.rs:17:31 + --> $DIR/pub-reexport-priv-extern-crate.rs:20:31 | LL | pub use crate::foo2::bar::core; | ^^^^ private crate import | note: the crate import `core` is defined here - --> $DIR/pub-reexport-priv-extern-crate.rs:12:9 + --> $DIR/pub-reexport-priv-extern-crate.rs:15:9 | LL | extern crate core; | ^^^^^^^^^^^^^^^^^^ @@ -36,7 +36,21 @@ help: consider making the `extern crate` item publicly accessible LL | pub extern crate core; | +++ -error: aborting due to 3 previous errors +error[E0365]: extern crate `core` is private and cannot be re-exported + --> $DIR/pub-reexport-priv-extern-crate.rs:2:9 + | +LL | pub use core as reexported_core; + | ^^^^^^^^^^^^^^^^^^^^^^^ + | + = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! + = note: for more information, see issue #127909 + = note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no` +help: consider making the `extern crate` item publicly accessible + | +LL | pub extern crate core; + | +++ + +error: aborting due to 4 previous errors Some errors have detailed explanations: E0365, E0603. For more information about an error, try `rustc --explain E0365`. @@ -55,3 +69,18 @@ help: consider making the `extern crate` item publicly accessible LL | pub extern crate core; | +++ +Future breakage diagnostic: +error[E0365]: extern crate `core` is private and cannot be re-exported + --> $DIR/pub-reexport-priv-extern-crate.rs:2:9 + | +LL | pub use core as reexported_core; + | ^^^^^^^^^^^^^^^^^^^^^^^ + | + = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! + = note: for more information, see issue #127909 + = note: `#[deny(pub_use_of_private_extern_crate)]` (part of `#[deny(future_incompatible)]`) on by default +help: consider making the `extern crate` item publicly accessible + | +LL | pub extern crate core; + | +++ + diff --git a/tests/ui/rust-2018/edition-lint-nested-empty-paths.fixed b/tests/ui/rust-2018/edition-lint-nested-empty-paths.fixed index 4a584a55e6483..64957d6fd4bf3 100644 --- a/tests/ui/rust-2018/edition-lint-nested-empty-paths.fixed +++ b/tests/ui/rust-2018/edition-lint-nested-empty-paths.fixed @@ -17,18 +17,28 @@ pub(crate) mod foo { use crate::foo::{bar::{baz::{}}}; //~^ ERROR absolute paths must start with //~| WARN this is accepted in the current edition +//~| ERROR absolute paths must start with +//~| WARN this is accepted in the current edition use crate::foo::{bar::{XX, baz::{}}}; //~^ ERROR absolute paths must start with //~| WARN this is accepted in the current edition //~| ERROR absolute paths must start with //~| WARN this is accepted in the current edition +//~| ERROR absolute paths must start with +//~| WARN this is accepted in the current edition +//~| ERROR absolute paths must start with +//~| WARN this is accepted in the current edition use crate::foo::{bar::{baz::{}, baz1::{}}}; //~^ ERROR absolute paths must start with //~| WARN this is accepted in the current edition //~| ERROR absolute paths must start with //~| WARN this is accepted in the current edition +//~| ERROR absolute paths must start with +//~| WARN this is accepted in the current edition +//~| ERROR absolute paths must start with +//~| WARN this is accepted in the current edition fn main() { } diff --git a/tests/ui/rust-2018/edition-lint-nested-empty-paths.rs b/tests/ui/rust-2018/edition-lint-nested-empty-paths.rs index 2baafbd9704e3..f0ffcdbe5326d 100644 --- a/tests/ui/rust-2018/edition-lint-nested-empty-paths.rs +++ b/tests/ui/rust-2018/edition-lint-nested-empty-paths.rs @@ -17,18 +17,28 @@ pub(crate) mod foo { use foo::{bar::{baz::{}}}; //~^ ERROR absolute paths must start with //~| WARN this is accepted in the current edition +//~| ERROR absolute paths must start with +//~| WARN this is accepted in the current edition use foo::{bar::{XX, baz::{}}}; //~^ ERROR absolute paths must start with //~| WARN this is accepted in the current edition //~| ERROR absolute paths must start with //~| WARN this is accepted in the current edition +//~| ERROR absolute paths must start with +//~| WARN this is accepted in the current edition +//~| ERROR absolute paths must start with +//~| WARN this is accepted in the current edition use foo::{bar::{baz::{}, baz1::{}}}; //~^ ERROR absolute paths must start with //~| WARN this is accepted in the current edition //~| ERROR absolute paths must start with //~| WARN this is accepted in the current edition +//~| ERROR absolute paths must start with +//~| WARN this is accepted in the current edition +//~| ERROR absolute paths must start with +//~| WARN this is accepted in the current edition fn main() { } diff --git a/tests/ui/rust-2018/edition-lint-nested-empty-paths.stderr b/tests/ui/rust-2018/edition-lint-nested-empty-paths.stderr index 041572be84411..eba5a3c7d0a90 100644 --- a/tests/ui/rust-2018/edition-lint-nested-empty-paths.stderr +++ b/tests/ui/rust-2018/edition-lint-nested-empty-paths.stderr @@ -13,16 +13,46 @@ LL | #![deny(absolute_paths_not_starting_with_crate)] | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: absolute paths must start with `self`, `super`, `crate`, or an external crate name in the 2018 edition - --> $DIR/edition-lint-nested-empty-paths.rs:21:5 + --> $DIR/edition-lint-nested-empty-paths.rs:17:5 + | +LL | use foo::{bar::{baz::{}}}; + | ^^^^^^^^^^^^^^^^^^^^^ help: use `crate`: `crate::foo::{bar::{baz::{}}}` + | + = warning: this is accepted in the current edition (Rust 2015) but is a hard error in Rust 2018! + = note: for more information, see issue #53130 + = note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no` + +error: absolute paths must start with `self`, `super`, `crate`, or an external crate name in the 2018 edition + --> $DIR/edition-lint-nested-empty-paths.rs:23:5 + | +LL | use foo::{bar::{XX, baz::{}}}; + | ^^^^^^^^^^^^^^^^^^^^^^^^^ help: use `crate`: `crate::foo::{bar::{XX, baz::{}}}` + | + = warning: this is accepted in the current edition (Rust 2015) but is a hard error in Rust 2018! + = note: for more information, see issue #53130 + +error: absolute paths must start with `self`, `super`, `crate`, or an external crate name in the 2018 edition + --> $DIR/edition-lint-nested-empty-paths.rs:23:5 + | +LL | use foo::{bar::{XX, baz::{}}}; + | ^^^^^^^^^^^^^^^^^^^^^^^^^ help: use `crate`: `crate::foo::{bar::{XX, baz::{}}}` + | + = warning: this is accepted in the current edition (Rust 2015) but is a hard error in Rust 2018! + = note: for more information, see issue #53130 + = note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no` + +error: absolute paths must start with `self`, `super`, `crate`, or an external crate name in the 2018 edition + --> $DIR/edition-lint-nested-empty-paths.rs:23:5 | LL | use foo::{bar::{XX, baz::{}}}; | ^^^^^^^^^^^^^^^^^^^^^^^^^ help: use `crate`: `crate::foo::{bar::{XX, baz::{}}}` | = warning: this is accepted in the current edition (Rust 2015) but is a hard error in Rust 2018! = note: for more information, see issue #53130 + = note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no` error: absolute paths must start with `self`, `super`, `crate`, or an external crate name in the 2018 edition - --> $DIR/edition-lint-nested-empty-paths.rs:21:5 + --> $DIR/edition-lint-nested-empty-paths.rs:23:5 | LL | use foo::{bar::{XX, baz::{}}}; | ^^^^^^^^^^^^^^^^^^^^^^^^^ help: use `crate`: `crate::foo::{bar::{XX, baz::{}}}` @@ -32,7 +62,7 @@ LL | use foo::{bar::{XX, baz::{}}}; = note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no` error: absolute paths must start with `self`, `super`, `crate`, or an external crate name in the 2018 edition - --> $DIR/edition-lint-nested-empty-paths.rs:27:5 + --> $DIR/edition-lint-nested-empty-paths.rs:33:5 | LL | use foo::{bar::{baz::{}, baz1::{}}}; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: use `crate`: `crate::foo::{bar::{baz::{}, baz1::{}}}` @@ -41,7 +71,27 @@ LL | use foo::{bar::{baz::{}, baz1::{}}}; = note: for more information, see issue #53130 error: absolute paths must start with `self`, `super`, `crate`, or an external crate name in the 2018 edition - --> $DIR/edition-lint-nested-empty-paths.rs:27:5 + --> $DIR/edition-lint-nested-empty-paths.rs:33:5 + | +LL | use foo::{bar::{baz::{}, baz1::{}}}; + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: use `crate`: `crate::foo::{bar::{baz::{}, baz1::{}}}` + | + = warning: this is accepted in the current edition (Rust 2015) but is a hard error in Rust 2018! + = note: for more information, see issue #53130 + = note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no` + +error: absolute paths must start with `self`, `super`, `crate`, or an external crate name in the 2018 edition + --> $DIR/edition-lint-nested-empty-paths.rs:33:5 + | +LL | use foo::{bar::{baz::{}, baz1::{}}}; + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: use `crate`: `crate::foo::{bar::{baz::{}, baz1::{}}}` + | + = warning: this is accepted in the current edition (Rust 2015) but is a hard error in Rust 2018! + = note: for more information, see issue #53130 + = note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no` + +error: absolute paths must start with `self`, `super`, `crate`, or an external crate name in the 2018 edition + --> $DIR/edition-lint-nested-empty-paths.rs:33:5 | LL | use foo::{bar::{baz::{}, baz1::{}}}; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: use `crate`: `crate::foo::{bar::{baz::{}, baz1::{}}}` @@ -50,5 +100,5 @@ LL | use foo::{bar::{baz::{}, baz1::{}}}; = note: for more information, see issue #53130 = note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no` -error: aborting due to 5 previous errors +error: aborting due to 10 previous errors diff --git a/tests/ui/rust-2018/edition-lint-nested-paths.fixed b/tests/ui/rust-2018/edition-lint-nested-paths.fixed index bf0038c3be451..32f8c331c65b7 100644 --- a/tests/ui/rust-2018/edition-lint-nested-paths.fixed +++ b/tests/ui/rust-2018/edition-lint-nested-paths.fixed @@ -8,6 +8,10 @@ use crate::foo::{a, b}; //~| WARN this is accepted in the current edition //~| ERROR absolute paths must start with //~| WARN this is accepted in the current edition +//~| ERROR absolute paths must start with +//~| WARN this is accepted in the current edition +//~| ERROR absolute paths must start with +//~| WARN this is accepted in the current edition mod foo { pub(crate) fn a() {} @@ -25,6 +29,10 @@ fn main() { //~| WARN this is accepted in the current edition //~| ERROR absolute paths must start with //~| WARN this is accepted in the current edition + //~| ERROR absolute paths must start with + //~| WARN this is accepted in the current edition + //~| ERROR absolute paths must start with + //~| WARN this is accepted in the current edition x::a(); c(); } diff --git a/tests/ui/rust-2018/edition-lint-nested-paths.rs b/tests/ui/rust-2018/edition-lint-nested-paths.rs index 87dc51a3745e9..124e95e2aa49e 100644 --- a/tests/ui/rust-2018/edition-lint-nested-paths.rs +++ b/tests/ui/rust-2018/edition-lint-nested-paths.rs @@ -8,6 +8,10 @@ use foo::{a, b}; //~| WARN this is accepted in the current edition //~| ERROR absolute paths must start with //~| WARN this is accepted in the current edition +//~| ERROR absolute paths must start with +//~| WARN this is accepted in the current edition +//~| ERROR absolute paths must start with +//~| WARN this is accepted in the current edition mod foo { pub(crate) fn a() {} @@ -25,6 +29,10 @@ fn main() { //~| WARN this is accepted in the current edition //~| ERROR absolute paths must start with //~| WARN this is accepted in the current edition + //~| ERROR absolute paths must start with + //~| WARN this is accepted in the current edition + //~| ERROR absolute paths must start with + //~| WARN this is accepted in the current edition x::a(); c(); } diff --git a/tests/ui/rust-2018/edition-lint-nested-paths.stderr b/tests/ui/rust-2018/edition-lint-nested-paths.stderr index 4a70bb7e5c875..91fd43c064494 100644 --- a/tests/ui/rust-2018/edition-lint-nested-paths.stderr +++ b/tests/ui/rust-2018/edition-lint-nested-paths.stderr @@ -23,16 +23,56 @@ LL | use foo::{a, b}; = note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no` error: absolute paths must start with `self`, `super`, `crate`, or an external crate name in the 2018 edition - --> $DIR/edition-lint-nested-paths.rs:23:13 + --> $DIR/edition-lint-nested-paths.rs:6:5 + | +LL | use foo::{a, b}; + | ^^^^^^^^^^^ help: use `crate`: `crate::foo::{a, b}` + | + = warning: this is accepted in the current edition (Rust 2015) but is a hard error in Rust 2018! + = note: for more information, see issue #53130 + = note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no` + +error: absolute paths must start with `self`, `super`, `crate`, or an external crate name in the 2018 edition + --> $DIR/edition-lint-nested-paths.rs:6:5 + | +LL | use foo::{a, b}; + | ^^^^^^^^^^^ help: use `crate`: `crate::foo::{a, b}` + | + = warning: this is accepted in the current edition (Rust 2015) but is a hard error in Rust 2018! + = note: for more information, see issue #53130 + = note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no` + +error: absolute paths must start with `self`, `super`, `crate`, or an external crate name in the 2018 edition + --> $DIR/edition-lint-nested-paths.rs:27:13 + | +LL | use foo::{self as x, c}; + | ^^^^^^^^^^^^^^^^^^^ help: use `crate`: `crate::foo::{self as x, c}` + | + = warning: this is accepted in the current edition (Rust 2015) but is a hard error in Rust 2018! + = note: for more information, see issue #53130 + +error: absolute paths must start with `self`, `super`, `crate`, or an external crate name in the 2018 edition + --> $DIR/edition-lint-nested-paths.rs:27:13 | LL | use foo::{self as x, c}; | ^^^^^^^^^^^^^^^^^^^ help: use `crate`: `crate::foo::{self as x, c}` | = warning: this is accepted in the current edition (Rust 2015) but is a hard error in Rust 2018! = note: for more information, see issue #53130 + = note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no` + +error: absolute paths must start with `self`, `super`, `crate`, or an external crate name in the 2018 edition + --> $DIR/edition-lint-nested-paths.rs:27:13 + | +LL | use foo::{self as x, c}; + | ^^^^^^^^^^^^^^^^^^^ help: use `crate`: `crate::foo::{self as x, c}` + | + = warning: this is accepted in the current edition (Rust 2015) but is a hard error in Rust 2018! + = note: for more information, see issue #53130 + = note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no` error: absolute paths must start with `self`, `super`, `crate`, or an external crate name in the 2018 edition - --> $DIR/edition-lint-nested-paths.rs:23:13 + --> $DIR/edition-lint-nested-paths.rs:27:13 | LL | use foo::{self as x, c}; | ^^^^^^^^^^^^^^^^^^^ help: use `crate`: `crate::foo::{self as x, c}` @@ -41,5 +81,5 @@ LL | use foo::{self as x, c}; = note: for more information, see issue #53130 = note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no` -error: aborting due to 4 previous errors +error: aborting due to 8 previous errors diff --git a/tests/ui/rust-2018/edition-lint-paths.fixed b/tests/ui/rust-2018/edition-lint-paths.fixed index 9664b461161ad..abb5e607e34dc 100644 --- a/tests/ui/rust-2018/edition-lint-paths.fixed +++ b/tests/ui/rust-2018/edition-lint-paths.fixed @@ -12,6 +12,8 @@ pub mod foo { use crate::bar::Bar; //~^ ERROR absolute //~| WARN this is accepted in the current edition + //~| ERROR absolute + //~| WARN this is accepted in the current edition use super::bar::Bar2; use crate::bar::Bar3; @@ -19,6 +21,8 @@ pub mod foo { use crate::bar; //~^ ERROR absolute //~| WARN this is accepted in the current edition + //~| ERROR absolute + //~| WARN this is accepted in the current edition use crate::bar as something_else; @@ -29,6 +33,16 @@ pub mod foo { //~| WARN this is accepted in the current edition //~| ERROR absolute //~| WARN this is accepted in the current edition + //~| ERROR absolute + //~| WARN this is accepted in the current edition + //~| ERROR absolute + //~| WARN this is accepted in the current edition + //~| ERROR absolute + //~| WARN this is accepted in the current edition + //~| ERROR absolute + //~| WARN this is accepted in the current edition + //~| ERROR absolute + //~| WARN this is accepted in the current edition use crate::{main as another_main, Bar as SomethingElse2}; @@ -40,6 +54,8 @@ pub mod foo { use crate::bar::Bar; //~^ ERROR absolute //~| WARN this is accepted in the current edition +//~| ERROR absolute +//~| WARN this is accepted in the current edition pub mod bar { use edition_lint_paths as foo; @@ -52,6 +68,8 @@ mod baz { use crate::*; //~^ ERROR absolute //~| WARN this is accepted in the current edition + //~| ERROR absolute + //~| WARN this is accepted in the current edition } impl crate::foo::SomeTrait for u32 {} diff --git a/tests/ui/rust-2018/edition-lint-paths.rs b/tests/ui/rust-2018/edition-lint-paths.rs index 39cdad3ab98b2..e8c38cc26ae2e 100644 --- a/tests/ui/rust-2018/edition-lint-paths.rs +++ b/tests/ui/rust-2018/edition-lint-paths.rs @@ -12,6 +12,8 @@ pub mod foo { use bar::Bar; //~^ ERROR absolute //~| WARN this is accepted in the current edition + //~| ERROR absolute + //~| WARN this is accepted in the current edition use super::bar::Bar2; use crate::bar::Bar3; @@ -19,6 +21,8 @@ pub mod foo { use bar; //~^ ERROR absolute //~| WARN this is accepted in the current edition + //~| ERROR absolute + //~| WARN this is accepted in the current edition use crate::bar as something_else; @@ -29,6 +33,16 @@ pub mod foo { //~| WARN this is accepted in the current edition //~| ERROR absolute //~| WARN this is accepted in the current edition + //~| ERROR absolute + //~| WARN this is accepted in the current edition + //~| ERROR absolute + //~| WARN this is accepted in the current edition + //~| ERROR absolute + //~| WARN this is accepted in the current edition + //~| ERROR absolute + //~| WARN this is accepted in the current edition + //~| ERROR absolute + //~| WARN this is accepted in the current edition use crate::{main as another_main, Bar as SomethingElse2}; @@ -40,6 +54,8 @@ pub mod foo { use bar::Bar; //~^ ERROR absolute //~| WARN this is accepted in the current edition +//~| ERROR absolute +//~| WARN this is accepted in the current edition pub mod bar { use edition_lint_paths as foo; @@ -52,6 +68,8 @@ mod baz { use *; //~^ ERROR absolute //~| WARN this is accepted in the current edition + //~| ERROR absolute + //~| WARN this is accepted in the current edition } impl ::foo::SomeTrait for u32 {} diff --git a/tests/ui/rust-2018/edition-lint-paths.stderr b/tests/ui/rust-2018/edition-lint-paths.stderr index fde17338d98a7..8e97c75711334 100644 --- a/tests/ui/rust-2018/edition-lint-paths.stderr +++ b/tests/ui/rust-2018/edition-lint-paths.stderr @@ -13,7 +13,17 @@ LL | #![deny(absolute_paths_not_starting_with_crate)] | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: absolute paths must start with `self`, `super`, `crate`, or an external crate name in the 2018 edition - --> $DIR/edition-lint-paths.rs:19:9 + --> $DIR/edition-lint-paths.rs:12:9 + | +LL | use bar::Bar; + | ^^^^^^^^ help: use `crate`: `crate::bar::Bar` + | + = warning: this is accepted in the current edition (Rust 2015) but is a hard error in Rust 2018! + = note: for more information, see issue #53130 + = note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no` + +error: absolute paths must start with `self`, `super`, `crate`, or an external crate name in the 2018 edition + --> $DIR/edition-lint-paths.rs:21:9 | LL | use bar; | ^^^ help: use `crate`: `crate::bar` @@ -22,16 +32,56 @@ LL | use bar; = note: for more information, see issue #53130 error: absolute paths must start with `self`, `super`, `crate`, or an external crate name in the 2018 edition - --> $DIR/edition-lint-paths.rs:25:9 + --> $DIR/edition-lint-paths.rs:21:9 + | +LL | use bar; + | ^^^ help: use `crate`: `crate::bar` + | + = warning: this is accepted in the current edition (Rust 2015) but is a hard error in Rust 2018! + = note: for more information, see issue #53130 + = note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no` + +error: absolute paths must start with `self`, `super`, `crate`, or an external crate name in the 2018 edition + --> $DIR/edition-lint-paths.rs:29:9 + | +LL | use {main, Bar as SomethingElse}; + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: use `crate`: `crate::{main, Bar as SomethingElse}` + | + = warning: this is accepted in the current edition (Rust 2015) but is a hard error in Rust 2018! + = note: for more information, see issue #53130 + +error: absolute paths must start with `self`, `super`, `crate`, or an external crate name in the 2018 edition + --> $DIR/edition-lint-paths.rs:29:9 + | +LL | use {main, Bar as SomethingElse}; + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: use `crate`: `crate::{main, Bar as SomethingElse}` + | + = warning: this is accepted in the current edition (Rust 2015) but is a hard error in Rust 2018! + = note: for more information, see issue #53130 + = note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no` + +error: absolute paths must start with `self`, `super`, `crate`, or an external crate name in the 2018 edition + --> $DIR/edition-lint-paths.rs:29:9 + | +LL | use {main, Bar as SomethingElse}; + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: use `crate`: `crate::{main, Bar as SomethingElse}` + | + = warning: this is accepted in the current edition (Rust 2015) but is a hard error in Rust 2018! + = note: for more information, see issue #53130 + = note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no` + +error: absolute paths must start with `self`, `super`, `crate`, or an external crate name in the 2018 edition + --> $DIR/edition-lint-paths.rs:29:9 | LL | use {main, Bar as SomethingElse}; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: use `crate`: `crate::{main, Bar as SomethingElse}` | = warning: this is accepted in the current edition (Rust 2015) but is a hard error in Rust 2018! = note: for more information, see issue #53130 + = note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no` error: absolute paths must start with `self`, `super`, `crate`, or an external crate name in the 2018 edition - --> $DIR/edition-lint-paths.rs:25:9 + --> $DIR/edition-lint-paths.rs:29:9 | LL | use {main, Bar as SomethingElse}; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: use `crate`: `crate::{main, Bar as SomethingElse}` @@ -41,7 +91,7 @@ LL | use {main, Bar as SomethingElse}; = note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no` error: absolute paths must start with `self`, `super`, `crate`, or an external crate name in the 2018 edition - --> $DIR/edition-lint-paths.rs:25:9 + --> $DIR/edition-lint-paths.rs:29:9 | LL | use {main, Bar as SomethingElse}; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: use `crate`: `crate::{main, Bar as SomethingElse}` @@ -51,25 +101,65 @@ LL | use {main, Bar as SomethingElse}; = note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no` error: absolute paths must start with `self`, `super`, `crate`, or an external crate name in the 2018 edition - --> $DIR/edition-lint-paths.rs:40:5 + --> $DIR/edition-lint-paths.rs:29:9 + | +LL | use {main, Bar as SomethingElse}; + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: use `crate`: `crate::{main, Bar as SomethingElse}` + | + = warning: this is accepted in the current edition (Rust 2015) but is a hard error in Rust 2018! + = note: for more information, see issue #53130 + = note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no` + +error: absolute paths must start with `self`, `super`, `crate`, or an external crate name in the 2018 edition + --> $DIR/edition-lint-paths.rs:29:9 + | +LL | use {main, Bar as SomethingElse}; + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: use `crate`: `crate::{main, Bar as SomethingElse}` + | + = warning: this is accepted in the current edition (Rust 2015) but is a hard error in Rust 2018! + = note: for more information, see issue #53130 + = note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no` + +error: absolute paths must start with `self`, `super`, `crate`, or an external crate name in the 2018 edition + --> $DIR/edition-lint-paths.rs:54:5 + | +LL | use bar::Bar; + | ^^^^^^^^ help: use `crate`: `crate::bar::Bar` + | + = warning: this is accepted in the current edition (Rust 2015) but is a hard error in Rust 2018! + = note: for more information, see issue #53130 + +error: absolute paths must start with `self`, `super`, `crate`, or an external crate name in the 2018 edition + --> $DIR/edition-lint-paths.rs:54:5 | LL | use bar::Bar; | ^^^^^^^^ help: use `crate`: `crate::bar::Bar` | = warning: this is accepted in the current edition (Rust 2015) but is a hard error in Rust 2018! = note: for more information, see issue #53130 + = note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no` + +error: absolute paths must start with `self`, `super`, `crate`, or an external crate name in the 2018 edition + --> $DIR/edition-lint-paths.rs:68:9 + | +LL | use *; + | ^ help: use `crate`: `crate::*` + | + = warning: this is accepted in the current edition (Rust 2015) but is a hard error in Rust 2018! + = note: for more information, see issue #53130 error: absolute paths must start with `self`, `super`, `crate`, or an external crate name in the 2018 edition - --> $DIR/edition-lint-paths.rs:52:9 + --> $DIR/edition-lint-paths.rs:68:9 | LL | use *; | ^ help: use `crate`: `crate::*` | = warning: this is accepted in the current edition (Rust 2015) but is a hard error in Rust 2018! = note: for more information, see issue #53130 + = note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no` error: absolute paths must start with `self`, `super`, `crate`, or an external crate name in the 2018 edition - --> $DIR/edition-lint-paths.rs:57:6 + --> $DIR/edition-lint-paths.rs:75:6 | LL | impl ::foo::SomeTrait for u32 {} | ^^^^^^^^^^^^^^^^ help: use `crate`: `crate::foo::SomeTrait` @@ -78,7 +168,7 @@ LL | impl ::foo::SomeTrait for u32 {} = note: for more information, see issue #53130 error: absolute paths must start with `self`, `super`, `crate`, or an external crate name in the 2018 edition - --> $DIR/edition-lint-paths.rs:62:13 + --> $DIR/edition-lint-paths.rs:80:13 | LL | let x = ::bar::Bar; | ^^^^^^^^^^ help: use `crate`: `crate::bar::Bar` @@ -86,5 +176,5 @@ LL | let x = ::bar::Bar; = warning: this is accepted in the current edition (Rust 2015) but is a hard error in Rust 2018! = note: for more information, see issue #53130 -error: aborting due to 9 previous errors +error: aborting due to 18 previous errors diff --git a/tests/ui/rust-2018/extern-crate-rename.fixed b/tests/ui/rust-2018/extern-crate-rename.fixed index b6b665f537e36..0d7e846697a64 100644 --- a/tests/ui/rust-2018/extern-crate-rename.fixed +++ b/tests/ui/rust-2018/extern-crate-rename.fixed @@ -12,6 +12,8 @@ extern crate edition_lint_paths as my_crate; use crate::my_crate::foo; //~^ ERROR absolute paths must start //~| WARNING this is accepted in the current edition +//~| ERROR absolute paths must start +//~| WARNING this is accepted in the current edition fn main() { foo(); diff --git a/tests/ui/rust-2018/extern-crate-rename.rs b/tests/ui/rust-2018/extern-crate-rename.rs index 3257ab876e1ee..3731c65cd7cd5 100644 --- a/tests/ui/rust-2018/extern-crate-rename.rs +++ b/tests/ui/rust-2018/extern-crate-rename.rs @@ -12,6 +12,8 @@ extern crate edition_lint_paths as my_crate; use my_crate::foo; //~^ ERROR absolute paths must start //~| WARNING this is accepted in the current edition +//~| ERROR absolute paths must start +//~| WARNING this is accepted in the current edition fn main() { foo(); diff --git a/tests/ui/rust-2018/extern-crate-rename.stderr b/tests/ui/rust-2018/extern-crate-rename.stderr index 36986c89c62bc..d1cfa31df9216 100644 --- a/tests/ui/rust-2018/extern-crate-rename.stderr +++ b/tests/ui/rust-2018/extern-crate-rename.stderr @@ -12,5 +12,15 @@ note: the lint level is defined here LL | #![deny(absolute_paths_not_starting_with_crate)] | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -error: aborting due to 1 previous error +error: absolute paths must start with `self`, `super`, `crate`, or an external crate name in the 2018 edition + --> $DIR/extern-crate-rename.rs:12:5 + | +LL | use my_crate::foo; + | ^^^^^^^^^^^^^ help: use `crate`: `crate::my_crate::foo` + | + = warning: this is accepted in the current edition (Rust 2015) but is a hard error in Rust 2018! + = note: for more information, see issue #53130 + = note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no` + +error: aborting due to 2 previous errors diff --git a/tests/ui/rust-2018/extern-crate-submod.fixed b/tests/ui/rust-2018/extern-crate-submod.fixed index 8657960e9725e..5e05add9e9542 100644 --- a/tests/ui/rust-2018/extern-crate-submod.fixed +++ b/tests/ui/rust-2018/extern-crate-submod.fixed @@ -19,6 +19,8 @@ mod m { use crate::m::edition_lint_paths::foo; //~^ ERROR absolute paths must start //~| WARNING this is accepted in the current edition +//~| ERROR absolute paths must start +//~| WARNING this is accepted in the current edition fn main() { foo(); diff --git a/tests/ui/rust-2018/extern-crate-submod.rs b/tests/ui/rust-2018/extern-crate-submod.rs index bf0a38d2b34ef..a7e00c0247562 100644 --- a/tests/ui/rust-2018/extern-crate-submod.rs +++ b/tests/ui/rust-2018/extern-crate-submod.rs @@ -19,6 +19,8 @@ mod m { use m::edition_lint_paths::foo; //~^ ERROR absolute paths must start //~| WARNING this is accepted in the current edition +//~| ERROR absolute paths must start +//~| WARNING this is accepted in the current edition fn main() { foo(); diff --git a/tests/ui/rust-2018/extern-crate-submod.stderr b/tests/ui/rust-2018/extern-crate-submod.stderr index 85e26d72a673b..deec24e6a1d68 100644 --- a/tests/ui/rust-2018/extern-crate-submod.stderr +++ b/tests/ui/rust-2018/extern-crate-submod.stderr @@ -12,5 +12,15 @@ note: the lint level is defined here LL | #![deny(absolute_paths_not_starting_with_crate)] | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -error: aborting due to 1 previous error +error: absolute paths must start with `self`, `super`, `crate`, or an external crate name in the 2018 edition + --> $DIR/extern-crate-submod.rs:19:5 + | +LL | use m::edition_lint_paths::foo; + | ^^^^^^^^^^^^^^^^^^^^^^^^^^ help: use `crate`: `crate::m::edition_lint_paths::foo` + | + = warning: this is accepted in the current edition (Rust 2015) but is a hard error in Rust 2018! + = note: for more information, see issue #53130 + = note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no` + +error: aborting due to 2 previous errors diff --git a/tests/ui/rust-2018/uniform-paths/ambiguity-macros-nested.rs b/tests/ui/rust-2018/uniform-paths/ambiguity-macros-nested.rs index f864779d9e5aa..399d90d24dbf2 100644 --- a/tests/ui/rust-2018/uniform-paths/ambiguity-macros-nested.rs +++ b/tests/ui/rust-2018/uniform-paths/ambiguity-macros-nested.rs @@ -7,6 +7,7 @@ mod foo { pub use std::io; //~^ ERROR `std` is ambiguous + //~| ERROR `std` is ambiguous macro_rules! m { () => { diff --git a/tests/ui/rust-2018/uniform-paths/ambiguity-macros-nested.stderr b/tests/ui/rust-2018/uniform-paths/ambiguity-macros-nested.stderr index f2536c1a1e988..8d93fa49d81fb 100644 --- a/tests/ui/rust-2018/uniform-paths/ambiguity-macros-nested.stderr +++ b/tests/ui/rust-2018/uniform-paths/ambiguity-macros-nested.stderr @@ -8,7 +8,7 @@ LL | pub use std::io; = note: `std` could refer to a built-in crate = help: use `::std` to refer to this crate unambiguously note: `std` could also refer to the module defined here - --> $DIR/ambiguity-macros-nested.rs:13:13 + --> $DIR/ambiguity-macros-nested.rs:14:13 | LL | / mod std { LL | | pub struct io; @@ -20,6 +20,29 @@ LL | m!(); = help: use `self::std` to refer to this module unambiguously = note: this error originates in the macro `m` (in Nightly builds, run with -Z macro-backtrace for more info) -error: aborting due to 1 previous error +error[E0659]: `std` is ambiguous + --> $DIR/ambiguity-macros-nested.rs:8:13 + | +LL | pub use std::io; + | ^^^ ambiguous name + | + = note: ambiguous because of a conflict between a macro-expanded name and a less macro-expanded name from outer scope during import or macro resolution + = note: `std` could refer to a built-in crate + = help: use `::std` to refer to this crate unambiguously +note: `std` could also refer to the module defined here + --> $DIR/ambiguity-macros-nested.rs:14:13 + | +LL | / mod std { +LL | | pub struct io; +LL | | } + | |_____________^ +... +LL | m!(); + | ---- in this macro invocation + = help: use `self::std` to refer to this module unambiguously + = note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no` + = note: this error originates in the macro `m` (in Nightly builds, run with -Z macro-backtrace for more info) + +error: aborting due to 2 previous errors For more information about this error, try `rustc --explain E0659`. diff --git a/tests/ui/rust-2018/uniform-paths/ambiguity-macros.rs b/tests/ui/rust-2018/uniform-paths/ambiguity-macros.rs index afa7f632945ea..74bda1be0dea1 100644 --- a/tests/ui/rust-2018/uniform-paths/ambiguity-macros.rs +++ b/tests/ui/rust-2018/uniform-paths/ambiguity-macros.rs @@ -6,6 +6,7 @@ use std::io; //~^ ERROR `std` is ambiguous +//~| ERROR `std` is ambiguous macro_rules! m { () => { diff --git a/tests/ui/rust-2018/uniform-paths/ambiguity-macros.stderr b/tests/ui/rust-2018/uniform-paths/ambiguity-macros.stderr index 3400183df6f41..54d5a40e961b6 100644 --- a/tests/ui/rust-2018/uniform-paths/ambiguity-macros.stderr +++ b/tests/ui/rust-2018/uniform-paths/ambiguity-macros.stderr @@ -8,7 +8,7 @@ LL | use std::io; = note: `std` could refer to a built-in crate = help: use `::std` to refer to this crate unambiguously note: `std` could also refer to the module defined here - --> $DIR/ambiguity-macros.rs:12:9 + --> $DIR/ambiguity-macros.rs:13:9 | LL | / mod std { LL | | pub struct io; @@ -20,6 +20,29 @@ LL | m!(); = help: use `crate::std` to refer to this module unambiguously = note: this error originates in the macro `m` (in Nightly builds, run with -Z macro-backtrace for more info) -error: aborting due to 1 previous error +error[E0659]: `std` is ambiguous + --> $DIR/ambiguity-macros.rs:7:5 + | +LL | use std::io; + | ^^^ ambiguous name + | + = note: ambiguous because of a conflict between a macro-expanded name and a less macro-expanded name from outer scope during import or macro resolution + = note: `std` could refer to a built-in crate + = help: use `::std` to refer to this crate unambiguously +note: `std` could also refer to the module defined here + --> $DIR/ambiguity-macros.rs:13:9 + | +LL | / mod std { +LL | | pub struct io; +LL | | } + | |_________^ +... +LL | m!(); + | ---- in this macro invocation + = help: use `crate::std` to refer to this module unambiguously + = note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no` + = note: this error originates in the macro `m` (in Nightly builds, run with -Z macro-backtrace for more info) + +error: aborting due to 2 previous errors For more information about this error, try `rustc --explain E0659`. diff --git a/tests/ui/rust-2018/uniform-paths/issue-56596.rs b/tests/ui/rust-2018/uniform-paths/issue-56596.rs index c1b5d9fad727a..b3620fd6c8170 100644 --- a/tests/ui/rust-2018/uniform-paths/issue-56596.rs +++ b/tests/ui/rust-2018/uniform-paths/issue-56596.rs @@ -7,6 +7,9 @@ mod m { } use m::*; -use issue_56596; //~ ERROR `issue_56596` is ambiguous +use issue_56596; +//~^ ERROR `issue_56596` is ambiguous +//~| ERROR `issue_56596` is ambiguous +//~| ERROR `issue_56596` is ambiguous fn main() {} diff --git a/tests/ui/rust-2018/uniform-paths/issue-56596.stderr b/tests/ui/rust-2018/uniform-paths/issue-56596.stderr index 363d7a7a25fa6..ef3a1e2de0326 100644 --- a/tests/ui/rust-2018/uniform-paths/issue-56596.stderr +++ b/tests/ui/rust-2018/uniform-paths/issue-56596.stderr @@ -15,6 +15,42 @@ LL | use m::*; = help: consider adding an explicit import of `issue_56596` to disambiguate = help: or use `crate::issue_56596` to refer to this module unambiguously -error: aborting due to 1 previous error +error[E0659]: `issue_56596` is ambiguous + --> $DIR/issue-56596.rs:10:5 + | +LL | use issue_56596; + | ^^^^^^^^^^^ ambiguous name + | + = note: ambiguous because of a conflict between a name from a glob import and an outer scope during import or macro resolution + = note: `issue_56596` could refer to a crate passed with `--extern` + = help: use `::issue_56596` to refer to this crate unambiguously +note: `issue_56596` could also refer to the module imported here + --> $DIR/issue-56596.rs:9:5 + | +LL | use m::*; + | ^^^^ + = help: consider adding an explicit import of `issue_56596` to disambiguate + = help: or use `crate::issue_56596` to refer to this module unambiguously + = note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no` + +error[E0659]: `issue_56596` is ambiguous + --> $DIR/issue-56596.rs:10:5 + | +LL | use issue_56596; + | ^^^^^^^^^^^ ambiguous name + | + = note: ambiguous because of a conflict between a name from a glob import and an outer scope during import or macro resolution + = note: `issue_56596` could refer to a crate passed with `--extern` + = help: use `::issue_56596` to refer to this crate unambiguously +note: `issue_56596` could also refer to the module imported here + --> $DIR/issue-56596.rs:9:5 + | +LL | use m::*; + | ^^^^ + = help: consider adding an explicit import of `issue_56596` to disambiguate + = help: or use `crate::issue_56596` to refer to this module unambiguously + = note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no` + +error: aborting due to 3 previous errors For more information about this error, try `rustc --explain E0659`. diff --git a/tests/ui/rust-2018/uniform-paths/macro-rules.rs b/tests/ui/rust-2018/uniform-paths/macro-rules.rs index 72a1a4116a6b2..c855d4f4a4bd5 100644 --- a/tests/ui/rust-2018/uniform-paths/macro-rules.rs +++ b/tests/ui/rust-2018/uniform-paths/macro-rules.rs @@ -8,7 +8,9 @@ mod m1 { use legacy_macro as _; // OK pub(crate) use legacy_macro as _; // OK - pub use legacy_macro as _; //~ ERROR `legacy_macro` is only public within the crate, and cannot be re-exported outside + pub use legacy_macro as _; + //~^ ERROR `legacy_macro` is only public within the crate, and cannot be re-exported outside + //~| ERROR `legacy_macro` is only public within the crate, and cannot be re-exported outside } mod m2 { diff --git a/tests/ui/rust-2018/uniform-paths/macro-rules.stderr b/tests/ui/rust-2018/uniform-paths/macro-rules.stderr index 43eacd5413f1c..138a86ee9f674 100644 --- a/tests/ui/rust-2018/uniform-paths/macro-rules.stderr +++ b/tests/ui/rust-2018/uniform-paths/macro-rules.stderr @@ -14,6 +14,23 @@ help: in case you want to use the macro within this crate only, reduce the visib LL | pub(crate) use legacy_macro as _; | +++++++ -error: aborting due to 1 previous error +error[E0364]: `legacy_macro` is only public within the crate, and cannot be re-exported outside + --> $DIR/macro-rules.rs:11:13 + | +LL | pub use legacy_macro as _; + | ^^^^^^^^^^^^^^^^^ + | +help: consider adding a `#[macro_export]` to the macro in the imported module + --> $DIR/macro-rules.rs:7:5 + | +LL | macro_rules! legacy_macro { () => () } + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + = note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no` +help: in case you want to use the macro within this crate only, reduce the visibility to `pub(crate)` + | +LL | pub(crate) use legacy_macro as _; + | +++++++ + +error: aborting due to 2 previous errors For more information about this error, try `rustc --explain E0364`. diff --git a/tests/ui/shadowed/shadowed-use-visibility.stderr b/tests/ui/shadowed/shadowed-use-visibility.stderr index f3b81fcac99e0..b062341dc8be8 100644 --- a/tests/ui/shadowed/shadowed-use-visibility.stderr +++ b/tests/ui/shadowed/shadowed-use-visibility.stderr @@ -1,31 +1,31 @@ -error[E0603]: module import `f` is private - --> $DIR/shadowed-use-visibility.rs:15:10 +error[E0603]: module import `bar` is private + --> $DIR/shadowed-use-visibility.rs:9:21 | -LL | use bar::f::f; - | ^ private module import +LL | use crate::foo::bar::f as g; + | ^^^ private module import | -note: the module import `f` is defined here... - --> $DIR/shadowed-use-visibility.rs:11:9 +note: the module import `bar` is defined here... + --> $DIR/shadowed-use-visibility.rs:4:9 | -LL | use crate::foo as f; - | ^^^^^^^^^^^^^^^ +LL | use crate::foo as bar; + | ^^^^^^^^^^^^^^^^^ note: ...and refers to the module `foo` which is defined here --> $DIR/shadowed-use-visibility.rs:1:1 | LL | mod foo { | ^^^^^^^ -error[E0603]: module import `bar` is private - --> $DIR/shadowed-use-visibility.rs:9:21 +error[E0603]: module import `f` is private + --> $DIR/shadowed-use-visibility.rs:15:10 | -LL | use crate::foo::bar::f as g; - | ^^^ private module import +LL | use bar::f::f; + | ^ private module import | -note: the module import `bar` is defined here... - --> $DIR/shadowed-use-visibility.rs:4:9 +note: the module import `f` is defined here... + --> $DIR/shadowed-use-visibility.rs:11:9 | -LL | use crate::foo as bar; - | ^^^^^^^^^^^^^^^^^ +LL | use crate::foo as f; + | ^^^^^^^^^^^^^^^ note: ...and refers to the module `foo` which is defined here --> $DIR/shadowed-use-visibility.rs:1:1 |