1
Fork 0

Add more tests + visit_ty in some places

This commit is contained in:
Ellen 2021-06-09 19:28:41 +01:00
parent 8e7299dfcd
commit c318364d48
6 changed files with 62 additions and 21 deletions

View file

@ -97,10 +97,19 @@ pub fn is_const_evaluatable<'cx, 'tcx>(
ControlFlow::CONTINUE
}
Node::Binop(_, _, _)
| Node::UnaryOp(_, _)
| Node::FunctionCall(_, _)
| Node::Cast(_, _, _) => ControlFlow::CONTINUE,
Node::Cast(_, _, ty) => {
let ty = ty.subst(tcx, ct.substs);
if ty.has_infer_types_or_consts() {
failure_kind = FailureKind::MentionsInfer;
} else if ty.has_param_types_or_consts() {
failure_kind = cmp::min(failure_kind, FailureKind::MentionsParam);
}
ControlFlow::CONTINUE
}
Node::Binop(_, _, _) | Node::UnaryOp(_, _) | Node::FunctionCall(_, _) => {
ControlFlow::CONTINUE
}
});
match failure_kind {

View file

@ -838,10 +838,10 @@ fn contains_illegal_self_type_reference<'tcx, T: TypeFoldable<'tcx>>(
let leaf = leaf.subst(self.tcx, ct.substs);
self.visit_const(leaf)
}
Node::Binop(..)
| Node::UnaryOp(..)
| Node::FunctionCall(_, _)
| Node::Cast(_, _, _) => ControlFlow::CONTINUE,
Node::Cast(_, _, ty) => self.visit_ty(ty),
Node::Binop(..) | Node::UnaryOp(..) | Node::FunctionCall(_, _) => {
ControlFlow::CONTINUE
}
})
} else {
ControlFlow::CONTINUE
@ -860,10 +860,10 @@ fn contains_illegal_self_type_reference<'tcx, T: TypeFoldable<'tcx>>(
let leaf = leaf.subst(self.tcx, ct.substs);
self.visit_const(leaf)
}
Node::Binop(..)
| Node::UnaryOp(..)
| Node::FunctionCall(_, _)
| Node::Cast(_, _, _) => ControlFlow::CONTINUE,
Node::Cast(_, _, ty) => self.visit_ty(ty),
Node::Binop(..) | Node::UnaryOp(..) | Node::FunctionCall(_, _) => {
ControlFlow::CONTINUE
}
})
} else {
ControlFlow::CONTINUE