@@ -268,41 +268,31 @@ fn opaque_types_defined_by<'tcx>(tcx: TyCtxt<'tcx>, item: LocalDefId) -> &'tcx [
268
268
trace ! ( ?kind) ;
269
269
let mut collector = OpaqueTypeCollector :: new ( tcx, item) ;
270
270
match kind {
271
- // We're also doing this for `AssocTy` for the wf checks in `check_opaque_meets_bounds`
271
+ // Walk over the signature of the function-like to find the opaques.
272
+ DefKind :: AssocFn | DefKind :: Fn => {
273
+ let ty_sig = tcx. fn_sig ( item) . subst_identity ( ) ;
274
+ let hir_sig = tcx. hir ( ) . get_by_def_id ( item) . fn_sig ( ) . unwrap ( ) ;
275
+ // Walk over the inputs and outputs manually in order to get good spans for them.
276
+ collector. visit_spanned ( hir_sig. decl . output . span ( ) , ty_sig. output ( ) ) ;
277
+ for ( hir, ty) in hir_sig. decl . inputs . iter ( ) . zip ( ty_sig. inputs ( ) . iter ( ) ) {
278
+ collector. visit_spanned ( hir. span , ty. map_bound ( |x| * x) ) ;
279
+ }
280
+ collector. collect_body_and_predicate_taits ( ) ;
281
+ }
282
+ // Walk over the type of the item to find opaques.
272
283
DefKind :: Static ( _)
273
284
| DefKind :: Const
274
285
| DefKind :: AssocConst
275
- | DefKind :: AssocFn
276
286
| DefKind :: AnonConst
277
- | DefKind :: InlineConst
278
- | DefKind :: Fn => {
279
- match kind {
280
- // Walk over the signature of the function-like to find the opaques.
281
- DefKind :: AssocFn | DefKind :: Fn => {
282
- let ty_sig = tcx. fn_sig ( item) . subst_identity ( ) ;
283
- let hir_sig = tcx. hir ( ) . get_by_def_id ( item) . fn_sig ( ) . unwrap ( ) ;
284
- // Walk over the inputs and outputs manually in order to get good spans for them.
285
- collector. visit_spanned ( hir_sig. decl . output . span ( ) , ty_sig. output ( ) ) ;
286
- for ( hir, ty) in hir_sig. decl . inputs . iter ( ) . zip ( ty_sig. inputs ( ) . iter ( ) ) {
287
- collector. visit_spanned ( hir. span , ty. map_bound ( |x| * x) ) ;
288
- }
289
- }
290
- // Walk over the type of the item to find opaques.
291
- DefKind :: Static ( _)
292
- | DefKind :: Const
293
- | DefKind :: AssocConst
294
- | DefKind :: AnonConst
295
- | DefKind :: InlineConst => {
296
- let span = match tcx. hir ( ) . get_by_def_id ( item) . ty ( ) {
297
- Some ( ty) => ty. span ,
298
- _ => tcx. def_span ( item) ,
299
- } ;
300
- collector. visit_spanned ( span, tcx. type_of ( item) . subst_identity ( ) ) ;
301
- }
302
- _ => unreachable ! ( ) ,
303
- }
287
+ | DefKind :: InlineConst => {
288
+ let span = match tcx. hir ( ) . get_by_def_id ( item) . ty ( ) {
289
+ Some ( ty) => ty. span ,
290
+ _ => tcx. def_span ( item) ,
291
+ } ;
292
+ collector. visit_spanned ( span, tcx. type_of ( item) . subst_identity ( ) ) ;
304
293
collector. collect_body_and_predicate_taits ( ) ;
305
294
}
295
+ // We're also doing this for `AssocTy` for the wf checks in `check_opaque_meets_bounds`
306
296
DefKind :: TyAlias | DefKind :: AssocTy => {
307
297
tcx. type_of ( item) . subst_identity ( ) . visit_with ( & mut collector) ;
308
298
}
0 commit comments