@@ -466,11 +466,12 @@ impl<'a> Resolver<'a> {
466
466
) -> Result < & ' a NameBinding < ' a > , Determinacy > {
467
467
bitflags:: bitflags! {
468
468
struct Flags : u8 {
469
- const MACRO_RULES = 1 << 0 ;
470
- const MODULE = 1 << 1 ;
471
- const MISC_SUGGEST_CRATE = 1 << 2 ;
472
- const MISC_SUGGEST_SELF = 1 << 3 ;
473
- const MISC_FROM_PRELUDE = 1 << 4 ;
469
+ const MACRO_RULES = 1 << 0 ;
470
+ const MODULE = 1 << 1 ;
471
+ const DERIVE_HELPER_COMPAT = 1 << 2 ;
472
+ const MISC_SUGGEST_CRATE = 1 << 3 ;
473
+ const MISC_SUGGEST_SELF = 1 << 4 ;
474
+ const MISC_FROM_PRELUDE = 1 << 5 ;
474
475
}
475
476
}
476
477
@@ -528,8 +529,10 @@ impl<'a> Resolver<'a> {
528
529
match this. resolve_macro_path ( derive, Some ( MacroKind :: Derive ) ,
529
530
parent_scope, true , force) {
530
531
Ok ( ( Some ( ext) , _) ) => if ext. helper_attrs . contains ( & ident. name ) {
531
- let res = Res :: NonMacroAttr ( NonMacroAttrKind :: DeriveHelper ) ;
532
- result = ok ( res, derive. span , this. arenas ) ;
532
+ let binding = ( Res :: NonMacroAttr ( NonMacroAttrKind :: DeriveHelper ) ,
533
+ ty:: Visibility :: Public , derive. span , ExpnId :: root ( ) )
534
+ . to_name_binding ( this. arenas ) ;
535
+ result = Ok ( ( binding, Flags :: DERIVE_HELPER_COMPAT ) ) ;
533
536
break ;
534
537
}
535
538
Ok ( _) | Err ( Determinacy :: Determined ) => { }
@@ -659,13 +662,17 @@ impl<'a> Resolver<'a> {
659
662
let ( res, innermost_res) = ( binding. res ( ) , innermost_binding. res ( ) ) ;
660
663
if res != innermost_res {
661
664
let builtin = Res :: NonMacroAttr ( NonMacroAttrKind :: Builtin ) ;
662
- let derive_helper = Res :: NonMacroAttr ( NonMacroAttrKind :: DeriveHelper ) ;
665
+ let is_derive_helper_compat = |res, flags : Flags | {
666
+ res == Res :: NonMacroAttr ( NonMacroAttrKind :: DeriveHelper ) &&
667
+ flags. contains ( Flags :: DERIVE_HELPER_COMPAT )
668
+ } ;
663
669
664
670
let ambiguity_error_kind = if is_import {
665
671
Some ( AmbiguityKind :: Import )
666
672
} else if innermost_res == builtin || res == builtin {
667
673
Some ( AmbiguityKind :: BuiltinAttr )
668
- } else if innermost_res == derive_helper || res == derive_helper {
674
+ } else if is_derive_helper_compat ( innermost_res, innermost_flags) ||
675
+ is_derive_helper_compat ( res, flags) {
669
676
Some ( AmbiguityKind :: DeriveHelper )
670
677
} else if innermost_flags. contains ( Flags :: MACRO_RULES ) &&
671
678
flags. contains ( Flags :: MODULE ) &&
0 commit comments