Skip to content

Commit c1b9a46

Browse files
committed
Add some assertions on obligation type sizes.
These are types that get memcpy'd a lot.
1 parent 36b37e2 commit c1b9a46

File tree

2 files changed

+12
-0
lines changed

2 files changed

+12
-0
lines changed

src/librustc/traits/fulfill.rs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,10 @@ pub struct PendingPredicateObligation<'tcx> {
6868
pub stalled_on: Vec<Ty<'tcx>>,
6969
}
7070

71+
// `PendingPredicateObligation` is used a lot. Make sure it doesn't unintentionally get bigger.
72+
#[cfg(target_arch = "x86_64")]
73+
static_assert_size!(PendingPredicateObligation<'_>, 160);
74+
7175
impl<'a, 'tcx> FulfillmentContext<'tcx> {
7276
/// Creates a new fulfillment context.
7377
pub fn new() -> FulfillmentContext<'tcx> {

src/librustc/traits/mod.rs

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -123,6 +123,10 @@ pub struct Obligation<'tcx, T> {
123123
pub type PredicateObligation<'tcx> = Obligation<'tcx, ty::Predicate<'tcx>>;
124124
pub type TraitObligation<'tcx> = Obligation<'tcx, ty::PolyTraitPredicate<'tcx>>;
125125

126+
// `PredicateObligation` is used a lot. Make sure it doesn't unintentionally get bigger.
127+
#[cfg(target_arch = "x86_64")]
128+
static_assert_size!(PredicateObligation<'_>, 136);
129+
126130
/// The reason why we incurred this obligation; used for error reporting.
127131
#[derive(Clone, Debug, PartialEq, Eq, Hash)]
128132
pub struct ObligationCause<'tcx> {
@@ -269,6 +273,10 @@ pub enum ObligationCauseCode<'tcx> {
269273
TrivialBound,
270274
}
271275

276+
// `ObligationCauseCode` is used a lot. Make sure it doesn't unintentionally get bigger.
277+
#[cfg(target_arch = "x86_64")]
278+
static_assert_size!(ObligationCauseCode<'_>, 56);
279+
272280
#[derive(Clone, Debug, PartialEq, Eq, Hash)]
273281
pub struct DerivedObligationCause<'tcx> {
274282
/// The trait reference of the parent obligation that led to the

0 commit comments

Comments
 (0)