@@ -148,8 +148,7 @@ fn ensure_impl_params_and_item_params_correspond<'tcx>(
148148 ty:: ImplPolarity :: Positive | ty:: ImplPolarity :: Reservation => "" ,
149149 ty:: ImplPolarity :: Negative => "!" ,
150150 } ;
151- let trait_name = tcx
152- . item_name ( tcx. trait_id_of_impl ( impl_def_id. to_def_id ( ) ) . expect ( "expected impl of trait" ) ) ;
151+ let trait_name = tcx. item_name ( tcx. impl_trait_id ( impl_def_id. to_def_id ( ) ) ) ;
153152 let mut err = struct_span_code_err ! (
154153 tcx. dcx( ) ,
155154 impl_span,
@@ -187,8 +186,7 @@ fn ensure_impl_predicates_are_implied_by_item_defn<'tcx>(
187186 let ocx = ObligationCtxt :: new_with_diagnostics ( & infcx) ;
188187
189188 let impl_span = tcx. def_span ( impl_def_id. to_def_id ( ) ) ;
190- let trait_name = tcx
191- . item_name ( tcx. trait_id_of_impl ( impl_def_id. to_def_id ( ) ) . expect ( "expected impl of trait" ) ) ;
189+ let trait_name = tcx. item_name ( tcx. impl_trait_id ( impl_def_id. to_def_id ( ) ) ) ;
192190 let polarity = match tcx. impl_polarity ( impl_def_id) {
193191 ty:: ImplPolarity :: Positive | ty:: ImplPolarity :: Reservation => "" ,
194192 ty:: ImplPolarity :: Negative => "!" ,
@@ -212,8 +210,7 @@ fn ensure_impl_predicates_are_implied_by_item_defn<'tcx>(
212210 ty:: EarlyBinder :: bind ( tcx. param_env ( adt_def_id) ) . instantiate ( tcx, adt_to_impl_args) ;
213211
214212 let fresh_impl_args = infcx. fresh_args_for_item ( impl_span, impl_def_id. to_def_id ( ) ) ;
215- let fresh_adt_ty =
216- tcx. impl_trait_ref ( impl_def_id) . unwrap ( ) . instantiate ( tcx, fresh_impl_args) . self_ty ( ) ;
213+ let fresh_adt_ty = tcx. impl_trait_ref ( impl_def_id) . instantiate ( tcx, fresh_impl_args) . self_ty ( ) ;
217214
218215 ocx. eq ( & ObligationCause :: dummy_with_span ( impl_span) , adt_env, fresh_adt_ty, impl_adt_ty)
219216 . expect ( "equating fully generic trait ref should never fail" ) ;
0 commit comments