diff --git a/compiler/rustc_hir/src/def.rs b/compiler/rustc_hir/src/def.rs index 2201d493f2de5..a583adcb7efb8 100644 --- a/compiler/rustc_hir/src/def.rs +++ b/compiler/rustc_hir/src/def.rs @@ -619,6 +619,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/build_reduced_graph.rs b/compiler/rustc_resolve/src/build_reduced_graph.rs index 2ad8543bf8ca4..ba862af23107d 100644 --- a/compiler/rustc_resolve/src/build_reduced_graph.rs +++ b/compiler/rustc_resolve/src/build_reduced_graph.rs @@ -491,7 +491,22 @@ impl<'a, 'ra, 'tcx> BuildReducedGraphVisitor<'a, 'ra, 'tcx> { } // We don't add prelude imports to the globs since they only affect lexical scopes, // which are not relevant to import resolution. - ImportKind::Glob { is_prelude: true, .. } => {} + ImportKind::Glob { is_prelude: true, .. } => { + // We do resolve the prelude path so it's set before import resolution. + let path_res = self.r.cm().maybe_resolve_path( + &import.module_path, + None, + &import.parent_scope, + Some(import), + ); + if let PathResult::Module( + module_or_uniform_root @ ModuleOrUniformRoot::Module(module), + ) = path_res + { + import.imported_module.set(Some(module_or_uniform_root)); + self.r.prelude = Some(module); + } + } ImportKind::Glob { .. } => current_module.globs.borrow_mut().push(import), _ => unreachable!(), } diff --git a/compiler/rustc_resolve/src/imports.rs b/compiler/rustc_resolve/src/imports.rs index 403d440bee786..5df7b9b5281f3 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,113 @@ 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, + Prelude, + Single { + parent: Module<'ra>, + import_bindings: PerNS>, + }, + Glob { + parent: Module<'ra>, + import_bindings: Vec<(NameBinding<'ra>, BindingKey, bool /* warn_ambiguity */)>, + path_res: PartialRes, + }, +} + +#[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); + + match (&import.kind, side_effect) { + ( + ImportKind::Single { target, bindings, .. }, + SideEffect::Single { parent, 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 { parent, import_bindings, path_res }, + ) => { + 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, path_res); + } + (ImportKind::Glob { is_prelude: true, .. }, SideEffect::Prelude) => { + let ModuleOrUniformRoot::Module(module) = import.imported_module.get().unwrap() + else { + unreachable!() + }; + r.prelude = Some(module); + } + + (_, 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> { @@ -552,22 +660,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) { @@ -840,16 +960,20 @@ 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 `{}`", + "(resolving import for module) resolving import `{}::{}` in `{}`", Segment::names_to_string(&import.module_path), + import_kind_to_string(&import.kind), module_to_string(import.parent_scope.module).unwrap_or_else(|| "???".to_string()), ); 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, @@ -858,8 +982,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); + } } }; @@ -869,16 +995,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 - // specualtive 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; @@ -890,8 +1014,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() @@ -906,43 +1029,28 @@ 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 - // specualtive 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 - // specualtive 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 { parent: import.parent_scope.module, import_bindings }, + indeterminate_count, + ) } /// Performs final import resolution, consistency checks and error reporting. @@ -1483,13 +1591,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, is_prelude, .. } = import.kind else { unreachable!() }; + let ImportKind::Glob { is_prelude, .. } = 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() { @@ -1503,15 +1614,11 @@ impl<'ra, 'tcx> Resolver<'ra, 'tcx> { } if module == import.parent_scope.module { - return; + return SideEffect::None; } else if is_prelude { - self.prelude = Some(module); - return; + return SideEffect::Prelude; } - // 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 @@ -1522,6 +1629,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), @@ -1534,18 +1642,16 @@ 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 { + parent: import.parent_scope.module, + import_bindings, + path_res: PartialRes::new(module.res().unwrap()), + } } // Miscellaneous post-processing, including recording re-exports, diff --git a/compiler/rustc_resolve/src/lib.rs b/compiler/rustc_resolve/src/lib.rs index e5df23a86cb9f..e8a4c14e860e1 100644 --- a/compiler/rustc_resolve/src/lib.rs +++ b/compiler/rustc_resolve/src/lib.rs @@ -2501,12 +2501,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/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 1c4768da827ac..845723d77e36d 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,50 +18,20 @@ 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 - | -LL | use super::prelude::*; - | ^^^^^^^^^^^^^^^^^ - = help: consider adding an explicit import of `date_range` to disambiguate - = note: `#[deny(ambiguous_glob_imports)]` on by default - -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,40 +44,16 @@ 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 - | -LL | pub use self::range::*; - | ^^^^^^^^^^^^^^ - = 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)]` 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 + --> $DIR/ambiguous-9.rs:16:13 | -LL | use dsl::*; - | ^^^^^^ +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:20:5 + --> $DIR/ambiguous-9.rs:15:13 | -LL | use prelude::*; - | ^^^^^^^^^^ +LL | pub use self::t::*; + | ^^^^^^^^^^ = help: consider adding an explicit import of `date_range` to disambiguate = note: `#[deny(ambiguous_glob_imports)]` on by default 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/proc-macro/derive-helper-legacy-spurious.rs b/tests/ui/proc-macro/derive-helper-legacy-spurious.rs index 8e902f3041932..0b55e775f38be 100644 --- a/tests/ui/proc-macro/derive-helper-legacy-spurious.rs +++ b/tests/ui/proc-macro/derive-helper-legacy-spurious.rs @@ -6,7 +6,7 @@ extern crate test_macros; #[derive(Empty)] -#[empty_helper] //~ ERROR cannot find attribute `empty_helper` in this scope +#[empty_helper] struct Foo {} fn main() {} diff --git a/tests/ui/proc-macro/derive-helper-legacy-spurious.stderr b/tests/ui/proc-macro/derive-helper-legacy-spurious.stderr index b34713b8ca68e..4cd89904ef3e1 100644 --- a/tests/ui/proc-macro/derive-helper-legacy-spurious.stderr +++ b/tests/ui/proc-macro/derive-helper-legacy-spurious.stderr @@ -4,11 +4,5 @@ error: cannot find attribute `dummy` in this scope LL | #![dummy] | ^^^^^ -error: cannot find attribute `empty_helper` in this scope - --> $DIR/derive-helper-legacy-spurious.rs:9:3 - | -LL | #[empty_helper] - | ^^^^^^^^^^^^ - -error: aborting due to 2 previous errors +error: aborting due to 1 previous error 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 |