]> git.lizzy.rs Git - rust.git/commitdiff
Cleanup
authorJack Huey <jack.huey@umassmed.edu>
Mon, 4 Jan 2021 06:58:33 +0000 (01:58 -0500)
committerJack Huey <jack.huey@umassmed.edu>
Sat, 16 Jan 2021 23:40:47 +0000 (18:40 -0500)
compiler/rustc_infer/src/traits/util.rs
compiler/rustc_middle/src/ty/codec.rs
compiler/rustc_middle/src/ty/context.rs
compiler/rustc_middle/src/ty/flags.rs
compiler/rustc_middle/src/ty/mod.rs
compiler/rustc_middle/src/ty/print/pretty.rs
compiler/rustc_middle/src/ty/structural_impls.rs
compiler/rustc_trait_selection/src/traits/fulfill.rs
compiler/rustc_traits/src/implied_outlives_bounds.rs
compiler/rustc_typeck/src/outlives/mod.rs
src/tools/clippy/clippy_lints/src/needless_pass_by_value.rs

index 113e2220d4d1f91689bc148ad9cd70dd691aeaa4..2b6b0759981baf5a254763bf282b90bea95b88c0 100644 (file)
@@ -9,7 +9,7 @@ pub fn anonymize_predicate<'tcx>(
     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)
 }
 
index 987cb32d914df21fbfb374340ea07c16791b495d..4d11804e2b4b2abf244556c0681620752ab76104 100644 (file)
@@ -46,7 +46,7 @@ fn variant(&self) -> &Self::Variant {
 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()
     }
 }
 
index 78ff8671d13af458cbce16c938ce1f02a6513d27..e9b5b71f9c3bd24d7d61716e0050f91156990ada 100644 (file)
@@ -133,13 +133,13 @@ fn intern_ty(&self, kind: TyKind<'tcx>) -> Ty<'tcx> {
     }
 
     #[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,
                 };
@@ -1936,7 +1936,7 @@ fn borrow<'a>(&'a self) -> &'a TyKind<'tcx> {
 // 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
     }
 }
 
@@ -1944,13 +1944,13 @@ impl<'tcx> Eq for Interned<'tcx, PredicateInner<'tcx>> {}
 
 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
     }
 }
 
@@ -2085,8 +2085,8 @@ pub fn mk_ty(self, st: TyKind<'tcx>) -> Ty<'tcx> {
     }
 
     #[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 }
     }
 
@@ -2094,9 +2094,9 @@ pub fn mk_predicate(self, kind: Binder<PredicateAtom<'tcx>>) -> Predicate<'tcx>
     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> {
index b99587fe73499a35da9bf9e5762e9d5e3328c605..e25320634d0adfa506cb30a801f7b5c687417eeb 100644 (file)
@@ -22,9 +22,9 @@ pub fn for_kind(kind: &ty::TyKind<'_>) -> FlagComputation {
         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
     }
 
@@ -204,7 +204,7 @@ fn add_kind(&mut self, kind: &ty::TyKind<'_>) {
         }
     }
 
-    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));
     }
 
index e023195605bbc968112b1a4c2b48608811523704..fc5a7b618bd125c688d4fdc46da7d2d9c50b4bd6 100644 (file)
@@ -1030,7 +1030,7 @@ fn instantiate_identity_into(
 
 #[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,
@@ -1060,16 +1060,6 @@ fn hash<H: Hasher>(&self, s: &mut H) {
 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.
@@ -1077,8 +1067,7 @@ pub fn kind_ref(&self) -> &Binder<PredicateAtom<'tcx>> {
     ///
     /// 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`.
@@ -1088,29 +1077,30 @@ pub fn skip_binders(self) -> PredicateAtom<'tcx> {
     /// 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.
@@ -1118,7 +1108,7 @@ fn hash_stable(&self, hcx: &mut StableHashingContext<'a>, hasher: &mut StableHas
             outer_exclusive_binder: _,
         } = self.inner;
 
-        kind.hash_stable(hcx, hasher);
+        binder.hash_stable(hcx, hasher);
     }
 }
 
index 04bea024bd38ea71c16e889e892b2bf7dc5be509..fbfc8a40faf0284f9d50745480bdbd0b4d40948f 100644 (file)
@@ -2068,7 +2068,7 @@ pub fn print_only_trait_path(self) -> ty::Binder<TraitRefPrintOnlyTraitPath<'tcx
     }
 
     ty::Predicate<'tcx> {
-        let binder = self.kind();
+        let binder = self.bound_atom();
         p!(print(binder))
     }
 
index 4c2c6d01a5f5f4f7b469f1709f7de1dd42f5c4a0..1abb4fd32bf5114b643545ec7ce02c562c489f26 100644 (file)
@@ -224,7 +224,7 @@ fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
 
 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())
     }
 }
 
@@ -1017,12 +1017,12 @@ fn visit_with<V: TypeVisitor<'tcx>>(&self, visitor: &mut V) -> ControlFlow<V::Br
 
 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> {
index aa7f746e52fe3b04923d72f3987bb5f8c9c005cc..86c5209354c8577e1a3c6bed0dca0e7d2a1d82de 100644 (file)
@@ -345,7 +345,7 @@ fn progress_changed_obligations(
 
         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.
index 0e8e15cb221cd2252eb5267b42b16f4e7bee6e5b..dc2eaf82d092c51566e4d69e6320224c1e461190 100644 (file)
@@ -94,7 +94,7 @@ fn compute_implied_outlives_bounds<'tcx>(
         // 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 {
index c0920895b66d617f06050b6e057c71db7f02c4d4..437d19e35f5e94a1c88056c71d6f90ff29fde3e5 100644 (file)
@@ -31,7 +31,7 @@ fn inferred_outlives_of(tcx: TyCtxt<'_>, item_def_id: DefId) -> &[(ty::Predicate
                     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(),
index d2a3bd3921d277203f4695cc781544a259210951..9306b198051c260d72134d767942cfbd547a9a7c 100644 (file)
@@ -115,7 +115,7 @@ fn check_fn(
             .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 {