44use std:: mem;
55use std:: sync:: Arc ;
66
7- use rustc_ast:: { self as ast, Crate , DUMMY_NODE_ID , NodeId } ;
7+ use rustc_ast:: { self as ast, Crate , DUMMY_NODE_ID , DelegationSuffixes , NodeId } ;
88use rustc_ast_pretty:: pprust;
99use rustc_attr_parsing:: AttributeParser ;
1010use rustc_errors:: { Applicability , DiagCtxtHandle , StashKey } ;
@@ -286,7 +286,8 @@ impl<'ra, 'tcx> ResolverExpand for Resolver<'ra, 'tcx> {
286286 InvocationKind :: Derive { ref path, .. } => ( path, MacroKind :: Derive ) ,
287287 InvocationKind :: GlobDelegation { ref item, .. } => {
288288 let ast:: AssocItemKind :: DelegationMac ( deleg) = & item. kind else { unreachable ! ( ) } ;
289- deleg_impl = Some ( self . invocation_parent ( invoc_id) ) ;
289+ let DelegationSuffixes :: Glob ( star_span) = deleg. suffixes else { unreachable ! ( ) } ;
290+ deleg_impl = Some ( ( self . invocation_parent ( invoc_id) , star_span) ) ;
290291 // It is sufficient to consider glob delegation a bang macro for now.
291292 ( & deleg. prefix , MacroKind :: Bang )
292293 }
@@ -530,6 +531,7 @@ impl<'ra, 'tcx> ResolverExpand for Resolver<'ra, 'tcx> {
530531 & self ,
531532 trait_def_id : DefId ,
532533 impl_def_id : LocalDefId ,
534+ star_span : Span ,
533535 ) -> Result < Vec < ( Ident , Option < Ident > ) > , Indeterminate > {
534536 let target_trait = self . expect_module ( trait_def_id) ;
535537 if !target_trait. unexpanded_invocations . borrow ( ) . is_empty ( ) {
@@ -549,13 +551,13 @@ impl<'ra, 'tcx> ResolverExpand for Resolver<'ra, 'tcx> {
549551
550552 let mut idents = Vec :: new ( ) ;
551553 target_trait. for_each_child ( self , |this, ident, orig_ident_span, ns, _binding| {
552- // FIXME: Adjust hygiene for idents from globs, like for glob imports.
553554 if let Some ( overriding_keys) = this. impl_binding_keys . get ( & impl_def_id)
554555 && overriding_keys. contains ( & BindingKey :: new ( ident, ns) )
555556 {
556557 // The name is overridden, do not produce it from the glob delegation.
557558 } else {
558- idents. push ( ( ident. orig ( orig_ident_span) , None ) ) ;
559+ // FIXME: Adjust hygiene for idents from globs, like for glob imports.
560+ idents. push ( ( ident. orig ( star_span. with_ctxt ( orig_ident_span. ctxt ( ) ) ) , None ) ) ;
559561 }
560562 } ) ;
561563 Ok ( idents)
@@ -579,7 +581,7 @@ impl<'ra, 'tcx> Resolver<'ra, 'tcx> {
579581 parent_scope : & ParentScope < ' ra > ,
580582 node_id : NodeId ,
581583 force : bool ,
582- deleg_impl : Option < LocalDefId > ,
584+ deleg_impl : Option < ( LocalDefId , Span ) > ,
583585 invoc_in_mod_inert_attr : Option < LocalDefId > ,
584586 suggestion_span : Option < Span > ,
585587 ) -> Result < ( Arc < SyntaxExtension > , Res ) , Indeterminate > {
@@ -771,7 +773,7 @@ impl<'ra, 'tcx> Resolver<'ra, 'tcx> {
771773 kind : MacroKind ,
772774 parent_scope : & ParentScope < ' ra > ,
773775 force : bool ,
774- deleg_impl : Option < LocalDefId > ,
776+ deleg_impl : Option < ( LocalDefId , Span ) > ,
775777 invoc_in_mod_inert_attr : Option < ( LocalDefId , NodeId ) > ,
776778 ignore_import : Option < Import < ' ra > > ,
777779 suggestion_span : Option < Span > ,
@@ -856,10 +858,15 @@ impl<'ra, 'tcx> Resolver<'ra, 'tcx> {
856858
857859 let res = res?;
858860 let ext = match deleg_impl {
859- Some ( impl_def_id) => match res {
861+ Some ( ( impl_def_id, star_span ) ) => match res {
860862 def:: Res :: Def ( DefKind :: Trait , def_id) => {
861863 let edition = self . tcx . sess . edition ( ) ;
862- Some ( Arc :: new ( SyntaxExtension :: glob_delegation ( def_id, impl_def_id, edition) ) )
864+ Some ( Arc :: new ( SyntaxExtension :: glob_delegation (
865+ def_id,
866+ impl_def_id,
867+ star_span,
868+ edition,
869+ ) ) )
863870 }
864871 _ => None ,
865872 } ,
0 commit comments