]> git.lizzy.rs Git - rust.git/commitdiff
Add some assertions on obligation type sizes.
authorNicholas Nethercote <nnethercote@mozilla.com>
Mon, 9 Sep 2019 04:06:14 +0000 (14:06 +1000)
committerNicholas Nethercote <nnethercote@mozilla.com>
Mon, 9 Sep 2019 04:06:46 +0000 (14:06 +1000)
These are types that get memcpy'd a lot.

src/librustc/traits/fulfill.rs
src/librustc/traits/mod.rs

index c1de4939c1d9154a567b4ea8c12342968f8d28b8..a59ea198963649b3985a1f9617dcb5f83a824a4d 100644 (file)
@@ -68,6 +68,10 @@ pub struct PendingPredicateObligation<'tcx> {
     pub stalled_on: Vec<Ty<'tcx>>,
 }
 
+// `PendingPredicateObligation` is used a lot. Make sure it doesn't unintentionally get bigger.
+#[cfg(target_arch = "x86_64")]
+static_assert_size!(PendingPredicateObligation<'_>, 160);
+
 impl<'a, 'tcx> FulfillmentContext<'tcx> {
     /// Creates a new fulfillment context.
     pub fn new() -> FulfillmentContext<'tcx> {
index 1ca92d79fa5f66bc5293cfd6dd2b7fd89e9e1fe9..f43fbbfee3e91d2f29bbb83135f2da0b4d785570 100644 (file)
@@ -123,6 +123,10 @@ pub struct Obligation<'tcx, T> {
 pub type PredicateObligation<'tcx> = Obligation<'tcx, ty::Predicate<'tcx>>;
 pub type TraitObligation<'tcx> = Obligation<'tcx, ty::PolyTraitPredicate<'tcx>>;
 
+// `PredicateObligation` is used a lot. Make sure it doesn't unintentionally get bigger.
+#[cfg(target_arch = "x86_64")]
+static_assert_size!(PredicateObligation<'_>, 136);
+
 /// The reason why we incurred this obligation; used for error reporting.
 #[derive(Clone, Debug, PartialEq, Eq, Hash)]
 pub struct ObligationCause<'tcx> {
@@ -269,6 +273,10 @@ pub enum ObligationCauseCode<'tcx> {
     TrivialBound,
 }
 
+// `ObligationCauseCode` is used a lot. Make sure it doesn't unintentionally get bigger.
+#[cfg(target_arch = "x86_64")]
+static_assert_size!(ObligationCauseCode<'_>, 56);
+
 #[derive(Clone, Debug, PartialEq, Eq, Hash)]
 pub struct DerivedObligationCause<'tcx> {
     /// The trait reference of the parent obligation that led to the