]> git.lizzy.rs Git - rust.git/commitdiff
resolve: Improve diagnostics for resolution ambiguities
authorVadim Petrochenkov <vadim.petrochenkov@gmail.com>
Sun, 4 Nov 2018 22:11:59 +0000 (01:11 +0300)
committerVadim Petrochenkov <vadim.petrochenkov@gmail.com>
Sun, 18 Nov 2018 10:51:40 +0000 (13:51 +0300)
41 files changed:
src/librustc/hir/def.rs
src/librustc_mir/hair/pattern/check_match.rs
src/librustc_resolve/build_reduced_graph.rs
src/librustc_resolve/lib.rs
src/librustc_resolve/macros.rs
src/librustc_resolve/resolve_imports.rs
src/test/ui-fulldeps/custom-derive/helper-attr-blocked-by-import-ambig.stderr
src/test/ui-fulldeps/proc-macro/ambiguous-builtin-attrs.stderr
src/test/ui-fulldeps/proc-macro/derive-helper-shadowing.stderr
src/test/ui/error-codes/E0659.stderr
src/test/ui/imports/duplicate.stderr
src/test/ui/imports/extern-prelude-extern-crate-restricted-shadowing.stderr
src/test/ui/imports/glob-shadowing.stderr
src/test/ui/imports/issue-53269.stderr
src/test/ui/imports/local-modularized-tricky-fail-1.stderr
src/test/ui/imports/macro-paths.stderr
src/test/ui/imports/macros.stderr
src/test/ui/imports/rfc-1560-warning-cycle.stderr
src/test/ui/imports/shadow_builtin_macros.stderr
src/test/ui/macros/ambiguity-legacy-vs-modern.stderr
src/test/ui/macros/macro-path-prelude-shadowing.stderr
src/test/ui/macros/macro-shadowing.stderr
src/test/ui/macros/restricted-shadowing-legacy.stderr
src/test/ui/macros/restricted-shadowing-modern.stderr
src/test/ui/out-of-order-shadowing.stderr
src/test/ui/rust-2018/uniform-paths-forward-compat/ambiguity-macros-nested.rs
src/test/ui/rust-2018/uniform-paths-forward-compat/ambiguity-macros-nested.stderr
src/test/ui/rust-2018/uniform-paths-forward-compat/ambiguity-macros.rs
src/test/ui/rust-2018/uniform-paths-forward-compat/ambiguity-macros.stderr
src/test/ui/rust-2018/uniform-paths-forward-compat/ambiguity-nested.rs
src/test/ui/rust-2018/uniform-paths-forward-compat/ambiguity-nested.stderr
src/test/ui/rust-2018/uniform-paths-forward-compat/ambiguity.rs
src/test/ui/rust-2018/uniform-paths-forward-compat/ambiguity.stderr
src/test/ui/rust-2018/uniform-paths/ambiguity-macros-nested.rs
src/test/ui/rust-2018/uniform-paths/ambiguity-macros-nested.stderr
src/test/ui/rust-2018/uniform-paths/ambiguity-macros.rs
src/test/ui/rust-2018/uniform-paths/ambiguity-macros.stderr
src/test/ui/rust-2018/uniform-paths/ambiguity-nested.rs
src/test/ui/rust-2018/uniform-paths/ambiguity-nested.stderr
src/test/ui/rust-2018/uniform-paths/ambiguity.rs
src/test/ui/rust-2018/uniform-paths/ambiguity.stderr

index e4c434b562ddc96d824d192d6af8fbbcead0eb8e..c5e631ebafab1efcb48602f25b39f06f3a10c764 100644 (file)
@@ -128,14 +128,6 @@ pub fn base_def(&self) -> Def {
     pub fn unresolved_segments(&self) -> usize {
         self.unresolved_segments
     }
-
-    pub fn kind_name(&self) -> &'static str {
-        if self.unresolved_segments != 0 {
-            "associated item"
-        } else {
-            self.base_def.kind_name()
-        }
-    }
 }
 
 /// Different kinds of symbols don't influence each other.
@@ -333,4 +325,12 @@ pub fn kind_name(&self) -> &'static str {
             Def::Err => "unresolved item",
         }
     }
+
+    pub fn article(&self) -> &'static str {
+        match *self {
+            Def::AssociatedTy(..) | Def::AssociatedConst(..) | Def::AssociatedExistential(..) |
+            Def::Enum(..) | Def::Existential(..) | Def::Err => "an",
+            _ => "a",
+        }
+    }
 }
index 32f8752c31be7dfe92a27c3328912181fe8bcd28..bafabe4e9972cf474ff4752f02a89107033730c1 100644 (file)
@@ -298,7 +298,8 @@ fn check_irrefutable(&self, pat: &'tcx Pat, origin: &str) {
             let label_msg = match pat.node {
                 PatKind::Path(hir::QPath::Resolved(None, ref path))
                         if path.segments.len() == 1 && path.segments[0].args.is_none() => {
-                    format!("interpreted as a {} pattern, not new variable", path.def.kind_name())
+                    format!("interpreted as {} {} pattern, not new variable",
+                            path.def.article(), path.def.kind_name())
                 }
                 _ => format!("pattern `{}` not covered", pattern_string),
             };
index 777543bcf37eba4abb420cc431f7677e4f784432..864aa7f6dc4f84e5bcee5ba75531c6d0e08abe52 100644 (file)
@@ -347,6 +347,23 @@ fn build_reduced_graph_for_item(&mut self, item: &Item, parent_scope: ParentScop
                 let used = self.process_legacy_macro_imports(item, module, &parent_scope);
                 let binding =
                     (module, ty::Visibility::Public, sp, expansion).to_name_binding(self.arenas);
+                let directive = self.arenas.alloc_import_directive(ImportDirective {
+                    root_id: item.id,
+                    id: item.id,
+                    parent_scope,
+                    imported_module: Cell::new(Some(ModuleOrUniformRoot::Module(module))),
+                    subclass: ImportDirectiveSubclass::ExternCrate {
+                        source: orig_name,
+                        target: ident,
+                    },
+                    root_span: item.span,
+                    span: item.span,
+                    module_path: Vec::new(),
+                    vis: Cell::new(vis),
+                    used: Cell::new(used),
+                });
+                self.potentially_unused_imports.push(directive);
+                let imported_binding = self.import(binding, directive);
                 if ptr::eq(self.current_module, self.graph_root) {
                     if let Some(entry) = self.extern_prelude.get(&ident.modern()) {
                         if expansion != Mark::root() && orig_name.is_some() &&
@@ -361,28 +378,11 @@ fn build_reduced_graph_for_item(&mut self, item: &Item, parent_scope: ParentScop
                         extern_crate_item: None,
                         introduced_by_item: true,
                     });
-                    entry.extern_crate_item = Some(binding);
+                    entry.extern_crate_item = Some(imported_binding);
                     if orig_name.is_some() {
                         entry.introduced_by_item = true;
                     }
                 }
-                let directive = self.arenas.alloc_import_directive(ImportDirective {
-                    root_id: item.id,
-                    id: item.id,
-                    parent_scope,
-                    imported_module: Cell::new(Some(ModuleOrUniformRoot::Module(module))),
-                    subclass: ImportDirectiveSubclass::ExternCrate {
-                        source: orig_name,
-                        target: ident,
-                    },
-                    root_span: item.span,
-                    span: item.span,
-                    module_path: Vec::new(),
-                    vis: Cell::new(vis),
-                    used: Cell::new(used),
-                });
-                self.potentially_unused_imports.push(directive);
-                let imported_binding = self.import(binding, directive);
                 self.define(parent, ident, TypeNS, imported_binding);
             }
 
index 279fbafdcd7a73e5e1144651fb7738c0401c6b58..23fff0d0126f966123e407a0d2ab00c2e17f7cf8 100644 (file)
@@ -391,14 +391,13 @@ fn resolve_struct_error<'sess, 'a>(resolver: &'sess Resolver,
             err
         }
         ResolutionError::BindingShadowsSomethingUnacceptable(what_binding, name, binding) => {
-            let shadows_what = PathResolution::new(binding.def()).kind_name();
-            let mut err = struct_span_err!(resolver.session,
-                                           span,
-                                           E0530,
-                                           "{}s cannot shadow {}s", what_binding, shadows_what);
-            err.span_label(span, format!("cannot be named the same as a {}", shadows_what));
+            let (shadows_what, article) = (binding.descr(), binding.article());
+            let mut err = struct_span_err!(resolver.session, span, E0530, "{}s cannot shadow {}s",
+                                           what_binding, shadows_what);
+            err.span_label(span, format!("cannot be named the same as {} {}",
+                                         article, shadows_what));
             let participle = if binding.is_import() { "imported" } else { "defined" };
-            let msg = format!("a {} `{}` is {} here", shadows_what, name, participle);
+            let msg = format!("{} {} `{}` is {} here", article, shadows_what, name, participle);
             err.span_label(binding.span, msg);
             err
         }
@@ -1195,6 +1194,7 @@ enum NameBindingKind<'a> {
         used: Cell<bool>,
     },
     Ambiguity {
+        kind: AmbiguityKind,
         b1: &'a NameBinding<'a>,
         b2: &'a NameBinding<'a>,
     }
@@ -1212,10 +1212,61 @@ struct UseError<'a> {
     better: bool,
 }
 
+#[derive(Clone, Copy, PartialEq, Debug)]
+enum AmbiguityKind {
+    Import,
+    BuiltinAttr,
+    DeriveHelper,
+    LegacyHelperVsPrelude,
+    LegacyVsModern,
+    GlobVsOuter,
+    GlobVsGlob,
+    GlobVsExpanded,
+    MoreExpandedVsOuter,
+}
+
+impl AmbiguityKind {
+    fn descr(self) -> &'static str {
+        match self {
+            AmbiguityKind::Import =>
+                "name vs any other name during import resolution",
+            AmbiguityKind::BuiltinAttr =>
+                "built-in attribute vs any other name",
+            AmbiguityKind::DeriveHelper =>
+                "derive helper attribute vs any other name",
+            AmbiguityKind::LegacyHelperVsPrelude =>
+                "legacy plugin helper attribute vs name from prelude",
+            AmbiguityKind::LegacyVsModern =>
+                "`macro_rules` vs non-`macro_rules` from other module",
+            AmbiguityKind::GlobVsOuter =>
+                "glob import vs any other name from outer scope during import/macro resolution",
+            AmbiguityKind::GlobVsGlob =>
+                "glob import vs glob import in the same module",
+            AmbiguityKind::GlobVsExpanded =>
+                "glob import vs macro-expanded name in the same \
+                 module during import/macro resolution",
+            AmbiguityKind::MoreExpandedVsOuter =>
+                "macro-expanded name vs less macro-expanded name \
+                 from outer scope during import/macro resolution",
+        }
+    }
+}
+
+/// Miscellaneous bits of metadata for better ambiguity error reporting.
+#[derive(Clone, Copy, PartialEq)]
+enum AmbiguityErrorMisc {
+    SuggestSelf,
+    FromPrelude,
+    None,
+}
+
 struct AmbiguityError<'a> {
+    kind: AmbiguityKind,
     ident: Ident,
     b1: &'a NameBinding<'a>,
     b2: &'a NameBinding<'a>,
+    misc1: AmbiguityErrorMisc,
+    misc2: AmbiguityErrorMisc,
 }
 
 impl<'a> NameBinding<'a> {
@@ -1268,6 +1319,9 @@ fn is_extern_crate(&self) -> bool {
                     subclass: ImportDirectiveSubclass::ExternCrate { .. }, ..
                 }, ..
             } => true,
+            NameBindingKind::Module(
+                &ModuleData { kind: ModuleKind::Def(Def::Mod(def_id), _), .. }
+            ) => def_id.index == CRATE_DEF_INDEX,
             _ => false,
         }
     }
@@ -1313,6 +1367,10 @@ fn descr(&self) -> &'static str {
         if self.is_extern_crate() { "extern crate" } else { self.def().kind_name() }
     }
 
+    fn article(&self) -> &'static str {
+        if self.is_extern_crate() { "an" } else { self.def().article() }
+    }
+
     // 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
@@ -1885,8 +1943,12 @@ fn record_use(&mut self, ident: Ident, ns: Namespace, binding: &'a NameBinding<'
                 self.record_use(ident, ns, binding)
             }
             NameBindingKind::Import { .. } => false,
