1
Fork 0

valtree construction: keep track of which type was valtree-incompatible

This commit is contained in:
Ralf Jung 2024-07-13 16:13:55 +02:00
parent 52f3c71c8d
commit fa74a9e6aa
11 changed files with 37 additions and 35 deletions

View file

@ -87,12 +87,12 @@ impl<'tcx> rustc_next_trait_solver::delegate::SolverDelegate for SolverDelegate<
) -> Option<ty::Const<'tcx>> {
use rustc_middle::mir::interpret::ErrorHandled;
match self.const_eval_resolve(param_env, unevaluated, DUMMY_SP) {
Ok(Some(val)) => Some(ty::Const::new_value(
Ok(Ok(val)) => Some(ty::Const::new_value(
self.tcx,
val,
self.tcx.type_of(unevaluated.def).instantiate(self.tcx, unevaluated.args),
)),
Ok(None) | Err(ErrorHandled::TooGeneric(_)) => None,
Ok(Err(_)) | Err(ErrorHandled::TooGeneric(_)) => None,
Err(ErrorHandled::Reported(e, _)) => Some(ty::Const::new_error(self.tcx, e.into())),
}
}

View file

@ -765,8 +765,8 @@ impl<'tcx> AutoTraitFinder<'tcx> {
unevaluated,
obligation.cause.span,
) {
Ok(Some(valtree)) => Ok(ty::Const::new_value(selcx.tcx(),valtree, self.tcx.type_of(unevaluated.def).instantiate(self.tcx, unevaluated.args))),
Ok(None) => {
Ok(Ok(valtree)) => Ok(ty::Const::new_value(selcx.tcx(),valtree, self.tcx.type_of(unevaluated.def).instantiate(self.tcx, unevaluated.args))),
Ok(Err(_)) => {
let tcx = self.tcx;
let reported =
tcx.dcx().emit_err(UnableToConstructConstantValue {