@@ -10,9 +10,7 @@ use rustc_hir::{HirId, Node};
1010use rustc_middle:: hir:: map:: Map ;
1111use rustc_middle:: ty:: subst:: { GenericArgKind , InternalSubsts } ;
1212use rustc_middle:: ty:: util:: IntTypeExt ;
13- use rustc_middle:: ty:: {
14- self , DefIdTree , OpaqueTypeKey , ResolvedOpaqueTy , Ty , TyCtxt , TypeFoldable ,
15- } ;
13+ use rustc_middle:: ty:: { self , DefIdTree , OpaqueTypeKey , Ty , TyCtxt , TypeFoldable } ;
1614use rustc_span:: symbol:: Ident ;
1715use rustc_span:: { Span , DUMMY_SP } ;
1816
@@ -353,7 +351,7 @@ pub(super) fn type_of(tcx: TyCtxt<'_>, def_id: DefId) -> Ty<'_> {
353351 & tcx. mir_borrowck ( owner. expect_local ( ) ) . concrete_opaque_types ,
354352 def_id. to_def_id ( ) ,
355353 )
356- . map ( |opaque| opaque . concrete_type )
354+ . map ( |& ( _ , concrete_ty ) | concrete_ty )
357355 . unwrap_or_else ( || {
358356 tcx. sess . delay_span_bug (
359357 DUMMY_SP ,
@@ -531,14 +529,13 @@ fn find_opaque_ty_constraints(tcx: TyCtxt<'_>, def_id: LocalDefId) -> Ty<'_> {
531529 return ;
532530 }
533531 // Use borrowck to get the type with unerased regions.
534- let ty = find_concrete_ty_from_def_id (
535- & self . tcx . mir_borrowck ( def_id) . concrete_opaque_types ,
536- self . def_id ,
537- ) ;
538- if let Some ( ty:: ResolvedOpaqueTy { concrete_type, substs } ) = ty {
532+ let concrete_opaque_types = & self . tcx . mir_borrowck ( def_id) . concrete_opaque_types ;
533+ if let Some ( ( opaque_type_key, concrete_type) ) =
534+ find_concrete_ty_from_def_id ( concrete_opaque_types, self . def_id )
535+ {
539536 debug ! (
540537 "find_opaque_ty_constraints: found constraint for `{:?}` at `{:?}`: {:?}" ,
541- self . def_id, def_id, ty ,
538+ self . def_id, def_id, concrete_type ,
542539 ) ;
543540
544541 // FIXME(oli-obk): trace the actual span from inference to improve errors.
@@ -549,7 +546,7 @@ fn find_opaque_ty_constraints(tcx: TyCtxt<'_>, def_id: LocalDefId) -> Ty<'_> {
549546 // using `delay_span_bug`, just in case `wfcheck` slips up.
550547 let opaque_generics = self . tcx . generics_of ( self . def_id ) ;
551548 let mut used_params: FxHashSet < _ > = FxHashSet :: default ( ) ;
552- for ( i, arg) in substs. iter ( ) . enumerate ( ) {
549+ for ( i, arg) in opaque_type_key . substs . iter ( ) . enumerate ( ) {
553550 let arg_is_param = match arg. unpack ( ) {
554551 GenericArgKind :: Type ( ty) => matches ! ( ty. kind( ) , ty:: Param ( _) ) ,
555552 GenericArgKind :: Lifetime ( lt) => {
@@ -710,7 +707,7 @@ fn let_position_impl_trait_type(tcx: TyCtxt<'_>, opaque_ty_id: LocalDefId) -> Ty
710707 let owner_typeck_results = tcx. typeck ( scope_def_id) ;
711708 let concrete_ty =
712709 find_concrete_ty_from_def_id ( & owner_typeck_results. concrete_opaque_types , opaque_ty_def_id)
713- . map ( |opaque| opaque . concrete_type )
710+ . map ( |& ( _ , concrete_ty ) | concrete_ty )
714711 . unwrap_or_else ( || {
715712 tcx. sess . delay_span_bug (
716713 DUMMY_SP ,
@@ -808,11 +805,8 @@ fn check_feature_inherent_assoc_ty(tcx: TyCtxt<'_>, span: Span) {
808805}
809806
810807fn find_concrete_ty_from_def_id < ' tcx > (
811- concrete_opaque_types : & ' tcx VecMap < OpaqueTypeKey < ' tcx > , ResolvedOpaqueTy < ' tcx > > ,
808+ concrete_opaque_types : & ' tcx VecMap < OpaqueTypeKey < ' tcx > , Ty < ' tcx > > ,
812809 def_id : DefId ,
813- ) -> Option < & ' tcx ResolvedOpaqueTy < ' tcx > > {
814- concrete_opaque_types
815- . iter ( )
816- . find ( |( opaque_type_key, _) | opaque_type_key. def_id == def_id)
817- . map ( |( _, resolved_opaque_ty) | resolved_opaque_ty)
810+ ) -> Option < & ' tcx ( OpaqueTypeKey < ' tcx > , Ty < ' tcx > ) > {
811+ concrete_opaque_types. iter ( ) . find ( |( opaque_type_key, _) | opaque_type_key. def_id == def_id)
818812}
0 commit comments