From 9d7d9ada6d108c113ea8728be97dbc19345e9892 Mon Sep 17 00:00:00 2001 From: Vadim Petrochenkov Date: Mon, 5 Nov 2018 01:00:31 +0300 Subject: [PATCH] resolve: Simplify ambiguity checking for built-in attributes --- src/librustc_resolve/macros.rs | 13 ++----------- .../proc-macro/ambiguous-builtin-attrs.stderr | 12 ++++++------ 2 files changed, 8 insertions(+), 17 deletions(-) diff --git a/src/librustc_resolve/macros.rs b/src/librustc_resolve/macros.rs index 4348f91a63e2..05a2ad23e64b 100644 --- a/src/librustc_resolve/macros.rs +++ b/src/librustc_resolve/macros.rs @@ -684,7 +684,7 @@ impl<'a, 'cl> Resolver<'a, 'cl> { let binding = (Def::NonMacroAttr(NonMacroAttrKind::Builtin), ty::Visibility::Public, ident.span, Mark::root()) .to_name_binding(self.arenas); - Ok((binding, Flags::PRELUDE, Flags::empty())) + Ok((binding, Flags::PRELUDE, Flags::all())) } else { Err(Determinacy::Determined) } @@ -917,18 +917,9 @@ impl<'a, 'cl> Resolver<'a, 'cl> { let builtin_attrs = mem::replace(&mut *module.builtin_attrs.borrow_mut(), Vec::new()); for (ident, parent_scope) in builtin_attrs { - let binding = self.early_resolve_ident_in_lexical_scope( + let _ = self.early_resolve_ident_in_lexical_scope( ident, MacroNS, Some(MacroKind::Attr), false, &parent_scope, true, true, ident.span ); - if let Ok(binding) = binding { - if binding.def_ignoring_ambiguity() != - Def::NonMacroAttr(NonMacroAttrKind::Builtin) { - let builtin_binding = (Def::NonMacroAttr(NonMacroAttrKind::Builtin), - ty::Visibility::Public, ident.span, Mark::root()) - .to_name_binding(self.arenas); - self.report_ambiguity_error(ident, binding, builtin_binding); - } - } } } diff --git a/src/test/ui-fulldeps/proc-macro/ambiguous-builtin-attrs.stderr b/src/test/ui-fulldeps/proc-macro/ambiguous-builtin-attrs.stderr index ea867faf47bb..0720ccb7cf9d 100644 --- a/src/test/ui-fulldeps/proc-macro/ambiguous-builtin-attrs.stderr +++ b/src/test/ui-fulldeps/proc-macro/ambiguous-builtin-attrs.stderr @@ -1,3 +1,9 @@ +error[E0425]: cannot find value `NonExistent` in this scope + --> $DIR/ambiguous-builtin-attrs.rs:30:5 + | +LL | NonExistent; //~ ERROR cannot find value `NonExistent` in this scope + | ^^^^^^^^^^^ not found in this scope + error[E0659]: `repr` is ambiguous --> $DIR/ambiguous-builtin-attrs.rs:9:3 | @@ -88,12 +94,6 @@ LL | #![feature(decl_macro)] //~ ERROR `feature` is ambiguous | ^^^^^^^ = note: consider adding an explicit import of `feature` to disambiguate -error[E0425]: cannot find value `NonExistent` in this scope - --> $DIR/ambiguous-builtin-attrs.rs:30:5 - | -LL | NonExistent; //~ ERROR cannot find value `NonExistent` in this scope - | ^^^^^^^^^^^ not found in this scope - error: aborting due to 6 previous errors Some errors occurred: E0425, E0659.