1
Fork 0

Add Ty to ConstKind::Value

This commit is contained in:
Boxy 2024-06-03 02:34:35 +01:00
parent 58feec9b85
commit a9702a6668
30 changed files with 180 additions and 186 deletions

View file

@ -1040,8 +1040,13 @@ impl<'tcx> EvalCtxt<'_, InferCtxt<'tcx>> {
) -> Option<ty::Const<'tcx>> {
use rustc_middle::mir::interpret::ErrorHandled;
match self.infcx.const_eval_resolve(param_env, unevaluated, DUMMY_SP) {
// THISPR
Ok(Some(val)) => Some(ty::Const::new_value(self.interner(), val, todo!())),
Ok(Some(val)) => Some(ty::Const::new_value(
self.interner(),
val,
self.interner()
.type_of(unevaluated.def)
.instantiate(self.interner(), unevaluated.args),
)),
Ok(None) | Err(ErrorHandled::TooGeneric(_)) => None,
Err(ErrorHandled::Reported(e, _)) => {
Some(ty::Const::new_error(self.interner(), e.into()))

View file

@ -178,7 +178,9 @@ impl<'a, 'tcx> EvalCtxt<'a, InferCtxt<'tcx>> {
ty::ConstKind::Infer(_) => {
self.evaluate_added_goals_and_make_canonical_response(Certainty::AMBIGUOUS)
}
ty::ConstKind::Placeholder(_) | ty::ConstKind::Value(_) | ty::ConstKind::Error(_) => {
ty::ConstKind::Placeholder(_)
| ty::ConstKind::Value(_, _)
| ty::ConstKind::Error(_) => {
self.evaluate_added_goals_and_make_canonical_response(Certainty::Yes)
}
// We can freely ICE here as:

View file

@ -765,8 +765,7 @@ impl<'tcx> AutoTraitFinder<'tcx> {
unevaluated,
obligation.cause.span,
) {
// THISPR
Ok(Some(valtree)) => Ok(ty::Const::new_value(selcx.tcx(),valtree, todo!())),
Ok(Some(valtree)) => Ok(ty::Const::new_value(selcx.tcx(),valtree, self.tcx.type_of(unevaluated.def).instantiate(self.tcx, unevaluated.args))),
Ok(None) => {
let tcx = self.tcx;
let reported =

View file

@ -34,7 +34,7 @@ pub fn is_const_evaluatable<'tcx>(
ty::ConstKind::Param(_)
| ty::ConstKind::Bound(_, _)
| ty::ConstKind::Placeholder(_)
| ty::ConstKind::Value(_)
| ty::ConstKind::Value(_, _)
| ty::ConstKind::Error(_) => return Ok(()),
ty::ConstKind::Infer(_) => return Err(NotConstEvaluatable::MentionsInfer),
};