Skip to content

Commit 408a086

Browse files
committed
unrevert # 88557
1 parent dec8ed4 commit 408a086

File tree

1 file changed

+5
-28
lines changed

1 file changed

+5
-28
lines changed

compiler/rustc_trait_selection/src/traits/object_safety.rs

+5-28
Original file line numberDiff line numberDiff line change
@@ -813,9 +813,10 @@ fn contains_illegal_self_type_reference<'tcx, T: TypeFoldable<'tcx>>(
813813
}
814814
}
815815

816-
fn visit_const(&mut self, ct: &'tcx ty::Const<'tcx>) -> ControlFlow<Self::BreakTy> {
817-
self.visit_ty(ct.ty)?;
818-
816+
fn visit_unevaluated_const(
817+
&mut self,
818+
uv: ty::Unevaluated<'tcx>,
819+
) -> ControlFlow<Self::BreakTy> {
819820
// Constants can only influence object safety if they reference `Self`.
820821
// This is only possible for unevaluated constants, so we walk these here.
821822
//
@@ -829,7 +830,7 @@ fn contains_illegal_self_type_reference<'tcx, T: TypeFoldable<'tcx>>(
829830
// This shouldn't really matter though as we can't really use any
830831
// constants which are not considered const evaluatable.
831832
use rustc_middle::thir::abstract_const::Node;
832-
if let Ok(Some(ct)) = AbstractConst::from_const(self.tcx, ct) {
833+
if let Ok(Some(ct)) = AbstractConst::new(self.tcx, uv.shrink()) {
833834
const_evaluatable::walk_abstract_const(self.tcx, ct, |node| {
834835
match node.root(self.tcx) {
835836
Node::Leaf(leaf) => self.visit_const(leaf),
@@ -843,30 +844,6 @@ fn contains_illegal_self_type_reference<'tcx, T: TypeFoldable<'tcx>>(
843844
ControlFlow::CONTINUE
844845
}
845846
}
846-
847-
fn visit_predicate(&mut self, pred: ty::Predicate<'tcx>) -> ControlFlow<Self::BreakTy> {
848-
if let ty::PredicateKind::ConstEvaluatable(uv) = pred.kind().skip_binder() {
849-
// FIXME(generic_const_exprs): We should probably deduplicate the logic for
850-
// `AbstractConst`s here, it might make sense to change `ConstEvaluatable` to
851-
// take a `ty::Const` instead.
852-
use rustc_middle::thir::abstract_const::Node;
853-
if let Ok(Some(ct)) = AbstractConst::new(self.tcx, uv) {
854-
const_evaluatable::walk_abstract_const(self.tcx, ct, |node| {
855-
match node.root(self.tcx) {
856-
Node::Leaf(leaf) => self.visit_const(leaf),
857-
Node::Cast(_, _, ty) => self.visit_ty(ty),
858-
Node::Binop(..) | Node::UnaryOp(..) | Node::FunctionCall(_, _) => {
859-
ControlFlow::CONTINUE
860-
}
861-
}
862-
})
863-
} else {
864-
ControlFlow::CONTINUE
865-
}
866-
} else {
867-
pred.super_visit_with(self)
868-
}
869-
}
870847
}
871848

872849
value

0 commit comments

Comments
 (0)