@@ -187,32 +187,38 @@ pub(super) fn all_local_trait_impls<'tcx>(
187
187
pub ( super ) fn trait_impls_of_provider ( tcx : TyCtxt < ' _ > , trait_id : DefId ) -> TraitImpls {
188
188
let mut impls = TraitImpls :: default ( ) ;
189
189
190
- {
191
- let mut add_impl = |impl_def_id : DefId | {
192
- let impl_self_ty = tcx. type_of ( impl_def_id) ;
193
- if impl_def_id. is_local ( ) && impl_self_ty. references_error ( ) {
194
- return ;
195
- }
196
-
197
- if let Some ( simplified_self_ty) = fast_reject:: simplify_type ( tcx, impl_self_ty, false ) {
198
- impls. non_blanket_impls . entry ( simplified_self_ty) . or_default ( ) . push ( impl_def_id) ;
199
- } else {
200
- impls. blanket_impls . push ( impl_def_id) ;
201
- }
202
- } ;
203
-
204
- // Traits defined in the current crate can't have impls in upstream
205
- // crates, so we don't bother querying the cstore.
206
- if !trait_id. is_local ( ) {
207
- for & cnum in tcx. crates ( ) . iter ( ) {
208
- for & def_id in tcx. implementations_of_trait ( ( cnum, trait_id) ) . iter ( ) {
209
- add_impl ( def_id) ;
190
+ // Traits defined in the current crate can't have impls in upstream
191
+ // crates, so we don't bother querying the cstore.
192
+ if !trait_id. is_local ( ) {
193
+ for & cnum in tcx. crates ( ) . iter ( ) {
194
+ for & ( impl_def_id, simplified_self_ty) in
195
+ tcx. implementations_of_trait ( ( cnum, trait_id) ) . iter ( )
196
+ {
197
+ if let Some ( simplified_self_ty) = simplified_self_ty {
198
+ impls
199
+ . non_blanket_impls
200
+ . entry ( simplified_self_ty)
201
+ . or_default ( )
202
+ . push ( impl_def_id) ;
203
+ } else {
204
+ impls. blanket_impls . push ( impl_def_id) ;
210
205
}
211
206
}
212
207
}
208
+ }
209
+
210
+ for & hir_id in tcx. hir ( ) . trait_impls ( trait_id) {
211
+ let impl_def_id = tcx. hir ( ) . local_def_id ( hir_id) . to_def_id ( ) ;
212
+
213
+ let impl_self_ty = tcx. type_of ( impl_def_id) ;
214
+ if impl_self_ty. references_error ( ) {
215
+ continue ;
216
+ }
213
217
214
- for & hir_id in tcx. hir ( ) . trait_impls ( trait_id) {
215
- add_impl ( tcx. hir ( ) . local_def_id ( hir_id) . to_def_id ( ) ) ;
218
+ if let Some ( simplified_self_ty) = fast_reject:: simplify_type ( tcx, impl_self_ty, false ) {
219
+ impls. non_blanket_impls . entry ( simplified_self_ty) . or_default ( ) . push ( impl_def_id) ;
220
+ } else {
221
+ impls. blanket_impls . push ( impl_def_id) ;
216
222
}
217
223
}
218
224
0 commit comments