@@ -394,38 +394,31 @@ impl<'ra, 'tcx> ResolverExpand for Resolver<'ra, 'tcx> {
394394 } ) ;
395395 let parent_scope = self . invocation_parent_scopes [ & expn_id] ;
396396 for ( i, resolution) in entry. resolutions . iter_mut ( ) . enumerate ( ) {
397- if resolution. exts . is_none ( ) {
398- resolution. exts = Some (
399- match self . cm ( ) . resolve_macro_path (
400- & resolution. path ,
401- MacroKind :: Derive ,
402- & parent_scope,
403- true ,
404- force,
405- None ,
406- None ,
407- ) {
408- Ok ( ( Some ( ext) , _) ) => {
409- if !ext. helper_attrs . is_empty ( ) {
410- let last_seg = resolution. path . segments . last ( ) . unwrap ( ) ;
411- let span = last_seg. ident . span . normalize_to_macros_2_0 ( ) ;
412- entry. helper_attrs . extend (
413- ext. helper_attrs
414- . iter ( )
415- . map ( |name| ( i, Ident :: new ( * name, span) ) ) ,
416- ) ;
417- }
418- entry. has_derive_copy |= ext. builtin_name == Some ( sym:: Copy ) ;
419- ext
420- }
421- Ok ( _) | Err ( Determinacy :: Determined ) => self . dummy_ext ( MacroKind :: Derive ) ,
422- Err ( Determinacy :: Undetermined ) => {
423- assert ! ( self . derive_data. is_empty( ) ) ;
424- self . derive_data = derive_data;
425- return Err ( Indeterminate ) ;
397+ if !resolution. has_been_handled {
398+ match self . cm ( ) . resolve_derive_macro_path (
399+ & resolution. path ,
400+ & parent_scope,
401+ force,
402+ None ,
403+ ) {
404+ Ok ( ( Some ( ext) , _) ) => {
405+ if !ext. helper_attrs . is_empty ( ) {
406+ let last_seg = resolution. path . segments . last ( ) . unwrap ( ) ;
407+ let span = last_seg. ident . span . normalize_to_macros_2_0 ( ) ;
408+ entry. helper_attrs . extend (
409+ ext. helper_attrs . iter ( ) . map ( |name| ( i, Ident :: new ( * name, span) ) ) ,
410+ ) ;
426411 }
427- } ,
428- ) ;
412+ entry. has_derive_copy |= ext. builtin_name == Some ( sym:: Copy ) ;
413+ }
414+ Ok ( _) | Err ( Determinacy :: Determined ) => ( ) ,
415+ Err ( Determinacy :: Undetermined ) => {
416+ assert ! ( self . derive_data. is_empty( ) ) ;
417+ self . derive_data = derive_data;
418+ return Err ( Indeterminate ) ;
419+ }
420+ }
421+ resolution. has_been_handled = true ;
429422 }
430423 }
431424 // Sort helpers in a stable way independent from the derive resolution order.
@@ -571,7 +564,6 @@ impl<'ra, 'tcx> Resolver<'ra, 'tcx> {
571564 path,
572565 kind,
573566 parent_scope,
574- true ,
575567 force,
576568 deleg_impl,
577569 invoc_in_mod_inert_attr. map ( |def_id| ( def_id, node_id) ) ,
@@ -713,26 +705,22 @@ impl<'ra, 'tcx> Resolver<'ra, 'tcx> {
713705 Ok ( ( ext, res) )
714706 }
715707
716- pub ( crate ) fn resolve_macro_path < ' r > (
708+ pub ( crate ) fn resolve_derive_macro_path < ' r > (
717709 self : CmResolver < ' r , ' ra , ' tcx > ,
718710 path : & ast:: Path ,
719- kind : MacroKind ,
720711 parent_scope : & ParentScope < ' ra > ,
721- trace : bool ,
722712 force : bool ,
723713 ignore_import : Option < Import < ' ra > > ,
724- suggestion_span : Option < Span > ,
725714 ) -> Result < ( Option < Arc < SyntaxExtension > > , Res ) , Determinacy > {
726715 self . resolve_macro_or_delegation_path (
727716 path,
728- kind ,
717+ MacroKind :: Derive ,
729718 parent_scope,
730- trace,
731719 force,
732720 None ,
733721 None ,
734722 ignore_import,
735- suggestion_span ,
723+ None ,
736724 )
737725 }
738726
@@ -741,7 +729,6 @@ impl<'ra, 'tcx> Resolver<'ra, 'tcx> {
741729 ast_path : & ast:: Path ,
742730 kind : MacroKind ,
743731 parent_scope : & ParentScope < ' ra > ,
744- trace : bool ,
745732 force : bool ,
746733 deleg_impl : Option < LocalDefId > ,
747734 invoc_in_mod_inert_attr : Option < ( LocalDefId , NodeId ) > ,
@@ -780,16 +767,14 @@ impl<'ra, 'tcx> Resolver<'ra, 'tcx> {
780767 PathResult :: Module ( ..) => unreachable ! ( ) ,
781768 } ;
782769
783- if trace {
784- self . multi_segment_macro_resolutions . borrow_mut ( & self ) . push ( (
785- path,
786- path_span,
787- kind,
788- * parent_scope,
789- res. ok ( ) ,
790- ns,
791- ) ) ;
792- }
770+ self . multi_segment_macro_resolutions . borrow_mut ( & self ) . push ( (
771+ path,
772+ path_span,
773+ kind,
774+ * parent_scope,
775+ res. ok ( ) ,
776+ ns,
777+ ) ) ;
793778
794779 self . prohibit_imported_non_macro_attrs ( None , res. ok ( ) , path_span) ;
795780 res
@@ -807,15 +792,13 @@ impl<'ra, 'tcx> Resolver<'ra, 'tcx> {
807792 return Err ( Determinacy :: Undetermined ) ;
808793 }
809794
810- if trace {
811- self . single_segment_macro_resolutions . borrow_mut ( & self ) . push ( (
812- path[ 0 ] . ident ,
813- kind,
814- * parent_scope,
815- binding. ok ( ) ,
816- suggestion_span,
817- ) ) ;
818- }
795+ self . single_segment_macro_resolutions . borrow_mut ( & self ) . push ( (
796+ path[ 0 ] . ident ,
797+ kind,
798+ * parent_scope,
799+ binding. ok ( ) ,
800+ suggestion_span,
801+ ) ) ;
819802
820803 let res = binding. map ( |binding| binding. res ( ) ) ;
821804 self . prohibit_imported_non_macro_attrs ( binding. ok ( ) , res. ok ( ) , path_span) ;
0 commit comments