implement valtrees as the type-system representation for constant values

This commit is contained in:
b-naber 2022-02-16 10:56:01 +01:00
parent edab34ab2a
commit 705d818bd5
116 changed files with 1606 additions and 1032 deletions

View file

@ -636,13 +636,15 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> {
let evaluate = |c: ty::Const<'tcx>| {
if let ty::ConstKind::Unevaluated(unevaluated) = c.kind() {
self.infcx
.const_eval_resolve(
obligation.param_env,
unevaluated,
Some(obligation.cause.span),
)
.map(|val| ty::Const::from_value(self.tcx(), val, c.ty()))
match self.infcx.try_const_eval_resolve(
obligation.param_env,
unevaluated,
c.ty(),
Some(obligation.cause.span),
) {
Ok(val) => Ok(val),
Err(e) => Err(e),
}
} else {
Ok(c)
}
@ -2576,7 +2578,11 @@ impl<'o, 'tcx> TraitObligationStackList<'o, 'tcx> {
}
fn depth(&self) -> usize {
if let Some(head) = self.head { head.depth } else { 0 }
if let Some(head) = self.head {
head.depth
} else {
0
}
}
}