1
Fork 0

introduce mir::Unevaluated

This commit is contained in:
b-naber 2022-09-19 19:46:53 +02:00
parent 3e50038a2d
commit 9f3784df89
32 changed files with 166 additions and 132 deletions

View file

@ -834,7 +834,7 @@ impl<'tcx> AutoTraitFinder<'tcx> {
let reported =
tcx.sess.emit_err(UnableToConstructConstantValue {
span: tcx.def_span(def_id),
unevaluated: unevaluated.expand(),
unevaluated: unevaluated,
});
Err(ErrorHandled::Reported(reported))
}

View file

@ -138,7 +138,7 @@ impl<'tcx> ConstUnifyCtxt<'tcx> {
#[instrument(skip(tcx), level = "debug")]
pub fn try_unify_abstract_consts<'tcx>(
tcx: TyCtxt<'tcx>,
(a, b): (ty::Unevaluated<'tcx, ()>, ty::Unevaluated<'tcx, ()>),
(a, b): (ty::Unevaluated<'tcx>, ty::Unevaluated<'tcx>),
param_env: ty::ParamEnv<'tcx>,
) -> bool {
(|| {
@ -161,7 +161,7 @@ pub fn try_unify_abstract_consts<'tcx>(
#[instrument(skip(infcx), level = "debug")]
pub fn is_const_evaluatable<'cx, 'tcx>(
infcx: &InferCtxt<'cx, 'tcx>,
uv: ty::Unevaluated<'tcx, ()>,
uv: ty::Unevaluated<'tcx>,
param_env: ty::ParamEnv<'tcx>,
span: Span,
) -> Result<(), NotConstEvaluatable> {

View file

@ -838,7 +838,10 @@ fn contains_illegal_self_type_reference<'tcx, T: TypeVisitable<'tcx>>(
}
}
fn visit_unevaluated(&mut self, uv: ty::Unevaluated<'tcx>) -> ControlFlow<Self::BreakTy> {
fn visit_ty_unevaluated(
&mut self,
uv: ty::Unevaluated<'tcx>,
) -> ControlFlow<Self::BreakTy> {
// Constants can only influence object safety if they reference `Self`.
// This is only possible for unevaluated constants, so we walk these here.
//
@ -852,7 +855,7 @@ fn contains_illegal_self_type_reference<'tcx, T: TypeVisitable<'tcx>>(
// This shouldn't really matter though as we can't really use any
// constants which are not considered const evaluatable.
use rustc_middle::ty::abstract_const::Node;
if let Ok(Some(ct)) = AbstractConst::new(self.tcx, uv.shrink()) {
if let Ok(Some(ct)) = AbstractConst::new(self.tcx, uv) {
walk_abstract_const(self.tcx, ct, |node| match node.root(self.tcx) {
Node::Leaf(leaf) => self.visit_const(leaf),
Node::Cast(_, _, ty) => self.visit_ty(ty),