1
Fork 0

AbstractConst::root: Always run subst when Node is Leaf

This commit is contained in:
Ethan Brierley 2021-09-04 15:44:26 +01:00
parent 72a51c39c6
commit 85d6029c13
3 changed files with 25 additions and 27 deletions

View file

@ -838,14 +838,16 @@ fn contains_illegal_self_type_reference<'tcx, T: TypeFoldable<'tcx>>(
// constants which are not considered const evaluatable.
use rustc_middle::mir::abstract_const::Node;
if let Ok(Some(ct)) = AbstractConst::new(self.tcx, uv.shrink()) {
const_evaluatable::walk_abstract_const(self.tcx, ct, |node| match node.root() {
Node::Leaf(leaf) => {
let leaf = leaf.subst(self.tcx, ct.substs);
self.visit_const(leaf)
}
Node::Cast(_, _, ty) => self.visit_ty(ty),
Node::Binop(..) | Node::UnaryOp(..) | Node::FunctionCall(_, _) => {
ControlFlow::CONTINUE
const_evaluatable::walk_abstract_const(self.tcx, ct, |node| {
match node.root(self.tcx, ct.substs) {
Node::Leaf(leaf) => {
// let leaf = leaf.subst(self.tcx, ct.substs);
self.visit_const(leaf)
}
Node::Cast(_, _, ty) => self.visit_ty(ty),
Node::Binop(..) | Node::UnaryOp(..) | Node::FunctionCall(_, _) => {
ControlFlow::CONTINUE
}
}
})
} else {