@@ -60,19 +60,41 @@ impl<'tcx, 'ctx> Analyzer<'tcx, 'ctx> {
6060 }
6161
6262 fn refine_local_defs ( & mut self ) {
63+ // Prioritize trait method specs so that they are always available when refining trait impl
64+ // functions; see the partialeq_impl.rs case.
6365 let mut keys = self . tcx . mir_keys ( ( ) ) . clone ( ) ;
66+ let mut formula_fn_keys = HashSet :: new ( ) ;
67+ let mut trait_method_spec_keys = HashSet :: new ( ) ;
6468 for local_def_id in self . tcx . mir_keys ( ( ) ) {
6569 let analyzer = self . ctx . local_def_analyzer ( * local_def_id) ;
6670 if analyzer. is_annotated_as_extern_spec_fn ( ) {
67- if let Some ( target_def_id) = analyzer. extern_spec_fn_target_def_id ( ) . as_local ( ) {
71+ let target_def_id = analyzer. extern_spec_fn_target_def_id ( ) ;
72+ if let Some ( local_target_def_id) = target_def_id. as_local ( ) {
6873 self . skip_analysis . insert ( local_target_def_id) ;
69- keys. swap_remove ( & target_def_id ) ;
74+ keys. swap_remove ( & local_target_def_id ) ;
7075 }
76+ if matches ! (
77+ self . tcx. def_kind( target_def_id) ,
78+ rustc_hir:: def:: DefKind :: AssocFn
79+ ) {
80+ trait_method_spec_keys. insert ( * local_def_id) ;
81+ keys. swap_remove ( local_def_id) ;
82+ }
83+ }
84+ if analyzer. is_annotated_as_formula_fn ( ) {
85+ formula_fn_keys. insert ( * local_def_id) ;
86+ keys. swap_remove ( local_def_id) ;
7187 }
7288 if !self . tcx . def_kind ( * local_def_id) . is_fn_like ( ) {
7389 keys. swap_remove ( local_def_id) ;
7490 }
7591 }
92+ for local_def_id in & formula_fn_keys {
93+ self . refine_fn_def ( * local_def_id) ;
94+ }
95+ for local_def_id in & trait_method_spec_keys {
96+ self . refine_fn_def ( * local_def_id) ;
97+ }
7698 for local_def_id in & keys {
7799 self . refine_fn_def ( * local_def_id) ;
78100 }
0 commit comments