Skip to content

Commit fc5633f

Browse files
committed
Make fields on AbstractConst private
1 parent 6e40618 commit fc5633f

File tree

3 files changed

+13
-13
lines changed

3 files changed

+13
-13
lines changed

compiler/rustc_privacy/src/lib.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -153,7 +153,7 @@ where
153153
tcx: TyCtxt<'tcx>,
154154
ct: AbstractConst<'tcx>,
155155
) -> ControlFlow<V::BreakTy> {
156-
const_evaluatable::walk_abstract_const(tcx, ct, |node| match node.root(tcx, ct.substs) {
156+
const_evaluatable::walk_abstract_const(tcx, ct, |node| match node.root(tcx) {
157157
ACNode::Leaf(leaf) => self.visit_const(leaf),
158158
ACNode::Cast(_, _, ty) => self.visit_ty(ty),
159159
ACNode::Binop(..) | ACNode::UnaryOp(..) | ACNode::FunctionCall(_, _) => {

compiler/rustc_trait_selection/src/traits/const_evaluatable.rs

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ use rustc_infer::infer::InferCtxt;
1616
use rustc_middle::mir::abstract_const::{Node, NodeId, NotConstEvaluatable};
1717
use rustc_middle::mir::interpret::ErrorHandled;
1818
use rustc_middle::mir::{self, Rvalue, StatementKind, TerminatorKind};
19-
use rustc_middle::ty::subst::{GenericArg, Subst, SubstsRef};
19+
use rustc_middle::ty::subst::{Subst, SubstsRef};
2020
use rustc_middle::ty::{self, TyCtxt, TypeFoldable};
2121
use rustc_session::lint;
2222
use rustc_span::def_id::LocalDefId;
@@ -80,7 +80,7 @@ pub fn is_const_evaluatable<'cx, 'tcx>(
8080
Concrete,
8181
}
8282
let mut failure_kind = FailureKind::Concrete;
83-
walk_abstract_const::<!, _>(tcx, ct, |node| match node.root(tcx, ct.substs) {
83+
walk_abstract_const::<!, _>(tcx, ct, |node| match node.root(tcx) {
8484
Node::Leaf(leaf) => {
8585
if leaf.has_infer_types_or_consts() {
8686
failure_kind = FailureKind::MentionsInfer;
@@ -185,8 +185,8 @@ pub fn is_const_evaluatable<'cx, 'tcx>(
185185
pub struct AbstractConst<'tcx> {
186186
// FIXME: Consider adding something like `IndexSlice`
187187
// and use this here.
188-
pub inner: &'tcx [Node<'tcx>],
189-
pub substs: SubstsRef<'tcx>,
188+
inner: &'tcx [Node<'tcx>],
189+
substs: SubstsRef<'tcx>,
190190
}
191191

192192
impl<'tcx> AbstractConst<'tcx> {
@@ -216,10 +216,10 @@ impl<'tcx> AbstractConst<'tcx> {
216216
}
217217

218218
#[inline]
219-
pub fn root(self, tcx: TyCtxt<'tcx>, substs: &[GenericArg<'tcx>]) -> Node<'tcx> {
220-
let mut node = self.inner.last().copied().unwrap();
219+
pub fn root(self, tcx: TyCtxt<'tcx>) -> Node<'tcx> {
220+
let node = self.inner.last().copied().unwrap();
221221
if let Node::Leaf(leaf) = node {
222-
node = Node::Leaf(leaf.subst(tcx, substs));
222+
return Node::Leaf(leaf.subst(tcx, self.substs));
223223
}
224224
node
225225
}
@@ -589,7 +589,7 @@ where
589589
f: &mut dyn FnMut(AbstractConst<'tcx>) -> ControlFlow<R>,
590590
) -> ControlFlow<R> {
591591
f(ct)?;
592-
let root = ct.root(tcx, ct.substs);
592+
let root = ct.root(tcx);
593593
match root {
594594
Node::Leaf(_) => ControlFlow::CONTINUE,
595595
Node::Binop(_, l, r) => {
@@ -617,22 +617,22 @@ pub(super) fn try_unify<'tcx>(
617617
// We substitute generics repeatedly to allow AbstractConsts to unify where a
618618
// ConstKind::Unevalated could be turned into an AbstractConst that would unify e.g.
619619
// Param(N) should unify with Param(T), substs: [Unevaluated("T2", [Unevaluated("T3", [Param(N)])])]
620-
while let Node::Leaf(a_ct) = a.root(tcx, a.substs) {
620+
while let Node::Leaf(a_ct) = a.root(tcx) {
621621
match AbstractConst::from_const(tcx, a_ct) {
622622
Ok(Some(a_act)) => a = a_act,
623623
Ok(None) => break,
624624
Err(_) => return true,
625625
}
626626
}
627-
while let Node::Leaf(b_ct) = b.root(tcx, b.substs) {
627+
while let Node::Leaf(b_ct) = b.root(tcx) {
628628
match AbstractConst::from_const(tcx, b_ct) {
629629
Ok(Some(b_act)) => b = b_act,
630630
Ok(None) => break,
631631
Err(_) => return true,
632632
}
633633
}
634634

635-
match (a.root(tcx, a.substs), b.root(tcx, b.substs)) {
635+
match (a.root(tcx), b.root(tcx)) {
636636
(Node::Leaf(a_ct), Node::Leaf(b_ct)) => {
637637
if a_ct.ty != b_ct.ty {
638638
return false;

compiler/rustc_trait_selection/src/traits/object_safety.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -839,7 +839,7 @@ fn contains_illegal_self_type_reference<'tcx, T: TypeFoldable<'tcx>>(
839839
use rustc_middle::mir::abstract_const::Node;
840840
if let Ok(Some(ct)) = AbstractConst::new(self.tcx, uv.shrink()) {
841841
const_evaluatable::walk_abstract_const(self.tcx, ct, |node| {
842-
match node.root(self.tcx, ct.substs) {
842+
match node.root(self.tcx) {
843843
Node::Leaf(leaf) => self.visit_const(leaf),
844844
Node::Cast(_, _, ty) => self.visit_ty(ty),
845845
Node::Binop(..) | Node::UnaryOp(..) | Node::FunctionCall(_, _) => {

0 commit comments

Comments
 (0)