diff --git a/src/librustc/infer/equate.rs b/src/librustc/infer/equate.rs index 5dfa0d29daf..96d40bc81ad 100644 --- a/src/librustc/infer/equate.rs +++ b/src/librustc/infer/equate.rs @@ -97,7 +97,7 @@ impl TypeRelation<'tcx> for Equate<'combine, 'infcx, 'tcx> { self.tag(), a, b); - let origin = Subtype(self.fields.trace.clone()); + let origin = Subtype(box self.fields.trace.clone()); self.fields.infcx.borrow_region_constraints() .make_eqregion(origin, a, b); Ok(a) diff --git a/src/librustc/infer/error_reporting/nice_region_error/placeholder_error.rs b/src/librustc/infer/error_reporting/nice_region_error/placeholder_error.rs index 19bd38b45b3..bfa8353ca34 100644 --- a/src/librustc/infer/error_reporting/nice_region_error/placeholder_error.rs +++ b/src/librustc/infer/error_reporting/nice_region_error/placeholder_error.rs @@ -30,7 +30,7 @@ impl NiceRegionError<'me, 'tcx> { Some(RegionResolutionError::SubSupConflict( vid, _, - SubregionOrigin::Subtype(TypeTrace { + SubregionOrigin::Subtype(box TypeTrace { cause, values: ValuePairs::TraitRefs(ExpectedFound { expected, found }), }), @@ -50,7 +50,7 @@ impl NiceRegionError<'me, 'tcx> { Some(RegionResolutionError::SubSupConflict( vid, _, - SubregionOrigin::Subtype(TypeTrace { + SubregionOrigin::Subtype(box TypeTrace { cause, values: ValuePairs::TraitRefs(ExpectedFound { expected, found }), }), @@ -70,7 +70,7 @@ impl NiceRegionError<'me, 'tcx> { Some(RegionResolutionError::SubSupConflict( vid, _, - SubregionOrigin::Subtype(TypeTrace { + SubregionOrigin::Subtype(box TypeTrace { cause, values: ValuePairs::TraitRefs(ExpectedFound { expected, found }), }), @@ -92,7 +92,7 @@ impl NiceRegionError<'me, 'tcx> { _, _, _, - SubregionOrigin::Subtype(TypeTrace { + SubregionOrigin::Subtype(box TypeTrace { cause, values: ValuePairs::TraitRefs(ExpectedFound { expected, found }), }), @@ -108,7 +108,7 @@ impl NiceRegionError<'me, 'tcx> { )), Some(RegionResolutionError::ConcreteFailure( - SubregionOrigin::Subtype(TypeTrace { + SubregionOrigin::Subtype(box TypeTrace { cause, values: ValuePairs::TraitRefs(ExpectedFound { expected, found }), }), @@ -125,7 +125,7 @@ impl NiceRegionError<'me, 'tcx> { )), Some(RegionResolutionError::ConcreteFailure( - SubregionOrigin::Subtype(TypeTrace { + SubregionOrigin::Subtype(box TypeTrace { cause, values: ValuePairs::TraitRefs(ExpectedFound { expected, found }), }), @@ -142,7 +142,7 @@ impl NiceRegionError<'me, 'tcx> { )), Some(RegionResolutionError::ConcreteFailure( - SubregionOrigin::Subtype(TypeTrace { + SubregionOrigin::Subtype(box TypeTrace { cause, values: ValuePairs::TraitRefs(ExpectedFound { expected, found }), }), diff --git a/src/librustc/infer/error_reporting/note.rs b/src/librustc/infer/error_reporting/note.rs index caed4288892..115ffea97bf 100644 --- a/src/librustc/infer/error_reporting/note.rs +++ b/src/librustc/infer/error_reporting/note.rs @@ -138,7 +138,7 @@ impl<'a, 'tcx> InferCtxt<'a, 'tcx> { sup: Region<'tcx>) -> DiagnosticBuilder<'tcx> { match origin { - infer::Subtype(trace) => { + infer::Subtype(box trace) => { let terr = TypeError::RegionsDoesNotOutlive(sup, sub); let mut err = self.report_and_explain_type_error(trace, &terr); self.tcx.note_and_explain_region(region_scope_tree, &mut err, "", sup, "..."); @@ -450,7 +450,7 @@ impl<'a, 'tcx> InferCtxt<'a, 'tcx> { ) -> DiagnosticBuilder<'tcx> { // I can't think how to do better than this right now. -nikomatsakis match placeholder_origin { - infer::Subtype(trace) => { + infer::Subtype(box trace) => { let terr = TypeError::RegionsPlaceholderMismatch; self.report_and_explain_type_error(trace, &terr) } diff --git a/src/librustc/infer/glb.rs b/src/librustc/infer/glb.rs index 2cef5211762..10e45321a6d 100644 --- a/src/librustc/infer/glb.rs +++ b/src/librustc/infer/glb.rs @@ -57,7 +57,7 @@ impl TypeRelation<'tcx> for Glb<'combine, 'infcx, 'tcx> { a, b); - let origin = Subtype(self.fields.trace.clone()); + let origin = Subtype(box self.fields.trace.clone()); Ok(self.fields.infcx.borrow_region_constraints().glb_regions(self.tcx(), origin, a, b)) } diff --git a/src/librustc/infer/lub.rs b/src/librustc/infer/lub.rs index e20372f1513..8b64cda7bd2 100644 --- a/src/librustc/infer/lub.rs +++ b/src/librustc/infer/lub.rs @@ -57,7 +57,7 @@ impl TypeRelation<'tcx> for Lub<'combine, 'infcx, 'tcx> { a, b); - let origin = Subtype(self.fields.trace.clone()); + let origin = Subtype(box self.fields.trace.clone()); Ok(self.fields.infcx.borrow_region_constraints().lub_regions(self.tcx(), origin, a, b)) } diff --git a/src/librustc/infer/mod.rs b/src/librustc/infer/mod.rs index 8638f42976f..a886c44a479 100644 --- a/src/librustc/infer/mod.rs +++ b/src/librustc/infer/mod.rs @@ -254,7 +254,7 @@ pub struct TypeTrace<'tcx> { #[derive(Clone, Debug)] pub enum SubregionOrigin<'tcx> { /// Arose from a subtyping relation - Subtype(TypeTrace<'tcx>), + Subtype(Box>), /// Stack-allocated closures cannot outlive innermost loop /// or function so as to ensure we only require finite stack @@ -340,6 +340,10 @@ pub enum SubregionOrigin<'tcx> { }, } +// `SubregionOrigin` is used a lot. Make sure it doesn't unintentionally get bigger. +#[cfg(target_arch = "x86_64")] +static_assert_size!(SubregionOrigin<'_>, 32); + /// Places that type/region parameters can appear. #[derive(Clone, Copy, Debug)] pub enum ParameterOrigin { diff --git a/src/librustc/infer/sub.rs b/src/librustc/infer/sub.rs index cd1d206b5fc..76db55ecfa8 100644 --- a/src/librustc/infer/sub.rs +++ b/src/librustc/infer/sub.rs @@ -130,7 +130,7 @@ impl TypeRelation<'tcx> for Sub<'combine, 'infcx, 'tcx> { // FIXME -- we have more fine-grained information available // from the "cause" field, we could perhaps give more tailored // error messages. - let origin = SubregionOrigin::Subtype(self.fields.trace.clone()); + let origin = SubregionOrigin::Subtype(box self.fields.trace.clone()); self.fields.infcx.borrow_region_constraints() .make_subregion(origin, a, b);