@@ -461,39 +461,29 @@ impl<'a, 'tcx> Instantiator<'a, 'tcx> {
461
461
if let Some ( def_id) = def_id. as_local ( ) {
462
462
let opaque_hir_id = tcx. hir ( ) . local_def_id_to_hir_id ( def_id) ;
463
463
let parent_def_id = self . infcx . defining_use_anchor ;
464
- let ( in_definition_scope, origin) = match tcx. hir ( ) . expect_item ( def_id) . kind
465
- {
464
+ let item_kind = & tcx. hir ( ) . expect_item ( def_id) . kind ;
465
+ let hir:: ItemKind :: OpaqueTy ( hir:: OpaqueTy { origin, .. } ) = item_kind else {
466
+ span_bug ! (
467
+ self . value_span,
468
+ "weird opaque type: {:#?}, {:#?}" ,
469
+ ty. kind( ) ,
470
+ item_kind
471
+ )
472
+ } ;
473
+ let in_definition_scope = match * origin {
466
474
// Async `impl Trait`
467
- hir:: ItemKind :: OpaqueTy ( hir:: OpaqueTy {
468
- origin : hir:: OpaqueTyOrigin :: AsyncFn ( parent) ,
469
- ..
470
- } ) => ( parent == parent_def_id, hir:: OpaqueTyOrigin :: AsyncFn ( parent) ) ,
475
+ hir:: OpaqueTyOrigin :: AsyncFn ( parent) => parent == parent_def_id,
471
476
// Anonymous `impl Trait`
472
- hir:: ItemKind :: OpaqueTy ( hir:: OpaqueTy {
473
- origin : hir:: OpaqueTyOrigin :: FnReturn ( parent) ,
474
- ..
475
- } ) => ( parent == parent_def_id, hir:: OpaqueTyOrigin :: FnReturn ( parent) ) ,
477
+ hir:: OpaqueTyOrigin :: FnReturn ( parent) => parent == parent_def_id,
476
478
// Named `type Foo = impl Bar;`
477
- hir:: ItemKind :: OpaqueTy ( hir:: OpaqueTy {
478
- origin : hir:: OpaqueTyOrigin :: TyAlias ,
479
- ..
480
- } ) => (
481
- may_define_opaque_type ( tcx, parent_def_id, opaque_hir_id) ,
482
- hir:: OpaqueTyOrigin :: TyAlias ,
483
- ) ,
484
- ref itemkind => {
485
- span_bug ! (
486
- self . value_span,
487
- "weird opaque type: {:#?}, {:#?}" ,
488
- ty. kind( ) ,
489
- itemkind
490
- )
479
+ hir:: OpaqueTyOrigin :: TyAlias => {
480
+ may_define_opaque_type ( tcx, parent_def_id, opaque_hir_id)
491
481
}
492
482
} ;
493
483
if in_definition_scope {
494
484
let opaque_type_key =
495
485
OpaqueTypeKey { def_id : def_id. to_def_id ( ) , substs } ;
496
- return self . fold_opaque_ty ( ty, opaque_type_key, origin) ;
486
+ return self . fold_opaque_ty ( ty, opaque_type_key, * origin) ;
497
487
}
498
488
499
489
debug ! (
0 commit comments