mirror of
https://github.com/rust-lang/rust.git
synced 2025-06-19 19:17:31 +00:00
Don't allocate misc obligation parents of derived obligations
This commit is contained in:
parent
9ba6ddb929
commit
1b51e1ad20
@ -191,9 +191,10 @@ impl<'tcx> ObligationCause<'tcx> {
|
|||||||
// NOTE(flaper87): As of now, it keeps track of the whole error
|
// NOTE(flaper87): As of now, it keeps track of the whole error
|
||||||
// chain. Ideally, we should have a way to configure this either
|
// chain. Ideally, we should have a way to configure this either
|
||||||
// by using -Z verbose or just a CLI argument.
|
// by using -Z verbose or just a CLI argument.
|
||||||
self.map_code(|parent_code| {
|
self.code = Some(
|
||||||
variant(DerivedObligationCause { parent_trait_pred, parent_code }).into()
|
variant(DerivedObligationCause { parent_trait_pred, parent_code: self.code.take() })
|
||||||
});
|
.into(),
|
||||||
|
);
|
||||||
self
|
self
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -443,7 +444,7 @@ impl<'tcx> ObligationCauseCode<'tcx> {
|
|||||||
BuiltinDerivedObligation(derived)
|
BuiltinDerivedObligation(derived)
|
||||||
| DerivedObligation(derived)
|
| DerivedObligation(derived)
|
||||||
| ImplDerivedObligation(box ImplDerivedObligationCause { derived, .. }) => {
|
| ImplDerivedObligation(box ImplDerivedObligationCause { derived, .. }) => {
|
||||||
Some((&derived.parent_code, Some(derived.parent_trait_pred)))
|
Some((derived.parent_code(), Some(derived.parent_trait_pred)))
|
||||||
}
|
}
|
||||||
_ => None,
|
_ => None,
|
||||||
}
|
}
|
||||||
@ -497,14 +498,14 @@ pub struct DerivedObligationCause<'tcx> {
|
|||||||
pub parent_trait_pred: ty::PolyTraitPredicate<'tcx>,
|
pub parent_trait_pred: ty::PolyTraitPredicate<'tcx>,
|
||||||
|
|
||||||
/// The parent trait had this cause.
|
/// The parent trait had this cause.
|
||||||
parent_code: Lrc<ObligationCauseCode<'tcx>>,
|
parent_code: Option<Lrc<ObligationCauseCode<'tcx>>>,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<'tcx> DerivedObligationCause<'tcx> {
|
impl<'tcx> DerivedObligationCause<'tcx> {
|
||||||
/// Get a reference to the derived obligation cause's parent code.
|
/// Get a reference to the derived obligation cause's parent code.
|
||||||
#[must_use]
|
#[must_use]
|
||||||
pub fn parent_code(&self) -> &ObligationCauseCode<'tcx> {
|
pub fn parent_code(&self) -> &ObligationCauseCode<'tcx> {
|
||||||
self.parent_code.as_ref()
|
self.parent_code.as_deref().unwrap_or(&MISC_OBLIGATION_CAUSE_CODE)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user