@@ -356,9 +356,6 @@ pub(super) fn type_of(tcx: TyCtxt<'_>, def_id: DefId) -> Ty<'_> {
356356 let substs = InternalSubsts :: identity_for_item ( tcx, def_id. to_def_id ( ) ) ;
357357 tcx. mk_adt ( def, substs)
358358 }
359- ItemKind :: OpaqueTy ( OpaqueTy { origin : hir:: OpaqueTyOrigin :: Binding , .. } ) => {
360- let_position_impl_trait_type ( tcx, def_id)
361- }
362359 ItemKind :: OpaqueTy ( OpaqueTy { impl_trait_fn : None , .. } ) => {
363360 find_opaque_ty_constraints ( tcx, def_id)
364361 }
@@ -696,60 +693,6 @@ fn find_opaque_ty_constraints(tcx: TyCtxt<'_>, def_id: LocalDefId) -> Ty<'_> {
696693 }
697694}
698695
699- /// Retrieve the inferred concrete type for let position impl trait.
700- ///
701- /// This is different to other kinds of impl trait because:
702- ///
703- /// 1. We know which function contains the defining use (the function that
704- /// contains the let statement)
705- /// 2. We do not currently allow (free) lifetimes in the return type. `let`
706- /// statements in some statically unreachable code are removed from the MIR
707- /// by the time we borrow check, and it's not clear how we should handle
708- /// those.
709- fn let_position_impl_trait_type ( tcx : TyCtxt < ' _ > , opaque_ty_id : LocalDefId ) -> Ty < ' _ > {
710- let scope = tcx. hir ( ) . get_defining_scope ( tcx. hir ( ) . local_def_id_to_hir_id ( opaque_ty_id) ) ;
711- let scope_def_id = tcx. hir ( ) . local_def_id ( scope) ;
712-
713- let opaque_ty_def_id = opaque_ty_id. to_def_id ( ) ;
714-
715- let owner_typeck_results = tcx. typeck ( scope_def_id) ;
716- let concrete_ty = owner_typeck_results
717- . concrete_opaque_types
718- . get_by ( |( key, _) | key. def_id == opaque_ty_def_id)
719- . map ( |concrete_ty| * concrete_ty)
720- . unwrap_or_else ( || {
721- tcx. sess . delay_span_bug (
722- DUMMY_SP ,
723- & format ! (
724- "owner {:?} has no opaque type for {:?} in its typeck results" ,
725- scope_def_id, opaque_ty_id
726- ) ,
727- ) ;
728- if let Some ( ErrorReported ) = owner_typeck_results. tainted_by_errors {
729- // Some error in the owner fn prevented us from populating the
730- // `concrete_opaque_types` table.
731- tcx. ty_error ( )
732- } else {
733- // We failed to resolve the opaque type or it resolves to
734- // itself. Return the non-revealed type, which should result in
735- // E0720.
736- tcx. mk_opaque (
737- opaque_ty_def_id,
738- InternalSubsts :: identity_for_item ( tcx, opaque_ty_def_id) ,
739- )
740- }
741- } ) ;
742- debug ! ( "concrete_ty = {:?}" , concrete_ty) ;
743- if concrete_ty. has_erased_regions ( ) {
744- // FIXME(impl_trait_in_bindings) Handle this case.
745- tcx. sess . span_fatal (
746- tcx. hir ( ) . span ( tcx. hir ( ) . local_def_id_to_hir_id ( opaque_ty_id) ) ,
747- "lifetimes in impl Trait types in bindings are not currently supported" ,
748- ) ;
749- }
750- concrete_ty
751- }
752-
753696fn infer_placeholder_type < ' a > (
754697 tcx : TyCtxt < ' a > ,
755698 def_id : LocalDefId ,
0 commit comments