Skip to content

Commit 905beab

Browse files
Reuse existing shared Lrc for MatchImpl parent
This is hopefully a small performance win for the hot path.
1 parent 4aed1ab commit 905beab

File tree

4 files changed

+4
-4
lines changed

4 files changed

+4
-4
lines changed

compiler/rustc_infer/src/infer/error_reporting/nice_region_error/mismatched_static_lifetime.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ impl<'a, 'tcx> NiceRegionError<'a, 'tcx> {
3333
ObligationCauseCode::MatchImpl(parent, impl_def_id) => (parent, impl_def_id),
3434
_ => return None,
3535
};
36-
let binding_span = match **parent {
36+
let binding_span = match parent.code {
3737
ObligationCauseCode::BindingObligation(_def_id, binding_span) => binding_span,
3838
_ => return None,
3939
};

compiler/rustc_infer/src/infer/error_reporting/nice_region_error/static_impl_trait.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -189,7 +189,7 @@ impl<'a, 'tcx> NiceRegionError<'a, 'tcx> {
189189
}
190190
if let SubregionOrigin::Subtype(box TypeTrace { cause, .. }) = &sub_origin {
191191
let code = match &cause.code {
192-
ObligationCauseCode::MatchImpl(parent, ..) => &**parent,
192+
ObligationCauseCode::MatchImpl(parent, ..) => &parent.code,
193193
_ => &cause.code,
194194
};
195195
if let ObligationCauseCode::ItemObligation(item_def_id) = *code {

compiler/rustc_middle/src/traits/mod.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -340,7 +340,7 @@ pub enum ObligationCauseCode<'tcx> {
340340
WellFormed(Option<WellFormedLoc>),
341341

342342
/// From `match_impl`. The cause for us having to match an impl, and the DefId we are matching against.
343-
MatchImpl(Lrc<ObligationCauseCode<'tcx>>, DefId),
343+
MatchImpl(ObligationCause<'tcx>, DefId),
344344
}
345345

346346
/// The 'location' at which we try to perform HIR-based wf checking.

compiler/rustc_trait_selection/src/traits/select/mod.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -2025,7 +2025,7 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> {
20252025
let cause = ObligationCause::new(
20262026
obligation.cause.span,
20272027
obligation.cause.body_id,
2028-
ObligationCauseCode::MatchImpl(Lrc::new(obligation.cause.code.clone()), impl_def_id),
2028+
ObligationCauseCode::MatchImpl(obligation.cause.clone(), impl_def_id),
20292029
);
20302030

20312031
let InferOk { obligations, .. } = self

0 commit comments

Comments
 (0)