@@ -7,7 +7,7 @@ use crate::errors::{
77use crate :: Namespace :: * ;
88use crate :: { BuiltinMacroState , Determinacy } ;
99use crate :: { DeriveData , Finalize , ParentScope , ResolutionError , Resolver , ScopeSet } ;
10- use crate :: { ModuleKind , ModuleOrUniformRoot , NameBinding , PathResult , Segment } ;
10+ use crate :: { ModuleKind , ModuleOrUniformRoot , NameBinding , PathResult , Segment , ToNameBinding } ;
1111use rustc_ast:: expand:: StrippedCfgItem ;
1212use rustc_ast:: { self as ast, attr, Crate , Inline , ItemKind , ModKind , NodeId } ;
1313use rustc_ast_pretty:: pprust;
@@ -20,10 +20,10 @@ use rustc_expand::base::{SyntaxExtension, SyntaxExtensionKind};
2020use rustc_expand:: compile_declarative_macro;
2121use rustc_expand:: expand:: { AstFragment , Invocation , InvocationKind , SupportsMacroExpansion } ;
2222use rustc_hir:: def:: { self , DefKind , NonMacroAttrKind } ;
23- use rustc_hir:: def_id:: { CrateNum , LocalDefId } ;
23+ use rustc_hir:: def_id:: { CrateNum , DefId , LocalDefId } ;
2424use rustc_middle:: middle:: stability;
2525use rustc_middle:: ty:: RegisteredTools ;
26- use rustc_middle:: ty:: TyCtxt ;
26+ use rustc_middle:: ty:: { TyCtxt , Visibility } ;
2727use rustc_session:: lint:: builtin:: {
2828 LEGACY_DERIVE_HELPERS , SOFT_UNSTABLE , UNKNOWN_DIAGNOSTIC_ATTRIBUTES ,
2929} ;
@@ -401,8 +401,17 @@ impl<'a, 'tcx> ResolverExpand for Resolver<'a, 'tcx> {
401401 }
402402 // Sort helpers in a stable way independent from the derive resolution order.
403403 entry. helper_attrs . sort_by_key ( |( i, _) | * i) ;
404- self . helper_attrs
405- . insert ( expn_id, entry. helper_attrs . iter ( ) . map ( |( _, ident) | * ident) . collect ( ) ) ;
404+ let helper_attrs = entry
405+ . helper_attrs
406+ . iter ( )
407+ . map ( |( _, ident) | {
408+ let res = Res :: NonMacroAttr ( NonMacroAttrKind :: DeriveHelper ) ;
409+ let binding = ( res, Visibility :: < DefId > :: Public , ident. span , expn_id)
410+ . to_name_binding ( self . arenas ) ;
411+ ( * ident, binding)
412+ } )
413+ . collect ( ) ;
414+ self . helper_attrs . insert ( expn_id, helper_attrs) ;
406415 // Mark this derive as having `Copy` either if it has `Copy` itself or if its parent derive
407416 // has `Copy`, to support cases like `#[derive(Clone, Copy)] #[derive(Debug)]`.
408417 if entry. has_derive_copy || self . has_derive_copy ( parent_scope. expansion ) {
0 commit comments