diff options
| author | bors <bors@rust-lang.org> | 2020-06-16 06:22:52 +0000 |
|---|---|---|
| committer | bors <bors@rust-lang.org> | 2020-06-16 06:22:52 +0000 |
| commit | c8a9c340de32cb70c8bad8af1a4474f805c5a969 (patch) | |
| tree | bf4dcf744636576c34c3ebb13d5908e42a3f93f5 /src/librustc_trait_selection/traits | |
| parent | f315c35a77e40bd11ce81fedc0556be0f410bbf4 (diff) | |
| parent | ea668d9c548d4490ae9e8ea9b4e8942bae02a8fe (diff) | |
| download | rust-c8a9c340de32cb70c8bad8af1a4474f805c5a969.tar.gz rust-c8a9c340de32cb70c8bad8af1a4474f805c5a969.zip | |
Auto merge of #72962 - lcnr:ObligationCause-lrc, r=ecstatic-morse
store `ObligationCause` on the heap Stores `ObligationCause` on the heap using an `Rc`. This PR trades off some transient memory allocations to reduce the size of–and thus the number of instructions required to memcpy–a few widely used data structures in trait solving.
Diffstat (limited to 'src/librustc_trait_selection/traits')
| -rw-r--r-- | src/librustc_trait_selection/traits/fulfill.rs | 2 | ||||
| -rw-r--r-- | src/librustc_trait_selection/traits/misc.rs | 2 | ||||
| -rw-r--r-- | src/librustc_trait_selection/traits/wf.rs | 7 |
3 files changed, 6 insertions, 5 deletions
diff --git a/src/librustc_trait_selection/traits/fulfill.rs b/src/librustc_trait_selection/traits/fulfill.rs index 4a08a3426c1..106753ed809 100644 --- a/src/librustc_trait_selection/traits/fulfill.rs +++ b/src/librustc_trait_selection/traits/fulfill.rs @@ -84,7 +84,7 @@ pub struct PendingPredicateObligation<'tcx> { // `PendingPredicateObligation` is used a lot. Make sure it doesn't unintentionally get bigger. #[cfg(target_arch = "x86_64")] -static_assert_size!(PendingPredicateObligation<'_>, 112); +static_assert_size!(PendingPredicateObligation<'_>, 72); impl<'a, 'tcx> FulfillmentContext<'tcx> { /// Creates a new fulfillment context. diff --git a/src/librustc_trait_selection/traits/misc.rs b/src/librustc_trait_selection/traits/misc.rs index 7403b936391..61567aeb57c 100644 --- a/src/librustc_trait_selection/traits/misc.rs +++ b/src/librustc_trait_selection/traits/misc.rs @@ -48,7 +48,7 @@ pub fn can_type_implement_copy( continue; } let span = tcx.def_span(field.did); - let cause = ObligationCause { span, ..ObligationCause::dummy() }; + let cause = ObligationCause::dummy_with_span(span); let ctx = traits::FulfillmentContext::new(); match traits::fully_normalize(&infcx, ctx, cause, param_env, &ty) { Ok(ty) => { diff --git a/src/librustc_trait_selection/traits/wf.rs b/src/librustc_trait_selection/traits/wf.rs index 5024392a0f9..90a9b876d8d 100644 --- a/src/librustc_trait_selection/traits/wf.rs +++ b/src/librustc_trait_selection/traits/wf.rs @@ -205,7 +205,7 @@ fn extend_cause_with_original_assoc_item_obligation<'tcx>( if let Some(impl_item_span) = items.iter().find(|item| item.ident == trait_assoc_item.ident).map(fix_span) { - cause.span = impl_item_span; + cause.make_mut().span = impl_item_span; } } } @@ -222,7 +222,7 @@ fn extend_cause_with_original_assoc_item_obligation<'tcx>( items.iter().find(|i| i.ident == trait_assoc_item.ident).map(fix_span) }) { - cause.span = impl_item_span; + cause.make_mut().span = impl_item_span; } } } @@ -273,7 +273,8 @@ impl<'a, 'tcx> WfPredicates<'a, 'tcx> { parent_trait_ref, parent_code: Rc::new(obligation.cause.code.clone()), }; - cause.code = traits::ObligationCauseCode::DerivedObligation(derived_cause); + cause.make_mut().code = + traits::ObligationCauseCode::DerivedObligation(derived_cause); } extend_cause_with_original_assoc_item_obligation( tcx, |
