@@ -7,7 +7,7 @@ use crate::errors::{
7
7
use crate :: Namespace :: * ;
8
8
use crate :: { BuiltinMacroState , Determinacy } ;
9
9
use crate :: { DeriveData , Finalize , ParentScope , ResolutionError , Resolver , ScopeSet } ;
10
- use crate :: { ModuleKind , ModuleOrUniformRoot , NameBinding , PathResult , Segment } ;
10
+ use crate :: { ModuleKind , ModuleOrUniformRoot , NameBinding , PathResult , Segment , ToNameBinding } ;
11
11
use rustc_ast:: expand:: StrippedCfgItem ;
12
12
use rustc_ast:: { self as ast, attr, Crate , Inline , ItemKind , ModKind , NodeId } ;
13
13
use rustc_ast_pretty:: pprust;
@@ -20,10 +20,10 @@ use rustc_expand::base::{SyntaxExtension, SyntaxExtensionKind};
20
20
use rustc_expand:: compile_declarative_macro;
21
21
use rustc_expand:: expand:: { AstFragment , Invocation , InvocationKind , SupportsMacroExpansion } ;
22
22
use rustc_hir:: def:: { self , DefKind , NonMacroAttrKind } ;
23
- use rustc_hir:: def_id:: { CrateNum , LocalDefId } ;
23
+ use rustc_hir:: def_id:: { CrateNum , DefId , LocalDefId } ;
24
24
use rustc_middle:: middle:: stability;
25
25
use rustc_middle:: ty:: RegisteredTools ;
26
- use rustc_middle:: ty:: TyCtxt ;
26
+ use rustc_middle:: ty:: { TyCtxt , Visibility } ;
27
27
use rustc_session:: lint:: builtin:: {
28
28
LEGACY_DERIVE_HELPERS , SOFT_UNSTABLE , UNKNOWN_DIAGNOSTIC_ATTRIBUTES ,
29
29
} ;
@@ -401,8 +401,17 @@ impl<'a, 'tcx> ResolverExpand for Resolver<'a, 'tcx> {
401
401
}
402
402
// Sort helpers in a stable way independent from the derive resolution order.
403
403
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) ;
406
415
// Mark this derive as having `Copy` either if it has `Copy` itself or if its parent derive
407
416
// has `Copy`, to support cases like `#[derive(Clone, Copy)] #[derive(Debug)]`.
408
417
if entry. has_derive_copy || self . has_derive_copy ( parent_scope. expansion ) {
0 commit comments