Replace const_error methods with Const::new_error

This commit is contained in:
Boxy
2023-07-04 14:46:32 +01:00
parent ddbc774e74
commit d30f56dbf2
15 changed files with 66 additions and 59 deletions

View File

@@ -2332,7 +2332,7 @@ impl<'tcx> ConstantKind<'tcx> {
if let Some(val) = c.kind().try_eval_for_mir(tcx, param_env) {
match val {
Ok(val) => Self::Val(val, c.ty()),
Err(guar) => Self::Ty(tcx.const_error(self.ty(), guar)),
Err(guar) => Self::Ty(ty::Const::new_error(tcx, guar, self.ty())),
}
} else {
self
@@ -2344,7 +2344,9 @@ impl<'tcx> ConstantKind<'tcx> {
match tcx.const_eval_resolve(param_env, uneval, None) {
Ok(val) => Self::Val(val, ty),
Err(ErrorHandled::TooGeneric) => self,
Err(ErrorHandled::Reported(guar)) => Self::Ty(tcx.const_error(ty, guar.into())),
Err(ErrorHandled::Reported(guar)) => {
Self::Ty(ty::Const::new_error(tcx, guar.into(), ty))
}
}
}
}