From d040c8a0c97e70065a2b180aea10a034e5857d90 Mon Sep 17 00:00:00 2001 From: Vadim Petrochenkov Date: Fri, 17 Oct 2025 20:45:51 +0300 Subject: [PATCH 1/2] resolve: Preserve ambiguous glob reexports in crate metadata So in cross-crate scenarios they can work in the same way as in crate-local scenarios. --- compiler/rustc_metadata/src/lib.rs | 1 + compiler/rustc_metadata/src/rmeta/decoder.rs | 15 +++ .../src/rmeta/decoder/cstore_impl.rs | 10 +- compiler/rustc_metadata/src/rmeta/encoder.rs | 8 ++ compiler/rustc_metadata/src/rmeta/mod.rs | 3 +- .../rustc_metadata/src/rmeta/parameterized.rs | 1 + compiler/rustc_middle/src/metadata.rs | 15 +++ compiler/rustc_middle/src/ty/mod.rs | 3 +- .../rustc_resolve/src/build_reduced_graph.rs | 100 +++++++++++++++--- compiler/rustc_resolve/src/diagnostics.rs | 7 +- compiler/rustc_resolve/src/imports.rs | 49 ++++++--- compiler/rustc_resolve/src/lib.rs | 27 ++++- tests/ui/imports/ambiguous-2.rs | 5 +- tests/ui/imports/ambiguous-2.stderr | 45 ++++++++ tests/ui/imports/ambiguous-4.rs | 5 +- tests/ui/imports/ambiguous-4.stderr | 45 ++++++++ tests/ui/imports/extern-with-ambiguous-2.rs | 5 +- .../ui/imports/extern-with-ambiguous-2.stderr | 23 ++++ tests/ui/imports/extern-with-ambiguous-3.rs | 5 +- .../ui/imports/extern-with-ambiguous-3.stderr | 23 ++++ .../ui/imports/glob-conflict-cross-crate-1.rs | 8 +- .../glob-conflict-cross-crate-1.stderr | 36 +++++-- .../ui/imports/glob-conflict-cross-crate-2.rs | 3 +- .../glob-conflict-cross-crate-2.stderr | 18 +++- .../ui/imports/glob-conflict-cross-crate-3.rs | 4 +- .../glob-conflict-cross-crate-3.stderr | 41 +++++++ tests/ui/imports/issue-114682-2.rs | 13 +-- tests/ui/imports/issue-114682-2.stderr | 40 ++++++- tests/ui/imports/issue-114682-3.rs | 4 +- tests/ui/imports/issue-114682-3.stderr | 18 ++++ tests/ui/imports/issue-114682-4.rs | 4 +- tests/ui/imports/issue-114682-4.stderr | 36 +++++++ tests/ui/imports/issue-114682-5.rs | 6 +- tests/ui/imports/issue-114682-5.stderr | 51 +++++++++ tests/ui/imports/issue-114682-6.rs | 4 +- tests/ui/imports/issue-114682-6.stderr | 21 ++++ 36 files changed, 605 insertions(+), 97 deletions(-) create mode 100644 tests/ui/imports/ambiguous-2.stderr create mode 100644 tests/ui/imports/ambiguous-4.stderr create mode 100644 tests/ui/imports/extern-with-ambiguous-2.stderr create mode 100644 tests/ui/imports/extern-with-ambiguous-3.stderr create mode 100644 tests/ui/imports/glob-conflict-cross-crate-3.stderr create mode 100644 tests/ui/imports/issue-114682-3.stderr create mode 100644 tests/ui/imports/issue-114682-4.stderr create mode 100644 tests/ui/imports/issue-114682-5.stderr create mode 100644 tests/ui/imports/issue-114682-6.stderr diff --git a/compiler/rustc_metadata/src/lib.rs b/compiler/rustc_metadata/src/lib.rs index 3e50689b5accb..9e5eba1103a1e 100644 --- a/compiler/rustc_metadata/src/lib.rs +++ b/compiler/rustc_metadata/src/lib.rs @@ -11,6 +11,7 @@ #![feature(min_specialization)] #![feature(never_type)] #![feature(proc_macro_internals)] +#![feature(result_option_map_or_default)] #![feature(rustdoc_internals)] #![feature(trusted_len)] // tidy-alphabetical-end diff --git a/compiler/rustc_metadata/src/rmeta/decoder.rs b/compiler/rustc_metadata/src/rmeta/decoder.rs index b895feb906247..4aeea6b77d833 100644 --- a/compiler/rustc_metadata/src/rmeta/decoder.rs +++ b/compiler/rustc_metadata/src/rmeta/decoder.rs @@ -1308,6 +1308,21 @@ impl<'a> CrateMetadataRef<'a> { } } + fn get_ambig_module_children( + self, + id: DefIndex, + sess: &Session, + ) -> impl Iterator { + gen move { + let children = self.root.tables.ambig_module_children.get(self, id); + if !children.is_default() { + for child in children.decode((self, sess)) { + yield child; + } + } + } + } + fn is_ctfe_mir_available(self, id: DefIndex) -> bool { self.root.tables.mir_for_ctfe.get(self, id).is_some() } diff --git a/compiler/rustc_metadata/src/rmeta/decoder/cstore_impl.rs b/compiler/rustc_metadata/src/rmeta/decoder/cstore_impl.rs index df3add316ec23..84cff32e06324 100644 --- a/compiler/rustc_metadata/src/rmeta/decoder/cstore_impl.rs +++ b/compiler/rustc_metadata/src/rmeta/decoder/cstore_impl.rs @@ -8,7 +8,7 @@ use rustc_hir::def_id::{CrateNum, DefId, DefIdMap, LOCAL_CRATE}; use rustc_hir::definitions::{DefKey, DefPath, DefPathHash}; use rustc_middle::arena::ArenaAllocatable; use rustc_middle::bug; -use rustc_middle::metadata::ModChild; +use rustc_middle::metadata::{AmbigModChild, ModChild}; use rustc_middle::middle::exported_symbols::ExportedSymbol; use rustc_middle::middle::stability::DeprecationEntry; use rustc_middle::query::{ExternProviders, LocalCrate}; @@ -582,6 +582,14 @@ impl CStore { self.get_crate_data(def_id.krate).get_expn_that_defined(def_id.index, sess) } + pub fn ambig_module_children_untracked( + &self, + def_id: DefId, + sess: &Session, + ) -> impl Iterator { + self.get_crate_data(def_id.krate).get_ambig_module_children(def_id.index, sess) + } + /// Only public-facing way to traverse all the definitions in a non-local crate. /// Critically useful for this third-party project: . /// See for context. diff --git a/compiler/rustc_metadata/src/rmeta/encoder.rs b/compiler/rustc_metadata/src/rmeta/encoder.rs index e13ef7e70f447..9de27ea52eb5e 100644 --- a/compiler/rustc_metadata/src/rmeta/encoder.rs +++ b/compiler/rustc_metadata/src/rmeta/encoder.rs @@ -1705,6 +1705,14 @@ impl<'a, 'tcx> EncodeContext<'a, 'tcx> { record_defaulted_array!(self.tables.module_children_reexports[def_id] <- module_children.iter().filter(|child| !child.reexport_chain.is_empty())); + + let ambig_module_children = tcx + .resolutions(()) + .ambig_module_children + .get(&local_def_id) + .map_or_default(|v| &v[..]); + record_defaulted_array!(self.tables.ambig_module_children[def_id] <- + ambig_module_children); } } diff --git a/compiler/rustc_metadata/src/rmeta/mod.rs b/compiler/rustc_metadata/src/rmeta/mod.rs index 9fbfa0a9f7654..eae16d180a5bf 100644 --- a/compiler/rustc_metadata/src/rmeta/mod.rs +++ b/compiler/rustc_metadata/src/rmeta/mod.rs @@ -21,7 +21,7 @@ use rustc_index::bit_set::DenseBitSet; use rustc_macros::{ Decodable, Encodable, MetadataDecodable, MetadataEncodable, TyDecodable, TyEncodable, }; -use rustc_middle::metadata::ModChild; +use rustc_middle::metadata::{AmbigModChild, ModChild}; use rustc_middle::middle::codegen_fn_attrs::CodegenFnAttrs; use rustc_middle::middle::debugger_visualizer::DebuggerVisualizerFile; use rustc_middle::middle::deduced_param_attrs::DeducedParamAttrs; @@ -398,6 +398,7 @@ define_tables! { // That's why the encoded list needs to contain `ModChild` structures describing all the names // individually instead of `DefId`s. module_children_reexports: Table>, + ambig_module_children: Table>, cross_crate_inlinable: Table, - optional: diff --git a/compiler/rustc_metadata/src/rmeta/parameterized.rs b/compiler/rustc_metadata/src/rmeta/parameterized.rs index 733e33f310a67..390949c0b4ed0 100644 --- a/compiler/rustc_metadata/src/rmeta/parameterized.rs +++ b/compiler/rustc_metadata/src/rmeta/parameterized.rs @@ -94,6 +94,7 @@ trivially_parameterized_over_tcx! { rustc_hir::def_id::DefIndex, rustc_hir::definitions::DefKey, rustc_index::bit_set::DenseBitSet, + rustc_middle::metadata::AmbigModChild, rustc_middle::metadata::ModChild, rustc_middle::middle::codegen_fn_attrs::CodegenFnAttrs, rustc_middle::middle::debugger_visualizer::DebuggerVisualizerFile, diff --git a/compiler/rustc_middle/src/metadata.rs b/compiler/rustc_middle/src/metadata.rs index 57c8960943b1c..e2ad6393c4147 100644 --- a/compiler/rustc_middle/src/metadata.rs +++ b/compiler/rustc_middle/src/metadata.rs @@ -44,3 +44,18 @@ pub struct ModChild { /// Empty if the module child is a proper item. pub reexport_chain: SmallVec<[Reexport; 2]>, } + +#[derive(Debug, TyEncodable, TyDecodable, HashStable)] +pub enum AmbigModChildKind { + GlobVsGlob, + GlobVsExpanded, +} + +/// Same as `ModChild`, however, it includes ambiguity error. +#[derive(Debug, TyEncodable, TyDecodable, HashStable)] +pub struct AmbigModChild { + pub main: ModChild, + pub second: ModChild, + pub kind: AmbigModChildKind, + pub warn_ambiguity: bool, +} diff --git a/compiler/rustc_middle/src/ty/mod.rs b/compiler/rustc_middle/src/ty/mod.rs index c3e1defef809d..475c9a5682efd 100644 --- a/compiler/rustc_middle/src/ty/mod.rs +++ b/compiler/rustc_middle/src/ty/mod.rs @@ -110,7 +110,7 @@ pub use self::typeck_results::{ Rust2024IncompatiblePatInfo, TypeckResults, UserType, UserTypeAnnotationIndex, UserTypeKind, }; use crate::error::{OpaqueHiddenTypeMismatch, TypeMismatchReason}; -use crate::metadata::ModChild; +use crate::metadata::{AmbigModChild, ModChild}; use crate::middle::privacy::EffectiveVisibilities; use crate::mir::{Body, CoroutineLayout, CoroutineSavedLocal, SourceInfo}; use crate::query::{IntoQueryParam, Providers}; @@ -175,6 +175,7 @@ pub struct ResolverGlobalCtxt { pub extern_crate_map: UnordMap, pub maybe_unused_trait_imports: FxIndexSet, pub module_children: LocalDefIdMap>, + pub ambig_module_children: LocalDefIdMap>, pub glob_map: FxIndexMap>, pub main_def: Option, pub trait_impls: FxIndexMap>, diff --git a/compiler/rustc_resolve/src/build_reduced_graph.rs b/compiler/rustc_resolve/src/build_reduced_graph.rs index 88fbc6dcb6650..e07bce38e49ac 100644 --- a/compiler/rustc_resolve/src/build_reduced_graph.rs +++ b/compiler/rustc_resolve/src/build_reduced_graph.rs @@ -22,7 +22,7 @@ use rustc_hir::def::{self, *}; use rustc_hir::def_id::{CRATE_DEF_ID, DefId, LocalDefId}; use rustc_index::bit_set::DenseBitSet; use rustc_metadata::creader::LoadedMacro; -use rustc_middle::metadata::ModChild; +use rustc_middle::metadata::{AmbigModChildKind, ModChild}; use rustc_middle::ty::{Feed, Visibility}; use rustc_middle::{bug, span_bug}; use rustc_span::hygiene::{ExpnId, LocalExpnId, MacroKind}; @@ -36,9 +36,9 @@ use crate::imports::{ImportData, ImportKind}; use crate::macros::{MacroRulesBinding, MacroRulesScope, MacroRulesScopeRef}; use crate::ref_mut::CmCell; use crate::{ - BindingKey, ExternPreludeEntry, Finalize, MacroData, Module, ModuleKind, ModuleOrUniformRoot, - NameBinding, ParentScope, PathResult, ResolutionError, Resolver, Segment, Used, - VisResolutionError, errors, + AmbiguityKind, BindingKey, ExternPreludeEntry, Finalize, MacroData, Module, ModuleKind, + ModuleOrUniformRoot, NameBinding, NameBindingData, NameBindingKind, ParentScope, PathResult, + ResolutionError, Resolver, Segment, Used, VisResolutionError, errors, }; type Res = def::Res; @@ -81,9 +81,18 @@ impl<'ra, 'tcx> Resolver<'ra, 'tcx> { res: Res, vis: Visibility, span: Span, - expn_id: LocalExpnId, + expansion: LocalExpnId, + ambiguity: Option<(NameBinding<'ra>, AmbiguityKind)>, + warn_ambiguity: bool, ) { - let binding = self.arenas.new_res_binding(res, vis, span, expn_id); + let binding = self.arenas.alloc_name_binding(NameBindingData { + kind: NameBindingKind::Res(res), + ambiguity, + warn_ambiguity, + vis, + span, + expansion, + }); // Even if underscore names cannot be looked up, we still need to add them to modules, // because they can be fetched by glob imports from those modules, and bring traits // into scope both directly and through glob imports. @@ -232,9 +241,22 @@ impl<'ra, 'tcx> Resolver<'ra, 'tcx> { } pub(crate) fn build_reduced_graph_external(&self, module: Module<'ra>) { - for (i, child) in self.tcx.module_children(module.def_id()).into_iter().enumerate() { - let parent_scope = ParentScope::module(module, self.arenas); - self.build_reduced_graph_for_external_crate_res(child, parent_scope, i) + let def_id = module.def_id(); + let children = self.tcx.module_children(def_id); + let parent_scope = ParentScope::module(module, self.arenas); + for (i, child) in self.tcx.module_children(def_id).iter().enumerate() { + self.build_reduced_graph_for_external_crate_res(child, parent_scope, i, None, false) + } + for (i, child) in + self.cstore().ambig_module_children_untracked(def_id, self.tcx.sess).enumerate() + { + self.build_reduced_graph_for_external_crate_res( + &child.main, + parent_scope, + children.len() + i, + Some((&child.second, child.kind)), + child.warn_ambiguity, + ) } } @@ -244,6 +266,8 @@ impl<'ra, 'tcx> Resolver<'ra, 'tcx> { child: &ModChild, parent_scope: ParentScope<'ra>, child_index: usize, + ambig_child: Option<(&ModChild, AmbigModChildKind)>, + warn_ambiguity: bool, ) { let parent = parent_scope.module; let ModChild { ident, res, vis, ref reexport_chain } = *child; @@ -255,6 +279,21 @@ impl<'ra, 'tcx> Resolver<'ra, 'tcx> { ); let res = res.expect_non_local(); let expansion = parent_scope.expansion; + let ambig = ambig_child.map(|(ambig_child, ambig_kind)| { + let ModChild { ident: _, res, vis, ref reexport_chain } = *ambig_child; + let span = self.def_span( + reexport_chain + .first() + .and_then(|reexport| reexport.id()) + .unwrap_or_else(|| res.def_id()), + ); + let res = res.expect_non_local(); + let ambig_kind = match ambig_kind { + AmbigModChildKind::GlobVsGlob => AmbiguityKind::GlobVsGlob, + AmbigModChildKind::GlobVsExpanded => AmbiguityKind::GlobVsExpanded, + }; + (self.arenas.new_res_binding(res, vis, span, expansion), ambig_kind) + }); // Record primary definitions. match res { Res::Def( @@ -272,9 +311,18 @@ impl<'ra, 'tcx> Resolver<'ra, 'tcx> { _, ) | Res::PrimTy(..) - | Res::ToolMod => { - self.define_extern(parent, ident, TypeNS, child_index, res, vis, span, expansion) - } + | Res::ToolMod => self.define_extern( + parent, + ident, + TypeNS, + child_index, + res, + vis, + span, + expansion, + ambig, + warn_ambiguity, + ), Res::Def( DefKind::Fn | DefKind::AssocFn @@ -283,10 +331,30 @@ impl<'ra, 'tcx> Resolver<'ra, 'tcx> { | DefKind::AssocConst | DefKind::Ctor(..), _, - ) => self.define_extern(parent, ident, ValueNS, child_index, res, vis, span, expansion), - Res::Def(DefKind::Macro(..), _) | Res::NonMacroAttr(..) => { - self.define_extern(parent, ident, MacroNS, child_index, res, vis, span, expansion) - } + ) => self.define_extern( + parent, + ident, + ValueNS, + child_index, + res, + vis, + span, + expansion, + ambig, + warn_ambiguity, + ), + Res::Def(DefKind::Macro(..), _) | Res::NonMacroAttr(..) => self.define_extern( + parent, + ident, + MacroNS, + child_index, + res, + vis, + span, + expansion, + ambig, + warn_ambiguity, + ), Res::Def( DefKind::TyParam | DefKind::ConstParam diff --git a/compiler/rustc_resolve/src/diagnostics.rs b/compiler/rustc_resolve/src/diagnostics.rs index 236ab1f09d35f..4800291ce6319 100644 --- a/compiler/rustc_resolve/src/diagnostics.rs +++ b/compiler/rustc_resolve/src/diagnostics.rs @@ -145,12 +145,13 @@ impl<'ra, 'tcx> Resolver<'ra, 'tcx> { for ambiguity_error in &self.ambiguity_errors { let diag = self.ambiguity_diagnostics(ambiguity_error); if ambiguity_error.warning { - let NameBindingKind::Import { import, .. } = ambiguity_error.b1.0.kind else { - unreachable!() + let node_id = match ambiguity_error.b1.0.kind { + NameBindingKind::Import { import, .. } => import.root_id, + NameBindingKind::Res(_) => CRATE_NODE_ID, }; self.lint_buffer.buffer_lint( AMBIGUOUS_GLOB_IMPORTS, - import.root_id, + node_id, ambiguity_error.ident.span, BuiltinLintDiag::AmbiguousGlobImports { diag }, ); diff --git a/compiler/rustc_resolve/src/imports.rs b/compiler/rustc_resolve/src/imports.rs index f98aaecea18ce..a82578c6724ed 100644 --- a/compiler/rustc_resolve/src/imports.rs +++ b/compiler/rustc_resolve/src/imports.rs @@ -9,7 +9,7 @@ use rustc_errors::codes::*; use rustc_errors::{Applicability, MultiSpan, pluralize, struct_span_code_err}; use rustc_hir::def::{self, DefKind, PartialRes}; use rustc_hir::def_id::{DefId, LocalDefIdMap}; -use rustc_middle::metadata::{ModChild, Reexport}; +use rustc_middle::metadata::{AmbigModChild, AmbigModChildKind, ModChild, Reexport}; use rustc_middle::span_bug; use rustc_middle::ty::Visibility; use rustc_session::lint::BuiltinLintDiag; @@ -21,7 +21,6 @@ use rustc_session::parse::feature_err; use rustc_span::edit_distance::find_best_match_for_name; use rustc_span::hygiene::LocalExpnId; use rustc_span::{Ident, Span, Symbol, kw, sym}; -use smallvec::SmallVec; use tracing::debug; use crate::Namespace::{self, *}; @@ -227,7 +226,7 @@ impl<'ra> ImportData<'ra> { } } - fn simplify(&self, r: &Resolver<'_, '_>) -> Reexport { + pub(crate) fn simplify(&self, r: &Resolver<'_, '_>) -> Reexport { let to_def_id = |id| r.local_def_id(id).to_def_id(); match self.kind { ImportKind::Single { id, .. } => Reexport::Single(to_def_id(id)), @@ -571,10 +570,12 @@ impl<'ra, 'tcx> Resolver<'ra, 'tcx> { pub(crate) fn finalize_imports(&mut self) { let mut module_children = Default::default(); + let mut ambig_module_children = Default::default(); for module in &self.local_modules { - self.finalize_resolutions_in(*module, &mut module_children); + self.finalize_resolutions_in(*module, &mut module_children, &mut ambig_module_children); } self.module_children = module_children; + self.ambig_module_children = ambig_module_children; let mut seen_spans = FxHashSet::default(); let mut errors = vec![]; @@ -1544,6 +1545,7 @@ impl<'ra, 'tcx> Resolver<'ra, 'tcx> { &self, module: Module<'ra>, module_children: &mut LocalDefIdMap>, + ambig_module_children: &mut LocalDefIdMap>, ) { // Since import resolution is finished, globs will not define any more names. *module.globs.borrow_mut(self) = Vec::new(); @@ -1551,26 +1553,45 @@ impl<'ra, 'tcx> Resolver<'ra, 'tcx> { let Some(def_id) = module.opt_def_id() else { return }; let mut children = Vec::new(); + let mut ambig_children = Vec::new(); module.for_each_child(self, |this, ident, _, binding| { let res = binding.res().expect_non_local(); - let error_ambiguity = binding.is_ambiguity_recursive() && !binding.warn_ambiguity; - if res != def::Res::Err && !error_ambiguity { - let mut reexport_chain = SmallVec::new(); - let mut next_binding = binding; - while let NameBindingKind::Import { binding, import, .. } = next_binding.kind { - reexport_chain.push(import.simplify(this)); - next_binding = binding; - } + if res != def::Res::Err { + if let Some((ambig_binding1, ambig_binding2, ambig_kind)) = + binding.descent_to_ambiguity() + { + let reexport_chain = ambig_binding1.reexport_chain(this); + let main = ModChild { ident: ident.0, res, vis: binding.vis, reexport_chain }; + + let second = ModChild { + ident: ident.0, + res: ambig_binding2.res().expect_non_local(), + vis: ambig_binding2.vis, + reexport_chain: ambig_binding2.reexport_chain(this), + }; + let kind = match ambig_kind { + AmbiguityKind::GlobVsGlob => AmbigModChildKind::GlobVsGlob, + AmbiguityKind::GlobVsExpanded => AmbigModChildKind::GlobVsExpanded, + _ => unreachable!(), + }; - children.push(ModChild { ident: ident.0, res, vis: binding.vis, reexport_chain }); + let warn_ambiguity = binding.warn_ambiguity_recursive(); + ambig_children.push(AmbigModChild { main, second, kind, warn_ambiguity }) + } else { + let reexport_chain = binding.reexport_chain(this); + let child = ModChild { ident: ident.0, res, vis: binding.vis, reexport_chain }; + children.push(child); + } } }); if !children.is_empty() { - // Should be fine because this code is only called for local modules. module_children.insert(def_id.expect_local(), children); } + if !ambig_children.is_empty() { + ambig_module_children.insert(def_id.expect_local(), ambig_children); + } } } diff --git a/compiler/rustc_resolve/src/lib.rs b/compiler/rustc_resolve/src/lib.rs index 1636605b234f4..8973dbc533a3c 100644 --- a/compiler/rustc_resolve/src/lib.rs +++ b/compiler/rustc_resolve/src/lib.rs @@ -64,7 +64,7 @@ use rustc_hir::definitions::DisambiguatorState; use rustc_hir::{PrimTy, TraitCandidate}; use rustc_index::bit_set::DenseBitSet; use rustc_metadata::creader::CStore; -use rustc_middle::metadata::ModChild; +use rustc_middle::metadata::{AmbigModChild, ModChild, Reexport}; use rustc_middle::middle::privacy::EffectiveVisibilities; use rustc_middle::query::Providers; use rustc_middle::span_bug; @@ -928,6 +928,18 @@ impl<'ra> NameBindingData<'ra> { } } + fn descent_to_ambiguity( + self: NameBinding<'ra>, + ) -> Option<(NameBinding<'ra>, NameBinding<'ra>, AmbiguityKind)> { + match self.ambiguity { + Some((ambig_binding, ambig_kind)) => Some((self, ambig_binding, ambig_kind)), + None => match self.kind { + NameBindingKind::Import { binding, .. } => binding.descent_to_ambiguity(), + _ => None, + }, + } + } + fn is_ambiguity_recursive(&self) -> bool { self.ambiguity.is_some() || match self.kind { @@ -991,6 +1003,16 @@ impl<'ra> NameBindingData<'ra> { self.res().macro_kinds() } + fn reexport_chain(self: NameBinding<'ra>, r: &Resolver<'_, '_>) -> SmallVec<[Reexport; 2]> { + let mut reexport_chain = SmallVec::new(); + let mut next_binding = self; + while let NameBindingKind::Import { binding, import, .. } = next_binding.kind { + reexport_chain.push(import.simplify(r)); + next_binding = binding; + } + reexport_chain + } + // Suppose that we resolved macro invocation with `invoc_parent_expansion` to binding `binding` // at some expansion round `max(invoc, binding)` when they both emerged from macros. // Then this function returns `true` if `self` may emerge from a macro *after* that @@ -1124,6 +1146,7 @@ pub struct Resolver<'ra, 'tcx> { /// `CrateNum` resolutions of `extern crate` items. extern_crate_map: UnordMap, module_children: LocalDefIdMap>, + ambig_module_children: LocalDefIdMap>, trait_map: NodeMap>, /// A map from nodes to anonymous modules. @@ -1581,6 +1604,7 @@ impl<'ra, 'tcx> Resolver<'ra, 'tcx> { extra_lifetime_params_map: Default::default(), extern_crate_map: Default::default(), module_children: Default::default(), + ambig_module_children: Default::default(), trait_map: NodeMap::default(), empty_module, local_modules, @@ -1767,6 +1791,7 @@ impl<'ra, 'tcx> Resolver<'ra, 'tcx> { effective_visibilities, extern_crate_map, module_children: self.module_children, + ambig_module_children: self.ambig_module_children, glob_map, maybe_unused_trait_imports, main_def, diff --git a/tests/ui/imports/ambiguous-2.rs b/tests/ui/imports/ambiguous-2.rs index 087431485ad62..65c971c00b9ac 100644 --- a/tests/ui/imports/ambiguous-2.rs +++ b/tests/ui/imports/ambiguous-2.rs @@ -1,10 +1,9 @@ -//@ check-pass //@ aux-build: ../ambiguous-1.rs // https://github.com/rust-lang/rust/pull/113099#issuecomment-1633574396 extern crate ambiguous_1; fn main() { - ambiguous_1::id(); - //^ FIXME: `id` should be identified as an ambiguous item. + ambiguous_1::id(); //~ ERROR `id` is ambiguous + //~| WARN this was previously accepted } diff --git a/tests/ui/imports/ambiguous-2.stderr b/tests/ui/imports/ambiguous-2.stderr new file mode 100644 index 0000000000000..d428e58a78fd7 --- /dev/null +++ b/tests/ui/imports/ambiguous-2.stderr @@ -0,0 +1,45 @@ +error: `id` is ambiguous + --> $DIR/ambiguous-2.rs:7:18 + | +LL | ambiguous_1::id(); + | ^^ 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: `id` could refer to the function defined here + --> $DIR/auxiliary/../ambiguous-1.rs:13:13 + | +LL | pub use self::evp::*; + | ^^^^^^^^^ +note: `id` could also refer to the function defined here + --> $DIR/auxiliary/../ambiguous-1.rs:15:13 + | +LL | pub use self::handwritten::*; + | ^^^^^^^^^^^^^^^^^ + = note: `#[deny(ambiguous_glob_imports)]` (part of `#[deny(future_incompatible)]`) on by default + +error: aborting due to 1 previous error + +Future incompatibility report: Future breakage diagnostic: +error: `id` is ambiguous + --> $DIR/ambiguous-2.rs:7:18 + | +LL | ambiguous_1::id(); + | ^^ 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: `id` could refer to the function defined here + --> $DIR/auxiliary/../ambiguous-1.rs:13:13 + | +LL | pub use self::evp::*; + | ^^^^^^^^^ +note: `id` could also refer to the function defined here + --> $DIR/auxiliary/../ambiguous-1.rs:15:13 + | +LL | pub use self::handwritten::*; + | ^^^^^^^^^^^^^^^^^ + = note: `#[deny(ambiguous_glob_imports)]` (part of `#[deny(future_incompatible)]`) on by default + diff --git a/tests/ui/imports/ambiguous-4.rs b/tests/ui/imports/ambiguous-4.rs index 3a9a14bfb524e..f7465215c9460 100644 --- a/tests/ui/imports/ambiguous-4.rs +++ b/tests/ui/imports/ambiguous-4.rs @@ -1,9 +1,8 @@ -//@ check-pass //@ aux-build: ../ambiguous-4-extern.rs extern crate ambiguous_4_extern; fn main() { - ambiguous_4_extern::id(); - //^ FIXME: `id` should be identified as an ambiguous item. + ambiguous_4_extern::id(); //~ ERROR `id` is ambiguous + //~| WARN this was previously accepted } diff --git a/tests/ui/imports/ambiguous-4.stderr b/tests/ui/imports/ambiguous-4.stderr new file mode 100644 index 0000000000000..02acf7f70b20b --- /dev/null +++ b/tests/ui/imports/ambiguous-4.stderr @@ -0,0 +1,45 @@ +error: `id` is ambiguous + --> $DIR/ambiguous-4.rs:6:25 + | +LL | ambiguous_4_extern::id(); + | ^^ 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: `id` could refer to the function defined here + --> $DIR/auxiliary/../ambiguous-4-extern.rs:12:9 + | +LL | pub use evp::*; + | ^^^ +note: `id` could also refer to the function defined here + --> $DIR/auxiliary/../ambiguous-4-extern.rs:13:9 + | +LL | pub use handwritten::*; + | ^^^^^^^^^^^ + = note: `#[deny(ambiguous_glob_imports)]` (part of `#[deny(future_incompatible)]`) on by default + +error: aborting due to 1 previous error + +Future incompatibility report: Future breakage diagnostic: +error: `id` is ambiguous + --> $DIR/ambiguous-4.rs:6:25 + | +LL | ambiguous_4_extern::id(); + | ^^ 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: `id` could refer to the function defined here + --> $DIR/auxiliary/../ambiguous-4-extern.rs:12:9 + | +LL | pub use evp::*; + | ^^^ +note: `id` could also refer to the function defined here + --> $DIR/auxiliary/../ambiguous-4-extern.rs:13:9 + | +LL | pub use handwritten::*; + | ^^^^^^^^^^^ + = note: `#[deny(ambiguous_glob_imports)]` (part of `#[deny(future_incompatible)]`) on by default + diff --git a/tests/ui/imports/extern-with-ambiguous-2.rs b/tests/ui/imports/extern-with-ambiguous-2.rs index dcab2bcc18eac..477d29ad0120d 100644 --- a/tests/ui/imports/extern-with-ambiguous-2.rs +++ b/tests/ui/imports/extern-with-ambiguous-2.rs @@ -1,4 +1,3 @@ -//@ check-pass //@ edition: 2021 //@ aux-build: extern-with-ambiguous-2-extern.rs @@ -11,8 +10,6 @@ mod s { } use s::*; use extern_with_ambiguous_2_extern::*; -use error::*; -//^ FIXME: An ambiguity error should be thrown for `error`, -// as there is ambiguity present within `extern-with-ambiguous-2-extern.rs`. +use error::*; //~ ERROR `error` is ambiguous fn main() {} diff --git a/tests/ui/imports/extern-with-ambiguous-2.stderr b/tests/ui/imports/extern-with-ambiguous-2.stderr new file mode 100644 index 0000000000000..2fd66932e4ed2 --- /dev/null +++ b/tests/ui/imports/extern-with-ambiguous-2.stderr @@ -0,0 +1,23 @@ +error[E0659]: `error` is ambiguous + --> $DIR/extern-with-ambiguous-2.rs:13:5 + | +LL | use error::*; + | ^^^^^ ambiguous name + | + = note: ambiguous because of multiple glob imports of a name in the same module +note: `error` could refer to the module imported here + --> $DIR/extern-with-ambiguous-2.rs:11:5 + | +LL | use s::*; + | ^^^^ + = help: consider adding an explicit import of `error` to disambiguate +note: `error` could also refer to the module imported here + --> $DIR/extern-with-ambiguous-2.rs:12:5 + | +LL | use extern_with_ambiguous_2_extern::*; + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + = help: consider adding an explicit import of `error` to disambiguate + +error: aborting due to 1 previous error + +For more information about this error, try `rustc --explain E0659`. diff --git a/tests/ui/imports/extern-with-ambiguous-3.rs b/tests/ui/imports/extern-with-ambiguous-3.rs index c65fedbe2c1df..c0c4741ec56a0 100644 --- a/tests/ui/imports/extern-with-ambiguous-3.rs +++ b/tests/ui/imports/extern-with-ambiguous-3.rs @@ -1,4 +1,3 @@ -//@ check-pass //@ edition: 2021 //@ aux-build: extern-with-ambiguous-3-extern.rs // https://github.com/rust-lang/rust/pull/113099#issuecomment-1643974121 @@ -12,8 +11,6 @@ mod s { } use s::*; use extern_with_ambiguous_3_extern::*; -use error::*; -//^ FIXME: An ambiguity error should be thrown for `error`, -// as there is ambiguity present within `extern-with-ambiguous-3-extern.rs`. +use error::*; //~ ERROR `error` is ambiguous fn main() {} diff --git a/tests/ui/imports/extern-with-ambiguous-3.stderr b/tests/ui/imports/extern-with-ambiguous-3.stderr new file mode 100644 index 0000000000000..95a1175c56b3b --- /dev/null +++ b/tests/ui/imports/extern-with-ambiguous-3.stderr @@ -0,0 +1,23 @@ +error[E0659]: `error` is ambiguous + --> $DIR/extern-with-ambiguous-3.rs:14:5 + | +LL | use error::*; + | ^^^^^ ambiguous name + | + = note: ambiguous because of multiple glob imports of a name in the same module +note: `error` could refer to the module imported here + --> $DIR/extern-with-ambiguous-3.rs:12:5 + | +LL | use s::*; + | ^^^^ + = help: consider adding an explicit import of `error` to disambiguate +note: `error` could also refer to the module imported here + --> $DIR/extern-with-ambiguous-3.rs:13:5 + | +LL | use extern_with_ambiguous_3_extern::*; + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + = help: consider adding an explicit import of `error` to disambiguate + +error: aborting due to 1 previous error + +For more information about this error, try `rustc --explain E0659`. diff --git a/tests/ui/imports/glob-conflict-cross-crate-1.rs b/tests/ui/imports/glob-conflict-cross-crate-1.rs index 5f0433d13fcfd..2a8e85c79931c 100644 --- a/tests/ui/imports/glob-conflict-cross-crate-1.rs +++ b/tests/ui/imports/glob-conflict-cross-crate-1.rs @@ -3,10 +3,6 @@ extern crate glob_conflict; 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` - //^ FIXME: `glob_conflict::glob::f` should raise an - // ambiguity error instead of a not found error. + glob_conflict::f(); //~ ERROR `f` is ambiguous + glob_conflict::glob::f(); //~ ERROR `f` is ambiguous } diff --git a/tests/ui/imports/glob-conflict-cross-crate-1.stderr b/tests/ui/imports/glob-conflict-cross-crate-1.stderr index 758087107f397..6c26e8e818879 100644 --- a/tests/ui/imports/glob-conflict-cross-crate-1.stderr +++ b/tests/ui/imports/glob-conflict-cross-crate-1.stderr @@ -1,15 +1,39 @@ -error[E0425]: cannot find function `f` in crate `glob_conflict` +error[E0659]: `f` is ambiguous --> $DIR/glob-conflict-cross-crate-1.rs:6:20 | LL | glob_conflict::f(); - | ^ not found in `glob_conflict` + | ^ ambiguous name + | + = note: ambiguous because of multiple glob imports of a name in the same module +note: `f` could refer to the function defined here + --> $DIR/auxiliary/glob-conflict.rs:10:9 + | +LL | pub use m1::*; + | ^^ +note: `f` could also refer to the function defined here + --> $DIR/auxiliary/glob-conflict.rs:11:9 + | +LL | pub use m2::*; + | ^^ -error[E0425]: cannot find function `f` in module `glob_conflict::glob` - --> $DIR/glob-conflict-cross-crate-1.rs:9:26 +error[E0659]: `f` is ambiguous + --> $DIR/glob-conflict-cross-crate-1.rs:7:26 | LL | glob_conflict::glob::f(); - | ^ not found in `glob_conflict::glob` + | ^ ambiguous name + | + = note: ambiguous because of multiple glob imports of a name in the same module +note: `f` could refer to the function defined here + --> $DIR/auxiliary/glob-conflict.rs:10:9 + | +LL | pub use m1::*; + | ^^ +note: `f` could also refer to the function defined here + --> $DIR/auxiliary/glob-conflict.rs:11:9 + | +LL | pub use m2::*; + | ^^ error: aborting due to 2 previous errors -For more information about this error, try `rustc --explain E0425`. +For more information about this error, try `rustc --explain E0659`. diff --git a/tests/ui/imports/glob-conflict-cross-crate-2.rs b/tests/ui/imports/glob-conflict-cross-crate-2.rs index b764685dd5796..2465f15abdccd 100644 --- a/tests/ui/imports/glob-conflict-cross-crate-2.rs +++ b/tests/ui/imports/glob-conflict-cross-crate-2.rs @@ -5,6 +5,5 @@ extern crate glob_conflict_cross_crate_2_extern; use glob_conflict_cross_crate_2_extern::*; fn main() { - let _a: C = 1; //~ ERROR cannot find type `C` in this scope - //^ FIXME: `C` should be identified as an ambiguous item. + let _a: C = 1; //~ ERROR `C` is ambiguous } diff --git a/tests/ui/imports/glob-conflict-cross-crate-2.stderr b/tests/ui/imports/glob-conflict-cross-crate-2.stderr index aebb2d59d063a..0641dbd665c90 100644 --- a/tests/ui/imports/glob-conflict-cross-crate-2.stderr +++ b/tests/ui/imports/glob-conflict-cross-crate-2.stderr @@ -1,9 +1,21 @@ -error[E0412]: cannot find type `C` in this scope +error[E0659]: `C` is ambiguous --> $DIR/glob-conflict-cross-crate-2.rs:8:13 | LL | let _a: C = 1; - | ^ not found in this scope + | ^ ambiguous name + | + = note: ambiguous because of multiple glob imports of a name in the same module +note: `C` could refer to the type alias defined here + --> $DIR/auxiliary/glob-conflict-cross-crate-2-extern.rs:9:9 + | +LL | pub use a::*; + | ^ +note: `C` could also refer to the type alias defined here + --> $DIR/auxiliary/glob-conflict-cross-crate-2-extern.rs:10:9 + | +LL | pub use b::*; + | ^ error: aborting due to 1 previous error -For more information about this error, try `rustc --explain E0412`. +For more information about this error, try `rustc --explain E0659`. diff --git a/tests/ui/imports/glob-conflict-cross-crate-3.rs b/tests/ui/imports/glob-conflict-cross-crate-3.rs index 7797b5b7c069a..c6f104e6358de 100644 --- a/tests/ui/imports/glob-conflict-cross-crate-3.rs +++ b/tests/ui/imports/glob-conflict-cross-crate-3.rs @@ -1,4 +1,3 @@ -//@ check-pass //@ aux-build:glob-conflict-cross-crate-2-extern.rs extern crate glob_conflict_cross_crate_2_extern; @@ -12,5 +11,6 @@ use a::*; fn main() { let _a: C = 1; - //^ FIXME: `C` should be identified as an ambiguous item. + //~^ ERROR `C` is ambiguous + //~| ERROR `C` is ambiguous } diff --git a/tests/ui/imports/glob-conflict-cross-crate-3.stderr b/tests/ui/imports/glob-conflict-cross-crate-3.stderr new file mode 100644 index 0000000000000..1de00dff585d6 --- /dev/null +++ b/tests/ui/imports/glob-conflict-cross-crate-3.stderr @@ -0,0 +1,41 @@ +error[E0659]: `C` is ambiguous + --> $DIR/glob-conflict-cross-crate-3.rs:13:13 + | +LL | let _a: C = 1; + | ^ ambiguous name + | + = note: ambiguous because of multiple glob imports of a name in the same module +note: `C` could refer to the type alias imported here + --> $DIR/glob-conflict-cross-crate-3.rs:9:5 + | +LL | use glob_conflict_cross_crate_2_extern::*; + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + = help: consider adding an explicit import of `C` to disambiguate +note: `C` could also refer to the type alias imported here + --> $DIR/glob-conflict-cross-crate-3.rs:10:5 + | +LL | use a::*; + | ^^^^ + = help: consider adding an explicit import of `C` to disambiguate + +error[E0659]: `C` is ambiguous + --> $DIR/glob-conflict-cross-crate-3.rs:13:13 + | +LL | let _a: C = 1; + | ^ ambiguous name + | + = note: ambiguous because of multiple glob imports of a name in the same module +note: `C` could refer to the type alias defined here + --> $DIR/auxiliary/glob-conflict-cross-crate-2-extern.rs:9:9 + | +LL | pub use a::*; + | ^ +note: `C` could also refer to the type alias defined here + --> $DIR/auxiliary/glob-conflict-cross-crate-2-extern.rs:10:9 + | +LL | pub use b::*; + | ^ + +error: aborting due to 2 previous errors + +For more information about this error, try `rustc --explain E0659`. diff --git a/tests/ui/imports/issue-114682-2.rs b/tests/ui/imports/issue-114682-2.rs index e99bcf77ab62d..767a51e63eb6d 100644 --- a/tests/ui/imports/issue-114682-2.rs +++ b/tests/ui/imports/issue-114682-2.rs @@ -3,17 +3,8 @@ extern crate issue_114682_2_extern; -use issue_114682_2_extern::max; +use issue_114682_2_extern::max; //~ ERROR `max` is ambiguous -type A = issue_114682_2_extern::max; -//~^ ERROR: expected type, found function `issue_114682_2_extern::max` -// FIXME: -// The above error was emitted due to `(Mod(issue_114682_2_extern), Namespace(Type), Ident(max))` -// being identified as an ambiguous item. -// However, there are two points worth discussing: -// First, should this ambiguous item be omitted considering the maximum visibility -// of `issue_114682_2_extern::m::max` in the type namespace is only within the extern crate. -// Second, if we retain the ambiguous item of the extern crate, should it be treated -// as an ambiguous item within the local crate for the same reasoning? +type A = issue_114682_2_extern::max; //~ ERROR `max` is ambiguous fn main() {} diff --git a/tests/ui/imports/issue-114682-2.stderr b/tests/ui/imports/issue-114682-2.stderr index 972bcecb56bc2..1a15d3d105433 100644 --- a/tests/ui/imports/issue-114682-2.stderr +++ b/tests/ui/imports/issue-114682-2.stderr @@ -1,9 +1,39 @@ -error[E0573]: expected type, found function `issue_114682_2_extern::max` - --> $DIR/issue-114682-2.rs:8:10 +error[E0659]: `max` is ambiguous + --> $DIR/issue-114682-2.rs:6:28 + | +LL | use issue_114682_2_extern::max; + | ^^^ ambiguous name + | + = note: ambiguous because of multiple glob imports of a name in the same module +note: `max` could refer to the type alias defined here + --> $DIR/auxiliary/issue-114682-2-extern.rs:17:9 + | +LL | pub use self::e::*; + | ^^^^^^^ +note: `max` could also refer to the module defined here + --> $DIR/auxiliary/issue-114682-2-extern.rs:16:9 + | +LL | pub use self::d::*; + | ^^^^^^^ + +error[E0659]: `max` is ambiguous + --> $DIR/issue-114682-2.rs:8:33 | LL | type A = issue_114682_2_extern::max; - | ^^^^^^^^^^^^^^^^^^^^^^^^^^ not a type + | ^^^ ambiguous name + | + = note: ambiguous because of multiple glob imports of a name in the same module +note: `max` could refer to the type alias defined here + --> $DIR/auxiliary/issue-114682-2-extern.rs:17:9 + | +LL | pub use self::e::*; + | ^^^^^^^ +note: `max` could also refer to the module defined here + --> $DIR/auxiliary/issue-114682-2-extern.rs:16:9 + | +LL | pub use self::d::*; + | ^^^^^^^ -error: aborting due to 1 previous error +error: aborting due to 2 previous errors -For more information about this error, try `rustc --explain E0573`. +For more information about this error, try `rustc --explain E0659`. diff --git a/tests/ui/imports/issue-114682-3.rs b/tests/ui/imports/issue-114682-3.rs index 6dc4df17a2daf..ac603b49e3215 100644 --- a/tests/ui/imports/issue-114682-3.rs +++ b/tests/ui/imports/issue-114682-3.rs @@ -1,4 +1,3 @@ -//@ check-pass //@ aux-build: issue-114682-3-extern.rs // https://github.com/rust-lang/rust/pull/114682#issuecomment-1880625909 @@ -19,6 +18,5 @@ pub use self::auto::*; fn main() { let a: u8 = 1; a.ext(); - //^ FIXME: it should report `ext` not found because `SettingsExt` - // is an ambiguous item in `issue-114682-3-extern.rs`. + //~^ ERROR no method named `ext` found for type `u8` in the current scope } diff --git a/tests/ui/imports/issue-114682-3.stderr b/tests/ui/imports/issue-114682-3.stderr new file mode 100644 index 0000000000000..6af7a4e026140 --- /dev/null +++ b/tests/ui/imports/issue-114682-3.stderr @@ -0,0 +1,18 @@ +error[E0599]: no method named `ext` found for type `u8` in the current scope + --> $DIR/issue-114682-3.rs:20:7 + | +LL | fn ext(&self) {} + | --- the method is available for `u8` here +... +LL | a.ext(); + | ^^^ method not found in `u8` + | + = help: items from traits can only be used if the trait is in scope +help: trait `SettingsExt` which provides `ext` is implemented but not in scope; perhaps you want to import it + | +LL + use auto::SettingsExt; + | + +error: aborting due to 1 previous error + +For more information about this error, try `rustc --explain E0599`. diff --git a/tests/ui/imports/issue-114682-4.rs b/tests/ui/imports/issue-114682-4.rs index 32c2ca7b26097..40f4b95d41493 100644 --- a/tests/ui/imports/issue-114682-4.rs +++ b/tests/ui/imports/issue-114682-4.rs @@ -1,4 +1,3 @@ -//@ check-pass //@ aux-build: issue-114682-4-extern.rs // https://github.com/rust-lang/rust/pull/114682#issuecomment-1880755441 @@ -6,7 +5,8 @@ extern crate issue_114682_4_extern; use issue_114682_4_extern::*; -fn a() -> Result { // FIXME: `Result` should be identified as an ambiguous item. +//~v ERROR type alias takes 1 generic argument but 2 generic arguments were supplied +fn a() -> Result { //~ ERROR `Result` is ambiguous Ok(1) } diff --git a/tests/ui/imports/issue-114682-4.stderr b/tests/ui/imports/issue-114682-4.stderr new file mode 100644 index 0000000000000..3a3d2ab5fd134 --- /dev/null +++ b/tests/ui/imports/issue-114682-4.stderr @@ -0,0 +1,36 @@ +error[E0659]: `Result` is ambiguous + --> $DIR/issue-114682-4.rs:9:11 + | +LL | fn a() -> Result { + | ^^^^^^ ambiguous name + | + = note: ambiguous because of multiple glob imports of a name in the same module +note: `Result` could refer to the type alias defined here + --> $DIR/auxiliary/issue-114682-4-extern.rs:9:9 + | +LL | pub use a::*; + | ^ +note: `Result` could also refer to the type alias defined here + --> $DIR/auxiliary/issue-114682-4-extern.rs:10:9 + | +LL | pub use b::*; + | ^ + +error[E0107]: type alias takes 1 generic argument but 2 generic arguments were supplied + --> $DIR/issue-114682-4.rs:9:11 + | +LL | fn a() -> Result { + | ^^^^^^ ---- help: remove the unnecessary generic argument + | | + | expected 1 generic argument + | +note: type alias defined here, with 1 generic parameter: `T` + --> $DIR/auxiliary/issue-114682-4-extern.rs:2:14 + | +LL | pub type Result = std::result::Result; + | ^^^^^^ - + +error: aborting due to 2 previous errors + +Some errors have detailed explanations: E0107, E0659. +For more information about an error, try `rustc --explain E0107`. diff --git a/tests/ui/imports/issue-114682-5.rs b/tests/ui/imports/issue-114682-5.rs index 7c6132ebd6ffd..16287dae6c456 100644 --- a/tests/ui/imports/issue-114682-5.rs +++ b/tests/ui/imports/issue-114682-5.rs @@ -1,4 +1,3 @@ -//@ check-pass //@ edition: 2018 //@ aux-build: issue-114682-5-extern-1.rs //@ aux-build: issue-114682-5-extern-2.rs @@ -9,7 +8,8 @@ extern crate issue_114682_5_extern_2; use issue_114682_5_extern_2::p::*; use issue_114682_5_extern_1::Url; -// FIXME: The `issue_114682_5_extern_1` should be considered an ambiguous item, -// as it has already been recognized as ambiguous in `issue_114682_5_extern_2`. +//~^ ERROR `issue_114682_5_extern_1` is ambiguous +//~| ERROR `issue_114682_5_extern_1` is ambiguous +//~| ERROR unresolved import `issue_114682_5_extern_1::Url` fn main() {} diff --git a/tests/ui/imports/issue-114682-5.stderr b/tests/ui/imports/issue-114682-5.stderr new file mode 100644 index 0000000000000..e89d3f9683461 --- /dev/null +++ b/tests/ui/imports/issue-114682-5.stderr @@ -0,0 +1,51 @@ +error[E0432]: unresolved import `issue_114682_5_extern_1::Url` + --> $DIR/issue-114682-5.rs:10:5 + | +LL | use issue_114682_5_extern_1::Url; + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ no `Url` in `types::issue_114682_5_extern_1` + | +help: consider importing this struct instead + | +LL | use ::issue_114682_5_extern_1::Url; + | ++ + +error[E0659]: `issue_114682_5_extern_1` is ambiguous + --> $DIR/issue-114682-5.rs:10:5 + | +LL | use issue_114682_5_extern_1::Url; + | ^^^^^^^^^^^^^^^^^^^^^^^ ambiguous name + | + = note: ambiguous because of multiple glob imports of a name in the same module +note: `issue_114682_5_extern_1` could refer to the module defined here + --> $DIR/auxiliary/issue-114682-5-extern-2.rs:6:13 + | +LL | pub use crate::types::*; + | ^^^^^^^^^^^^ +note: `issue_114682_5_extern_1` could also refer to the crate defined here + --> $DIR/auxiliary/issue-114682-5-extern-2.rs:7:13 + | +LL | pub use crate::*; + | ^^^^^ + = help: use `::issue_114682_5_extern_1` to refer to this crate unambiguously + +error[E0659]: `issue_114682_5_extern_1` is ambiguous + --> $DIR/issue-114682-5.rs:10:5 + | +LL | use issue_114682_5_extern_1::Url; + | ^^^^^^^^^^^^^^^^^^^^^^^ 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_114682_5_extern_1` could refer to a crate passed with `--extern` + = help: use `::issue_114682_5_extern_1` to refer to this crate unambiguously +note: `issue_114682_5_extern_1` could also refer to the module imported here + --> $DIR/issue-114682-5.rs:9:5 + | +LL | use issue_114682_5_extern_2::p::*; + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + = help: consider adding an explicit import of `issue_114682_5_extern_1` to disambiguate + = help: or use `crate::issue_114682_5_extern_1` to refer to this module unambiguously + +error: aborting due to 3 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-114682-6.rs b/tests/ui/imports/issue-114682-6.rs index d47b9f8a4e857..671b59706bd18 100644 --- a/tests/ui/imports/issue-114682-6.rs +++ b/tests/ui/imports/issue-114682-6.rs @@ -1,4 +1,3 @@ -//@ check-pass //@ aux-build: issue-114682-6-extern.rs // https://github.com/rust-lang/rust/pull/114682#issuecomment-1880755441 @@ -7,7 +6,6 @@ extern crate issue_114682_6_extern; use issue_114682_6_extern::*; fn main() { - let log = 2; - //^ `log` should be identified as an ambiguous item. + let log = 2; //~ ERROR `log` is ambiguous let _ = log; } diff --git a/tests/ui/imports/issue-114682-6.stderr b/tests/ui/imports/issue-114682-6.stderr new file mode 100644 index 0000000000000..924a46858d353 --- /dev/null +++ b/tests/ui/imports/issue-114682-6.stderr @@ -0,0 +1,21 @@ +error[E0659]: `log` is ambiguous + --> $DIR/issue-114682-6.rs:9:9 + | +LL | let log = 2; + | ^^^ ambiguous name + | + = note: ambiguous because of multiple glob imports of a name in the same module +note: `log` could refer to the function defined here + --> $DIR/auxiliary/issue-114682-6-extern.rs:8:9 + | +LL | pub use self::a::*; + | ^^^^^^^ +note: `log` could also refer to the function defined here + --> $DIR/auxiliary/issue-114682-6-extern.rs:9:9 + | +LL | pub use self::b::*; + | ^^^^^^^ + +error: aborting due to 1 previous error + +For more information about this error, try `rustc --explain E0659`. From e388d621b8ecf8165631d304028f3d4794ec3978 Mon Sep 17 00:00:00 2001 From: Vadim Petrochenkov Date: Wed, 22 Oct 2025 16:06:43 +0300 Subject: [PATCH 2/2] report everything as a lint for crater --- .../rustc_resolve/src/build_reduced_graph.rs | 5 +- .../ui/imports/glob-conflict-cross-crate-1.rs | 2 + .../glob-conflict-cross-crate-1.stderr | 56 ++++++++++++++++-- .../ui/imports/glob-conflict-cross-crate-2.rs | 1 + .../glob-conflict-cross-crate-2.stderr | 28 ++++++++- .../ui/imports/glob-conflict-cross-crate-3.rs | 2 + .../glob-conflict-cross-crate-3.stderr | 58 +++++++++++++++++-- tests/ui/imports/issue-114682-2.rs | 2 + tests/ui/imports/issue-114682-2.stderr | 56 ++++++++++++++++-- tests/ui/imports/issue-114682-4.rs | 1 + tests/ui/imports/issue-114682-4.stderr | 30 +++++++++- tests/ui/imports/issue-114682-5.rs | 1 + tests/ui/imports/issue-114682-5.stderr | 54 ++++++++++++----- tests/ui/imports/issue-114682-6.rs | 1 + tests/ui/imports/issue-114682-6.stderr | 28 ++++++++- 15 files changed, 290 insertions(+), 35 deletions(-) diff --git a/compiler/rustc_resolve/src/build_reduced_graph.rs b/compiler/rustc_resolve/src/build_reduced_graph.rs index e07bce38e49ac..a544b891e89ff 100644 --- a/compiler/rustc_resolve/src/build_reduced_graph.rs +++ b/compiler/rustc_resolve/src/build_reduced_graph.rs @@ -83,12 +83,13 @@ impl<'ra, 'tcx> Resolver<'ra, 'tcx> { span: Span, expansion: LocalExpnId, ambiguity: Option<(NameBinding<'ra>, AmbiguityKind)>, - warn_ambiguity: bool, + _warn_ambiguity: bool, ) { let binding = self.arenas.alloc_name_binding(NameBindingData { kind: NameBindingKind::Res(res), ambiguity, - warn_ambiguity, + // FIXME: report everything as a lint for crater + warn_ambiguity: true, vis, span, expansion, diff --git a/tests/ui/imports/glob-conflict-cross-crate-1.rs b/tests/ui/imports/glob-conflict-cross-crate-1.rs index 2a8e85c79931c..5d4e741258b26 100644 --- a/tests/ui/imports/glob-conflict-cross-crate-1.rs +++ b/tests/ui/imports/glob-conflict-cross-crate-1.rs @@ -4,5 +4,7 @@ extern crate glob_conflict; fn main() { glob_conflict::f(); //~ ERROR `f` is ambiguous + //~| WARN this was previously accepted glob_conflict::glob::f(); //~ ERROR `f` is ambiguous + //~| WARN this was previously accepted } diff --git a/tests/ui/imports/glob-conflict-cross-crate-1.stderr b/tests/ui/imports/glob-conflict-cross-crate-1.stderr index 6c26e8e818879..ac5240cfd3cad 100644 --- a/tests/ui/imports/glob-conflict-cross-crate-1.stderr +++ b/tests/ui/imports/glob-conflict-cross-crate-1.stderr @@ -1,9 +1,11 @@ -error[E0659]: `f` is ambiguous +error: `f` is ambiguous --> $DIR/glob-conflict-cross-crate-1.rs:6:20 | LL | glob_conflict::f(); | ^ 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: `f` could refer to the function defined here --> $DIR/auxiliary/glob-conflict.rs:10:9 @@ -15,13 +17,16 @@ note: `f` could also refer to the function defined here | LL | pub use m2::*; | ^^ + = note: `#[deny(ambiguous_glob_imports)]` (part of `#[deny(future_incompatible)]`) on by default -error[E0659]: `f` is ambiguous - --> $DIR/glob-conflict-cross-crate-1.rs:7:26 +error: `f` is ambiguous + --> $DIR/glob-conflict-cross-crate-1.rs:8:26 | LL | glob_conflict::glob::f(); | ^ 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: `f` could refer to the function defined here --> $DIR/auxiliary/glob-conflict.rs:10:9 @@ -36,4 +41,47 @@ LL | pub use m2::*; error: aborting due to 2 previous errors -For more information about this error, try `rustc --explain E0659`. +Future incompatibility report: Future breakage diagnostic: +error: `f` is ambiguous + --> $DIR/glob-conflict-cross-crate-1.rs:6:20 + | +LL | glob_conflict::f(); + | ^ 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: `f` could refer to the function defined here + --> $DIR/auxiliary/glob-conflict.rs:10:9 + | +LL | pub use m1::*; + | ^^ +note: `f` could also refer to the function defined here + --> $DIR/auxiliary/glob-conflict.rs:11:9 + | +LL | pub use m2::*; + | ^^ + = note: `#[deny(ambiguous_glob_imports)]` (part of `#[deny(future_incompatible)]`) on by default + +Future breakage diagnostic: +error: `f` is ambiguous + --> $DIR/glob-conflict-cross-crate-1.rs:8:26 + | +LL | glob_conflict::glob::f(); + | ^ 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: `f` could refer to the function defined here + --> $DIR/auxiliary/glob-conflict.rs:10:9 + | +LL | pub use m1::*; + | ^^ +note: `f` could also refer to the function defined here + --> $DIR/auxiliary/glob-conflict.rs:11:9 + | +LL | pub use m2::*; + | ^^ + = note: `#[deny(ambiguous_glob_imports)]` (part of `#[deny(future_incompatible)]`) on by default + diff --git a/tests/ui/imports/glob-conflict-cross-crate-2.rs b/tests/ui/imports/glob-conflict-cross-crate-2.rs index 2465f15abdccd..b4dd3d8eeb443 100644 --- a/tests/ui/imports/glob-conflict-cross-crate-2.rs +++ b/tests/ui/imports/glob-conflict-cross-crate-2.rs @@ -6,4 +6,5 @@ use glob_conflict_cross_crate_2_extern::*; fn main() { let _a: C = 1; //~ ERROR `C` is ambiguous + //~| WARN this was previously accepted } diff --git a/tests/ui/imports/glob-conflict-cross-crate-2.stderr b/tests/ui/imports/glob-conflict-cross-crate-2.stderr index 0641dbd665c90..cbc2180c14f43 100644 --- a/tests/ui/imports/glob-conflict-cross-crate-2.stderr +++ b/tests/ui/imports/glob-conflict-cross-crate-2.stderr @@ -1,9 +1,11 @@ -error[E0659]: `C` is ambiguous +error: `C` is ambiguous --> $DIR/glob-conflict-cross-crate-2.rs:8:13 | LL | let _a: C = 1; | ^ 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: `C` could refer to the type alias defined here --> $DIR/auxiliary/glob-conflict-cross-crate-2-extern.rs:9:9 @@ -15,7 +17,29 @@ note: `C` could also refer to the type alias defined here | LL | pub use b::*; | ^ + = note: `#[deny(ambiguous_glob_imports)]` (part of `#[deny(future_incompatible)]`) on by default error: aborting due to 1 previous error -For more information about this error, try `rustc --explain E0659`. +Future incompatibility report: Future breakage diagnostic: +error: `C` is ambiguous + --> $DIR/glob-conflict-cross-crate-2.rs:8:13 + | +LL | let _a: C = 1; + | ^ 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: `C` could refer to the type alias defined here + --> $DIR/auxiliary/glob-conflict-cross-crate-2-extern.rs:9:9 + | +LL | pub use a::*; + | ^ +note: `C` could also refer to the type alias defined here + --> $DIR/auxiliary/glob-conflict-cross-crate-2-extern.rs:10:9 + | +LL | pub use b::*; + | ^ + = note: `#[deny(ambiguous_glob_imports)]` (part of `#[deny(future_incompatible)]`) on by default + diff --git a/tests/ui/imports/glob-conflict-cross-crate-3.rs b/tests/ui/imports/glob-conflict-cross-crate-3.rs index c6f104e6358de..31c234b9250fc 100644 --- a/tests/ui/imports/glob-conflict-cross-crate-3.rs +++ b/tests/ui/imports/glob-conflict-cross-crate-3.rs @@ -13,4 +13,6 @@ fn main() { let _a: C = 1; //~^ ERROR `C` is ambiguous //~| ERROR `C` is ambiguous + //~| WARN this was previously accepted + //~| WARN this was previously accepted } diff --git a/tests/ui/imports/glob-conflict-cross-crate-3.stderr b/tests/ui/imports/glob-conflict-cross-crate-3.stderr index 1de00dff585d6..213eafda20b72 100644 --- a/tests/ui/imports/glob-conflict-cross-crate-3.stderr +++ b/tests/ui/imports/glob-conflict-cross-crate-3.stderr @@ -1,9 +1,32 @@ -error[E0659]: `C` is ambiguous +error: `C` is ambiguous --> $DIR/glob-conflict-cross-crate-3.rs:13:13 | LL | let _a: C = 1; | ^ 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: `C` could refer to the type alias defined here + --> $DIR/auxiliary/glob-conflict-cross-crate-2-extern.rs:9:9 + | +LL | pub use a::*; + | ^ +note: `C` could also refer to the type alias defined here + --> $DIR/auxiliary/glob-conflict-cross-crate-2-extern.rs:10:9 + | +LL | pub use b::*; + | ^ + = note: `#[deny(ambiguous_glob_imports)]` (part of `#[deny(future_incompatible)]`) on by default + +error: `C` is ambiguous + --> $DIR/glob-conflict-cross-crate-3.rs:13:13 + | +LL | let _a: C = 1; + | ^ 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: `C` could refer to the type alias imported here --> $DIR/glob-conflict-cross-crate-3.rs:9:5 @@ -18,12 +41,17 @@ LL | use a::*; | ^^^^ = help: consider adding an explicit import of `C` to disambiguate -error[E0659]: `C` is ambiguous +error: aborting due to 2 previous errors + +Future incompatibility report: Future breakage diagnostic: +error: `C` is ambiguous --> $DIR/glob-conflict-cross-crate-3.rs:13:13 | LL | let _a: C = 1; | ^ 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: `C` could refer to the type alias defined here --> $DIR/auxiliary/glob-conflict-cross-crate-2-extern.rs:9:9 @@ -35,7 +63,29 @@ note: `C` could also refer to the type alias defined here | LL | pub use b::*; | ^ + = note: `#[deny(ambiguous_glob_imports)]` (part of `#[deny(future_incompatible)]`) on by default -error: aborting due to 2 previous errors +Future breakage diagnostic: +error: `C` is ambiguous + --> $DIR/glob-conflict-cross-crate-3.rs:13:13 + | +LL | let _a: C = 1; + | ^ 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: `C` could refer to the type alias imported here + --> $DIR/glob-conflict-cross-crate-3.rs:9:5 + | +LL | use glob_conflict_cross_crate_2_extern::*; + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + = help: consider adding an explicit import of `C` to disambiguate +note: `C` could also refer to the type alias imported here + --> $DIR/glob-conflict-cross-crate-3.rs:10:5 + | +LL | use a::*; + | ^^^^ + = help: consider adding an explicit import of `C` to disambiguate + = note: `#[deny(ambiguous_glob_imports)]` (part of `#[deny(future_incompatible)]`) on by default -For more information about this error, try `rustc --explain E0659`. diff --git a/tests/ui/imports/issue-114682-2.rs b/tests/ui/imports/issue-114682-2.rs index 767a51e63eb6d..a9459c5b02ef6 100644 --- a/tests/ui/imports/issue-114682-2.rs +++ b/tests/ui/imports/issue-114682-2.rs @@ -4,7 +4,9 @@ extern crate issue_114682_2_extern; use issue_114682_2_extern::max; //~ ERROR `max` is ambiguous + //~| WARN this was previously accepted type A = issue_114682_2_extern::max; //~ ERROR `max` is ambiguous + //~| WARN this was previously accepted fn main() {} diff --git a/tests/ui/imports/issue-114682-2.stderr b/tests/ui/imports/issue-114682-2.stderr index 1a15d3d105433..07c696651c388 100644 --- a/tests/ui/imports/issue-114682-2.stderr +++ b/tests/ui/imports/issue-114682-2.stderr @@ -1,9 +1,11 @@ -error[E0659]: `max` is ambiguous +error: `max` is ambiguous --> $DIR/issue-114682-2.rs:6:28 | LL | use issue_114682_2_extern::max; | ^^^ 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: `max` could refer to the type alias defined here --> $DIR/auxiliary/issue-114682-2-extern.rs:17:9 @@ -15,13 +17,16 @@ note: `max` could also refer to the module defined here | LL | pub use self::d::*; | ^^^^^^^ + = note: `#[deny(ambiguous_glob_imports)]` (part of `#[deny(future_incompatible)]`) on by default -error[E0659]: `max` is ambiguous - --> $DIR/issue-114682-2.rs:8:33 +error: `max` is ambiguous + --> $DIR/issue-114682-2.rs:9:33 | LL | type A = issue_114682_2_extern::max; | ^^^ 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: `max` could refer to the type alias defined here --> $DIR/auxiliary/issue-114682-2-extern.rs:17:9 @@ -36,4 +41,47 @@ LL | pub use self::d::*; error: aborting due to 2 previous errors -For more information about this error, try `rustc --explain E0659`. +Future incompatibility report: Future breakage diagnostic: +error: `max` is ambiguous + --> $DIR/issue-114682-2.rs:6:28 + | +LL | use issue_114682_2_extern::max; + | ^^^ 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: `max` could refer to the type alias defined here + --> $DIR/auxiliary/issue-114682-2-extern.rs:17:9 + | +LL | pub use self::e::*; + | ^^^^^^^ +note: `max` could also refer to the module defined here + --> $DIR/auxiliary/issue-114682-2-extern.rs:16:9 + | +LL | pub use self::d::*; + | ^^^^^^^ + = note: `#[deny(ambiguous_glob_imports)]` (part of `#[deny(future_incompatible)]`) on by default + +Future breakage diagnostic: +error: `max` is ambiguous + --> $DIR/issue-114682-2.rs:9:33 + | +LL | type A = issue_114682_2_extern::max; + | ^^^ 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: `max` could refer to the type alias defined here + --> $DIR/auxiliary/issue-114682-2-extern.rs:17:9 + | +LL | pub use self::e::*; + | ^^^^^^^ +note: `max` could also refer to the module defined here + --> $DIR/auxiliary/issue-114682-2-extern.rs:16:9 + | +LL | pub use self::d::*; + | ^^^^^^^ + = note: `#[deny(ambiguous_glob_imports)]` (part of `#[deny(future_incompatible)]`) on by default + diff --git a/tests/ui/imports/issue-114682-4.rs b/tests/ui/imports/issue-114682-4.rs index 40f4b95d41493..01921928a0079 100644 --- a/tests/ui/imports/issue-114682-4.rs +++ b/tests/ui/imports/issue-114682-4.rs @@ -7,6 +7,7 @@ use issue_114682_4_extern::*; //~v ERROR type alias takes 1 generic argument but 2 generic arguments were supplied fn a() -> Result { //~ ERROR `Result` is ambiguous + //~| WARN this was previously accepted Ok(1) } diff --git a/tests/ui/imports/issue-114682-4.stderr b/tests/ui/imports/issue-114682-4.stderr index 3a3d2ab5fd134..5e677cd7ae724 100644 --- a/tests/ui/imports/issue-114682-4.stderr +++ b/tests/ui/imports/issue-114682-4.stderr @@ -1,9 +1,11 @@ -error[E0659]: `Result` is ambiguous +error: `Result` is ambiguous --> $DIR/issue-114682-4.rs:9:11 | LL | fn a() -> Result { | ^^^^^^ 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: `Result` could refer to the type alias defined here --> $DIR/auxiliary/issue-114682-4-extern.rs:9:9 @@ -15,6 +17,7 @@ note: `Result` could also refer to the type alias defined here | LL | pub use b::*; | ^ + = note: `#[deny(ambiguous_glob_imports)]` (part of `#[deny(future_incompatible)]`) on by default error[E0107]: type alias takes 1 generic argument but 2 generic arguments were supplied --> $DIR/issue-114682-4.rs:9:11 @@ -32,5 +35,26 @@ LL | pub type Result = std::result::Result; error: aborting due to 2 previous errors -Some errors have detailed explanations: E0107, E0659. -For more information about an error, try `rustc --explain E0107`. +For more information about this error, try `rustc --explain E0107`. +Future incompatibility report: Future breakage diagnostic: +error: `Result` is ambiguous + --> $DIR/issue-114682-4.rs:9:11 + | +LL | fn a() -> Result { + | ^^^^^^ 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: `Result` could refer to the type alias defined here + --> $DIR/auxiliary/issue-114682-4-extern.rs:9:9 + | +LL | pub use a::*; + | ^ +note: `Result` could also refer to the type alias defined here + --> $DIR/auxiliary/issue-114682-4-extern.rs:10:9 + | +LL | pub use b::*; + | ^ + = note: `#[deny(ambiguous_glob_imports)]` (part of `#[deny(future_incompatible)]`) on by default + diff --git a/tests/ui/imports/issue-114682-5.rs b/tests/ui/imports/issue-114682-5.rs index 16287dae6c456..be33960e40b81 100644 --- a/tests/ui/imports/issue-114682-5.rs +++ b/tests/ui/imports/issue-114682-5.rs @@ -11,5 +11,6 @@ use issue_114682_5_extern_1::Url; //~^ ERROR `issue_114682_5_extern_1` is ambiguous //~| ERROR `issue_114682_5_extern_1` is ambiguous //~| ERROR unresolved import `issue_114682_5_extern_1::Url` +//~| WARN this was previously accepted fn main() {} diff --git a/tests/ui/imports/issue-114682-5.stderr b/tests/ui/imports/issue-114682-5.stderr index e89d3f9683461..427a5b16765b5 100644 --- a/tests/ui/imports/issue-114682-5.stderr +++ b/tests/ui/imports/issue-114682-5.stderr @@ -15,6 +15,25 @@ error[E0659]: `issue_114682_5_extern_1` is ambiguous LL | use issue_114682_5_extern_1::Url; | ^^^^^^^^^^^^^^^^^^^^^^^ 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_114682_5_extern_1` could refer to a crate passed with `--extern` + = help: use `::issue_114682_5_extern_1` to refer to this crate unambiguously +note: `issue_114682_5_extern_1` could also refer to the module imported here + --> $DIR/issue-114682-5.rs:9:5 + | +LL | use issue_114682_5_extern_2::p::*; + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + = help: consider adding an explicit import of `issue_114682_5_extern_1` to disambiguate + = help: or use `crate::issue_114682_5_extern_1` to refer to this module unambiguously + +error: `issue_114682_5_extern_1` is ambiguous + --> $DIR/issue-114682-5.rs:10:5 + | +LL | use issue_114682_5_extern_1::Url; + | ^^^^^^^^^^^^^^^^^^^^^^^ 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: `issue_114682_5_extern_1` could refer to the module defined here --> $DIR/auxiliary/issue-114682-5-extern-2.rs:6:13 @@ -27,25 +46,32 @@ note: `issue_114682_5_extern_1` could also refer to the crate defined here LL | pub use crate::*; | ^^^^^ = help: use `::issue_114682_5_extern_1` to refer to this crate unambiguously + = note: `#[deny(ambiguous_glob_imports)]` (part of `#[deny(future_incompatible)]`) on by default -error[E0659]: `issue_114682_5_extern_1` is ambiguous +error: aborting due to 3 previous errors + +Some errors have detailed explanations: E0432, E0659. +For more information about an error, try `rustc --explain E0432`. +Future incompatibility report: Future breakage diagnostic: +error: `issue_114682_5_extern_1` is ambiguous --> $DIR/issue-114682-5.rs:10:5 | LL | use issue_114682_5_extern_1::Url; | ^^^^^^^^^^^^^^^^^^^^^^^ 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_114682_5_extern_1` could refer to a crate passed with `--extern` - = help: use `::issue_114682_5_extern_1` to refer to this crate unambiguously -note: `issue_114682_5_extern_1` could also refer to the module imported here - --> $DIR/issue-114682-5.rs:9:5 + = 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: `issue_114682_5_extern_1` could refer to the module defined here + --> $DIR/auxiliary/issue-114682-5-extern-2.rs:6:13 | -LL | use issue_114682_5_extern_2::p::*; - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - = help: consider adding an explicit import of `issue_114682_5_extern_1` to disambiguate - = help: or use `crate::issue_114682_5_extern_1` to refer to this module unambiguously - -error: aborting due to 3 previous errors +LL | pub use crate::types::*; + | ^^^^^^^^^^^^ +note: `issue_114682_5_extern_1` could also refer to the crate defined here + --> $DIR/auxiliary/issue-114682-5-extern-2.rs:7:13 + | +LL | pub use crate::*; + | ^^^^^ + = help: use `::issue_114682_5_extern_1` to refer to this crate unambiguously + = note: `#[deny(ambiguous_glob_imports)]` (part of `#[deny(future_incompatible)]`) on by default -Some errors have detailed explanations: E0432, E0659. -For more information about an error, try `rustc --explain E0432`. diff --git a/tests/ui/imports/issue-114682-6.rs b/tests/ui/imports/issue-114682-6.rs index 671b59706bd18..92173f4b8464f 100644 --- a/tests/ui/imports/issue-114682-6.rs +++ b/tests/ui/imports/issue-114682-6.rs @@ -7,5 +7,6 @@ use issue_114682_6_extern::*; fn main() { let log = 2; //~ ERROR `log` is ambiguous + //~| WARN this was previously accepted let _ = log; } diff --git a/tests/ui/imports/issue-114682-6.stderr b/tests/ui/imports/issue-114682-6.stderr index 924a46858d353..67ad25798c192 100644 --- a/tests/ui/imports/issue-114682-6.stderr +++ b/tests/ui/imports/issue-114682-6.stderr @@ -1,9 +1,11 @@ -error[E0659]: `log` is ambiguous +error: `log` is ambiguous --> $DIR/issue-114682-6.rs:9:9 | LL | let log = 2; | ^^^ 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: `log` could refer to the function defined here --> $DIR/auxiliary/issue-114682-6-extern.rs:8:9 @@ -15,7 +17,29 @@ note: `log` could also refer to the function defined here | LL | pub use self::b::*; | ^^^^^^^ + = note: `#[deny(ambiguous_glob_imports)]` (part of `#[deny(future_incompatible)]`) on by default error: aborting due to 1 previous error -For more information about this error, try `rustc --explain E0659`. +Future incompatibility report: Future breakage diagnostic: +error: `log` is ambiguous + --> $DIR/issue-114682-6.rs:9:9 + | +LL | let log = 2; + | ^^^ 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: `log` could refer to the function defined here + --> $DIR/auxiliary/issue-114682-6-extern.rs:8:9 + | +LL | pub use self::a::*; + | ^^^^^^^ +note: `log` could also refer to the function defined here + --> $DIR/auxiliary/issue-114682-6-extern.rs:9:9 + | +LL | pub use self::b::*; + | ^^^^^^^ + = note: `#[deny(ambiguous_glob_imports)]` (part of `#[deny(future_incompatible)]`) on by default +