Remove clone_code
method
This commit is contained in:
parent
dc21fcb2fc
commit
05a62c5527
3 changed files with 15 additions and 31 deletions
|
@ -80,7 +80,7 @@ impl<'tcx> TraitObligation<'tcx> {
|
||||||
|
|
||||||
pub fn derived_cause(
|
pub fn derived_cause(
|
||||||
&self,
|
&self,
|
||||||
variant: fn(DerivedObligationCause<'tcx>) -> ObligationCauseCode<'tcx>,
|
variant: impl FnOnce(DerivedObligationCause<'tcx>) -> ObligationCauseCode<'tcx>,
|
||||||
) -> ObligationCause<'tcx> {
|
) -> ObligationCause<'tcx> {
|
||||||
self.cause.clone().derived_cause(self.predicate, variant)
|
self.cause.clone().derived_cause(self.predicate, variant)
|
||||||
}
|
}
|
||||||
|
|
|
@ -163,13 +163,6 @@ impl<'tcx> ObligationCause<'tcx> {
|
||||||
self.code.as_deref().unwrap_or(&MISC_OBLIGATION_CAUSE_CODE)
|
self.code.as_deref().unwrap_or(&MISC_OBLIGATION_CAUSE_CODE)
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn clone_code(&self) -> Lrc<ObligationCauseCode<'tcx>> {
|
|
||||||
match &self.code {
|
|
||||||
Some(code) => code.clone(),
|
|
||||||
None => Lrc::new(MISC_OBLIGATION_CAUSE_CODE),
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
pub fn map_code(
|
pub fn map_code(
|
||||||
&mut self,
|
&mut self,
|
||||||
f: impl FnOnce(Lrc<ObligationCauseCode<'tcx>>) -> Lrc<ObligationCauseCode<'tcx>>,
|
f: impl FnOnce(Lrc<ObligationCauseCode<'tcx>>) -> Lrc<ObligationCauseCode<'tcx>>,
|
||||||
|
|
|
@ -19,14 +19,13 @@ use rustc_span::def_id::DefId;
|
||||||
use crate::traits::project::{normalize_with_depth, normalize_with_depth_to};
|
use crate::traits::project::{normalize_with_depth, normalize_with_depth_to};
|
||||||
use crate::traits::util::{self, closure_trait_ref_and_return_type, predicate_for_trait_def};
|
use crate::traits::util::{self, closure_trait_ref_and_return_type, predicate_for_trait_def};
|
||||||
use crate::traits::{
|
use crate::traits::{
|
||||||
BuiltinDerivedObligation, DerivedObligationCause, ImplDerivedObligation,
|
BuiltinDerivedObligation, ImplDerivedObligation, ImplDerivedObligationCause, ImplSource,
|
||||||
ImplDerivedObligationCause, ImplSource, ImplSourceAutoImplData, ImplSourceBuiltinData,
|
ImplSourceAutoImplData, ImplSourceBuiltinData, ImplSourceClosureData,
|
||||||
ImplSourceClosureData, ImplSourceConstDestructData, ImplSourceDiscriminantKindData,
|
ImplSourceConstDestructData, ImplSourceDiscriminantKindData, ImplSourceFnPointerData,
|
||||||
ImplSourceFnPointerData, ImplSourceGeneratorData, ImplSourceObjectData, ImplSourcePointeeData,
|
ImplSourceGeneratorData, ImplSourceObjectData, ImplSourcePointeeData, ImplSourceTraitAliasData,
|
||||||
ImplSourceTraitAliasData, ImplSourceTraitUpcastingData, ImplSourceUserDefinedData, Normalized,
|
ImplSourceTraitUpcastingData, ImplSourceUserDefinedData, Normalized, ObjectCastObligation,
|
||||||
ObjectCastObligation, Obligation, ObligationCause, OutputTypeParameterMismatch,
|
Obligation, ObligationCause, OutputTypeParameterMismatch, PredicateObligation, Selection,
|
||||||
PredicateObligation, Selection, SelectionError, TraitNotObjectSafe, TraitObligation,
|
SelectionError, TraitNotObjectSafe, TraitObligation, Unimplemented, VtblSegment,
|
||||||
Unimplemented, VtblSegment,
|
|
||||||
};
|
};
|
||||||
|
|
||||||
use super::BuiltinImplConditions;
|
use super::BuiltinImplConditions;
|
||||||
|
@ -1125,21 +1124,13 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> {
|
||||||
let substs = self.rematch_impl(impl_def_id, &new_obligation);
|
let substs = self.rematch_impl(impl_def_id, &new_obligation);
|
||||||
debug!(?substs, "impl substs");
|
debug!(?substs, "impl substs");
|
||||||
|
|
||||||
let derived = DerivedObligationCause {
|
let cause = obligation.derived_cause(|derived| {
|
||||||
parent_trait_pred: obligation.predicate,
|
ImplDerivedObligation(Box::new(ImplDerivedObligationCause {
|
||||||
parent_code: obligation.cause.clone_code(),
|
derived,
|
||||||
};
|
impl_def_id,
|
||||||
let derived_code = ImplDerivedObligation(Box::new(ImplDerivedObligationCause {
|
span: obligation.cause.span,
|
||||||
derived,
|
}))
|
||||||
impl_def_id,
|
});
|
||||||
span: obligation.cause.span,
|
|
||||||
}));
|
|
||||||
|
|
||||||
let cause = ObligationCause::new(
|
|
||||||
obligation.cause.span,
|
|
||||||
obligation.cause.body_id,
|
|
||||||
derived_code,
|
|
||||||
);
|
|
||||||
ensure_sufficient_stack(|| {
|
ensure_sufficient_stack(|| {
|
||||||
self.vtable_impl(
|
self.vtable_impl(
|
||||||
impl_def_id,
|
impl_def_id,
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue