Skip to content

Commit e76476a

Browse files
committed
Cleanup
1 parent 876192e commit e76476a

File tree

11 files changed

+35
-45
lines changed

11 files changed

+35
-45
lines changed

compiler/rustc_infer/src/traits/util.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ pub fn anonymize_predicate<'tcx>(
99
tcx: TyCtxt<'tcx>,
1010
pred: ty::Predicate<'tcx>,
1111
) -> ty::Predicate<'tcx> {
12-
let new = tcx.anonymize_late_bound_regions(pred.kind());
12+
let new = tcx.anonymize_late_bound_regions(pred.bound_atom());
1313
tcx.reuse_or_mk_predicate(pred, new)
1414
}
1515

compiler/rustc_middle/src/ty/codec.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ impl<'tcx, E: TyEncoder<'tcx>> EncodableWithShorthand<'tcx, E> for Ty<'tcx> {
4646
impl<'tcx, E: TyEncoder<'tcx>> EncodableWithShorthand<'tcx, E> for ty::Predicate<'tcx> {
4747
type Variant = ty::Binder<ty::PredicateAtom<'tcx>>;
4848
fn variant(&self) -> &Self::Variant {
49-
self.kind_ref()
49+
self.bound_atom_ref()
5050
}
5151
}
5252

compiler/rustc_middle/src/ty/context.rs

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -133,13 +133,13 @@ impl<'tcx> CtxtInterners<'tcx> {
133133
}
134134

135135
#[inline(never)]
136-
fn intern_predicate(&self, kind: Binder<PredicateAtom<'tcx>>) -> &'tcx PredicateInner<'tcx> {
136+
fn intern_predicate(&self, binder: Binder<PredicateAtom<'tcx>>) -> &'tcx PredicateInner<'tcx> {
137137
self.predicate
138-
.intern(kind, |kind| {
139-
let flags = super::flags::FlagComputation::for_predicate(kind);
138+
.intern(binder, |binder| {
139+
let flags = super::flags::FlagComputation::for_predicate(binder);
140140

141141
let predicate_struct = PredicateInner {
142-
kind,
142+
binder,
143143
flags: flags.flags,
144144
outer_exclusive_binder: flags.outer_exclusive_binder,
145145
};
@@ -1936,21 +1936,21 @@ impl<'tcx> Borrow<TyKind<'tcx>> for Interned<'tcx, TyS<'tcx>> {
19361936
// N.B., an `Interned<PredicateInner>` compares and hashes as a `PredicateKind`.
19371937
impl<'tcx> PartialEq for Interned<'tcx, PredicateInner<'tcx>> {
19381938
fn eq(&self, other: &Interned<'tcx, PredicateInner<'tcx>>) -> bool {
1939-
self.0.kind == other.0.kind
1939+
self.0.binder == other.0.binder
19401940
}
19411941
}
19421942

19431943
impl<'tcx> Eq for Interned<'tcx, PredicateInner<'tcx>> {}
19441944

19451945
impl<'tcx> Hash for Interned<'tcx, PredicateInner<'tcx>> {
19461946
fn hash<H: Hasher>(&self, s: &mut H) {
1947-
self.0.kind.hash(s)
1947+
self.0.binder.hash(s)
19481948
}
19491949
}
19501950

19511951
impl<'tcx> Borrow<Binder<PredicateAtom<'tcx>>> for Interned<'tcx, PredicateInner<'tcx>> {
19521952
fn borrow<'a>(&'a self) -> &'a Binder<PredicateAtom<'tcx>> {
1953-
&self.0.kind
1953+
&self.0.binder
19541954
}
19551955
}
19561956

@@ -2085,18 +2085,18 @@ impl<'tcx> TyCtxt<'tcx> {
20852085
}
20862086

20872087
#[inline]
2088-
pub fn mk_predicate(self, kind: Binder<PredicateAtom<'tcx>>) -> Predicate<'tcx> {
2089-
let inner = self.interners.intern_predicate(kind);
2088+
pub fn mk_predicate(self, binder: Binder<PredicateAtom<'tcx>>) -> Predicate<'tcx> {
2089+
let inner = self.interners.intern_predicate(binder);
20902090
Predicate { inner }
20912091
}
20922092

20932093
#[inline]
20942094
pub fn reuse_or_mk_predicate(
20952095
self,
20962096
pred: Predicate<'tcx>,
2097-
kind: Binder<PredicateAtom<'tcx>>,
2097+
binder: Binder<PredicateAtom<'tcx>>,
20982098
) -> Predicate<'tcx> {
2099-
if pred.kind() != kind { self.mk_predicate(kind) } else { pred }
2099+
if pred.bound_atom() != binder { self.mk_predicate(binder) } else { pred }
21002100
}
21012101

21022102
pub fn mk_mach_int(self, tm: ast::IntTy) -> Ty<'tcx> {

compiler/rustc_middle/src/ty/flags.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,9 +22,9 @@ impl FlagComputation {
2222
result
2323
}
2424

25-
pub fn for_predicate(kind: ty::Binder<ty::PredicateAtom<'_>>) -> FlagComputation {
25+
pub fn for_predicate(binder: ty::Binder<ty::PredicateAtom<'_>>) -> FlagComputation {
2626
let mut result = FlagComputation::new();
27-
result.add_predicate_kind(kind);
27+
result.add_predicate(binder);
2828
result
2929
}
3030

@@ -204,7 +204,7 @@ impl FlagComputation {
204204
}
205205
}
206206

207-
fn add_predicate_kind(&mut self, binder: ty::Binder<ty::PredicateAtom<'_>>) {
207+
fn add_predicate(&mut self, binder: ty::Binder<ty::PredicateAtom<'_>>) {
208208
self.bound_computation(binder, |computation, atom| computation.add_predicate_atom(atom));
209209
}
210210

compiler/rustc_middle/src/ty/mod.rs

Lines changed: 11 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1030,7 +1030,7 @@ impl<'tcx> GenericPredicates<'tcx> {
10301030

10311031
#[derive(Debug)]
10321032
crate struct PredicateInner<'tcx> {
1033-
kind: Binder<PredicateAtom<'tcx>>,
1033+
binder: Binder<PredicateAtom<'tcx>>,
10341034
flags: TypeFlags,
10351035
/// See the comment for the corresponding field of [TyS].
10361036
outer_exclusive_binder: ty::DebruijnIndex,
@@ -1060,25 +1060,14 @@ impl Hash for Predicate<'_> {
10601060
impl<'tcx> Eq for Predicate<'tcx> {}
10611061

10621062
impl<'tcx> Predicate<'tcx> {
1063-
#[inline(always)]
1064-
pub fn kind(self) -> Binder<PredicateAtom<'tcx>> {
1065-
self.inner.kind
1066-
}
1067-
1068-
#[inline(always)]
1069-
pub fn kind_ref(&self) -> &Binder<PredicateAtom<'tcx>> {
1070-
&self.inner.kind
1071-
}
1072-
10731063
/// Returns the inner `PredicateAtom`.
10741064
///
10751065
/// The returned atom may contain unbound variables bound to binders skipped in this method.
10761066
/// It is safe to reapply binders to the given atom.
10771067
///
10781068
/// Note that this method panics in case this predicate has unbound variables.
10791069
pub fn skip_binders(self) -> PredicateAtom<'tcx> {
1080-
let binder = self.kind();
1081-
binder.skip_binder()
1070+
self.inner.binder.skip_binder()
10821071
}
10831072

10841073
/// Returns the inner `PredicateAtom`.
@@ -1088,37 +1077,38 @@ impl<'tcx> Predicate<'tcx> {
10881077
/// Rebinding the returned atom can causes the previously bound variables
10891078
/// to end up at the wrong binding level.
10901079
pub fn skip_binders_unchecked(self) -> PredicateAtom<'tcx> {
1091-
let binder = self.kind();
1092-
binder.skip_binder()
1080+
self.inner.binder.skip_binder()
10931081
}
10941082

10951083
/// Converts this to a `Binder<PredicateAtom<'tcx>>`. If the value was an
10961084
/// `Atom`, then it is not allowed to contain escaping bound vars.
10971085
pub fn bound_atom(self) -> Binder<PredicateAtom<'tcx>> {
1098-
let binder = self.kind();
1099-
binder
1086+
self.inner.binder
1087+
}
1088+
1089+
pub fn bound_atom_ref(self) -> &'tcx Binder<PredicateAtom<'tcx>> {
1090+
&self.inner.binder
11001091
}
11011092

11021093
/// Allows using a `Binder<PredicateAtom<'tcx>>` even if the given predicate previously
11031094
/// contained unbound variables by shifting these variables outwards.
11041095
pub fn bound_atom_with_opt_escaping(self, _tcx: TyCtxt<'tcx>) -> Binder<PredicateAtom<'tcx>> {
1105-
let binder = self.kind();
1106-
binder
1096+
self.inner.binder
11071097
}
11081098
}
11091099

11101100
impl<'a, 'tcx> HashStable<StableHashingContext<'a>> for Predicate<'tcx> {
11111101
fn hash_stable(&self, hcx: &mut StableHashingContext<'a>, hasher: &mut StableHasher) {
11121102
let PredicateInner {
1113-
ref kind,
1103+
ref binder,
11141104

11151105
// The other fields just provide fast access to information that is
11161106
// also contained in `kind`, so no need to hash them.
11171107
flags: _,
11181108
outer_exclusive_binder: _,
11191109
} = self.inner;
11201110

1121-
kind.hash_stable(hcx, hasher);
1111+
binder.hash_stable(hcx, hasher);
11221112
}
11231113
}
11241114

compiler/rustc_middle/src/ty/print/pretty.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2068,7 +2068,7 @@ define_print_and_forward_display! {
20682068
}
20692069

20702070
ty::Predicate<'tcx> {
2071-
let binder = self.kind();
2071+
let binder = self.bound_atom();
20722072
p!(print(binder))
20732073
}
20742074

compiler/rustc_middle/src/ty/structural_impls.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -224,7 +224,7 @@ impl fmt::Debug for ty::ProjectionPredicate<'tcx> {
224224

225225
impl fmt::Debug for ty::Predicate<'tcx> {
226226
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
227-
write!(f, "{:?}", self.kind())
227+
write!(f, "{:?}", self.bound_atom())
228228
}
229229
}
230230

@@ -1017,12 +1017,12 @@ impl<'tcx> TypeFoldable<'tcx> for ty::Region<'tcx> {
10171017

10181018
impl<'tcx> TypeFoldable<'tcx> for ty::Predicate<'tcx> {
10191019
fn super_fold_with<F: TypeFolder<'tcx>>(self, folder: &mut F) -> Self {
1020-
let new = self.inner.kind.fold_with(folder);
1020+
let new = self.inner.binder.fold_with(folder);
10211021
folder.tcx().reuse_or_mk_predicate(self, new)
10221022
}
10231023

10241024
fn super_visit_with<V: TypeVisitor<'tcx>>(&self, visitor: &mut V) -> ControlFlow<V::BreakTy> {
1025-
self.inner.kind.super_visit_with(visitor)
1025+
self.inner.binder.visit_with(visitor)
10261026
}
10271027

10281028
fn visit_with<V: TypeVisitor<'tcx>>(&self, visitor: &mut V) -> ControlFlow<V::BreakTy> {

compiler/rustc_trait_selection/src/traits/fulfill.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -345,7 +345,7 @@ impl<'a, 'b, 'tcx> FulfillProcessor<'a, 'b, 'tcx> {
345345

346346
let infcx = self.selcx.infcx();
347347

348-
let binder = obligation.predicate.kind();
348+
let binder = obligation.predicate.bound_atom();
349349
if binder.skip_binder().has_escaping_bound_vars() {
350350
match binder.skip_binder() {
351351
// Evaluation will discard candidates using the leak check.

compiler/rustc_traits/src/implied_outlives_bounds.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,7 @@ fn compute_implied_outlives_bounds<'tcx>(
9494
// region relationships.
9595
implied_bounds.extend(obligations.into_iter().flat_map(|obligation| {
9696
assert!(!obligation.has_escaping_bound_vars());
97-
let binder = obligation.predicate.kind();
97+
let binder = obligation.predicate.bound_atom();
9898
if binder.skip_binder().has_escaping_bound_vars() {
9999
vec![]
100100
} else {

compiler/rustc_typeck/src/outlives/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ fn inferred_outlives_of(tcx: TyCtxt<'_>, item_def_id: DefId) -> &[(ty::Predicate
3131
let mut pred: Vec<String> = predicates
3232
.iter()
3333
.map(|(out_pred, _)| {
34-
let binder = out_pred.kind();
34+
let binder = out_pred.bound_atom();
3535
match binder.skip_binder() {
3636
ty::PredicateAtom::RegionOutlives(p) => p.to_string(),
3737
ty::PredicateAtom::TypeOutlives(p) => p.to_string(),

src/tools/clippy/clippy_lints/src/needless_pass_by_value.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -115,7 +115,7 @@ impl<'tcx> LateLintPass<'tcx> for NeedlessPassByValue {
115115
.filter(|p| !p.is_global())
116116
.filter_map(|obligation| {
117117
// Note that we do not want to deal with qualified predicates here.
118-
let binder = obligation.predicate.kind();
118+
let binder = obligation.predicate.bound_atom();
119119
match binder.skip_binder() {
120120
ty::PredicateAtom::Trait(pred, _) if !binder.has_escaping_bound_vars() => {
121121
if pred.def_id() == sized_trait {

0 commit comments

Comments
 (0)