-            NameBindingKind::Ambiguity { b1, b2 } => {
-                self.ambiguity_errors.push(AmbiguityError { ident, b1, b2 });
+            NameBindingKind::Ambiguity { kind, b1, b2 } => {
+                self.ambiguity_errors.push(AmbiguityError {
+                    kind, ident, b1, b2,
+                    misc1: AmbiguityErrorMisc::None,
+                    misc2: AmbiguityErrorMisc::None,
+                });
                 true
             }
             _ => false
@@ -2024,7 +2086,7 @@ fn resolve_ident_in_lexical_scope(&mut self,
             }
             if ns == TypeNS && is_known_tool(ident.name) {
                 let binding = (Def::ToolMod, ty::Visibility::Public,
-                               ident.span, Mark::root()).to_name_binding(self.arenas);
+                               DUMMY_SP, Mark::root()).to_name_binding(self.arenas);
                 return Some(LexicalScopeBinding::Item(binding));
             }
             if let Some(prelude) = self.prelude {
@@ -4631,37 +4693,79 @@ fn disambiguate_legacy_vs_modern(
         }
     }
 
-    fn report_ambiguity_error(&self, ident: Ident, b1: &NameBinding, b2: &NameBinding) {
-        let participle = |is_import: bool| if is_import { "imported" } else { "defined" };
-        let msg1 =
-            format!("`{}` could refer to the name {} here", ident, participle(b1.is_import()));
-        let msg2 =
-            format!("`{}` could also refer to the name {} here", ident, participle(b2.is_import()));
-        let note = if b1.expansion != Mark::root() {
-            Some(if let Def::Macro(..) = b1.def() {
-                format!("macro-expanded {} do not shadow",
-                        if b1.is_import() { "macro imports" } else { "macros" })
-            } else {
-                format!("macro-expanded {} do not shadow when used in a macro invocation path",
-                        if b1.is_import() { "imports" } else { "items" })
-            })
-        } else if b1.is_glob_import() {
-            Some(format!("consider adding an explicit import of `{}` to disambiguate", ident))
+    fn report_ambiguity_error(&self, ambiguity_error: &AmbiguityError) {
+        let AmbiguityError { kind, ident, b1, b2, misc1, misc2 } = *ambiguity_error;
+        let (b1, b2, misc1, misc2, swapped) = if b2.span.is_dummy() && !b1.span.is_dummy() {
+            // We have to print the span-less alternative first, otherwise formatting looks bad.
+            (b2, b1, misc2, misc1, true)
         } else {
-            None
+            (b1, b2, misc1, misc2, false)
         };
 
-        let mut err = struct_span_err!(self.session, ident.span, E0659, "`{}` is ambiguous", ident);
+        let mut err = struct_span_err!(self.session, ident.span, E0659,
+                                       "`{ident}` is ambiguous ({why})",
+                                       ident = ident, why = kind.descr());
         err.span_label(ident.span, "ambiguous name");
-        err.span_note(b1.span, &msg1);
-        match b2.def() {
-            Def::Macro(..) if b2.span.is_dummy() =>
-                err.note(&format!("`{}` is also a builtin macro", ident)),
-            _ => err.span_note(b2.span, &msg2),
+
+        let mut could_refer_to = |b: &NameBinding, misc: AmbiguityErrorMisc, also: &str| {
+            let what = if b.span.is_dummy() {
+                let add_built_in = match b.def() {
+                    // These already contain the "built-in" prefix or look bad with it.
+                    Def::NonMacroAttr(..) | Def::PrimTy(..) | Def::ToolMod => false,
+                    _ => true,
+                };
+                let (built_in, from) = if misc == AmbiguityErrorMisc::FromPrelude {
+                    ("", " from prelude")
+                } else if b.is_extern_crate() && !b.is_import() &&
+                          self.session.opts.externs.get(&ident.as_str()).is_some() {
+                    ("", " passed with `--extern`")
+                } else if add_built_in {
+                    (" built-in", "")
+                } else {
+                    ("", "")
+                };
+
+                let article = if built_in.is_empty() { b.article() } else { "a" };
+                format!("{a}{built_in} {thing}{from}",
+                        a = article, thing = b.descr(), built_in = built_in, from = from)
+            } else {
+                let participle = if b.is_import() { "imported" } else { "defined" };
+                format!("the {thing} {introduced} here",
+                        thing = b.descr(), introduced = participle)
+            };
+            let note_msg = format!("`{ident}` could{also} refer to {what}",
+                                   ident = ident, also = also, what = what);
+
+            let mut help_msgs = Vec::new();
+            if b.is_glob_import() && (kind == AmbiguityKind::GlobVsGlob ||
+                                      kind == AmbiguityKind::GlobVsExpanded ||
+                                      kind == AmbiguityKind::GlobVsOuter &&
+                                      swapped != also.is_empty()) {
+                help_msgs.push(format!("consider adding an explicit import of \
+                                        `{ident}` to disambiguate", ident = ident))
+            }
+            if b.is_extern_crate() && self.session.rust_2018() {
+                help_msgs.push(format!("use `::{ident}` to refer to the {thing} unambiguously",
+                                       ident = ident, thing = b.descr()))
+            }
+            if misc == AmbiguityErrorMisc::SuggestSelf {
+                help_msgs.push(format!("use `self::{ident}` to refer to the {thing} unambiguously",
+                                       ident = ident, thing = b.descr()))
+            }
+
+            if b.span.is_dummy() {
+                err.note(&note_msg);
+            } else {
+                err.span_note(b.span, &note_msg);
+            }
+            for (i, help_msg) in help_msgs.iter().enumerate() {
+                let or = if i == 0 { "" } else { "or " };
+                err.help(&format!("{}{}", or, help_msg));
+            }
         };
-        if let Some(note) = note {
-            err.note(&note);
-        }
+
+        could_refer_to(b1, misc1, "");
+        could_refer_to(b2, misc2, " also");
         err.emit();
     }
 
@@ -4680,9 +4784,9 @@ fn report_errors(&mut self, krate: &Crate) {
             );
         }
 
-        for &AmbiguityError { ident, b1, b2 } in &self.ambiguity_errors {
-            if reported_spans.insert(ident.span) {
-                self.report_ambiguity_error(ident, b1, b2);
+        for ambiguity_error in &self.ambiguity_errors {
+            if reported_spans.insert(ambiguity_error.ident.span) {
+                self.report_ambiguity_error(ambiguity_error);
             }
         }
 
@@ -4860,7 +4964,7 @@ fn extern_prelude_get(&mut self, ident: Ident, speculative: bool, skip_feature_g
                 };
                 let crate_root = self.get_module(DefId { krate: crate_id, index: CRATE_DEF_INDEX });
                 self.populate_module_if_necessary(&crate_root);
-                Some((crate_root, ty::Visibility::Public, ident.span, Mark::root())
+                Some((crate_root, ty::Visibility::Public, DUMMY_SP, Mark::root())
                     .to_name_binding(self.arenas))
             }
         })
index 05a2ad23e64b5c0e98321bc7843186beda7b0d36..e38ffaca324b8beb6b107ec79cbced115c9eeed1 100644 (file)
@@ -8,8 +8,9 @@
 // option. This file may not be copied, modified, or distributed
 // except according to those terms.
 
-use {AmbiguityError, CrateLint, Resolver, ResolutionError, is_known_tool, resolve_error};
-use {Module, ModuleKind, NameBinding, NameBindingKind, PathResult, Segment, ToNameBinding};
+use {AmbiguityError, AmbiguityKind, AmbiguityErrorMisc};
+use {CrateLint, Resolver, ResolutionError, is_known_tool, resolve_error};
+use {Module, ModuleKind, NameBinding, NameBindingKind, PathResult, ToNameBinding};
 use ModuleOrUniformRoot;
 use Namespace::{self, *};
 use build_reduced_graph::{BuildReducedGraphVisitor, IsMacroExport};
@@ -597,10 +598,11 @@ enum WhereToResolve<'a> {
 
         bitflags! {
             struct Flags: u8 {
-                const DERIVE_HELPERS = 1 << 0;
-                const MACRO_RULES    = 1 << 1;
-                const MODULE         = 1 << 2;
-                const PRELUDE        = 1 << 3;
+                const MACRO_RULES       = 1 << 0;
+                const MODULE            = 1 << 1;
+                const PRELUDE           = 1 << 2;
+                const MISC_SUGGEST_SELF = 1 << 3;
+                const MISC_FROM_PRELUDE = 1 << 4;
             }
         }
 
@@ -619,7 +621,7 @@ struct Flags: u8 {
         // }
         // So we have to save the innermost solution and continue searching in outer scopes
         // to detect potential ambiguities.
-        let mut innermost_result: Option<(&NameBinding, Flags, /* conflicts with */ Flags)> = None;
+        let mut innermost_result: Option<(&NameBinding, Flags)> = None;
 
         // Go through all the scopes and try to resolve the name.
         let mut where_to_resolve = WhereToResolve::DeriveHelpers;
@@ -638,7 +640,7 @@ struct Flags: u8 {
                                         (Def::NonMacroAttr(NonMacroAttrKind::DeriveHelper),
                                         ty::Visibility::Public, derive.span, Mark::root())
                                         .to_name_binding(self.arenas);
-                                    result = Ok((binding, Flags::DERIVE_HELPERS, Flags::all()));
+                                    result = Ok((binding, Flags::empty()));
                                     break;
                                 }
                             }
@@ -648,7 +650,7 @@ struct Flags: u8 {
                 }
                 WhereToResolve::MacroRules(legacy_scope) => match legacy_scope {
                     LegacyScope::Binding(legacy_binding) if ident == legacy_binding.ident =>
-                        Ok((legacy_binding.binding, Flags::MACRO_RULES, Flags::empty())),
+                        Ok((legacy_binding.binding, Flags::MACRO_RULES)),
                     _ => Err(Determinacy::Determined),
                 }
                 WhereToResolve::Module(module) => {
@@ -662,29 +664,34 @@ struct Flags: u8 {
                         path_span,
                     );
                     self.current_module = orig_current_module;
-                    binding.map(|binding| (binding, Flags::MODULE, Flags::empty()))
+                    let misc_flags = if module.is_normal() {
+                        Flags::MISC_SUGGEST_SELF
+                    } else {
+                        Flags::empty()
+                    };
+                    binding.map(|binding| (binding, Flags::MODULE | misc_flags))
                 }
                 WhereToResolve::MacroUsePrelude => {
                     let mut result = Err(Determinacy::Determined);
                     if use_prelude || self.session.rust_2015() {
                         if let Some(binding) = self.macro_use_prelude.get(&ident.name).cloned() {
-                            result = Ok((binding, Flags::PRELUDE, Flags::empty()));
+                            result = Ok((binding, Flags::PRELUDE | Flags::MISC_FROM_PRELUDE));
                         }
                     }
                     result
                 }
                 WhereToResolve::BuiltinMacros => {
                     match self.builtin_macros.get(&ident.name).cloned() {
-                        Some(binding) => Ok((binding, Flags::PRELUDE, Flags::empty())),
+                        Some(binding) => Ok((binding, Flags::PRELUDE)),
                         None => Err(Determinacy::Determined),
                     }
                 }
                 WhereToResolve::BuiltinAttrs => {
                     if is_builtin_attr_name(ident.name) {
                         let binding = (Def::NonMacroAttr(NonMacroAttrKind::Builtin),
-                                       ty::Visibility::Public, ident.span, Mark::root())
+                                       ty::Visibility::Public, DUMMY_SP, Mark::root())
                                        .to_name_binding(self.arenas);
-                        Ok((binding, Flags::PRELUDE, Flags::all()))
+                        Ok((binding, Flags::PRELUDE))
                     } else {
                         Err(Determinacy::Determined)
                     }
@@ -694,9 +701,9 @@ struct Flags: u8 {
                        self.session.plugin_attributes.borrow().iter()
                                                      .any(|(name, _)| ident.name == &**name) {
                         let binding = (Def::NonMacroAttr(NonMacroAttrKind::LegacyPluginHelper),
-                                       ty::Visibility::Public, ident.span, Mark::root())
+                                       ty::Visibility::Public, DUMMY_SP, Mark::root())
                                        .to_name_binding(self.arenas);
-                        Ok((binding, Flags::PRELUDE, Flags::PRELUDE))
+                        Ok((binding, Flags::PRELUDE))
                     } else {
                         Err(Determinacy::Determined)
                     }
@@ -706,7 +713,7 @@ struct Flags: u8 {
                     if use_prelude {
                         if let Some(binding) = self.extern_prelude_get(ident, !record_used,
                                                                        innermost_result.is_some()) {
-                            result = Ok((binding, Flags::PRELUDE, Flags::empty()));
+                            result = Ok((binding, Flags::PRELUDE));
                         }
                     }
                     result
@@ -714,8 +721,8 @@ struct Flags: u8 {
                 WhereToResolve::ToolPrelude => {
                     if use_prelude && is_known_tool(ident.name) {
                         let binding = (Def::ToolMod, ty::Visibility::Public,
-                                       ident.span, Mark::root()).to_name_binding(self.arenas);
-                        Ok((binding, Flags::PRELUDE, Flags::empty()))
+                                       DUMMY_SP, Mark::root()).to_name_binding(self.arenas);
+                        Ok((binding, Flags::PRELUDE))
                     } else {
                         Err(Determinacy::Determined)
                     }
@@ -732,7 +739,7 @@ struct Flags: u8 {
                                 false,
                                 path_span,
                             ) {
-                                result = Ok((binding, Flags::PRELUDE, Flags::empty()));
+                                result = Ok((binding, Flags::PRELUDE | Flags::MISC_FROM_PRELUDE));
                             }
                         }
                     }
@@ -742,8 +749,8 @@ struct Flags: u8 {
                     match self.primitive_type_table.primitive_types.get(&ident.name).cloned() {
                         Some(prim_ty) => {
                             let binding = (Def::PrimTy(prim_ty), ty::Visibility::Public,
-                                           ident.span, Mark::root()).to_name_binding(self.arenas);
-                            Ok((binding, Flags::PRELUDE, Flags::empty()))
+                                           DUMMY_SP, Mark::root()).to_name_binding(self.arenas);
+                            Ok((binding, Flags::PRELUDE))
                         }
                         None => Err(Determinacy::Determined)
                     }
@@ -793,7 +800,7 @@ macro_rules! continue_search { () => {
             }}
 
             match result {
-                Ok((binding, flags, ambig_flags)) => {
+                Ok((binding, flags)) => {
                     if sub_namespace_mismatch(macro_kind, binding.macro_kind()) {
                         continue_search!();
                     }
@@ -802,28 +809,61 @@ macro_rules! continue_search { () => {
                         return Ok(binding);
                     }
 
-                    if let Some((innermost_binding, innermost_flags, innermost_ambig_flags))
-                            = innermost_result {
+                    if let Some((innermost_binding, innermost_flags)) = innermost_result {
                         // Found another solution, if the first one was "weak", report an error.
-                        if binding.def() != innermost_binding.def() &&
-                           (is_import ||
-                            innermost_binding.is_glob_import() ||
-                            innermost_binding.may_appear_after(parent_scope.expansion, binding) ||
-                            innermost_flags.intersects(ambig_flags) ||
-                            flags.intersects(innermost_ambig_flags) ||
-                            (innermost_flags.contains(Flags::MACRO_RULES) &&
-                             flags.contains(Flags::MODULE) &&
-                             !self.disambiguate_legacy_vs_modern(innermost_binding, binding))) {
-                            self.ambiguity_errors.push(AmbiguityError {
-                                ident,
-                                b1: innermost_binding,
-                                b2: binding,
-                            });
-                            return Ok(innermost_binding);
+                        let (def, innermost_def) = (binding.def(), innermost_binding.def());
+                        if def != innermost_def {
+                            let builtin = Def::NonMacroAttr(NonMacroAttrKind::Builtin);
+                            let derive_helper = Def::NonMacroAttr(NonMacroAttrKind::DeriveHelper);
+                            let legacy_helper =
+                                Def::NonMacroAttr(NonMacroAttrKind::LegacyPluginHelper);
+
+                            let ambiguity_error_kind = if is_import {
+                                Some(AmbiguityKind::Import)
+                            } else if innermost_def == builtin || def == builtin {
+                                Some(AmbiguityKind::BuiltinAttr)
+                            } else if innermost_def == derive_helper || def == derive_helper {
+                                Some(AmbiguityKind::DeriveHelper)
+                            } else if innermost_def == legacy_helper &&
+                                      flags.contains(Flags::PRELUDE) ||
+                                      def == legacy_helper &&
+                                      innermost_flags.contains(Flags::PRELUDE) {
+                                Some(AmbiguityKind::LegacyHelperVsPrelude)
+                            } else if innermost_flags.contains(Flags::MACRO_RULES) &&
+                                      flags.contains(Flags::MODULE) &&
+                                      !self.disambiguate_legacy_vs_modern(innermost_binding,
+                                                                          binding) {
+                                Some(AmbiguityKind::LegacyVsModern)
+                            } else if innermost_binding.is_glob_import() {
+                                Some(AmbiguityKind::GlobVsOuter)
+                            } else if innermost_binding.may_appear_after(parent_scope.expansion,
+                                                                         binding) {
+                                Some(AmbiguityKind::MoreExpandedVsOuter)
+                            } else {
+                                None
+                            };
+                            if let Some(kind) = ambiguity_error_kind {
+                                let misc = |f: Flags| if f.contains(Flags::MISC_SUGGEST_SELF) {
+                                    AmbiguityErrorMisc::SuggestSelf
+                                } else if f.contains(Flags::MISC_FROM_PRELUDE) {
+                                    AmbiguityErrorMisc::FromPrelude
+                                } else {
+                                    AmbiguityErrorMisc::None
+                                };
+                                self.ambiguity_errors.push(AmbiguityError {
+                                    kind,
+                                    ident,
+                                    b1: innermost_binding,
+                                    b2: binding,
+                                    misc1: misc(innermost_flags),
+                                    misc2: misc(flags),
+                                });
+                                return Ok(innermost_binding);
+                            }
                         }
                     } else {
                         // Found the first solution.
-                        innermost_result = Some((binding, flags, ambig_flags));
+                        innermost_result = Some((binding, flags));
                     }
 
                     continue_search!();
index 60d6bb7bdc912e3f06606122657db8702f86d3d1..890655c398c3d81abe01aee718d85bb979f9d6bf 100644 (file)
@@ -10,7 +10,8 @@
 
 use self::ImportDirectiveSubclass::*;
 
-use {AmbiguityError, CrateLint, Module, ModuleOrUniformRoot, PerNS};
+use {AmbiguityError, AmbiguityKind, AmbiguityErrorMisc};
+use {CrateLint, Module, ModuleOrUniformRoot, PerNS};
 use Namespace::{self, TypeNS, MacroNS};
 use {NameBinding, NameBindingKind, ToNameBinding, PathResult, PrivacyError};
 use {Resolver, Segment};
@@ -219,7 +220,7 @@ pub fn resolve_ident_in_module_unadjusted(&mut self,
                 };
                 self.populate_module_if_necessary(crate_root);
                 let binding = (crate_root, ty::Visibility::Public,
-                               ident.span, Mark::root()).to_name_binding(self.arenas);
+                               crate_root.span, Mark::root()).to_name_binding(self.arenas);
                 return Ok(binding);
             }
         };
@@ -244,12 +245,14 @@ pub fn resolve_ident_in_module_unadjusted(&mut self,
                     // Forbid expanded shadowing to avoid time travel.
                     if restricted_shadowing &&
                        binding.expansion != Mark::root() &&
-                       ns != MacroNS && // In MacroNS, `try_define` always forbids this shadowing
                        binding.def() != shadowed_glob.def() {
                         self.ambiguity_errors.push(AmbiguityError {
+                            kind: AmbiguityKind::GlobVsExpanded,
                             ident,
                             b1: binding,
                             b2: shadowed_glob,
+                            misc1: AmbiguityErrorMisc::None,
+                            misc2: AmbiguityErrorMisc::None,
                         });
                     }
                 }
@@ -471,38 +474,48 @@ pub fn try_define(&mut self,
         self.set_binding_parent_module(binding, module);
         self.update_resolution(module, ident, ns, |this, resolution| {
             if let Some(old_binding) = resolution.binding {
-                if binding.is_glob_import() {
-                    if !old_binding.is_glob_import() &&
-                       !(ns == MacroNS && old_binding.expansion != Mark::root()) {
-                        resolution.shadowed_glob = Some(binding);
-                    } else if binding.def() != old_binding.def() {
-                        resolution.binding = Some(this.ambiguity(old_binding, binding));
-                    } else if !old_binding.vis.is_at_least(binding.vis, &*this) {
-                        // We are glob-importing the same item but with greater visibility.
-                        resolution.binding = Some(binding);
+                match (old_binding.is_glob_import(), binding.is_glob_import()) {
+                    (true, true) => {
+                        if binding.def() != old_binding.def() {
+                            resolution.binding = Some(this.ambiguity(AmbiguityKind::GlobVsGlob,
+                                                                     old_binding, binding));
+                        } else if !old_binding.vis.is_at_least(binding.vis, &*this) {
+                            // We are glob-importing the same item but with greater visibility.
+                            resolution.binding = Some(binding);
+                        }
                     }
-                } else if old_binding.is_glob_import() {
-                    if ns == MacroNS && binding.expansion != Mark::root() &&
-                       binding.def() != old_binding.def() {
-                        resolution.binding = Some(this.ambiguity(binding, old_binding));
-                    } else {
-                        resolution.binding = Some(binding);
-                        resolution.shadowed_glob = Some(old_binding);
+                    (old_glob @ true, false) | (old_glob @ false, true) => {
+                        let (glob_binding, nonglob_binding) = if old_glob {
+                            (old_binding, binding)
+                        } else {
+                            (binding, old_binding)
+                        };
+                        if glob_binding.def() != nonglob_binding.def() &&
+                           ns == MacroNS && nonglob_binding.expansion != Mark::root() {
+                            resolution.binding = Some(this.ambiguity(AmbiguityKind::GlobVsExpanded,
+                                                                    nonglob_binding, glob_binding));
+                        } else {
+                            resolution.binding = Some(nonglob_binding);
+                            resolution.shadowed_glob = Some(glob_binding);
+                        }
+                    }
+                    (false, false) => {
+                        if let (&NameBindingKind::Def(_, true), &NameBindingKind::Def(_, true)) =
+                               (&old_binding.kind, &binding.kind) {
+
+                            this.session.buffer_lint_with_diagnostic(
+                                DUPLICATE_MACRO_EXPORTS,
+                                CRATE_NODE_ID,
+                                binding.span,
+                                &format!("a macro named `{}` has already been exported", ident),
+                                BuiltinLintDiagnostics::DuplicatedMacroExports(
+                                    ident, old_binding.span, binding.span));
+
+                            resolution.binding = Some(binding);
+                        } else {
+                            return Err(old_binding);
+                        }
                     }
-                } else if let (&NameBindingKind::Def(_, true), &NameBindingKind::Def(_, true)) =
-                        (&old_binding.kind, &binding.kind) {
-
-                    this.session.buffer_lint_with_diagnostic(
-                        DUPLICATE_MACRO_EXPORTS,
-                        CRATE_NODE_ID,
-                        binding.span,
-                        &format!("a macro named `{}` has already been exported", ident),
-                        BuiltinLintDiagnostics::DuplicatedMacroExports(
-                            ident, old_binding.span, binding.span));
-
-                    resolution.binding = Some(binding);
-                } else {
-                    return Err(old_binding);
                 }
             } else {
                 resolution.binding = Some(binding);
@@ -512,10 +525,10 @@ pub fn try_define(&mut self,
         })
     }
 
-    pub fn ambiguity(&self, b1: &'a NameBinding<'a>, b2: &'a NameBinding<'a>)
+    fn ambiguity(&self, kind: AmbiguityKind, b1: &'a NameBinding<'a>, b2: &'a NameBinding<'a>)
                      -> &'a NameBinding<'a> {
         self.arenas.alloc_name_binding(NameBinding {
-            kind: NameBindingKind::Ambiguity { b1, b2 },
+            kind: NameBindingKind::Ambiguity { kind, b1, b2 },
             vis: if b1.vis.is_at_least(b2.vis, self) { b1.vis } else { b2.vis },
             span: b1.span,
             expansion: Mark::root(),
index 059629c0b62d5ad17b33ef6c015381d01cea313e..fc55dc1eef67a967d5818169aaaeff6bd34f612e 100644 (file)
@@ -1,19 +1,20 @@
-error[E0659]: `helper` is ambiguous
+error[E0659]: `helper` is ambiguous (derive helper attribute vs any other name)
   --> $DIR/helper-attr-blocked-by-import-ambig.rs:10:3
    |
 LL | #[helper] //~ ERROR `helper` is ambiguous
    |   ^^^^^^ ambiguous name
    |
-note: `helper` could refer to the name defined here
+note: `helper` could refer to the derive helper attribute defined here
   --> $DIR/helper-attr-blocked-by-import-ambig.rs:9:10
    |
 LL | #[derive(WithHelper)]
    |          ^^^^^^^^^^
-note: `helper` could also refer to the name imported here
+note: `helper` could also refer to the attribute macro imported here
   --> $DIR/helper-attr-blocked-by-import-ambig.rs:7:5
    |
 LL | use plugin::helper;
    |     ^^^^^^^^^^^^^^
+   = help: use `self::helper` to refer to the attribute macro unambiguously
 
 error: aborting due to previous error
 
index 0720ccb7cf9df056e284c65dd2ddb1f539e39661..00f5cfc2613a087427c5f969d9682b7b45e922ee 100644 (file)
@@ -4,95 +4,75 @@ error[E0425]: cannot find value `NonExistent` in this scope
 LL |     NonExistent; //~ ERROR cannot find value `NonExistent` in this scope
    |     ^^^^^^^^^^^ not found in this scope
 
-error[E0659]: `repr` is ambiguous
+error[E0659]: `repr` is ambiguous (built-in attribute vs any other name)
   --> $DIR/ambiguous-builtin-attrs.rs:9:3
    |
 LL | #[repr(C)] //~ ERROR `repr` is ambiguous
    |   ^^^^ ambiguous name
    |
-note: `repr` could refer to the name imported here
+   = note: `repr` could refer to a built-in attribute
+note: `repr` could also refer to the attribute macro imported here
   --> $DIR/ambiguous-builtin-attrs.rs:7:5
    |
 LL | use builtin_attrs::*;
    |     ^^^^^^^^^^^^^^^^
-note: `repr` could also refer to the name defined here
-  --> $DIR/ambiguous-builtin-attrs.rs:9:3
-   |
-LL | #[repr(C)] //~ ERROR `repr` is ambiguous
-   |   ^^^^
-   = note: consider adding an explicit import of `repr` to disambiguate
+   = help: use `self::repr` to refer to the attribute macro unambiguously
 
-error[E0659]: `repr` is ambiguous
+error[E0659]: `repr` is ambiguous (built-in attribute vs any other name)
   --> $DIR/ambiguous-builtin-attrs.rs:11:19
    |
 LL | #[cfg_attr(all(), repr(C))] //~ ERROR `repr` is ambiguous
    |                   ^^^^ ambiguous name
    |
-note: `repr` could refer to the name imported here
+   = note: `repr` could refer to a built-in attribute
+note: `repr` could also refer to the attribute macro imported here
   --> $DIR/ambiguous-builtin-attrs.rs:7:5
    |
 LL | use builtin_attrs::*;
    |     ^^^^^^^^^^^^^^^^
-note: `repr` could also refer to the name defined here
-  --> $DIR/ambiguous-builtin-attrs.rs:11:19
-   |
-LL | #[cfg_attr(all(), repr(C))] //~ ERROR `repr` is ambiguous
-   |                   ^^^^
-   = note: consider adding an explicit import of `repr` to disambiguate
+   = help: use `self::repr` to refer to the attribute macro unambiguously
 
-error[E0659]: `repr` is ambiguous
+error[E0659]: `repr` is ambiguous (built-in attribute vs any other name)
   --> $DIR/ambiguous-builtin-attrs.rs:20:34
    |
 LL | fn non_macro_expanded_location<#[repr(C)] T>() { //~ ERROR `repr` is ambiguous
    |                                  ^^^^ ambiguous name
    |
-note: `repr` could refer to the name imported here
+   = note: `repr` could refer to a built-in attribute
+note: `repr` could also refer to the attribute macro imported here
   --> $DIR/ambiguous-builtin-attrs.rs:7:5
    |
 LL | use builtin_attrs::*;
    |     ^^^^^^^^^^^^^^^^
-note: `repr` could also refer to the name defined here
-  --> $DIR/ambiguous-builtin-attrs.rs:20:34
-   |
-LL | fn non_macro_expanded_location<#[repr(C)] T>() { //~ ERROR `repr` is ambiguous
-   |                                  ^^^^
-   = note: consider adding an explicit import of `repr` to disambiguate
+   = help: use `self::repr` to refer to the attribute macro unambiguously
 
-error[E0659]: `repr` is ambiguous
+error[E0659]: `repr` is ambiguous (built-in attribute vs any other name)
   --> $DIR/ambiguous-builtin-attrs.rs:22:11
    |
 LL |         #[repr(C)] //~ ERROR `repr` is ambiguous
    |           ^^^^ ambiguous name
    |
-note: `repr` could refer to the name imported here
+   = note: `repr` could refer to a built-in attribute
+note: `repr` could also refer to the attribute macro imported here
   --> $DIR/ambiguous-builtin-attrs.rs:7:5
    |
 LL | use builtin_attrs::*;
    |     ^^^^^^^^^^^^^^^^
-note: `repr` could also refer to the name defined here
-  --> $DIR/ambiguous-builtin-attrs.rs:22:11
-   |
-LL |         #[repr(C)] //~ ERROR `repr` is ambiguous
-   |           ^^^^
-   = note: consider adding an explicit import of `repr` to disambiguate
+   = help: use `self::repr` to refer to the attribute macro unambiguously
 
-error[E0659]: `feature` is ambiguous
+error[E0659]: `feature` is ambiguous (built-in attribute vs any other name)
   --> $DIR/ambiguous-builtin-attrs.rs:3:4
    |
 LL | #![feature(decl_macro)] //~ ERROR `feature` is ambiguous
    |    ^^^^^^^ ambiguous name
    |
-note: `feature` could refer to the name imported here
+   = note: `feature` could refer to a built-in attribute
+note: `feature` could also refer to the attribute macro imported here
   --> $DIR/ambiguous-builtin-attrs.rs:7:5
    |
 LL | use builtin_attrs::*;
    |     ^^^^^^^^^^^^^^^^
-note: `feature` could also refer to the name defined here
-  --> $DIR/ambiguous-builtin-attrs.rs:3:4
-   |
-LL | #![feature(decl_macro)] //~ ERROR `feature` is ambiguous
-   |    ^^^^^^^
-   = note: consider adding an explicit import of `feature` to disambiguate
+   = help: use `self::feature` to refer to the attribute macro unambiguously
 
 error: aborting due to 6 previous errors
 
index e0aeae4ba6c54ffa2202bccc166f042d061c3c91..4950b016d37669799849afd78b17f2b759350b8c 100644 (file)
@@ -1,19 +1,20 @@
-error[E0659]: `my_attr` is ambiguous
+error[E0659]: `my_attr` is ambiguous (derive helper attribute vs any other name)
   --> $DIR/derive-helper-shadowing.rs:6:3
    |
 LL | #[my_attr] //~ ERROR `my_attr` is ambiguous
    |   ^^^^^^^ ambiguous name
    |
-note: `my_attr` could refer to the name defined here
+note: `my_attr` could refer to the derive helper attribute defined here
   --> $DIR/derive-helper-shadowing.rs:7:10
    |
 LL | #[derive(MyTrait)]
    |          ^^^^^^^
-note: `my_attr` could also refer to the name imported here
+note: `my_attr` could also refer to the attribute macro imported here
   --> $DIR/derive-helper-shadowing.rs:4:5
    |
 LL | use derive_helper_shadowing::*;
    |     ^^^^^^^^^^^^^^^^^^^^^^^^^^
+   = help: use `self::my_attr` to refer to the attribute macro unambiguously
 
 error: aborting due to previous error
 
index f168b7797ca6d0097e0833ea8410defe96d1cd2b..7bfe159405beae19a5a1c6417aadd8ffe2662198 100644 (file)
@@ -1,20 +1,21 @@
-error[E0659]: `foo` is ambiguous
+error[E0659]: `foo` is ambiguous (glob import vs glob import in the same module)
   --> $DIR/E0659.rs:25:15
    |
 LL |     collider::foo(); //~ ERROR E0659
    |               ^^^ ambiguous name
    |
-note: `foo` could refer to the name imported here
+note: `foo` could refer to the function imported here
   --> $DIR/E0659.rs:20:13
    |
 LL |     pub use moon::*;
    |             ^^^^^^^
-note: `foo` could also refer to the name imported here
+   = help: consider adding an explicit import of `foo` to disambiguate
+note: `foo` could also refer to the function imported here
   --> $DIR/E0659.rs:21:13
    |
 LL |     pub use earth::*;
    |             ^^^^^^^^
-   = note: consider adding an explicit import of `foo` to disambiguate
+   = help: consider adding an explicit import of `foo` to disambiguate
 
 error: aborting due to previous error
 
index 5d51981e8afa9599aeb0a1305f8a18292f37050f..f53ba9cd5de8ea5b2c30d7ca1f4baed749096f7d 100644 (file)
@@ -12,77 +12,81 @@ help: you can use `as` to change the binding name of the import
 LL |     use a::foo as other_foo; //~ ERROR the name `foo` is defined multiple times
    |         ^^^^^^^^^^^^^^^^^^^
 
-error[E0659]: `foo` is ambiguous
+error[E0659]: `foo` is ambiguous (glob import vs glob import in the same module)
   --> $DIR/duplicate.rs:56:15
    |
 LL |     use self::foo::bar; //~ ERROR `foo` is ambiguous
    |               ^^^ ambiguous name
    |
-note: `foo` could refer to the name imported here
+note: `foo` could refer to the module imported here
   --> $DIR/duplicate.rs:53:9
    |
 LL |     use self::m1::*;
    |         ^^^^^^^^^^^
-note: `foo` could also refer to the name imported here
+   = help: consider adding an explicit import of `foo` to disambiguate
+note: `foo` could also refer to the module imported here
   --> $DIR/duplicate.rs:54:9
    |
 LL |     use self::m2::*;
    |         ^^^^^^^^^^^
-   = note: consider adding an explicit import of `foo` to disambiguate
+   = help: consider adding an explicit import of `foo` to disambiguate
 
-error[E0659]: `foo` is ambiguous
+error[E0659]: `foo` is ambiguous (glob import vs glob import in the same module)
   --> $DIR/duplicate.rs:45:8
    |
 LL |     f::foo(); //~ ERROR `foo` is ambiguous
    |        ^^^ ambiguous name
    |
-note: `foo` could refer to the name imported here
+note: `foo` could refer to the function imported here
   --> $DIR/duplicate.rs:34:13
    |
 LL |     pub use a::*;
    |             ^^^^
-note: `foo` could also refer to the name imported here
+   = help: consider adding an explicit import of `foo` to disambiguate
+note: `foo` could also refer to the function imported here
   --> $DIR/duplicate.rs:35:13
    |
 LL |     pub use b::*;
    |             ^^^^
-   = note: consider adding an explicit import of `foo` to disambiguate
+   = help: consider adding an explicit import of `foo` to disambiguate
 
-error[E0659]: `foo` is ambiguous
+error[E0659]: `foo` is ambiguous (glob import vs glob import in the same module)
   --> $DIR/duplicate.rs:46:8
    |
 LL |     g::foo(); //~ ERROR `foo` is ambiguous
    |        ^^^ ambiguous name
    |
-note: `foo` could refer to the name imported here
+note: `foo` could refer to the function imported here
   --> $DIR/duplicate.rs:39:13
    |
 LL |     pub use a::*;
    |             ^^^^
-note: `foo` could also refer to the name imported here
+   = help: consider adding an explicit import of `foo` to disambiguate
+note: `foo` could also refer to the unresolved item imported here
   --> $DIR/duplicate.rs:40:13
    |
 LL |     pub use f::*;
    |             ^^^^
-   = note: consider adding an explicit import of `foo` to disambiguate
+   = help: consider adding an explicit import of `foo` to disambiguate
 
-error[E0659]: `foo` is ambiguous
+error[E0659]: `foo` is ambiguous (glob import vs glob import in the same module)
   --> $DIR/duplicate.rs:59:9
    |
 LL |         foo::bar(); //~ ERROR `foo` is ambiguous
    |         ^^^ ambiguous name
    |
-note: `foo` could refer to the name imported here
+note: `foo` could refer to the module imported here
   --> $DIR/duplicate.rs:53:9
    |
 LL |     use self::m1::*;
    |         ^^^^^^^^^^^
-note: `foo` could also refer to the name imported here
+   = help: consider adding an explicit import of `foo` to disambiguate
+note: `foo` could also refer to the module imported here
   --> $DIR/duplicate.rs:54:9
    |
 LL |     use self::m2::*;
    |         ^^^^^^^^^^^
-   = note: consider adding an explicit import of `foo` to disambiguate
+   = help: consider adding an explicit import of `foo` to disambiguate
 
 error: aborting due to 5 previous errors
 
index 6c832e70e49a75396e2c0bdec13a58b9a34c86a9..218dfb796f77ad3964915b2a834875a4c48b00bf 100644 (file)
@@ -1,10 +1,11 @@
-error[E0659]: `Vec` is ambiguous
+error[E0659]: `Vec` is ambiguous (macro-expanded name vs less macro-expanded name from outer scope during import/macro resolution)
   --> $DIR/extern-prelude-extern-crate-restricted-shadowing.rs:15:9
    |
 LL |         Vec::panic!(); //~ ERROR `Vec` is ambiguous
    |         ^^^ ambiguous name
    |
-note: `Vec` could refer to the name defined here
+   = note: `Vec` could refer to a struct from prelude
+note: `Vec` could also refer to the extern crate imported here
   --> $DIR/extern-prelude-extern-crate-restricted-shadowing.rs:7:9
    |
 LL |         extern crate std as Vec;
@@ -12,8 +13,6 @@ LL |         extern crate std as Vec;
 ...
 LL | define_vec!();
    | -------------- in this macro invocation
-note: `Vec` could also refer to the name defined here
-   = note: macro-expanded items do not shadow when used in a macro invocation path
 
 error: aborting due to previous error
 
index 33a2963fa29474a7381e8d3160e1a6d571b5ecb8..93d3fa969efc30752fabcbbb3a623b80cd10b7d2 100644 (file)
@@ -1,48 +1,50 @@
-error[E0659]: `env` is ambiguous
+error[E0659]: `env` is ambiguous (glob import vs any other name from outer scope during import/macro resolution)
   --> $DIR/glob-shadowing.rs:21:17
    |
 LL |         let x = env!("PATH"); //~ ERROR `env` is ambiguous
    |                 ^^^ ambiguous name
    |
-note: `env` could refer to the name imported here
+   = note: `env` could refer to a built-in macro
+note: `env` could also refer to the macro imported here
   --> $DIR/glob-shadowing.rs:19:9
    |
 LL |     use m::*;
    |         ^^^^
-   = note: `env` is also a builtin macro
-   = note: consider adding an explicit import of `env` to disambiguate
+   = help: consider adding an explicit import of `env` to disambiguate
+   = help: or use `self::env` to refer to the macro unambiguously
 
-error[E0659]: `env` is ambiguous
+error[E0659]: `env` is ambiguous (glob import vs any other name from outer scope during import/macro resolution)
   --> $DIR/glob-shadowing.rs:29:21
    |
 LL |             let x = env!("PATH"); //~ ERROR `env` is ambiguous
    |                     ^^^ ambiguous name
    |
-note: `env` could refer to the name imported here
+   = note: `env` could refer to a built-in macro
+note: `env` could also refer to the macro imported here
   --> $DIR/glob-shadowing.rs:27:13
    |
 LL |         use m::*;
    |             ^^^^
-   = note: `env` is also a builtin macro
-   = note: consider adding an explicit import of `env` to disambiguate
+   = help: consider adding an explicit import of `env` to disambiguate
 
-error[E0659]: `fenv` is ambiguous
+error[E0659]: `fenv` is ambiguous (glob import vs any other name from outer scope during import/macro resolution)
   --> $DIR/glob-shadowing.rs:39:21
    |
 LL |             let x = fenv!(); //~ ERROR `fenv` is ambiguous
    |                     ^^^^ ambiguous name
    |
-note: `fenv` could refer to the name imported here
+note: `fenv` could refer to the macro imported here
   --> $DIR/glob-shadowing.rs:37:13
    |
 LL |         use m::*;
    |             ^^^^
-note: `fenv` could also refer to the name defined here
+   = help: consider adding an explicit import of `fenv` to disambiguate
+note: `fenv` could also refer to the macro defined here
   --> $DIR/glob-shadowing.rs:35:5
    |
 LL |     pub macro fenv($e: expr) { $e }
    |     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
-   = note: consider adding an explicit import of `fenv` to disambiguate
+   = help: use `self::fenv` to refer to the macro unambiguously
 
 error: aborting due to 3 previous errors
 
index e125983151d2b6c38d12e80cbe063be62bf174f0..9fa438e91cd221226c8a057edf02575f4593367f 100644 (file)
@@ -4,22 +4,23 @@ error[E0432]: unresolved import `nonexistent_module`
 LL |     use nonexistent_module::mac; //~ ERROR unresolved import `nonexistent_module`
    |         ^^^^^^^^^^^^^^^^^^ Maybe a missing `extern crate nonexistent_module;`?
 
-error[E0659]: `mac` is ambiguous
+error[E0659]: `mac` is ambiguous (`macro_rules` vs non-`macro_rules` from other module)
   --> $DIR/issue-53269.rs:18:5
    |
 LL |     mac!(); //~ ERROR `mac` is ambiguous
    |     ^^^ ambiguous name
    |
-note: `mac` could refer to the name defined here
+note: `mac` could refer to the macro defined here
   --> $DIR/issue-53269.rs:13:1
    |
 LL | macro_rules! mac { () => () }
    | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
-note: `mac` could also refer to the name imported here
+note: `mac` could also refer to the unresolved item imported here
   --> $DIR/issue-53269.rs:16:9
    |
 LL |     use nonexistent_module::mac; //~ ERROR unresolved import `nonexistent_module`
    |         ^^^^^^^^^^^^^^^^^^^^^^^
+   = help: use `self::mac` to refer to the unresolved item unambiguously
 
 error: aborting due to 2 previous errors
 
index 9c475451ce32f64e14cdd86af0a7e6512f7c0968..91e569d1764617a50c5524bc0ce3c3dacf37bdb4 100644 (file)
@@ -1,10 +1,10 @@
-error[E0659]: `exported` is ambiguous
+error[E0659]: `exported` is ambiguous (glob import vs macro-expanded name in the same module during import/macro resolution)
   --> $DIR/local-modularized-tricky-fail-1.rs:38:1
    |
 LL | exported!(); //~ ERROR `exported` is ambiguous
    | ^^^^^^^^ ambiguous name
    |
-note: `exported` could refer to the name defined here
+note: `exported` could refer to the macro defined here
   --> $DIR/local-modularized-tricky-fail-1.rs:15:5
    |
 LL | /     macro_rules! exported {
@@ -14,20 +14,21 @@ LL | |     }
 ...
 LL |       define_exported!();
    |       ------------------- in this macro invocation
-note: `exported` could also refer to the name imported here
+note: `exported` could also refer to the macro imported here
   --> $DIR/local-modularized-tricky-fail-1.rs:32:5
    |
 LL | use inner1::*;
    |     ^^^^^^^^^
-   = note: macro-expanded macros do not shadow
+   = help: consider adding an explicit import of `exported` to disambiguate
 
-error[E0659]: `include` is ambiguous
+error[E0659]: `include` is ambiguous (macro-expanded name vs less macro-expanded name from outer scope during import/macro resolution)
   --> $DIR/local-modularized-tricky-fail-1.rs:56:1
    |
 LL | include!(); //~ ERROR `include` is ambiguous
    | ^^^^^^^ ambiguous name
    |
-note: `include` could refer to the name defined here
+   = note: `include` could refer to a built-in macro
+note: `include` could also refer to the macro defined here
   --> $DIR/local-modularized-tricky-fail-1.rs:27:5
    |
 LL | /     macro_rules! include {
@@ -37,16 +38,16 @@ LL | |     }
 ...
 LL |       define_include!();
    |       ------------------ in this macro invocation
-   = note: `include` is also a builtin macro
-   = note: macro-expanded macros do not shadow
+   = help: use `self::include` to refer to the macro unambiguously
 
-error[E0659]: `panic` is ambiguous
+error[E0659]: `panic` is ambiguous (macro-expanded name vs less macro-expanded name from outer scope during import/macro resolution)
   --> $DIR/local-modularized-tricky-fail-1.rs:45:5
    |
 LL |     panic!(); //~ ERROR `panic` is ambiguous
    |     ^^^^^ ambiguous name
    |
-note: `panic` could refer to the name defined here
+   = note: `panic` could refer to a macro from prelude
+note: `panic` could also refer to the macro defined here
   --> $DIR/local-modularized-tricky-fail-1.rs:21:5
    |
 LL | /     macro_rules! panic {
@@ -56,16 +57,16 @@ LL | |     }
 ...
 LL |       define_panic!();
    |       ---------------- in this macro invocation
-   = note: `panic` is also a builtin macro
-   = note: macro-expanded macros do not shadow
+   = help: use `self::panic` to refer to the macro unambiguously
 
-error[E0659]: `panic` is ambiguous
+error[E0659]: `panic` is ambiguous (macro-expanded name vs less macro-expanded name from outer scope during import/macro resolution)
   --> <::std::macros::panic macros>:1:13
    |
 LL | (  ) => ( { panic ! ( "explicit panic" ) } ) ; ( $ msg : expr ) => (
    |             ^^^^^ ambiguous name
    |
-note: `panic` could refer to the name defined here
+   = note: `panic` could refer to a macro from prelude
+note: `panic` could also refer to the macro defined here
   --> $DIR/local-modularized-tricky-fail-1.rs:21:5
    |
 LL | /     macro_rules! panic {
@@ -75,8 +76,7 @@ LL | |     }
 ...
 LL |       define_panic!();
    |       ---------------- in this macro invocation
-   = note: `panic` is also a builtin macro
-   = note: macro-expanded macros do not shadow
+   = help: use `self::panic` to refer to the macro unambiguously
 
 error: aborting due to 4 previous errors
 
index a612c64c2f4705daf0bbadab487087b88209648d..96880492e285f255884626c0bfdde1b736d4c1b5 100644 (file)
@@ -1,40 +1,40 @@
-error[E0659]: `bar` is ambiguous
+error[E0659]: `bar` is ambiguous (glob import vs macro-expanded name in the same module during import/macro resolution)
   --> $DIR/macro-paths.rs:23:5
    |
 LL |     bar::m! { //~ ERROR ambiguous
    |     ^^^ ambiguous name
    |
-note: `bar` could refer to the name defined here
+note: `bar` could refer to the module defined here
   --> $DIR/macro-paths.rs:24:9
    |
 LL |         mod bar { pub use two_macros::m; }
    |         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
-note: `bar` could also refer to the name imported here
+note: `bar` could also refer to the module imported here
   --> $DIR/macro-paths.rs:22:9
    |
 LL |     use foo::*;
    |         ^^^^^^
-   = note: macro-expanded items do not shadow when used in a macro invocation path
+   = help: consider adding an explicit import of `bar` to disambiguate
 
-error[E0659]: `baz` is ambiguous
+error[E0659]: `baz` is ambiguous (macro-expanded name vs less macro-expanded name from outer scope during import/macro resolution)
   --> $DIR/macro-paths.rs:33:5
    |
 LL |     baz::m! { //~ ERROR ambiguous
    |     ^^^ ambiguous name
    |
-note: `baz` could refer to the name defined here
+note: `baz` could refer to the module defined here
   --> $DIR/macro-paths.rs:34:9
    |
 LL |         mod baz { pub use two_macros::m; }
    |         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
-note: `baz` could also refer to the name defined here
+note: `baz` could also refer to the module defined here
   --> $DIR/macro-paths.rs:28:1
    |
 LL | / pub mod baz {
 LL | |     pub use two_macros::m;
 LL | | }
    | |_^
-   = note: macro-expanded items do not shadow when used in a macro invocation path
+   = help: use `self::baz` to refer to the module unambiguously
 
 error: aborting due to 2 previous errors
 
index 209d449dfd84016acb13a3417fe0293c86ccf6b6..ade49e6be2483bd7f377bfafbbfee3e12a8887e4 100644 (file)
@@ -1,38 +1,38 @@
-error[E0659]: `m` is ambiguous
+error[E0659]: `m` is ambiguous (glob import vs macro-expanded name in the same module during import/macro resolution)
   --> $DIR/macros.rs:26:5
    |
 LL |     m! { //~ ERROR ambiguous
    |     ^ ambiguous name
    |
-note: `m` could refer to the name imported here
+note: `m` could refer to the macro imported here
   --> $DIR/macros.rs:27:13
    |
 LL |         use foo::m;
    |             ^^^^^^
-note: `m` could also refer to the name imported here
+note: `m` could also refer to the macro imported here
   --> $DIR/macros.rs:25:9
    |
 LL |     use two_macros::*;
    |         ^^^^^^^^^^^^^
-   = note: macro-expanded macro imports do not shadow
+   = help: consider adding an explicit import of `m` to disambiguate
 
-error[E0659]: `m` is ambiguous
+error[E0659]: `m` is ambiguous (macro-expanded name vs less macro-expanded name from outer scope during import/macro resolution)
   --> $DIR/macros.rs:39:9
    |
 LL |         m! { //~ ERROR ambiguous
    |         ^ ambiguous name
    |
-note: `m` could refer to the name imported here
+note: `m` could refer to the macro imported here
   --> $DIR/macros.rs:40:17
    |
 LL |             use two_macros::n as m;
    |                 ^^^^^^^^^^^^^^^^^^
-note: `m` could also refer to the name imported here
+note: `m` could also refer to the macro imported here
   --> $DIR/macros.rs:32:9
    |
 LL |     use two_macros::m;
    |         ^^^^^^^^^^^^^
-   = note: macro-expanded macro imports do not shadow
+   = help: use `self::m` to refer to the macro unambiguously
 
 error: aborting due to 2 previous errors
 
index 91af3a4b6ac736d625116d66a3e923a43f19b94e..946dc084cd0f8c4fc6e53893cebe8ab40afc9310 100644 (file)
@@ -1,20 +1,21 @@
-error[E0659]: `Foo` is ambiguous
+error[E0659]: `Foo` is ambiguous (glob import vs glob import in the same module)
   --> $DIR/rfc-1560-warning-cycle.rs:19:17
    |
 LL |         fn f(_: Foo) {} //~ ERROR `Foo` is ambiguous
    |                 ^^^ ambiguous name
    |
-note: `Foo` could refer to the name imported here
+note: `Foo` could refer to the struct imported here
   --> $DIR/rfc-1560-warning-cycle.rs:17:13
    |
 LL |         use *;
    |             ^
-note: `Foo` could also refer to the name imported here
+   = help: consider adding an explicit import of `Foo` to disambiguate
+note: `Foo` could also refer to the struct imported here
   --> $DIR/rfc-1560-warning-cycle.rs:18:13
    |
 LL |         use bar::*;
    |             ^^^^^^
-   = note: consider adding an explicit import of `Foo` to disambiguate
+   = help: consider adding an explicit import of `Foo` to disambiguate
 
 error: aborting due to previous error
 
index 7e5ab0c5abe07596fa3cfaac5249cd1f18b62b47..4d6c1aa3ea5e7a27bd5695dec1c656fee78925f4 100644 (file)
@@ -1,38 +1,40 @@
-error[E0659]: `panic` is ambiguous
+error[E0659]: `panic` is ambiguous (glob import vs any other name from outer scope during import/macro resolution)
   --> $DIR/shadow_builtin_macros.rs:25:14
    |
 LL |     fn f() { panic!(); } //~ ERROR ambiguous
    |              ^^^^^ ambiguous name
    |
-note: `panic` could refer to the name imported here
+   = note: `panic` could refer to a macro from prelude
+note: `panic` could also refer to the macro imported here
   --> $DIR/shadow_builtin_macros.rs:24:9
    |
 LL |     use foo::*;
    |         ^^^^^^
-   = note: `panic` is also a builtin macro
-   = note: consider adding an explicit import of `panic` to disambiguate
+   = help: consider adding an explicit import of `panic` to disambiguate
+   = help: or use `self::panic` to refer to the macro unambiguously
 
-error[E0659]: `panic` is ambiguous
+error[E0659]: `panic` is ambiguous (macro-expanded name vs less macro-expanded name from outer scope during import/macro resolution)
   --> $DIR/shadow_builtin_macros.rs:30:14
    |
 LL |     fn f() { panic!(); } //~ ERROR ambiguous
    |              ^^^^^ ambiguous name
    |
-note: `panic` could refer to the name imported here
+   = note: `panic` could refer to a macro from prelude
+note: `panic` could also refer to the macro imported here
   --> $DIR/shadow_builtin_macros.rs:29:26
    |
 LL |     ::two_macros::m!(use foo::panic;);
    |                          ^^^^^^^^^^
-   = note: `panic` is also a builtin macro
-   = note: macro-expanded macro imports do not shadow
+   = help: use `self::panic` to refer to the macro unambiguously
 
-error[E0659]: `panic` is ambiguous
+error[E0659]: `panic` is ambiguous (macro-expanded name vs less macro-expanded name from outer scope during import/macro resolution)
   --> $DIR/shadow_builtin_macros.rs:43:5
    |
 LL |     panic!(); //~ ERROR `panic` is ambiguous
    |     ^^^^^ ambiguous name
    |
-note: `panic` could refer to the name defined here
+   = note: `panic` could refer to a macro from prelude
+note: `panic` could also refer to the macro defined here
   --> $DIR/shadow_builtin_macros.rs:40:9
    |
 LL |         macro_rules! panic { () => {} }
@@ -40,26 +42,25 @@ LL |         macro_rules! panic { () => {} }
 LL |     } }
 LL |     m!();
    |     ----- in this macro invocation
-   = note: `panic` is also a builtin macro
-   = note: macro-expanded macros do not shadow
 
-error[E0659]: `n` is ambiguous
+error[E0659]: `n` is ambiguous (glob import vs any other name from outer scope during import/macro resolution)
   --> $DIR/shadow_builtin_macros.rs:59:5
    |
 LL |     n!(); //~ ERROR ambiguous
    |     ^ ambiguous name
    |
-note: `n` could refer to the name imported here
+note: `n` could refer to the macro imported here
   --> $DIR/shadow_builtin_macros.rs:58:9
    |
 LL |     use bar::*;
    |         ^^^^^^
-note: `n` could also refer to the name imported here
+   = help: consider adding an explicit import of `n` to disambiguate
+   = help: or use `self::n` to refer to the macro unambiguously
+note: `n` could also refer to the macro imported here
   --> $DIR/shadow_builtin_macros.rs:46:13
    |
 LL | #[macro_use(n)]
    |             ^
-   = note: consider adding an explicit import of `n` to disambiguate
 
 error: aborting due to 4 previous errors
 
index b5e1e751737b4b39f37bfc78307069bf602e45da..2785594585dd8d85652e6b3f155d0ae10a3047d6 100644 (file)
@@ -1,32 +1,32 @@
-error[E0659]: `m` is ambiguous
+error[E0659]: `m` is ambiguous (`macro_rules` vs non-`macro_rules` from other module)
   --> $DIR/ambiguity-legacy-vs-modern.rs:31:9
    |
 LL |         m!() //~ ERROR `m` is ambiguous
    |         ^ ambiguous name
    |
-note: `m` could refer to the name defined here
+note: `m` could refer to the macro defined here
   --> $DIR/ambiguity-legacy-vs-modern.rs:26:5
    |
 LL |     macro_rules! m { () => (()) }
    |     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
-note: `m` could also refer to the name defined here
+note: `m` could also refer to the macro defined here
   --> $DIR/ambiguity-legacy-vs-modern.rs:29:9
    |
 LL |         macro m() { 0 }
    |         ^^^^^^^^^^^^^^^
 
-error[E0659]: `m` is ambiguous
+error[E0659]: `m` is ambiguous (`macro_rules` vs non-`macro_rules` from other module)
   --> $DIR/ambiguity-legacy-vs-modern.rs:43:5
    |
 LL |     m!() //~ ERROR `m` is ambiguous
    |     ^ ambiguous name
    |
-note: `m` could refer to the name defined here
+note: `m` could refer to the macro defined here
   --> $DIR/ambiguity-legacy-vs-modern.rs:40:9
    |
 LL |         macro_rules! m { () => (()) }
    |         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
-note: `m` could also refer to the name defined here
+note: `m` could also refer to the macro defined here
   --> $DIR/ambiguity-legacy-vs-modern.rs:36:5
    |
 LL |     macro m() { 0 }
index 688b9dc2797d05032cf8415e625c0bb65b1f417e..3e0ea82364265675ac55076e6f29a9d3cb53f545 100644 (file)
@@ -1,16 +1,17 @@
-error[E0659]: `std` is ambiguous
+error[E0659]: `std` is ambiguous (glob import vs any other name from outer scope during import/macro resolution)
   --> $DIR/macro-path-prelude-shadowing.rs:39:9
    |
 LL |         std::panic!(); //~ ERROR `std` is ambiguous
    |         ^^^ ambiguous name
    |
-note: `std` could refer to the name imported here
+   = note: `std` could refer to a built-in extern crate
+note: `std` could also refer to the module imported here
   --> $DIR/macro-path-prelude-shadowing.rs:37:9
    |
 LL |     use m2::*; // glob-import user-defined `std`
    |         ^^^^^
-note: `std` could also refer to the name defined here
-   = note: consider adding an explicit import of `std` to disambiguate
+   = help: consider adding an explicit import of `std` to disambiguate
+   = help: or use `self::std` to refer to the module unambiguously
 
 error: aborting due to previous error
 
index d996f3a7041953300d268de80ec3d8bed343ec02..6985dfcc6c27e5518960bef7c25b252850c4fe16 100644 (file)
@@ -9,13 +9,13 @@ LL | m1!();
    |
    = note: macro-expanded `#[macro_use]`s may not shadow existing macros (see RFC 1560)
 
-error[E0659]: `foo` is ambiguous
+error[E0659]: `foo` is ambiguous (macro-expanded name vs less macro-expanded name from outer scope during import/macro resolution)
   --> $DIR/macro-shadowing.rs:27:1
    |
 LL | foo!(); //~ ERROR `foo` is ambiguous
    | ^^^ ambiguous name
    |
-note: `foo` could refer to the name defined here
+note: `foo` could refer to the macro defined here
   --> $DIR/macro-shadowing.rs:20:5
    |
 LL |     macro_rules! foo { () => {} }
@@ -23,12 +23,11 @@ LL |     macro_rules! foo { () => {} }
 ...
 LL | m1!();
    | ------ in this macro invocation
-note: `foo` could also refer to the name defined here
+note: `foo` could also refer to the macro defined here
   --> $DIR/macro-shadowing.rs:15:1
    |
 LL | macro_rules! foo { () => {} }
    | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
-   = note: macro-expanded macros do not shadow
 
 error: aborting due to 2 previous errors
 
index 9e0d40c44b6834d1832dd1901ea3f9aace3bcc06..2135d63c80ec28e4b96e4bde5f07fd1f503cc0eb 100644 (file)
@@ -1,10 +1,10 @@
-error[E0659]: `m` is ambiguous
+error[E0659]: `m` is ambiguous (macro-expanded name vs less macro-expanded name from outer scope during import/macro resolution)
   --> $DIR/restricted-shadowing-legacy.rs:101:13
    |
 LL |             m!(); //~ ERROR `m` is ambiguous
    |             ^ ambiguous name
    |
-note: `m` could refer to the name defined here
+note: `m` could refer to the macro defined here
   --> $DIR/restricted-shadowing-legacy.rs:88:9
    |
 LL |         macro_rules! m { () => { Right } }
@@ -12,7 +12,7 @@ LL |         macro_rules! m { () => { Right } }
 ...
 LL | include!();
    | ----------- in this macro invocation
-note: `m` could also refer to the name defined here
+note: `m` could also refer to the macro defined here
   --> $DIR/restricted-shadowing-legacy.rs:97:9
    |
 LL |         macro_rules! m { () => {} }
@@ -20,15 +20,14 @@ LL |         macro_rules! m { () => {} }
 ...
 LL | include!();
    | ----------- in this macro invocation
-   = note: macro-expanded macros do not shadow
 
-error[E0659]: `m` is ambiguous
+error[E0659]: `m` is ambiguous (macro-expanded name vs less macro-expanded name from outer scope during import/macro resolution)
   --> $DIR/restricted-shadowing-legacy.rs:139:42
    |
 LL |         macro_rules! gen_invoc { () => { m!() } } //~ ERROR `m` is ambiguous
    |                                          ^ ambiguous name
    |
-note: `m` could refer to the name defined here
+note: `m` could refer to the macro defined here
   --> $DIR/restricted-shadowing-legacy.rs:88:9
    |
 LL |         macro_rules! m { () => { Right } }
@@ -36,7 +35,7 @@ LL |         macro_rules! m { () => { Right } }
 ...
 LL | include!();
    | ----------- in this macro invocation
-note: `m` could also refer to the name defined here
+note: `m` could also refer to the macro defined here
   --> $DIR/restricted-shadowing-legacy.rs:135:9
    |
 LL |         macro_rules! m { () => {} }
@@ -44,15 +43,14 @@ LL |         macro_rules! m { () => {} }
 ...
 LL | include!();
    | ----------- in this macro invocation
-   = note: macro-expanded macros do not shadow
 
-error[E0659]: `m` is ambiguous
+error[E0659]: `m` is ambiguous (macro-expanded name vs less macro-expanded name from outer scope during import/macro resolution)
   --> $DIR/restricted-shadowing-legacy.rs:148:9
    |
 LL |         m!(); //~ ERROR `m` is ambiguous
    |         ^ ambiguous name
    |
-note: `m` could refer to the name defined here
+note: `m` could refer to the macro defined here
   --> $DIR/restricted-shadowing-legacy.rs:88:9
    |
 LL |         macro_rules! m { () => { Right } }
@@ -60,7 +58,7 @@ LL |         macro_rules! m { () => { Right } }
 ...
 LL | include!();
    | ----------- in this macro invocation
-note: `m` could also refer to the name defined here
+note: `m` could also refer to the macro defined here
   --> $DIR/restricted-shadowing-legacy.rs:144:9
    |
 LL |         macro_rules! m { () => {} }
@@ -68,15 +66,14 @@ LL |         macro_rules! m { () => {} }
 ...
 LL | include!();
    | ----------- in this macro invocation
-   = note: macro-expanded macros do not shadow
 
-error[E0659]: `m` is ambiguous
+error[E0659]: `m` is ambiguous (macro-expanded name vs less macro-expanded name from outer scope during import/macro resolution)
   --> $DIR/restricted-shadowing-legacy.rs:164:9
    |
 LL |         m!(); //~ ERROR `m` is ambiguous
    |         ^ ambiguous name
    |
-note: `m` could refer to the name defined here
+note: `m` could refer to the macro defined here
   --> $DIR/restricted-shadowing-legacy.rs:88:9
    |
 LL |         macro_rules! m { () => { Right } }
@@ -84,7 +81,7 @@ LL |         macro_rules! m { () => { Right } }
 ...
 LL | include!();
    | ----------- in this macro invocation
-note: `m` could also refer to the name defined here
+note: `m` could also refer to the macro defined here
   --> $DIR/restricted-shadowing-legacy.rs:85:9
    |
 LL |         macro_rules! m { () => { Wrong } }
@@ -92,15 +89,14 @@ LL |         macro_rules! m { () => { Wrong } }
 ...
 LL | include!();
    | ----------- in this macro invocation
-   = note: macro-expanded macros do not shadow
 
-error[E0659]: `m` is ambiguous
+error[E0659]: `m` is ambiguous (macro-expanded name vs less macro-expanded name from outer scope during import/macro resolution)
   --> $DIR/restricted-shadowing-legacy.rs:180:13
    |
 LL |             m!(); //~ ERROR `m` is ambiguous
    |             ^ ambiguous name
    |
-note: `m` could refer to the name defined here
+note: `m` could refer to the macro defined here
   --> $DIR/restricted-shadowing-legacy.rs:88:9
    |
 LL |         macro_rules! m { () => { Right } }
@@ -108,7 +104,7 @@ LL |         macro_rules! m { () => { Right } }
 ...
 LL | include!();
    | ----------- in this macro invocation
-note: `m` could also refer to the name defined here
+note: `m` could also refer to the macro defined here
   --> $DIR/restricted-shadowing-legacy.rs:85:9
    |
 LL |         macro_rules! m { () => { Wrong } }
@@ -116,15 +112,14 @@ LL |         macro_rules! m { () => { Wrong } }
 ...
 LL | include!();
    | ----------- in this macro invocation
-   = note: macro-expanded macros do not shadow
 
-error[E0659]: `m` is ambiguous
+error[E0659]: `m` is ambiguous (macro-expanded name vs less macro-expanded name from outer scope during import/macro resolution)
   --> $DIR/restricted-shadowing-legacy.rs:218:42
    |
 LL |         macro_rules! gen_invoc { () => { m!() } } //~ ERROR `m` is ambiguous
    |                                          ^ ambiguous name
    |
-note: `m` could refer to the name defined here
+note: `m` could refer to the macro defined here
   --> $DIR/restricted-shadowing-legacy.rs:88:9
    |
 LL |         macro_rules! m { () => { Right } }
@@ -132,7 +127,7 @@ LL |         macro_rules! m { () => { Right } }
 ...
 LL | include!();
    | ----------- in this macro invocation
-note: `m` could also refer to the name defined here
+note: `m` could also refer to the macro defined here
   --> $DIR/restricted-shadowing-legacy.rs:85:9
    |
 LL |         macro_rules! m { () => { Wrong } }
@@ -140,15 +135,14 @@ LL |         macro_rules! m { () => { Wrong } }
 ...
 LL | include!();
    | ----------- in this macro invocation
-   = note: macro-expanded macros do not shadow
 
-error[E0659]: `m` is ambiguous
+error[E0659]: `m` is ambiguous (macro-expanded name vs less macro-expanded name from outer scope during import/macro resolution)
   --> $DIR/restricted-shadowing-legacy.rs:232:9
    |
 LL |         m!(); //~ ERROR `m` is ambiguous
    |         ^ ambiguous name
    |
-note: `m` could refer to the name defined here
+note: `m` could refer to the macro defined here
   --> $DIR/restricted-shadowing-legacy.rs:88:9
    |
 LL |         macro_rules! m { () => { Right } }
@@ -156,7 +150,7 @@ LL |         macro_rules! m { () => { Right } }
 ...
 LL | include!();
    | ----------- in this macro invocation
-note: `m` could also refer to the name defined here
+note: `m` could also refer to the macro defined here
   --> $DIR/restricted-shadowing-legacy.rs:227:13
    |
 LL |             macro_rules! m { () => {} }
@@ -164,15 +158,14 @@ LL |             macro_rules! m { () => {} }
 ...
 LL | include!();
    | ----------- in this macro invocation
-   = note: macro-expanded macros do not shadow
 
-error[E0659]: `m` is ambiguous
+error[E0659]: `m` is ambiguous (macro-expanded name vs less macro-expanded name from outer scope during import/macro resolution)
   --> $DIR/restricted-shadowing-legacy.rs:262:42
    |
 LL |         macro_rules! gen_invoc { () => { m!() } } //~ ERROR `m` is ambiguous
    |                                          ^ ambiguous name
    |
-note: `m` could refer to the name defined here
+note: `m` could refer to the macro defined here
   --> $DIR/restricted-shadowing-legacy.rs:88:9
    |
 LL |         macro_rules! m { () => { Right } }
@@ -180,7 +173,7 @@ LL |         macro_rules! m { () => { Right } }
 ...
 LL | include!();
    | ----------- in this macro invocation
-note: `m` could also refer to the name defined here
+note: `m` could also refer to the macro defined here
   --> $DIR/restricted-shadowing-legacy.rs:257:13
    |
 LL |             macro_rules! m { () => {} }
@@ -188,7 +181,6 @@ LL |             macro_rules! m { () => {} }
 ...
 LL | include!();
    | ----------- in this macro invocation
-   = note: macro-expanded macros do not shadow
 
 error: aborting due to 8 previous errors
 
index 0462438be78079a161f61bbcd833c35ba42406d1..2449e8512d3cd1ed73f82238a75309e9a487f7a0 100644 (file)
@@ -1,10 +1,10 @@
-error[E0659]: `m` is ambiguous
+error[E0659]: `m` is ambiguous (macro-expanded name vs less macro-expanded name from outer scope during import/macro resolution)
   --> $DIR/restricted-shadowing-modern.rs:106:17
    |
 LL |                 m!(); //~ ERROR `m` is ambiguous
    |                 ^ ambiguous name
    |
-note: `m` could refer to the name defined here
+note: `m` could refer to the macro defined here
   --> $DIR/restricted-shadowing-modern.rs:91:9
    |
 LL |         macro m() { Right }
@@ -12,7 +12,7 @@ LL |         macro m() { Right }
 ...
 LL | include!();
    | ----------- in this macro invocation
-note: `m` could also refer to the name defined here
+note: `m` could also refer to the macro defined here
   --> $DIR/restricted-shadowing-modern.rs:101:9
    |
 LL |         macro m() {}
@@ -20,15 +20,14 @@ LL |         macro m() {}
 ...
 LL | include!();
    | ----------- in this macro invocation
-   = note: macro-expanded macros do not shadow
 
-error[E0659]: `m` is ambiguous
+error[E0659]: `m` is ambiguous (macro-expanded name vs less macro-expanded name from outer scope during import/macro resolution)
   --> $DIR/restricted-shadowing-modern.rs:149:33
    |
 LL |             macro gen_invoc() { m!() } //~ ERROR `m` is ambiguous
    |                                 ^ ambiguous name
    |
-note: `m` could refer to the name defined here
+note: `m` could refer to the macro defined here
   --> $DIR/restricted-shadowing-modern.rs:91:9
    |
 LL |         macro m() { Right }
@@ -36,7 +35,7 @@ LL |         macro m() { Right }
 ...
 LL | include!();
    | ----------- in this macro invocation
-note: `m` could also refer to the name defined here
+note: `m` could also refer to the macro defined here
   --> $DIR/restricted-shadowing-modern.rs:145:9
    |
 LL |         macro m() {}
@@ -44,15 +43,14 @@ LL |         macro m() {}
 ...
 LL | include!();
    | ----------- in this macro invocation
-   = note: macro-expanded macros do not shadow
 
-error[E0659]: `m` is ambiguous
+error[E0659]: `m` is ambiguous (macro-expanded name vs less macro-expanded name from outer scope during import/macro resolution)
   --> $DIR/restricted-shadowing-modern.rs:158:13
    |
 LL |             m!(); //~ ERROR `m` is ambiguous
    |             ^ ambiguous name
    |
-note: `m` could refer to the name defined here
+note: `m` could refer to the macro defined here
   --> $DIR/restricted-shadowing-modern.rs:91:9
    |
 LL |         macro m() { Right }
@@ -60,7 +58,7 @@ LL |         macro m() { Right }
 ...
 LL | include!();
    | ----------- in this macro invocation
-note: `m` could also refer to the name defined here
+note: `m` could also refer to the macro defined here
   --> $DIR/restricted-shadowing-modern.rs:155:9
    |
 LL |         macro m() {}
@@ -68,15 +66,14 @@ LL |         macro m() {}
 ...
 LL | include!();
    | ----------- in this macro invocation
-   = note: macro-expanded macros do not shadow
 
-error[E0659]: `m` is ambiguous
+error[E0659]: `m` is ambiguous (macro-expanded name vs less macro-expanded name from outer scope during import/macro resolution)
   --> $DIR/restricted-shadowing-modern.rs:174:13
    |
 LL |             m!(); //~ ERROR `m` is ambiguous
    |             ^ ambiguous name
    |
-note: `m` could refer to the name defined here
+note: `m` could refer to the macro defined here
   --> $DIR/restricted-shadowing-modern.rs:91:9
    |
 LL |         macro m() { Right }
@@ -84,7 +81,7 @@ LL |         macro m() { Right }
 ...
 LL | include!();
    | ----------- in this macro invocation
-note: `m` could also refer to the name defined here
+note: `m` could also refer to the macro defined here
   --> $DIR/restricted-shadowing-modern.rs:87:9
    |
 LL |         macro m() { Wrong }
@@ -92,15 +89,14 @@ LL |         macro m() { Wrong }
 ...
 LL | include!();
    | ----------- in this macro invocation
-   = note: macro-expanded macros do not shadow
 
-error[E0659]: `m` is ambiguous
+error[E0659]: `m` is ambiguous (macro-expanded name vs less macro-expanded name from outer scope during import/macro resolution)
   --> $DIR/restricted-shadowing-modern.rs:192:17
    |
 LL |                 m!(); //~ ERROR `m` is ambiguous
    |                 ^ ambiguous name
    |
-note: `m` could refer to the name defined here
+note: `m` could refer to the macro defined here
   --> $DIR/restricted-shadowing-modern.rs:91:9
    |
 LL |         macro m() { Right }
@@ -108,7 +104,7 @@ LL |         macro m() { Right }
 ...
 LL | include!();
    | ----------- in this macro invocation
-note: `m` could also refer to the name defined here
+note: `m` could also refer to the macro defined here
   --> $DIR/restricted-shadowing-modern.rs:87:9
    |
 LL |         macro m() { Wrong }
@@ -116,15 +112,14 @@ LL |         macro m() { Wrong }
 ...
 LL | include!();
    | ----------- in this macro invocation
-   = note: macro-expanded macros do not shadow
 
-error[E0659]: `m` is ambiguous
+error[E0659]: `m` is ambiguous (macro-expanded name vs less macro-expanded name from outer scope during import/macro resolution)
   --> $DIR/restricted-shadowing-modern.rs:235:33
    |
 LL |             macro gen_invoc() { m!() } //~ ERROR `m` is ambiguous
    |                                 ^ ambiguous name
    |
-note: `m` could refer to the name defined here
+note: `m` could refer to the macro defined here
   --> $DIR/restricted-shadowing-modern.rs:91:9
    |
 LL |         macro m() { Right }
@@ -132,7 +127,7 @@ LL |         macro m() { Right }
 ...
 LL | include!();
    | ----------- in this macro invocation
-note: `m` could also refer to the name defined here
+note: `m` could also refer to the macro defined here
   --> $DIR/restricted-shadowing-modern.rs:87:9
    |
 LL |         macro m() { Wrong }
@@ -140,7 +135,6 @@ LL |         macro m() { Wrong }
 ...
 LL | include!();
    | ----------- in this macro invocation
-   = note: macro-expanded macros do not shadow
 
 error: aborting due to 6 previous errors
 
index d96a802cb3f8f66b3a90707390534021e433cce2..4696e2057282a5f1c1c7576fb8a2bccb25239cd1 100644 (file)
@@ -1,20 +1,19 @@
-error[E0659]: `bar` is ambiguous
+error[E0659]: `bar` is ambiguous (macro-expanded name vs less macro-expanded name from outer scope during import/macro resolution)
   --> $DIR/out-of-order-shadowing.rs:15:1
    |
 LL | bar!(); //~ ERROR `bar` is ambiguous
    | ^^^ ambiguous name
    |
-note: `bar` could refer to the name defined here
+note: `bar` could refer to the macro defined here
   --> $DIR/out-of-order-shadowing.rs:14:1
    |
 LL | define_macro!(bar);
    | ^^^^^^^^^^^^^^^^^^^
-note: `bar` could also refer to the name defined here
+note: `bar` could also refer to the macro defined here
   --> $DIR/out-of-order-shadowing.rs:13:1
    |
 LL | macro_rules! bar { () => {} }
    | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
-   = note: macro-expanded macros do not shadow
    = note: this error originates in a macro outside of the current crate (in Nightly builds, run with -Z external-macro-backtrace for more info)
 
 error: aborting due to previous error
index 590e83b07819a24e4f33994fc1b9f72d0f14c55a..4819711115c27a76a5f25123447bd20bf04cb70b 100644 (file)
@@ -14,7 +14,7 @@
 
 mod foo {
     pub use std::io;
-    //~^ ERROR `std` import is ambiguous
+    //~^ ERROR `std` is ambiguous
 
     macro_rules! m {
         () => {
index 948043cff7614ee3cf0b5187d24e108d444caf0d..b8cbabeea2c8e71a93570e2c5134ee0e7b476b9b 100644 (file)
@@ -1,16 +1,23 @@
-error: `std` import is ambiguous
+error[E0659]: `std` is ambiguous (name vs any other name during import resolution)
   --> $DIR/ambiguity-macros-nested.rs:16:13
    |
-LL |       pub use std::io;
-   |               ^^^ can refer to external crate `::std`
-...
+LL |     pub use std::io;
+   |             ^^^ ambiguous name
+   |
+   = note: `std` could refer to a built-in extern crate
+   = help: use `::std` to refer to the extern crate unambiguously
+note: `std` could also refer to the module defined here
+  --> $DIR/ambiguity-macros-nested.rs:21:13
+   |
 LL | /             mod std {
 LL | |                 pub struct io;
 LL | |             }
-   | |_____________- may refer to `self::std` in the future
-   |
-   = help: write `::std` or `self::std` explicitly instead
-   = note: in the future, `#![feature(uniform_paths)]` may become the default
+   | |_____________^
+...
+LL |       m!();
+   |       ----- in this macro invocation
+   = help: use `self::std` to refer to the module unambiguously
 
 error: aborting due to previous error
 
+For more information about this error, try `rustc --explain E0659`.
index 861efba14f80c9ccf098c011b3e80312e6f7299d..148320de556d30d4633d90afacbccedaf4da14ea 100644 (file)
@@ -13,7 +13,7 @@
 // This test is similar to `ambiguity.rs`, but with macros defining local items.
 
 use std::io;
-//~^ ERROR `std` import is ambiguous
+//~^ ERROR `std` is ambiguous
 
 macro_rules! m {
     () => {
index 40cceea2440b95330876db764e4f0482b0bcdf12..5c9ab11085454256f02c3e75dde54e329f2f74a7 100644 (file)
@@ -1,16 +1,23 @@
-error: `std` import is ambiguous
+error[E0659]: `std` is ambiguous (name vs any other name during import resolution)
   --> $DIR/ambiguity-macros.rs:15:5
    |
-LL |   use std::io;
-   |       ^^^ can refer to external crate `::std`
-...
+LL | use std::io;
+   |     ^^^ ambiguous name
+   |
+   = note: `std` could refer to a built-in extern crate
+   = help: use `::std` to refer to the extern crate unambiguously
+note: `std` could also refer to the module defined here
+  --> $DIR/ambiguity-macros.rs:20:9
+   |
 LL | /         mod std {
 LL | |             pub struct io;
 LL | |         }
-   | |_________- may refer to `self::std` in the future
-   |
-   = help: write `::std` or `self::std` explicitly instead
-   = note: in the future, `#![feature(uniform_paths)]` may become the default
+   | |_________^
+...
+LL |   m!();
+   |   ----- in this macro invocation
+   = help: use `self::std` to refer to the module unambiguously
 
 error: aborting due to previous error
 
+For more information about this error, try `rustc --explain E0659`.
index a69eb101917fa50bd4b711fbd939e00339b782a3..2791d4580daf1a476deeff60b98c9cbbe4ab5faf 100644 (file)
@@ -14,7 +14,7 @@
 
 mod foo {
     pub use std::io;
-    //~^ ERROR `std` import is ambiguous
+    //~^ ERROR `std` is ambiguous
 
     mod std {
         pub struct io;
index 7538d3d2d917a2a5988c9154328c99521cfcee37..e98b9ad9a2ae6f7140592b82c4ca3345238eceae 100644 (file)
@@ -1,16 +1,20 @@
-error: `std` import is ambiguous
+error[E0659]: `std` is ambiguous (name vs any other name during import resolution)
   --> $DIR/ambiguity-nested.rs:16:13
    |
-LL |       pub use std::io;
-   |               ^^^ can refer to external crate `::std`
-...
+LL |     pub use std::io;
+   |             ^^^ ambiguous name
+   |
+   = note: `std` could refer to a built-in extern crate
+   = help: use `::std` to refer to the extern crate unambiguously
+note: `std` could also refer to the module defined here
+  --> $DIR/ambiguity-nested.rs:19:5
+   |
 LL | /     mod std {
 LL | |         pub struct io;
 LL | |     }
-   | |_____- may refer to `self::std` in the future
-   |
-   = help: write `::std` or `self::std` explicitly instead
-   = note: in the future, `#![feature(uniform_paths)]` may become the default
+   | |_____^
+   = help: use `self::std` to refer to the module unambiguously
 
 error: aborting due to previous error
 
+For more information about this error, try `rustc --explain E0659`.
index 500e9f6c63ff87901671b965ddd82d69af5fe6a0..2bfbb6b287153ded300d89545cab2ff528019c5e 100644 (file)
@@ -11,7 +11,7 @@
 // edition:2018
 
 use std::io;
-//~^ ERROR `std` import is ambiguous
+//~^ ERROR `std` is ambiguous
 
 mod std {
     pub struct io;
index 7b64b8f02464af6025435535d8de29daa2b6012e..75387454015b9f7dab75e8b9a910dbb94f6f1083 100644 (file)
@@ -1,16 +1,20 @@
-error: `std` import is ambiguous
+error[E0659]: `std` is ambiguous (name vs any other name during import resolution)
   --> $DIR/ambiguity.rs:13:5
    |
-LL |   use std::io;
-   |       ^^^ can refer to external crate `::std`
-...
+LL | use std::io;
+   |     ^^^ ambiguous name
+   |
+   = note: `std` could refer to a built-in extern crate
+   = help: use `::std` to refer to the extern crate unambiguously
+note: `std` could also refer to the module defined here
+  --> $DIR/ambiguity.rs:16:1
+   |
 LL | / mod std {
 LL | |     pub struct io;
 LL | | }
-   | |_- may refer to `self::std` in the future
-   |
-   = help: write `::std` or `self::std` explicitly instead
-   = note: in the future, `#![feature(uniform_paths)]` may become the default
+   | |_^
+   = help: use `self::std` to refer to the module unambiguously
 
 error: aborting due to previous error
 
+For more information about this error, try `rustc --explain E0659`.
index e0992c906663248c172273a83d12a542974edd1c..9f440d71fb003c24953214b7889f35dbfed999e3 100644 (file)
@@ -16,7 +16,7 @@
 
 mod foo {
     pub use std::io;
-    //~^ ERROR `std` import is ambiguous
+    //~^ ERROR `std` is ambiguous
 
     macro_rules! m {
         () => {
index 154ee412e72825024a5babb822f9d7c7d5ccc623..f18de7edcdcbc23396a416a7f14e352b6a41d648 100644 (file)
@@ -1,16 +1,23 @@
-error: `std` import is ambiguous
+error[E0659]: `std` is ambiguous (name vs any other name during import resolution)
   --> $DIR/ambiguity-macros-nested.rs:18:13
    |
-LL |       pub use std::io;
-   |               ^^^ can refer to external crate `::std`
-...
+LL |     pub use std::io;
+   |             ^^^ ambiguous name
+   |
+   = note: `std` could refer to a built-in extern crate
+   = help: use `::std` to refer to the extern crate unambiguously
+note: `std` could also refer to the module defined here
+  --> $DIR/ambiguity-macros-nested.rs:23:13
+   |
 LL | /             mod std {
 LL | |                 pub struct io;
 LL | |             }
-   | |_____________- can refer to `self::std`
-   |
-   = help: write `::std` or `self::std` explicitly instead
-   = note: relative `use` paths enabled by `#![feature(uniform_paths)]`
+   | |_____________^
+...
+LL |       m!();
+   |       ----- in this macro invocation
+   = help: use `self::std` to refer to the module unambiguously
 
 error: aborting due to previous error
 
+For more information about this error, try `rustc --explain E0659`.
index 9439d92aa710be0470b34d6b6a30891389a19f88..f1ed48150c0b862eb4bb6bf6aae773a27a9d707d 100644 (file)
@@ -15,7 +15,7 @@
 // This test is similar to `ambiguity.rs`, but with macros defining local items.
 
 use std::io;
-//~^ ERROR `std` import is ambiguous
+//~^ ERROR `std` is ambiguous
 
 macro_rules! m {
     () => {
index 3c0d5601f9c8a9e22056d85b0bc6f6beaa0c13c2..16e083b0980836f32fff005c018b4435e98a1495 100644 (file)
@@ -1,16 +1,23 @@
-error: `std` import is ambiguous
+error[E0659]: `std` is ambiguous (name vs any other name during import resolution)
   --> $DIR/ambiguity-macros.rs:17:5
    |
-LL |   use std::io;
-   |       ^^^ can refer to external crate `::std`
-...
+LL | use std::io;
+   |     ^^^ ambiguous name
+   |
+   = note: `std` could refer to a built-in extern crate
+   = help: use `::std` to refer to the extern crate unambiguously
+note: `std` could also refer to the module defined here
+  --> $DIR/ambiguity-macros.rs:22:9
+   |
 LL | /         mod std {
 LL | |             pub struct io;
 LL | |         }
-   | |_________- can refer to `self::std`
-   |
-   = help: write `::std` or `self::std` explicitly instead
-   = note: relative `use` paths enabled by `#![feature(uniform_paths)]`
+   | |_________^
+...
+LL |   m!();
+   |   ----- in this macro invocation
+   = help: use `self::std` to refer to the module unambiguously
 
 error: aborting due to previous error
 
+For more information about this error, try `rustc --explain E0659`.
index 1756acc6057f2dac81da6dcf785ea94671ae1d15..0d0d34df1f833e7639ba2c3e6c816c48275552e5 100644 (file)
@@ -16,7 +16,7 @@
 
 mod foo {
     pub use std::io;
-    //~^ ERROR `std` import is ambiguous
+    //~^ ERROR `std` is ambiguous
 
     mod std {
         pub struct io;
index a607eeb0b43e0afe693f75e6e1266f8fae4e5f5a..cb38102c5997e1446b2a3dd7f332bce2b967cf0c 100644 (file)
@@ -1,16 +1,20 @@
-error: `std` import is ambiguous
+error[E0659]: `std` is ambiguous (name vs any other name during import resolution)
   --> $DIR/ambiguity-nested.rs:18:13
    |
-LL |       pub use std::io;
-   |               ^^^ can refer to external crate `::std`
-...
+LL |     pub use std::io;
+   |             ^^^ ambiguous name
+   |
+   = note: `std` could refer to a built-in extern crate
+   = help: use `::std` to refer to the extern crate unambiguously
+note: `std` could also refer to the module defined here
+  --> $DIR/ambiguity-nested.rs:21:5
+   |
 LL | /     mod std {
 LL | |         pub struct io;
 LL | |     }
-   | |_____- can refer to `self::std`
-   |
-   = help: write `::std` or `self::std` explicitly instead
-   = note: relative `use` paths enabled by `#![feature(uniform_paths)]`
+   | |_____^
+   = help: use `self::std` to refer to the module unambiguously
 
 error: aborting due to previous error
 
+For more information about this error, try `rustc --explain E0659`.
index 9ae3d79c22cf225e540ead2fe63e0a21d9cdf849..259f451e4d22d2275b45cfeea4ef4775f6e207f1 100644 (file)
@@ -13,7 +13,7 @@
 #![feature(uniform_paths)]
 
 use std::io;
-//~^ ERROR `std` import is ambiguous
+//~^ ERROR `std` is ambiguous
 
 mod std {
     pub struct io;
index c65db3072f440d8435e06516d43623149b7c9114..ce0c64b226b59200a212f4e403a4b2adc729ab6f 100644 (file)
@@ -1,16 +1,20 @@
-error: `std` import is ambiguous
+error[E0659]: `std` is ambiguous (name vs any other name during import resolution)
   --> $DIR/ambiguity.rs:15:5
    |
-LL |   use std::io;
-   |       ^^^ can refer to external crate `::std`
-...
+LL | use std::io;
+   |     ^^^ ambiguous name
+   |
+   = note: `std` could refer to a built-in extern crate
+   = help: use `::std` to refer to the extern crate unambiguously
+note: `std` could also refer to the module defined here
+  --> $DIR/ambiguity.rs:18:1
+   |
 LL | / mod std {
 LL | |     pub struct io;
 LL | | }
-   | |_- can refer to `self::std`
-   |
-   = help: write `::std` or `self::std` explicitly instead
-   = note: relative `use` paths enabled by `#![feature(uniform_paths)]`
+   | |_^
+   = help: use `self::std` to refer to the module unambiguously
 
 error: aborting due to previous error
 
+For more information about this error, try `rustc --explain E0659`.