@@ -38,6 +38,7 @@ use rustc_span::def_id::LocalDefId;
3838use rustc_span:: symbol:: { kw, sym, Ident , Symbol } ;
3939use rustc_span:: { BytePos , DesugaringKind , ExpnKind , MacroKind , Span , DUMMY_SP } ;
4040use rustc_target:: spec:: abi;
41+ use std:: assert_matches:: debug_assert_matches;
4142use std:: borrow:: Cow ;
4243use std:: iter;
4344
@@ -4219,18 +4220,13 @@ impl<'tcx> TypeErrCtxt<'_, 'tcx> {
42194220 } ;
42204221
42214222 let origin = TypeVariableOrigin { kind : TypeVariableOriginKind :: TypeInference , span } ;
4222- let trait_def_id = proj. trait_def_id ( self . tcx ) ;
42234223 // Make `Self` be equivalent to the type of the call chain
42244224 // expression we're looking at now, so that we can tell what
42254225 // for example `Iterator::Item` is at this point in the chain.
4226- let args = GenericArgs :: for_item ( self . tcx , trait_def_id, |param, _| {
4227- match param. kind {
4228- ty:: GenericParamDefKind :: Type { .. } => {
4229- if param. index == 0 {
4230- return prev_ty. into ( ) ;
4231- }
4232- }
4233- ty:: GenericParamDefKind :: Lifetime | ty:: GenericParamDefKind :: Const { .. } => { }
4226+ let args = GenericArgs :: for_item ( self . tcx , proj. def_id , |param, _| {
4227+ if param. index == 0 {
4228+ debug_assert_matches ! ( param. kind, ty:: GenericParamDefKind :: Type { .. } ) ;
4229+ return prev_ty. into ( ) ;
42344230 }
42354231 self . var_for_def ( span, param)
42364232 } ) ;
0 commit comments