diff options
| author | Ellen <supbscripter@gmail.com> | 2021-06-09 19:28:41 +0100 |
|---|---|---|
| committer | Ellen <supbscripter@gmail.com> | 2021-06-09 19:28:41 +0100 |
| commit | c318364d485a5673015678b3ad0037eff71d6a8e (patch) | |
| tree | fd4463fb04d435b9f73e082b60566769876ae5f2 /compiler | |
| parent | 8e7299dfcd4628965b58da10ec7393ab8f2c7e14 (diff) | |
| download | rust-c318364d485a5673015678b3ad0037eff71d6a8e.tar.gz rust-c318364d485a5673015678b3ad0037eff71d6a8e.zip | |
Add more tests + visit_ty in some places
Diffstat (limited to 'compiler')
| -rw-r--r-- | compiler/rustc_privacy/src/lib.rs | 8 | ||||
| -rw-r--r-- | compiler/rustc_trait_selection/src/traits/const_evaluatable.rs | 17 | ||||
| -rw-r--r-- | compiler/rustc_trait_selection/src/traits/object_safety.rs | 16 |
3 files changed, 25 insertions, 16 deletions
diff --git a/compiler/rustc_privacy/src/lib.rs b/compiler/rustc_privacy/src/lib.rs index 05139b9404f..5a79a9cc6ec 100644 --- a/compiler/rustc_privacy/src/lib.rs +++ b/compiler/rustc_privacy/src/lib.rs @@ -156,10 +156,10 @@ where let leaf = leaf.subst(tcx, ct.substs); self.visit_const(leaf) } - ACNode::Binop(..) - | ACNode::UnaryOp(..) - | ACNode::FunctionCall(_, _) - | ACNode::Cast(_, _, _) => ControlFlow::CONTINUE, + ACNode::Cast(_, _, ty) => self.visit_ty(ty), + ACNode::Binop(..) | ACNode::UnaryOp(..) | ACNode::FunctionCall(_, _) => { + ControlFlow::CONTINUE + } }) } diff --git a/compiler/rustc_trait_selection/src/traits/const_evaluatable.rs b/compiler/rustc_trait_selection/src/traits/const_evaluatable.rs index 8954918b43c..8094b01b380 100644 --- a/compiler/rustc_trait_selection/src/traits/const_evaluatable.rs +++ b/compiler/rustc_trait_selection/src/traits/const_evaluatable.rs @@ -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 { diff --git a/compiler/rustc_trait_selection/src/traits/object_safety.rs b/compiler/rustc_trait_selection/src/traits/object_safety.rs index ac63f2e25db..7ebef7f8883 100644 --- a/compiler/rustc_trait_selection/src/traits/object_safety.rs +++ b/compiler/rustc_trait_selection/src/traits/object_safety.rs @@ -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 |
