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.
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",
+ }
+ }
}
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),
};
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() &&
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);
}
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
}
used: Cell<bool>,
},
Ambiguity {
+ kind: AmbiguityKind,
b1: &'a NameBinding<'a>,
b2: &'a NameBinding<'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> {
subclass: ImportDirectiveSubclass::ExternCrate { .. }, ..
}, ..
} => true,
+ NameBindingKind::Module(
+ &ModuleData { kind: ModuleKind::Def(Def::Mod(def_id), _), .. }
+ ) => def_id.index == CRATE_DEF_INDEX,
_ => false,
}
}
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
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
}
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 {
}
}
- 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(¬e_msg);
+ } else {
+ err.span_note(b.span, ¬e_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(¬e);
- }
+
+ could_refer_to(b1, misc1, "");
+ could_refer_to(b2, misc2, " also");
err.emit();
}
);
}
- 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);
}
}
};
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))
}
})
// 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};
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;
}
}
// }
// 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;
(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;
}
}
}
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) => {
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)
}
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)
}
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
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)
}
false,
path_span,
) {
- result = Ok((binding, Flags::PRELUDE, Flags::empty()));
+ result = Ok((binding, Flags::PRELUDE | Flags::MISC_FROM_PRELUDE));
}
}
}
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)
}
}}
match result {
- Ok((binding, flags, ambig_flags)) => {
+ Ok((binding, flags)) => {
if sub_namespace_mismatch(macro_kind, binding.macro_kind()) {
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!();
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};
};
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);
}
};
// 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,
});
}
}
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);
})
}
- 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(),
-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
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
-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
-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
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
-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;
...
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
-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
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
-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 {
...
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 {
...
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 {
...
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 {
...
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
-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
-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
-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
-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 { () => {} }
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
-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 }
-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
|
= 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 { () => {} }
...
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
-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 } }
...
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 { () => {} }
...
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 } }
...
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 { () => {} }
...
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 } }
...
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 { () => {} }
...
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 } }
...
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 } }
...
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 } }
...
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 } }
...
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 } }
...
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 } }
...
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 } }
...
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 { () => {} }
...
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 } }
...
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 { () => {} }
...
LL | include!();
| ----------- in this macro invocation
- = note: macro-expanded macros do not shadow
error: aborting due to 8 previous errors
-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 }
...
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() {}
...
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 }
...
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() {}
...
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 }
...
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() {}
...
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 }
...
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 }
...
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 }
...
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 }
...
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 }
...
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 }
...
LL | include!();
| ----------- in this macro invocation
- = note: macro-expanded macros do not shadow
error: aborting due to 6 previous errors
-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
mod foo {
pub use std::io;
- //~^ ERROR `std` import is ambiguous
+ //~^ ERROR `std` is ambiguous
macro_rules! m {
() => {
-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`.
// 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 {
() => {
-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`.
mod foo {
pub use std::io;
- //~^ ERROR `std` import is ambiguous
+ //~^ ERROR `std` is ambiguous
mod std {
pub struct io;
-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`.
// edition:2018
use std::io;
-//~^ ERROR `std` import is ambiguous
+//~^ ERROR `std` is ambiguous
mod std {
pub struct io;
-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`.
mod foo {
pub use std::io;
- //~^ ERROR `std` import is ambiguous
+ //~^ ERROR `std` is ambiguous
macro_rules! m {
() => {
-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`.
// 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 {
() => {
-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`.
mod foo {
pub use std::io;
- //~^ ERROR `std` import is ambiguous
+ //~^ ERROR `std` is ambiguous
mod std {
pub struct io;
-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`.
#![feature(uniform_paths)]
use std::io;
-//~^ ERROR `std` import is ambiguous
+//~^ ERROR `std` is ambiguous
mod std {
pub struct io;
-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`.