Skip to content
This repository was archived by the owner on May 28, 2025. It is now read-only.

Commit 97a22a4

Browse files
committed
Add u32 for bound variables to Binder
1 parent 4955d75 commit 97a22a4

File tree

3 files changed

+14
-13
lines changed

3 files changed

+14
-13
lines changed

compiler/rustc_middle/src/traits/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -341,7 +341,7 @@ impl ObligationCauseCode<'_> {
341341

342342
// `ObligationCauseCode` is used a lot. Make sure it doesn't unintentionally get bigger.
343343
#[cfg(all(target_arch = "x86_64", target_pointer_width = "64"))]
344-
static_assert_size!(ObligationCauseCode<'_>, 32);
344+
static_assert_size!(ObligationCauseCode<'_>, 40);
345345

346346
#[derive(Copy, Clone, Debug, PartialEq, Eq, Hash)]
347347
pub enum StatementAsExpression {

compiler/rustc_middle/src/ty/mod.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -302,7 +302,7 @@ impl<'tcx> TyS<'tcx> {
302302

303303
// `TyS` is used a lot. Make sure it doesn't unintentionally get bigger.
304304
#[cfg(all(target_arch = "x86_64", target_pointer_width = "64"))]
305-
static_assert_size!(TyS<'_>, 32);
305+
static_assert_size!(TyS<'_>, 40);
306306

307307
impl<'tcx> Ord for TyS<'tcx> {
308308
fn cmp(&self, other: &TyS<'tcx>) -> Ordering {
@@ -366,7 +366,7 @@ crate struct PredicateInner<'tcx> {
366366
}
367367

368368
#[cfg(all(target_arch = "x86_64", target_pointer_width = "64"))]
369-
static_assert_size!(PredicateInner<'_>, 40);
369+
static_assert_size!(PredicateInner<'_>, 48);
370370

371371
#[derive(Clone, Copy, Lift)]
372372
pub struct Predicate<'tcx> {

compiler/rustc_middle/src/ty/sty.rs

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -232,7 +232,7 @@ impl TyKind<'tcx> {
232232

233233
// `TyKind` is used a lot. Make sure it doesn't unintentionally get bigger.
234234
#[cfg(all(target_arch = "x86_64", target_pointer_width = "64"))]
235-
static_assert_size!(TyKind<'_>, 24);
235+
static_assert_size!(TyKind<'_>, 32);
236236

237237
/// A closure can be modeled as a struct that looks like:
238238
///
@@ -957,7 +957,7 @@ impl<'tcx> PolyExistentialTraitRef<'tcx> {
957957
///
958958
/// `Decodable` and `Encodable` are implemented for `Binder<T>` using the `impl_binder_encode_decode!` macro.
959959
#[derive(Copy, Clone, PartialEq, Eq, PartialOrd, Ord, Hash, Debug)]
960-
pub struct Binder<T>(T);
960+
pub struct Binder<T>(T, u32);
961961

962962
impl<T> Binder<T> {
963963
/// Wraps `value` in a binder, asserting that `value` does not
@@ -969,12 +969,12 @@ impl<T> Binder<T> {
969969
T: TypeFoldable<'tcx>,
970970
{
971971
debug_assert!(!value.has_escaping_bound_vars());
972-
Binder(value)
972+
Binder(value, 0)
973973
}
974974

975975
/// Wraps `value` in a binder, binding higher-ranked vars (if any).
976976
pub fn bind(value: T) -> Binder<T> {
977-
Binder(value)
977+
Binder(value, 0)
978978
}
979979

980980
/// Skips the binder and returns the "bound" value. This is a
@@ -998,7 +998,7 @@ impl<T> Binder<T> {
998998
}
999999

10001000
pub fn as_ref(&self) -> Binder<&T> {
1001-
Binder(&self.0)
1001+
Binder(&self.0, self.1)
10021002
}
10031003

10041004
pub fn map_bound_ref<F, U>(&self, f: F) -> Binder<U>
@@ -1012,7 +1012,7 @@ impl<T> Binder<T> {
10121012
where
10131013
F: FnOnce(T) -> U,
10141014
{
1015-
Binder(f(self.0))
1015+
Binder(f(self.0), self.1)
10161016
}
10171017

10181018
/// Wraps a `value` in a binder, using the same bound variables as the
@@ -1025,7 +1025,7 @@ impl<T> Binder<T> {
10251025
/// because bound vars aren't allowed to change here, whereas they are
10261026
/// in `bind`. This may be (debug) asserted in the future.
10271027
pub fn rebind<U>(&self, value: U) -> Binder<U> {
1028-
Binder(value)
1028+
Binder(value, self.1)
10291029
}
10301030

10311031
/// Unwraps and returns the value within, but only if it contains
@@ -1056,7 +1056,7 @@ impl<T> Binder<T> {
10561056
where
10571057
F: FnOnce(T, U) -> R,
10581058
{
1059-
Binder(f(self.0, u.0))
1059+
Binder(f(self.0, u.0), self.1)
10601060
}
10611061

10621062
/// Splits the contents into two things that share the same binder
@@ -1070,13 +1070,14 @@ impl<T> Binder<T> {
10701070
F: FnOnce(T) -> (U, V),
10711071
{
10721072
let (u, v) = f(self.0);
1073-
(Binder(u), Binder(v))
1073+
(Binder(u, self.1), Binder(v, self.1))
10741074
}
10751075
}
10761076

10771077
impl<T> Binder<Option<T>> {
10781078
pub fn transpose(self) -> Option<Binder<T>> {
1079-
self.0.map(Binder)
1079+
let bound_vars = self.1;
1080+
self.0.map(|v| Binder(v, bound_vars))
10801081
}
10811082
}
10821083

0 commit comments

Comments
 (0)