diff options
| author | Jack Huey <jack.huey@umassmed.edu> | 2020-06-01 19:23:23 -0400 |
|---|---|---|
| committer | Jack Huey <jack.huey@umassmed.edu> | 2021-03-31 10:05:32 -0400 |
| commit | 97a22a4f9cee6d48d0dad51e638c5f2306de084f (patch) | |
| tree | 0126583149030fc8a58964ae1eea975e63ebe847 | |
| parent | 4955d755d3ffdfecfd2c22139c65fe1a10d60939 (diff) | |
Add u32 for bound variables to Binder
| -rw-r--r-- | compiler/rustc_middle/src/traits/mod.rs | 2 | ||||
| -rw-r--r-- | compiler/rustc_middle/src/ty/mod.rs | 4 | ||||
| -rw-r--r-- | compiler/rustc_middle/src/ty/sty.rs | 21 |
3 files changed, 14 insertions, 13 deletions
diff --git a/compiler/rustc_middle/src/traits/mod.rs b/compiler/rustc_middle/src/traits/mod.rs index 90b82020551..922d14bc2f5 100644 --- a/compiler/rustc_middle/src/traits/mod.rs +++ b/compiler/rustc_middle/src/traits/mod.rs @@ -341,7 +341,7 @@ impl ObligationCauseCode<'_> { // `ObligationCauseCode` is used a lot. Make sure it doesn't unintentionally get bigger. #[cfg(all(target_arch = "x86_64", target_pointer_width = "64"))] -static_assert_size!(ObligationCauseCode<'_>, 32); +static_assert_size!(ObligationCauseCode<'_>, 40); #[derive(Copy, Clone, Debug, PartialEq, Eq, Hash)] pub enum StatementAsExpression { diff --git a/compiler/rustc_middle/src/ty/mod.rs b/compiler/rustc_middle/src/ty/mod.rs index c0025cf3fc8..8fc35193498 100644 --- a/compiler/rustc_middle/src/ty/mod.rs +++ b/compiler/rustc_middle/src/ty/mod.rs @@ -302,7 +302,7 @@ impl<'tcx> TyS<'tcx> { // `TyS` is used a lot. Make sure it doesn't unintentionally get bigger. #[cfg(all(target_arch = "x86_64", target_pointer_width = "64"))] -static_assert_size!(TyS<'_>, 32); +static_assert_size!(TyS<'_>, 40); impl<'tcx> Ord for TyS<'tcx> { fn cmp(&self, other: &TyS<'tcx>) -> Ordering { @@ -366,7 +366,7 @@ crate struct PredicateInner<'tcx> { } #[cfg(all(target_arch = "x86_64", target_pointer_width = "64"))] -static_assert_size!(PredicateInner<'_>, 40); +static_assert_size!(PredicateInner<'_>, 48); #[derive(Clone, Copy, Lift)] pub struct Predicate<'tcx> { diff --git a/compiler/rustc_middle/src/ty/sty.rs b/compiler/rustc_middle/src/ty/sty.rs index b8fe7aa7fd0..c7896d2b1e8 100644 --- a/compiler/rustc_middle/src/ty/sty.rs +++ b/compiler/rustc_middle/src/ty/sty.rs @@ -232,7 +232,7 @@ impl TyKind<'tcx> { // `TyKind` is used a lot. Make sure it doesn't unintentionally get bigger. #[cfg(all(target_arch = "x86_64", target_pointer_width = "64"))] -static_assert_size!(TyKind<'_>, 24); +static_assert_size!(TyKind<'_>, 32); /// A closure can be modeled as a struct that looks like: /// @@ -957,7 +957,7 @@ impl<'tcx> PolyExistentialTraitRef<'tcx> { /// /// `Decodable` and `Encodable` are implemented for `Binder<T>` using the `impl_binder_encode_decode!` macro. #[derive(Copy, Clone, PartialEq, Eq, PartialOrd, Ord, Hash, Debug)] -pub struct Binder<T>(T); +pub struct Binder<T>(T, u32); impl<T> Binder<T> { /// Wraps `value` in a binder, asserting that `value` does not @@ -969,12 +969,12 @@ impl<T> Binder<T> { T: TypeFoldable<'tcx>, { debug_assert!(!value.has_escaping_bound_vars()); - Binder(value) + Binder(value, 0) } /// Wraps `value` in a binder, binding higher-ranked vars (if any). pub fn bind(value: T) -> Binder<T> { - Binder(value) + Binder(value, 0) } /// Skips the binder and returns the "bound" value. This is a @@ -998,7 +998,7 @@ impl<T> Binder<T> { } pub fn as_ref(&self) -> Binder<&T> { - Binder(&self.0) + Binder(&self.0, self.1) } pub fn map_bound_ref<F, U>(&self, f: F) -> Binder<U> @@ -1012,7 +1012,7 @@ impl<T> Binder<T> { where F: FnOnce(T) -> U, { - Binder(f(self.0)) + Binder(f(self.0), self.1) } /// Wraps a `value` in a binder, using the same bound variables as the @@ -1025,7 +1025,7 @@ impl<T> Binder<T> { /// because bound vars aren't allowed to change here, whereas they are /// in `bind`. This may be (debug) asserted in the future. pub fn rebind<U>(&self, value: U) -> Binder<U> { - Binder(value) + Binder(value, self.1) } /// Unwraps and returns the value within, but only if it contains @@ -1056,7 +1056,7 @@ impl<T> Binder<T> { where F: FnOnce(T, U) -> R, { - Binder(f(self.0, u.0)) + Binder(f(self.0, u.0), self.1) } /// Splits the contents into two things that share the same binder @@ -1070,13 +1070,14 @@ impl<T> Binder<T> { F: FnOnce(T) -> (U, V), { let (u, v) = f(self.0); - (Binder(u), Binder(v)) + (Binder(u, self.1), Binder(v, self.1)) } } impl<T> Binder<Option<T>> { pub fn transpose(self) -> Option<Binder<T>> { - self.0.map(Binder) + let bound_vars = self.1; + self.0.map(|v| Binder(v, bound_vars)) } } |
