Change:
So pointed out to me that some recent changes in name resolution seem to have broken . They pointed me at dealing with the fallout -- maybe you can leave a few notes as to what errors you were seeing before this commit? cc -- could this be the recent changes around name resolution of helper attributes in macros? It seems the relevant code is stuff like:
(Nominated for discussion around the breakage policy/implications here.)
Duplicate of , I'll prepare a fix.
fix Or rather a "tiebreaker" for the ambiguity, since both names are indeed in scope and create ambiguity, which is correctly detected after .
Fixed in

Discussion:
) -> Result<&'a NameBinding<'a>, Determinacy> { bitflags::bitflags! { struct Flags: u8 { <del> const MACRO_RULES        = 1 << 0; const MODULE             = 1 << 1; const MISC_SUGGEST_CRATE = 1 << 2; const MISC_SUGGEST_SELF  = 1 << 3; const MISC_FROM_PRELUDE  = 1 << 4; </del> <ins> const MACRO_RULES          = 1 << 0; const MODULE               = 1 << 1; const DERIVE_HELPER_COMPAT = 1 << 2; const MISC_SUGGEST_CRATE   = 1 << 3; const MISC_SUGGEST_SELF    = 1 << 4; const MISC_FROM_PRELUDE    = 1 << 5; </ins> } }

match this.resolve_macro_path(derive, Some(MacroKind::Derive), parent_scope, true, force) { Ok((Some(ext), _)) => if ext.helper_attrs.contains(&ident.name) { <del> let res = Res::NonMacroAttr(NonMacroAttrKind::DeriveHelper); result = ok(res, derive.span, this.arenas); </del> <ins> let binding = (Res::NonMacroAttr(NonMacroAttrKind::DeriveHelper), ty::Visibility::Public, derive.span, ExpnId::root()) .to_name_binding(this.arenas); result = Ok((binding, Flags::DERIVE_HELPER_COMPAT)); </ins> break; } Ok(_) | Err(Determinacy::Determined) => {}

let (res, innermost_res) = (binding.res(), innermost_binding.res()); if res != innermost_res { let builtin = Res::NonMacroAttr(NonMacroAttrKind::Builtin); <del> let derive_helper = Res::NonMacroAttr(NonMacroAttrKind::DeriveHelper); </del> <ins> let is_derive_helper_compat = |res, flags: Flags| { res == Res::NonMacroAttr(NonMacroAttrKind::DeriveHelper) && flags.contains(Flags::DERIVE_HELPER_COMPAT) }; </ins> let ambiguity_error_kind = if is_import { Some(AmbiguityKind::Import) } else if innermost_res == builtin || res == builtin { Some(AmbiguityKind::BuiltinAttr) <del> } else if innermost_res == derive_helper || res == derive_helper { </del> <ins> } else if is_derive_helper_compat(innermost_res, innermost_flags) || is_derive_helper_compat(res, flags) { </ins> Some(AmbiguityKind::DeriveHelper) } else if innermost_flags.contains(Flags::MACRO_RULES) && flags.contains(Flags::MODULE) &&

<ins> // force-host // no-prefer-dynamic #![crate_type = "proc-macro"] extern crate proc_macro; use proc_macro::*; #[proc_macro_derive(same_name, attributes(same_name))] pub fn derive_a(_: TokenStream) -> TokenStream { TokenStream::new() } </ins>

<ins> // If a derive macro introduces a helper attribute with the same name as that macro, // then make sure that it's usable without ambiguities. // check-pass // aux-build:derive-helper-shadowing-2.rs #[macro_use] extern crate derive_helper_shadowing_2; #[derive(same_name)] struct S { #[same_name] // OK, no ambiguity, derive helpers have highest priority field: u8, } fn main() {} </ins>

#[empty_helper] //~ ERROR `empty_helper` is ambiguous #[derive(Empty)] struct S { <del> #[empty_helper] //~ ERROR `empty_helper` is ambiguous </del> <ins> #[empty_helper] // OK, no ambiguity, derive helpers have highest priority </ins> field: [u8; { use empty_helper; //~ ERROR `empty_helper` is ambiguous <del> #[empty_helper] //~ ERROR `empty_helper` is ambiguous </del> <ins> #[empty_helper] // OK, no ambiguity, derive helpers have highest priority </ins> struct U; mod inner {

|     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ = help: use `crate::empty_helper` to refer to this attribute macro unambiguously <del> error[E0659]: `empty_helper` is ambiguous (derive helper attribute vs any other name) --> $DIR/derive-helper-shadowing.rs:22:7 | LL |     #[empty_helper] |       ^^^^^^^^^^^^ ambiguous name | note: `empty_helper` could refer to the derive helper attribute defined here --> $DIR/derive-helper-shadowing.rs:20:10 | LL | #[derive(Empty)] |          ^^^^^ note: `empty_helper` could also refer to the attribute macro imported here --> $DIR/derive-helper-shadowing.rs:10:5 | LL | use test_macros::empty_attr as empty_helper; |     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ = help: use `crate::empty_helper` to refer to this attribute macro unambiguously error[E0659]: `empty_helper` is ambiguous (derive helper attribute vs any other name) --> $DIR/derive-helper-shadowing.rs:26:11 | LL |         #[empty_helper] |           ^^^^^^^^^^^^ ambiguous name | note: `empty_helper` could refer to the derive helper attribute defined here --> $DIR/derive-helper-shadowing.rs:20:10 | LL | #[derive(Empty)] |          ^^^^^ note: `empty_helper` could also refer to the attribute macro imported here --> $DIR/derive-helper-shadowing.rs:10:5 | LL | use test_macros::empty_attr as empty_helper; |     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ = help: use `crate::empty_helper` to refer to this attribute macro unambiguously error: aborting due to 7 previous errors </del> <ins> error: aborting due to 5 previous errors </ins> For more information about this error, try `rustc --explain E0659`.