From 4dcce38cda48bc484d61e092f858063eaf3c2f90 Mon Sep 17 00:00:00 2001 From: Vadim Petrochenkov Date: Mon, 29 May 2023 23:36:06 +0300 Subject: [PATCH] resolve: Remove artificial import ambiguity errors --- compiler/rustc_resolve/src/diagnostics.rs | 5 +- compiler/rustc_resolve/src/ident.rs | 23 ++++--- compiler/rustc_resolve/src/imports.rs | 23 ++----- compiler/rustc_resolve/src/lib.rs | 6 +- compiler/rustc_resolve/src/macros.rs | 2 +- tests/ui/imports/issue-56125.stderr | 15 +++-- tests/ui/imports/issue-57539.stderr | 5 +- .../ui/proc-macro/derive-helper-shadowing.rs | 2 +- .../proc-macro/derive-helper-shadowing.stderr | 21 +------ .../ambiguity-macros-nested.stderr | 2 +- .../uniform-paths/ambiguity-macros.stderr | 2 +- .../uniform-paths/ambiguity-nested.rs | 4 +- .../uniform-paths/ambiguity-nested.stderr | 21 ------- tests/ui/rust-2018/uniform-paths/ambiguity.rs | 4 +- .../rust-2018/uniform-paths/ambiguity.stderr | 21 ------- .../block-scoped-shadow-nested.rs | 3 +- .../block-scoped-shadow-nested.stderr | 24 -------- .../uniform-paths/block-scoped-shadow.rs | 8 +-- .../uniform-paths/block-scoped-shadow.stderr | 60 ------------------- .../uniform-paths/issue-56596.stderr | 5 +- .../ui/rust-2018/uniform-paths/macro-rules.rs | 3 +- .../uniform-paths/macro-rules.stderr | 24 +------- 22 files changed, 53 insertions(+), 230 deletions(-) delete mode 100644 tests/ui/rust-2018/uniform-paths/ambiguity-nested.stderr delete mode 100644 tests/ui/rust-2018/uniform-paths/ambiguity.stderr delete mode 100644 tests/ui/rust-2018/uniform-paths/block-scoped-shadow-nested.stderr delete mode 100644 tests/ui/rust-2018/uniform-paths/block-scoped-shadow.stderr diff --git a/compiler/rustc_resolve/src/diagnostics.rs b/compiler/rustc_resolve/src/diagnostics.rs index d77fb922e844d..d9e4974626d78 100644 --- a/compiler/rustc_resolve/src/diagnostics.rs +++ b/compiler/rustc_resolve/src/diagnostics.rs @@ -1403,7 +1403,7 @@ impl<'a, 'tcx> Resolver<'a, 'tcx> { for ns in [Namespace::MacroNS, Namespace::TypeNS, Namespace::ValueNS] { if let Ok(binding) = self.early_resolve_ident_in_lexical_scope( ident, - ScopeSet::All(ns, false), + ScopeSet::All(ns), &parent_scope, None, false, @@ -1841,10 +1841,9 @@ impl<'a, 'tcx> Resolver<'a, 'tcx> { _ => None, } } else { - let scopes = ScopeSet::All(ns_to_try, opt_ns.is_none()); self.early_resolve_ident_in_lexical_scope( ident, - scopes, + ScopeSet::All(ns_to_try), parent_scope, None, false, diff --git a/compiler/rustc_resolve/src/ident.rs b/compiler/rustc_resolve/src/ident.rs index e5fa062967ff2..8e921f1ecb1a2 100644 --- a/compiler/rustc_resolve/src/ident.rs +++ b/compiler/rustc_resolve/src/ident.rs @@ -88,7 +88,7 @@ impl<'a, 'tcx> Resolver<'a, 'tcx> { let rust_2015 = ctxt.edition().is_rust_2015(); let (ns, macro_kind, is_absolute_path) = match scope_set { - ScopeSet::All(ns, _) => (ns, None, false), + ScopeSet::All(ns) => (ns, None, false), ScopeSet::AbsolutePath(ns) => (ns, None, true), ScopeSet::Macro(macro_kind) => (MacroNS, Some(macro_kind), false), ScopeSet::Late(ns, ..) => (ns, None, false), @@ -397,11 +397,11 @@ impl<'a, 'tcx> Resolver<'a, 'tcx> { return Err(Determinacy::Determined); } - let (ns, macro_kind, is_import) = match scope_set { - ScopeSet::All(ns, is_import) => (ns, None, is_import), - ScopeSet::AbsolutePath(ns) => (ns, None, false), - ScopeSet::Macro(macro_kind) => (MacroNS, Some(macro_kind), false), - ScopeSet::Late(ns, ..) => (ns, None, false), + let (ns, macro_kind) = match scope_set { + ScopeSet::All(ns) => (ns, None), + ScopeSet::AbsolutePath(ns) => (ns, None), + ScopeSet::Macro(macro_kind) => (MacroNS, Some(macro_kind)), + ScopeSet::Late(ns, ..) => (ns, None), }; // This is *the* result, resolution from the scope closest to the resolved identifier. @@ -631,9 +631,9 @@ impl<'a, 'tcx> Resolver<'a, 'tcx> { let derive_helper_compat = Res::NonMacroAttr(NonMacroAttrKind::DeriveHelperCompat); - let ambiguity_error_kind = if is_import { - Some(AmbiguityKind::Import) - } else if is_builtin(innermost_res) || is_builtin(res) { + let ambiguity_error_kind = if is_builtin(innermost_res) + || is_builtin(res) + { Some(AmbiguityKind::BuiltinAttr) } else if innermost_res == derive_helper_compat || res == derive_helper_compat && innermost_res != derive_helper @@ -853,10 +853,9 @@ impl<'a, 'tcx> Resolver<'a, 'tcx> { } } - let scopes = ScopeSet::All(ns, true); let binding = self.early_resolve_ident_in_lexical_scope( ident, - scopes, + ScopeSet::All(ns), parent_scope, finalize, finalize.is_some(), @@ -1497,7 +1496,7 @@ impl<'a, 'tcx> Resolver<'a, 'tcx> { } else { self.early_resolve_ident_in_lexical_scope( ident, - ScopeSet::All(ns, opt_ns.is_none()), + ScopeSet::All(ns), parent_scope, finalize, finalize.is_some(), diff --git a/compiler/rustc_resolve/src/imports.rs b/compiler/rustc_resolve/src/imports.rs index 35491ebe10cfd..8bd08921fe603 100644 --- a/compiler/rustc_resolve/src/imports.rs +++ b/compiler/rustc_resolve/src/imports.rs @@ -10,10 +10,7 @@ use crate::errors::{ use crate::Determinacy::{self, *}; use crate::{fluent_generated as fluent, Namespace::*}; use crate::{module_to_string, names_to_string, ImportSuggestion}; -use crate::{ - AmbiguityError, AmbiguityErrorMisc, AmbiguityKind, BindingKey, ModuleKind, ResolutionError, - Resolver, Segment, -}; +use crate::{AmbiguityKind, BindingKey, ModuleKind, ResolutionError, Resolver, Segment}; use crate::{Finalize, Module, ModuleOrUniformRoot, ParentScope, PerNS, ScopeSet}; use crate::{NameBinding, NameBindingKind, PathResult}; @@ -984,7 +981,7 @@ impl<'a, 'tcx> Resolver<'a, 'tcx> { match binding { Ok(binding) => { // Consistency checks, analogous to `finalize_macro_resolutions`. - let initial_binding = source_bindings[ns].get().map(|initial_binding| { + let initial_res = source_bindings[ns].get().map(|initial_binding| { all_ns_err = false; if let Some(target_binding) = target_bindings[ns].get() { if target.name == kw::Underscore @@ -998,20 +995,12 @@ impl<'a, 'tcx> Resolver<'a, 'tcx> { ); } } - initial_binding + initial_binding.res() }); let res = binding.res(); - if let Ok(initial_binding) = initial_binding { - let initial_res = initial_binding.res(); + if let Ok(initial_res) = initial_res { if res != initial_res && this.ambiguity_errors.is_empty() { - this.ambiguity_errors.push(AmbiguityError { - kind: AmbiguityKind::Import, - ident, - b1: initial_binding, - b2: binding, - misc1: AmbiguityErrorMisc::None, - misc2: AmbiguityErrorMisc::None, - }); + span_bug!(import.span, "inconsistent resolution for an import"); } } else if res != Res::Err && this.ambiguity_errors.is_empty() @@ -1283,7 +1272,7 @@ impl<'a, 'tcx> Resolver<'a, 'tcx> { match this.early_resolve_ident_in_lexical_scope( target, - ScopeSet::All(ns, false), + ScopeSet::All(ns), &import.parent_scope, None, false, diff --git a/compiler/rustc_resolve/src/lib.rs b/compiler/rustc_resolve/src/lib.rs index 8c1cd2f155715..ff698452ad550 100644 --- a/compiler/rustc_resolve/src/lib.rs +++ b/compiler/rustc_resolve/src/lib.rs @@ -131,7 +131,7 @@ enum Scope<'a> { #[derive(Clone, Copy)] enum ScopeSet<'a> { /// All scopes with the given namespace. - All(Namespace, /*is_import*/ bool), + All(Namespace), /// Crate root, then extern prelude (used for mixed 2015-2018 mode in macros). AbsolutePath(Namespace), /// All scopes with macro namespace and the given macro kind restriction. @@ -718,7 +718,6 @@ struct UseError<'a> { #[derive(Clone, Copy, PartialEq, Debug)] enum AmbiguityKind { - Import, BuiltinAttr, DeriveHelper, MacroRulesVsModularized, @@ -731,7 +730,6 @@ enum AmbiguityKind { impl AmbiguityKind { fn descr(self) -> &'static str { match self { - AmbiguityKind::Import => "multiple potential import sources", AmbiguityKind::BuiltinAttr => "a name conflict with a builtin attribute", AmbiguityKind::DeriveHelper => "a name conflict with a derive helper attribute", AmbiguityKind::MacroRulesVsModularized => { @@ -1557,7 +1555,7 @@ impl<'a, 'tcx> Resolver<'a, 'tcx> { } } - self.visit_scopes(ScopeSet::All(TypeNS, false), parent_scope, ctxt, |this, scope, _, _| { + self.visit_scopes(ScopeSet::All(TypeNS), parent_scope, ctxt, |this, scope, _, _| { match scope { Scope::Module(module, _) => { this.traits_in_module(module, assoc_item, &mut found_traits); diff --git a/compiler/rustc_resolve/src/macros.rs b/compiler/rustc_resolve/src/macros.rs index 4dcef8f6efd99..d33e8d40b6383 100644 --- a/compiler/rustc_resolve/src/macros.rs +++ b/compiler/rustc_resolve/src/macros.rs @@ -645,7 +645,7 @@ impl<'a, 'tcx> Resolver<'a, 'tcx> { self.prohibit_imported_non_macro_attrs(None, res.ok(), path_span); res } else { - let scope_set = kind.map_or(ScopeSet::All(MacroNS, false), ScopeSet::Macro); + let scope_set = kind.map_or(ScopeSet::All(MacroNS), ScopeSet::Macro); let binding = self.early_resolve_ident_in_lexical_scope( path[0].ident, scope_set, diff --git a/tests/ui/imports/issue-56125.stderr b/tests/ui/imports/issue-56125.stderr index 3448f3119778a..15477fb6f1015 100644 --- a/tests/ui/imports/issue-56125.stderr +++ b/tests/ui/imports/issue-56125.stderr @@ -22,7 +22,7 @@ error[E0659]: `issue_56125` is ambiguous LL | use issue_56125::last_segment::*; | ^^^^^^^^^^^ ambiguous name | - = note: ambiguous because of multiple potential import sources + = note: ambiguous because of a conflict between a name from a glob import and an outer scope during import or macro resolution = note: `issue_56125` could refer to a crate passed with `--extern` = help: use `::issue_56125` to refer to this crate unambiguously note: `issue_56125` could also refer to the module imported here @@ -30,7 +30,8 @@ note: `issue_56125` could also refer to the module imported here | LL | use issue_56125::last_segment::*; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - = help: use `self::issue_56125` to refer to this module unambiguously + = help: consider adding an explicit import of `issue_56125` to disambiguate + = help: or use `self::issue_56125` to refer to this module unambiguously error[E0659]: `issue_56125` is ambiguous --> $DIR/issue-56125.rs:11:9 @@ -38,7 +39,7 @@ error[E0659]: `issue_56125` is ambiguous LL | use issue_56125::non_last_segment::non_last_segment::*; | ^^^^^^^^^^^ ambiguous name | - = note: ambiguous because of multiple potential import sources + = note: ambiguous because of a conflict between a name from a glob import and an outer scope during import or macro resolution = note: `issue_56125` could refer to a crate passed with `--extern` = help: use `::issue_56125` to refer to this crate unambiguously note: `issue_56125` could also refer to the module imported here @@ -46,7 +47,8 @@ note: `issue_56125` could also refer to the module imported here | LL | use issue_56125::non_last_segment::non_last_segment::*; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - = help: use `self::issue_56125` to refer to this module unambiguously + = help: consider adding an explicit import of `issue_56125` to disambiguate + = help: or use `self::issue_56125` to refer to this module unambiguously error[E0659]: `issue_56125` is ambiguous --> $DIR/issue-56125.rs:18:9 @@ -54,7 +56,7 @@ error[E0659]: `issue_56125` is ambiguous LL | use issue_56125::*; | ^^^^^^^^^^^ ambiguous name | - = note: ambiguous because of multiple potential import sources + = note: ambiguous because of a conflict between a name from a glob import and an outer scope during import or macro resolution = note: `issue_56125` could refer to a crate passed with `--extern` = help: use `::issue_56125` to refer to this crate unambiguously note: `issue_56125` could also refer to the module imported here @@ -62,7 +64,8 @@ note: `issue_56125` could also refer to the module imported here | LL | use issue_56125::*; | ^^^^^^^^^^^^^^ - = help: use `self::issue_56125` to refer to this module unambiguously + = help: consider adding an explicit import of `issue_56125` to disambiguate + = help: or use `self::issue_56125` to refer to this module unambiguously error: aborting due to 4 previous errors diff --git a/tests/ui/imports/issue-57539.stderr b/tests/ui/imports/issue-57539.stderr index 1a3ca4edaca9b..88cc42ccf6682 100644 --- a/tests/ui/imports/issue-57539.stderr +++ b/tests/ui/imports/issue-57539.stderr @@ -4,7 +4,7 @@ error[E0659]: `core` is ambiguous LL | use core; | ^^^^ ambiguous name | - = note: ambiguous because of multiple potential import sources + = note: ambiguous because of a conflict between a name from a glob import and an outer scope during import or macro resolution = note: `core` could refer to a built-in crate = help: use `::core` to refer to this crate unambiguously note: `core` could also refer to the module imported here @@ -12,7 +12,8 @@ note: `core` could also refer to the module imported here | LL | use crate::*; | ^^^^^^^^ - = help: use `self::core` to refer to this module unambiguously + = help: consider adding an explicit import of `core` to disambiguate + = help: or use `self::core` to refer to this module unambiguously error: aborting due to previous error diff --git a/tests/ui/proc-macro/derive-helper-shadowing.rs b/tests/ui/proc-macro/derive-helper-shadowing.rs index 80d982d2504db..4f25b4b0dca54 100644 --- a/tests/ui/proc-macro/derive-helper-shadowing.rs +++ b/tests/ui/proc-macro/derive-helper-shadowing.rs @@ -23,7 +23,7 @@ macro_rules! gen_helper_use { struct S { #[empty_helper] // OK, no ambiguity, derive helpers have highest priority field: [u8; { - use empty_helper; //~ ERROR `empty_helper` is ambiguous + use empty_helper; // OK, no ambiguity, derive helpers have highest priority #[empty_helper] // OK, no ambiguity, derive helpers have highest priority struct U; diff --git a/tests/ui/proc-macro/derive-helper-shadowing.stderr b/tests/ui/proc-macro/derive-helper-shadowing.stderr index 566c41308468a..f284b1c54dd61 100644 --- a/tests/ui/proc-macro/derive-helper-shadowing.stderr +++ b/tests/ui/proc-macro/derive-helper-shadowing.stderr @@ -37,25 +37,6 @@ help: consider importing this attribute macro through its public re-export LL + use crate::empty_helper; | -error[E0659]: `empty_helper` is ambiguous - --> $DIR/derive-helper-shadowing.rs:26:13 - | -LL | use empty_helper; - | ^^^^^^^^^^^^ ambiguous name - | - = note: ambiguous because of multiple potential import sources -note: `empty_helper` could refer to the derive helper attribute defined here - --> $DIR/derive-helper-shadowing.rs:22:10 - | -LL | #[derive(Empty)] - | ^^^^^ -note: `empty_helper` could also refer to the attribute macro imported here - --> $DIR/derive-helper-shadowing.rs:10:5 - | -LL | use test_macros::empty_attr as empty_helper; - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - = help: use `crate::empty_helper` to refer to this attribute macro unambiguously - error[E0659]: `empty_helper` is ambiguous --> $DIR/derive-helper-shadowing.rs:19:3 | @@ -88,6 +69,6 @@ LL | #[derive(Empty)] = note: for more information, see issue #79202 = note: `#[warn(legacy_derive_helpers)]` on by default -error: aborting due to 5 previous errors; 1 warning emitted +error: aborting due to 4 previous errors; 1 warning emitted For more information about this error, try `rustc --explain E0659`. diff --git a/tests/ui/rust-2018/uniform-paths/ambiguity-macros-nested.stderr b/tests/ui/rust-2018/uniform-paths/ambiguity-macros-nested.stderr index 7e008d46574c6..a5c79366bf0dc 100644 --- a/tests/ui/rust-2018/uniform-paths/ambiguity-macros-nested.stderr +++ b/tests/ui/rust-2018/uniform-paths/ambiguity-macros-nested.stderr @@ -4,7 +4,7 @@ error[E0659]: `std` is ambiguous LL | pub use std::io; | ^^^ ambiguous name | - = note: ambiguous because of multiple potential import sources + = note: ambiguous because of a conflict between a macro-expanded name and a less macro-expanded name from outer scope during import or macro resolution = note: `std` could refer to a built-in crate = help: use `::std` to refer to this crate unambiguously note: `std` could also refer to the module defined here diff --git a/tests/ui/rust-2018/uniform-paths/ambiguity-macros.stderr b/tests/ui/rust-2018/uniform-paths/ambiguity-macros.stderr index 771d2c10c1da2..8045f3a45b607 100644 --- a/tests/ui/rust-2018/uniform-paths/ambiguity-macros.stderr +++ b/tests/ui/rust-2018/uniform-paths/ambiguity-macros.stderr @@ -4,7 +4,7 @@ error[E0659]: `std` is ambiguous LL | use std::io; | ^^^ ambiguous name | - = note: ambiguous because of multiple potential import sources + = note: ambiguous because of a conflict between a macro-expanded name and a less macro-expanded name from outer scope during import or macro resolution = note: `std` could refer to a built-in crate = help: use `::std` to refer to this crate unambiguously note: `std` could also refer to the module defined here diff --git a/tests/ui/rust-2018/uniform-paths/ambiguity-nested.rs b/tests/ui/rust-2018/uniform-paths/ambiguity-nested.rs index 50c8fc8229c35..0ef580d7aa53d 100644 --- a/tests/ui/rust-2018/uniform-paths/ambiguity-nested.rs +++ b/tests/ui/rust-2018/uniform-paths/ambiguity-nested.rs @@ -1,3 +1,4 @@ +// check-pass // edition:2018 // This test is similar to `ambiguity.rs`, but nested in a module. @@ -5,8 +6,7 @@ #![allow(non_camel_case_types)] mod foo { - pub use std::io; - //~^ ERROR `std` is ambiguous + pub use std::io; // OK mod std { pub struct io; diff --git a/tests/ui/rust-2018/uniform-paths/ambiguity-nested.stderr b/tests/ui/rust-2018/uniform-paths/ambiguity-nested.stderr deleted file mode 100644 index defb16f797038..0000000000000 --- a/tests/ui/rust-2018/uniform-paths/ambiguity-nested.stderr +++ /dev/null @@ -1,21 +0,0 @@ -error[E0659]: `std` is ambiguous - --> $DIR/ambiguity-nested.rs:8:13 - | -LL | pub use std::io; - | ^^^ ambiguous name - | - = note: ambiguous because of multiple potential import sources - = note: `std` could refer to a built-in crate - = help: use `::std` to refer to this crate unambiguously -note: `std` could also refer to the module defined here - --> $DIR/ambiguity-nested.rs:11:5 - | -LL | / mod std { -LL | | pub struct io; -LL | | } - | |_____^ - = help: use `self::std` to refer to this module unambiguously - -error: aborting due to previous error - -For more information about this error, try `rustc --explain E0659`. diff --git a/tests/ui/rust-2018/uniform-paths/ambiguity.rs b/tests/ui/rust-2018/uniform-paths/ambiguity.rs index 60f77a1c663c7..890e8b7b3c037 100644 --- a/tests/ui/rust-2018/uniform-paths/ambiguity.rs +++ b/tests/ui/rust-2018/uniform-paths/ambiguity.rs @@ -1,9 +1,9 @@ +// check-pass // edition:2018 #![allow(non_camel_case_types)] -use std::io; -//~^ ERROR `std` is ambiguous +use std::io; // OK mod std { pub struct io; diff --git a/tests/ui/rust-2018/uniform-paths/ambiguity.stderr b/tests/ui/rust-2018/uniform-paths/ambiguity.stderr deleted file mode 100644 index 2d735c7e3fdfe..0000000000000 --- a/tests/ui/rust-2018/uniform-paths/ambiguity.stderr +++ /dev/null @@ -1,21 +0,0 @@ -error[E0659]: `std` is ambiguous - --> $DIR/ambiguity.rs:5:5 - | -LL | use std::io; - | ^^^ ambiguous name - | - = note: ambiguous because of multiple potential import sources - = note: `std` could refer to a built-in crate - = help: use `::std` to refer to this crate unambiguously -note: `std` could also refer to the module defined here - --> $DIR/ambiguity.rs:8:1 - | -LL | / mod std { -LL | | pub struct io; -LL | | } - | |_^ - = help: use `crate::std` to refer to this module unambiguously - -error: aborting due to previous error - -For more information about this error, try `rustc --explain E0659`. diff --git a/tests/ui/rust-2018/uniform-paths/block-scoped-shadow-nested.rs b/tests/ui/rust-2018/uniform-paths/block-scoped-shadow-nested.rs index 3f5897901a056..4cba0949802ad 100644 --- a/tests/ui/rust-2018/uniform-paths/block-scoped-shadow-nested.rs +++ b/tests/ui/rust-2018/uniform-paths/block-scoped-shadow-nested.rs @@ -1,3 +1,4 @@ +// check-pass // edition:2018 mod my { @@ -13,7 +14,7 @@ mod sub { fn foo() { use my::sub; { - use sub::bar; //~ ERROR `sub` is ambiguous + use sub::bar; // OK } } diff --git a/tests/ui/rust-2018/uniform-paths/block-scoped-shadow-nested.stderr b/tests/ui/rust-2018/uniform-paths/block-scoped-shadow-nested.stderr deleted file mode 100644 index 3d45a81402940..0000000000000 --- a/tests/ui/rust-2018/uniform-paths/block-scoped-shadow-nested.stderr +++ /dev/null @@ -1,24 +0,0 @@ -error[E0659]: `sub` is ambiguous - --> $DIR/block-scoped-shadow-nested.rs:16:13 - | -LL | use sub::bar; - | ^^^ ambiguous name - | - = note: ambiguous because of multiple potential import sources -note: `sub` could refer to the module imported here - --> $DIR/block-scoped-shadow-nested.rs:14:9 - | -LL | use my::sub; - | ^^^^^^^ -note: `sub` could also refer to the module defined here - --> $DIR/block-scoped-shadow-nested.rs:9:1 - | -LL | / mod sub { -LL | | pub fn bar() {} -LL | | } - | |_^ - = help: use `crate::sub` to refer to this module unambiguously - -error: aborting due to previous error - -For more information about this error, try `rustc --explain E0659`. diff --git a/tests/ui/rust-2018/uniform-paths/block-scoped-shadow.rs b/tests/ui/rust-2018/uniform-paths/block-scoped-shadow.rs index 828ee4fe474b7..c902d133e7cec 100644 --- a/tests/ui/rust-2018/uniform-paths/block-scoped-shadow.rs +++ b/tests/ui/rust-2018/uniform-paths/block-scoped-shadow.rs @@ -1,3 +1,4 @@ +// check-pass // edition:2018 #![allow(non_camel_case_types)] @@ -8,14 +9,11 @@ struct std; fn main() { enum Foo { A, B } - use Foo::*; - //~^ ERROR `Foo` is ambiguous + use Foo::*; // OK let _ = (A, B); fn std() {} enum std {} - use std as foo; - //~^ ERROR `std` is ambiguous - //~| ERROR `std` is ambiguous + use std as foo; // OK } diff --git a/tests/ui/rust-2018/uniform-paths/block-scoped-shadow.stderr b/tests/ui/rust-2018/uniform-paths/block-scoped-shadow.stderr deleted file mode 100644 index b068312cedd6f..0000000000000 --- a/tests/ui/rust-2018/uniform-paths/block-scoped-shadow.stderr +++ /dev/null @@ -1,60 +0,0 @@ -error[E0659]: `Foo` is ambiguous - --> $DIR/block-scoped-shadow.rs:11:9 - | -LL | use Foo::*; - | ^^^ ambiguous name - | - = note: ambiguous because of multiple potential import sources -note: `Foo` could refer to the enum defined here - --> $DIR/block-scoped-shadow.rs:10:5 - | -LL | enum Foo { A, B } - | ^^^^^^^^^^^^^^^^^ -note: `Foo` could also refer to the enum defined here - --> $DIR/block-scoped-shadow.rs:5:1 - | -LL | enum Foo {} - | ^^^^^^^^^^^ - = help: use `crate::Foo` to refer to this enum unambiguously - -error[E0659]: `std` is ambiguous - --> $DIR/block-scoped-shadow.rs:18:9 - | -LL | use std as foo; - | ^^^ ambiguous name - | - = note: ambiguous because of multiple potential import sources -note: `std` could refer to the enum defined here - --> $DIR/block-scoped-shadow.rs:17:5 - | -LL | enum std {} - | ^^^^^^^^^^^ -note: `std` could also refer to the struct defined here - --> $DIR/block-scoped-shadow.rs:7:1 - | -LL | struct std; - | ^^^^^^^^^^^ - = help: use `crate::std` to refer to this struct unambiguously - -error[E0659]: `std` is ambiguous - --> $DIR/block-scoped-shadow.rs:18:9 - | -LL | use std as foo; - | ^^^ ambiguous name - | - = note: ambiguous because of multiple potential import sources -note: `std` could refer to the function defined here - --> $DIR/block-scoped-shadow.rs:16:5 - | -LL | fn std() {} - | ^^^^^^^^^^^ -note: `std` could also refer to the unit struct defined here - --> $DIR/block-scoped-shadow.rs:7:1 - | -LL | struct std; - | ^^^^^^^^^^^ - = help: use `crate::std` to refer to this unit struct unambiguously - -error: aborting due to 3 previous errors - -For more information about this error, try `rustc --explain E0659`. diff --git a/tests/ui/rust-2018/uniform-paths/issue-56596.stderr b/tests/ui/rust-2018/uniform-paths/issue-56596.stderr index 8b8ab26dce224..849d6275eb85b 100644 --- a/tests/ui/rust-2018/uniform-paths/issue-56596.stderr +++ b/tests/ui/rust-2018/uniform-paths/issue-56596.stderr @@ -4,7 +4,7 @@ error[E0659]: `issue_56596` is ambiguous LL | use issue_56596; | ^^^^^^^^^^^ ambiguous name | - = note: ambiguous because of multiple potential import sources + = note: ambiguous because of a conflict between a name from a glob import and an outer scope during import or macro resolution = note: `issue_56596` could refer to a crate passed with `--extern` = help: use `::issue_56596` to refer to this crate unambiguously note: `issue_56596` could also refer to the module imported here @@ -12,7 +12,8 @@ note: `issue_56596` could also refer to the module imported here | LL | use m::*; | ^^^^ - = help: use `crate::issue_56596` to refer to this module unambiguously + = help: consider adding an explicit import of `issue_56596` to disambiguate + = help: or use `crate::issue_56596` to refer to this module unambiguously error: aborting due to previous error diff --git a/tests/ui/rust-2018/uniform-paths/macro-rules.rs b/tests/ui/rust-2018/uniform-paths/macro-rules.rs index 2d9a6a9a92499..1084f5e8b344a 100644 --- a/tests/ui/rust-2018/uniform-paths/macro-rules.rs +++ b/tests/ui/rust-2018/uniform-paths/macro-rules.rs @@ -27,8 +27,7 @@ mod m3 { fn f() { macro_rules! legacy_macro { () => () } - // Legacy macro imports create ambiguities with other names in the same namespace. - use legacy_macro as _; //~ ERROR `legacy_macro` is ambiguous + use legacy_macro as _; // OK } } diff --git a/tests/ui/rust-2018/uniform-paths/macro-rules.stderr b/tests/ui/rust-2018/uniform-paths/macro-rules.stderr index 9f8c928c32c04..8a978c98a443e 100644 --- a/tests/ui/rust-2018/uniform-paths/macro-rules.stderr +++ b/tests/ui/rust-2018/uniform-paths/macro-rules.stderr @@ -10,26 +10,6 @@ help: consider adding a `#[macro_export]` to the macro in the imported module LL | macro_rules! legacy_macro { () => () } | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -error[E0659]: `legacy_macro` is ambiguous - --> $DIR/macro-rules.rs:31:13 - | -LL | use legacy_macro as _; - | ^^^^^^^^^^^^ ambiguous name - | - = note: ambiguous because of multiple potential import sources -note: `legacy_macro` could refer to the macro defined here - --> $DIR/macro-rules.rs:28:9 - | -LL | macro_rules! legacy_macro { () => () } - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -note: `legacy_macro` could also refer to the macro defined here - --> $DIR/macro-rules.rs:25:5 - | -LL | macro legacy_macro() {} - | ^^^^^^^^^^^^^^^^^^^^^^^ - = help: use `self::legacy_macro` to refer to this macro unambiguously - -error: aborting due to 2 previous errors +error: aborting due to previous error -Some errors have detailed explanations: E0364, E0659. -For more information about an error, try `rustc --explain E0364`. +For more information about this error, try `rustc --explain E0364`.