@@ -691,58 +691,73 @@ impl<'a, 'tcx> CrateLoader<'a, 'tcx> {
691691 where
692692 ' a : ' b ,
693693 {
694- // Use a new crate locator and crate rejections so trying to load a proc macro doesn't
695- // affect the error message we emit
696- let mut proc_macro_locator = locator. clone ( ) ;
697- let mut proc_macro_crate_rejections = CrateRejections :: default ( ) ;
698-
699- // Try to load a proc macro
700- proc_macro_locator. is_proc_macro = true ;
701-
702- // Load the proc macro crate for the target
703- let ( locator, crate_rejections, target_result) =
704- if self . sess . opts . unstable_opts . dual_proc_macros {
705- let result =
706- match self . load ( & mut proc_macro_locator, & mut proc_macro_crate_rejections) ? {
707- Some ( LoadResult :: Previous ( cnum) ) => {
708- return Ok ( Some ( ( LoadResult :: Previous ( cnum) , None ) ) ) ;
709- }
710- Some ( LoadResult :: Loaded ( library) ) => Some ( LoadResult :: Loaded ( library) ) ,
711- None => return Ok ( None ) ,
712- } ;
713- locator. hash = host_hash;
714- // Use the locator when looking for the host proc macro crate, as that is required
715- // so we want it to affect the error message
716- ( locator, crate_rejections, result)
717- } else {
718- ( & mut proc_macro_locator, & mut proc_macro_crate_rejections, None )
719- } ;
694+ if self . sess . opts . unstable_opts . dual_proc_macros {
695+ // Use a new crate locator and crate rejections so trying to load a proc macro doesn't
696+ // affect the error message we emit
697+ let mut proc_macro_locator = locator. clone ( ) ;
698+
699+ // Try to load a proc macro
700+ proc_macro_locator. is_proc_macro = true ;
701+
702+ // Load the proc macro crate for the target
703+ let target_result =
704+ match self . load ( & mut proc_macro_locator, & mut CrateRejections :: default ( ) ) ? {
705+ Some ( LoadResult :: Previous ( cnum) ) => {
706+ return Ok ( Some ( ( LoadResult :: Previous ( cnum) , None ) ) ) ;
707+ }
708+ Some ( LoadResult :: Loaded ( library) ) => Some ( LoadResult :: Loaded ( library) ) ,
709+ None => return Ok ( None ) ,
710+ } ;
720711
721- // Load the proc macro crate for the host
712+ // Load the proc macro crate for the host
722713
723- * crate_rejections = CrateRejections :: default ( ) ;
724- // FIXME use a separate CrateLocator for the host rather than mutating the target CrateLocator
725- locator. is_proc_macro = true ;
726- locator. target = & self . sess . host ;
727- locator. tuple = TargetTuple :: from_tuple ( config:: host_tuple ( ) ) ;
728- locator. filesearch = self . sess . host_filesearch ( ) ;
729- locator. path_kind = path_kind;
714+ // Use the existing crate_rejections as we want the error message to be affected by
715+ // loading the host proc macro.
716+ * crate_rejections = CrateRejections :: default ( ) ;
717+ // FIXME use a separate CrateLocator for the host rather than mutating the target CrateLocator
718+ locator. is_proc_macro = true ;
719+ locator. target = & self . sess . host ;
720+ locator. tuple = TargetTuple :: from_tuple ( config:: host_tuple ( ) ) ;
721+ locator. filesearch = self . sess . host_filesearch ( ) ;
722+ locator. path_kind = path_kind;
730723
731- let Some ( host_result) = self . load ( locator, crate_rejections) ? else {
732- return Ok ( None ) ;
733- } ;
724+ locator. hash = host_hash;
725+
726+ let Some ( host_result) = self . load ( locator, crate_rejections) ? else {
727+ return Ok ( None ) ;
728+ } ;
734729
735- Ok ( Some ( if self . sess . opts . unstable_opts . dual_proc_macros {
736730 let host_result = match host_result {
737731 LoadResult :: Previous ( ..) => {
738732 panic ! ( "host and target proc macros must be loaded in lock-step" )
739733 }
740734 LoadResult :: Loaded ( library) => library,
741735 } ;
742- ( target_result. unwrap ( ) , Some ( host_result) )
736+ Ok ( Some ( ( target_result. unwrap ( ) , Some ( host_result) ) ) )
743737 } else {
744- ( host_result, None )
745- } ) )
738+ // Use a new crate locator and crate rejections so trying to load a proc macro doesn't
739+ // affect the error message we emit
740+ let mut proc_macro_locator = locator. clone ( ) ;
741+
742+ // Try to load a proc macro
743+ proc_macro_locator. is_proc_macro = true ;
744+
745+ // Load the proc macro crate for the host
746+
747+ // FIXME use a separate CrateLocator for the host rather than mutating the target CrateLocator
748+ proc_macro_locator. target = & self . sess . host ;
749+ proc_macro_locator. tuple = TargetTuple :: from_tuple ( config:: host_tuple ( ) ) ;
750+ proc_macro_locator. filesearch = self . sess . host_filesearch ( ) ;
751+ proc_macro_locator. path_kind = path_kind;
752+
753+ let Some ( host_result) =
754+ self . load ( & mut proc_macro_locator, & mut CrateRejections :: default ( ) ) ?
755+ else {
756+ return Ok ( None ) ;
757+ } ;
758+
759+ Ok ( Some ( ( host_result, None ) ) )
760+ }
746761 }
747762
748763 fn resolve_crate (
0 commit comments