tcx: TyCtxt<'tcx>,
pred: ty::Predicate<'tcx>,
) -> ty::Predicate<'tcx> {
- let new = tcx.anonymize_late_bound_regions(pred.kind());
+ let new = tcx.anonymize_late_bound_regions(pred.bound_atom());
tcx.reuse_or_mk_predicate(pred, new)
}
impl<'tcx, E: TyEncoder<'tcx>> EncodableWithShorthand<'tcx, E> for ty::Predicate<'tcx> {
type Variant = ty::Binder<ty::PredicateAtom<'tcx>>;
fn variant(&self) -> &Self::Variant {
- self.kind_ref()
+ self.bound_atom_ref()
}
}
}
#[inline(never)]
- fn intern_predicate(&self, kind: Binder<PredicateAtom<'tcx>>) -> &'tcx PredicateInner<'tcx> {
+ fn intern_predicate(&self, binder: Binder<PredicateAtom<'tcx>>) -> &'tcx PredicateInner<'tcx> {
self.predicate
- .intern(kind, |kind| {
- let flags = super::flags::FlagComputation::for_predicate(kind);
+ .intern(binder, |binder| {
+ let flags = super::flags::FlagComputation::for_predicate(binder);
let predicate_struct = PredicateInner {
- kind,
+ binder,
flags: flags.flags,
outer_exclusive_binder: flags.outer_exclusive_binder,
};
// N.B., an `Interned<PredicateInner>` compares and hashes as a `PredicateKind`.
impl<'tcx> PartialEq for Interned<'tcx, PredicateInner<'tcx>> {
fn eq(&self, other: &Interned<'tcx, PredicateInner<'tcx>>) -> bool {
- self.0.kind == other.0.kind
+ self.0.binder == other.0.binder
}
}
impl<'tcx> Hash for Interned<'tcx, PredicateInner<'tcx>> {
fn hash<H: Hasher>(&self, s: &mut H) {
- self.0.kind.hash(s)
+ self.0.binder.hash(s)
}
}
impl<'tcx> Borrow<Binder<PredicateAtom<'tcx>>> for Interned<'tcx, PredicateInner<'tcx>> {
fn borrow<'a>(&'a self) -> &'a Binder<PredicateAtom<'tcx>> {
- &self.0.kind
+ &self.0.binder
}
}
}
#[inline]
- pub fn mk_predicate(self, kind: Binder<PredicateAtom<'tcx>>) -> Predicate<'tcx> {
- let inner = self.interners.intern_predicate(kind);
+ pub fn mk_predicate(self, binder: Binder<PredicateAtom<'tcx>>) -> Predicate<'tcx> {
+ let inner = self.interners.intern_predicate(binder);
Predicate { inner }
}
pub fn reuse_or_mk_predicate(
self,
pred: Predicate<'tcx>,
- kind: Binder<PredicateAtom<'tcx>>,
+ binder: Binder<PredicateAtom<'tcx>>,
) -> Predicate<'tcx> {
- if pred.kind() != kind { self.mk_predicate(kind) } else { pred }
+ if pred.bound_atom() != binder { self.mk_predicate(binder) } else { pred }
}
pub fn mk_mach_int(self, tm: ast::IntTy) -> Ty<'tcx> {
result
}
- pub fn for_predicate(kind: ty::Binder<ty::PredicateAtom<'_>>) -> FlagComputation {
+ pub fn for_predicate(binder: ty::Binder<ty::PredicateAtom<'_>>) -> FlagComputation {
let mut result = FlagComputation::new();
- result.add_predicate_kind(kind);
+ result.add_predicate(binder);
result
}
}
}
- fn add_predicate_kind(&mut self, binder: ty::Binder<ty::PredicateAtom<'_>>) {
+ fn add_predicate(&mut self, binder: ty::Binder<ty::PredicateAtom<'_>>) {
self.bound_computation(binder, |computation, atom| computation.add_predicate_atom(atom));
}
#[derive(Debug)]
crate struct PredicateInner<'tcx> {
- kind: Binder<PredicateAtom<'tcx>>,
+ binder: Binder<PredicateAtom<'tcx>>,
flags: TypeFlags,
/// See the comment for the corresponding field of [TyS].
outer_exclusive_binder: ty::DebruijnIndex,
impl<'tcx> Eq for Predicate<'tcx> {}
impl<'tcx> Predicate<'tcx> {
- #[inline(always)]
- pub fn kind(self) -> Binder<PredicateAtom<'tcx>> {
- self.inner.kind
- }
-
- #[inline(always)]
- pub fn kind_ref(&self) -> &Binder<PredicateAtom<'tcx>> {
- &self.inner.kind
- }
-
/// Returns the inner `PredicateAtom`.
///
/// The returned atom may contain unbound variables bound to binders skipped in this method.
///
/// Note that this method panics in case this predicate has unbound variables.
pub fn skip_binders(self) -> PredicateAtom<'tcx> {
- let binder = self.kind();
- binder.skip_binder()
+ self.inner.binder.skip_binder()
}
/// Returns the inner `PredicateAtom`.
/// Rebinding the returned atom can causes the previously bound variables
/// to end up at the wrong binding level.
pub fn skip_binders_unchecked(self) -> PredicateAtom<'tcx> {
- let binder = self.kind();
- binder.skip_binder()
+ self.inner.binder.skip_binder()
}
/// Converts this to a `Binder<PredicateAtom<'tcx>>`. If the value was an
/// `Atom`, then it is not allowed to contain escaping bound vars.
pub fn bound_atom(self) -> Binder<PredicateAtom<'tcx>> {
- let binder = self.kind();
- binder
+ self.inner.binder
+ }
+
+ pub fn bound_atom_ref(self) -> &'tcx Binder<PredicateAtom<'tcx>> {
+ &self.inner.binder
}
/// Allows using a `Binder<PredicateAtom<'tcx>>` even if the given predicate previously
/// contained unbound variables by shifting these variables outwards.
pub fn bound_atom_with_opt_escaping(self, _tcx: TyCtxt<'tcx>) -> Binder<PredicateAtom<'tcx>> {
- let binder = self.kind();
- binder
+ self.inner.binder
}
}
impl<'a, 'tcx> HashStable<StableHashingContext<'a>> for Predicate<'tcx> {
fn hash_stable(&self, hcx: &mut StableHashingContext<'a>, hasher: &mut StableHasher) {
let PredicateInner {
- ref kind,
+ ref binder,
// The other fields just provide fast access to information that is
// also contained in `kind`, so no need to hash them.
outer_exclusive_binder: _,
} = self.inner;
- kind.hash_stable(hcx, hasher);
+ binder.hash_stable(hcx, hasher);
}
}
}
ty::Predicate<'tcx> {
- let binder = self.kind();
+ let binder = self.bound_atom();
p!(print(binder))
}
impl fmt::Debug for ty::Predicate<'tcx> {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
- write!(f, "{:?}", self.kind())
+ write!(f, "{:?}", self.bound_atom())
}
}
impl<'tcx> TypeFoldable<'tcx> for ty::Predicate<'tcx> {
fn super_fold_with<F: TypeFolder<'tcx>>(self, folder: &mut F) -> Self {
- let new = self.inner.kind.fold_with(folder);
+ let new = self.inner.binder.fold_with(folder);
folder.tcx().reuse_or_mk_predicate(self, new)
}
fn super_visit_with<V: TypeVisitor<'tcx>>(&self, visitor: &mut V) -> ControlFlow<V::BreakTy> {
- self.inner.kind.super_visit_with(visitor)
+ self.inner.binder.visit_with(visitor)
}
fn visit_with<V: TypeVisitor<'tcx>>(&self, visitor: &mut V) -> ControlFlow<V::BreakTy> {
let infcx = self.selcx.infcx();
- let binder = obligation.predicate.kind();
+ let binder = obligation.predicate.bound_atom();
if binder.skip_binder().has_escaping_bound_vars() {
match binder.skip_binder() {
// Evaluation will discard candidates using the leak check.
// region relationships.
implied_bounds.extend(obligations.into_iter().flat_map(|obligation| {
assert!(!obligation.has_escaping_bound_vars());
- let binder = obligation.predicate.kind();
+ let binder = obligation.predicate.bound_atom();
if binder.skip_binder().has_escaping_bound_vars() {
vec![]
} else {
let mut pred: Vec<String> = predicates
.iter()
.map(|(out_pred, _)| {
- let binder = out_pred.kind();
+ let binder = out_pred.bound_atom();
match binder.skip_binder() {
ty::PredicateAtom::RegionOutlives(p) => p.to_string(),
ty::PredicateAtom::TypeOutlives(p) => p.to_string(),
.filter(|p| !p.is_global())
.filter_map(|obligation| {
// Note that we do not want to deal with qualified predicates here.
- let binder = obligation.predicate.kind();
+ let binder = obligation.predicate.bound_atom();
match binder.skip_binder() {
ty::PredicateAtom::Trait(pred, _) if !binder.has_escaping_bound_vars() => {
if pred.def_id() == sized_trait {