Avoid ICE by accounting for missing type

Fix #105330
This commit is contained in:
Esteban Küber 2022-12-05 16:13:32 -08:00
parent 203c8765ea
commit eff76455fd
3 changed files with 131 additions and 1 deletions

View file

@ -1607,7 +1607,7 @@ impl<'tcx> InferCtxtPrivExt<'tcx> for TypeErrCtxt<'_, 'tcx> {
| ObligationCauseCode::ObjectCastObligation(..)
| ObligationCauseCode::OpaqueType
);
let expected_ty = data.term.ty().unwrap();
let expected_ty = data.term.ty().unwrap_or_else(|| self.tcx.ty_error());
// constrain inference variables a bit more to nested obligations from normalize so
// we can have more helpful errors.