diff options
| author | Mark Rousskov <mark.simulacrum@gmail.com> | 2021-09-15 22:58:40 -0400 |
|---|---|---|
| committer | Mark Rousskov <mark.simulacrum@gmail.com> | 2021-09-15 22:58:40 -0400 |
| commit | 905beab38ead75dcc283c641ebdaf84450e6e3c2 (patch) | |
| tree | 63b679c780825e321957fe54dfabff5baa096bde | |
| parent | 4aed1abb706a31331fd8b612ca400935aeddd0e0 (diff) | |
| download | rust-905beab38ead75dcc283c641ebdaf84450e6e3c2.tar.gz rust-905beab38ead75dcc283c641ebdaf84450e6e3c2.zip | |
Reuse existing shared Lrc for MatchImpl parent
This is hopefully a small performance win for the hot path.
4 files changed, 4 insertions, 4 deletions
diff --git a/compiler/rustc_infer/src/infer/error_reporting/nice_region_error/mismatched_static_lifetime.rs b/compiler/rustc_infer/src/infer/error_reporting/nice_region_error/mismatched_static_lifetime.rs index c60a7149e40..dec5e93a026 100644 --- a/compiler/rustc_infer/src/infer/error_reporting/nice_region_error/mismatched_static_lifetime.rs +++ b/compiler/rustc_infer/src/infer/error_reporting/nice_region_error/mismatched_static_lifetime.rs @@ -33,7 +33,7 @@ impl<'a, 'tcx> NiceRegionError<'a, 'tcx> { ObligationCauseCode::MatchImpl(parent, impl_def_id) => (parent, impl_def_id), _ => return None, }; - let binding_span = match **parent { + let binding_span = match parent.code { ObligationCauseCode::BindingObligation(_def_id, binding_span) => binding_span, _ => return None, }; diff --git a/compiler/rustc_infer/src/infer/error_reporting/nice_region_error/static_impl_trait.rs b/compiler/rustc_infer/src/infer/error_reporting/nice_region_error/static_impl_trait.rs index 81059fbcb10..2d47e72780e 100644 --- a/compiler/rustc_infer/src/infer/error_reporting/nice_region_error/static_impl_trait.rs +++ b/compiler/rustc_infer/src/infer/error_reporting/nice_region_error/static_impl_trait.rs @@ -189,7 +189,7 @@ impl<'a, 'tcx> NiceRegionError<'a, 'tcx> { } if let SubregionOrigin::Subtype(box TypeTrace { cause, .. }) = &sub_origin { let code = match &cause.code { - ObligationCauseCode::MatchImpl(parent, ..) => &**parent, + ObligationCauseCode::MatchImpl(parent, ..) => &parent.code, _ => &cause.code, }; if let ObligationCauseCode::ItemObligation(item_def_id) = *code { diff --git a/compiler/rustc_middle/src/traits/mod.rs b/compiler/rustc_middle/src/traits/mod.rs index 07c2ffac8c7..e1abe7f670e 100644 --- a/compiler/rustc_middle/src/traits/mod.rs +++ b/compiler/rustc_middle/src/traits/mod.rs @@ -340,7 +340,7 @@ pub enum ObligationCauseCode<'tcx> { WellFormed(Option<WellFormedLoc>), /// From `match_impl`. The cause for us having to match an impl, and the DefId we are matching against. - MatchImpl(Lrc<ObligationCauseCode<'tcx>>, DefId), + MatchImpl(ObligationCause<'tcx>, DefId), } /// The 'location' at which we try to perform HIR-based wf checking. diff --git a/compiler/rustc_trait_selection/src/traits/select/mod.rs b/compiler/rustc_trait_selection/src/traits/select/mod.rs index 7b948a0939f..2a9be427480 100644 --- a/compiler/rustc_trait_selection/src/traits/select/mod.rs +++ b/compiler/rustc_trait_selection/src/traits/select/mod.rs @@ -2025,7 +2025,7 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> { let cause = ObligationCause::new( obligation.cause.span, obligation.cause.body_id, - ObligationCauseCode::MatchImpl(Lrc::new(obligation.cause.code.clone()), impl_def_id), + ObligationCauseCode::MatchImpl(obligation.cause.clone(), impl_def_id), ); let InferOk { obligations, .. } = self |
