Renamed DerivedObligation to WellFormedDeriveObligation

This commit is contained in:
Michael Goulet 2024-04-25 16:55:15 -04:00
parent 1c84675e1f
commit 132f8ce3dc
4 changed files with 11 additions and 6 deletions

View File

@ -328,11 +328,16 @@ pub enum ObligationCauseCode<'tcx> {
/// `static` items must have `Sync` type. /// `static` items must have `Sync` type.
SharedStatic, SharedStatic,
/// Derived obligation (i.e. theoretical `where` clause) on a built-in
/// implementation like `Copy` or `Sized`.
BuiltinDerivedObligation(DerivedObligationCause<'tcx>), BuiltinDerivedObligation(DerivedObligationCause<'tcx>),
/// Derived obligation (i.e. `where` clause) on an user-provided impl
/// or a trait alias.
ImplDerivedObligation(Box<ImplDerivedObligationCause<'tcx>>), ImplDerivedObligation(Box<ImplDerivedObligationCause<'tcx>>),
DerivedObligation(DerivedObligationCause<'tcx>), /// Derived obligation for WF goals.
WellFormedDerivedObligation(DerivedObligationCause<'tcx>),
FunctionArgumentObligation { FunctionArgumentObligation {
/// The node of the relevant argument in the function call. /// The node of the relevant argument in the function call.
@ -534,7 +539,7 @@ pub fn parent(&self) -> Option<(&Self, Option<ty::PolyTraitPredicate<'tcx>>)> {
match self { match self {
FunctionArgumentObligation { parent_code, .. } => Some((parent_code, None)), FunctionArgumentObligation { parent_code, .. } => Some((parent_code, None)),
BuiltinDerivedObligation(derived) BuiltinDerivedObligation(derived)
| DerivedObligation(derived) | WellFormedDerivedObligation(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)))
} }

View File

@ -128,7 +128,7 @@ fn on_unimplemented_note(
match obligation.cause.code() { match obligation.cause.code() {
ObligationCauseCode::BuiltinDerivedObligation(..) ObligationCauseCode::BuiltinDerivedObligation(..)
| ObligationCauseCode::ImplDerivedObligation(..) | ObligationCauseCode::ImplDerivedObligation(..)
| ObligationCauseCode::DerivedObligation(..) => {} | ObligationCauseCode::WellFormedDerivedObligation(..) => {}
_ => { _ => {
// this is a "direct", user-specified, rather than derived, // this is a "direct", user-specified, rather than derived,
// obligation. // obligation.

View File

@ -2294,7 +2294,7 @@ fn maybe_note_obligation_cause_for_async_await<G: EmissionGuarantee>(
next_code = Some(&cause.derived.parent_code); next_code = Some(&cause.derived.parent_code);
} }
ObligationCauseCode::DerivedObligation(derived_obligation) ObligationCauseCode::WellFormedDerivedObligation(derived_obligation)
| ObligationCauseCode::BuiltinDerivedObligation(derived_obligation) => { | ObligationCauseCode::BuiltinDerivedObligation(derived_obligation) => {
let ty = derived_obligation.parent_trait_pred.skip_binder().self_ty(); let ty = derived_obligation.parent_trait_pred.skip_binder().self_ty();
debug!( debug!(
@ -3423,7 +3423,7 @@ fn note_obligation_cause_code<G: EmissionGuarantee, T>(
) )
}); });
} }
ObligationCauseCode::DerivedObligation(ref data) => { ObligationCauseCode::WellFormedDerivedObligation(ref data) => {
let parent_trait_ref = self.resolve_vars_if_possible(data.parent_trait_pred); let parent_trait_ref = self.resolve_vars_if_possible(data.parent_trait_pred);
let parent_predicate = parent_trait_ref; let parent_predicate = parent_trait_ref;
// #74711: avoid a stack overflow // #74711: avoid a stack overflow

View File

@ -381,7 +381,7 @@ fn compute_trait_pred(&mut self, trait_pred: ty::TraitPredicate<'tcx>, elaborate
if let Some(parent_trait_pred) = predicate.to_opt_poly_trait_pred() { if let Some(parent_trait_pred) = predicate.to_opt_poly_trait_pred() {
cause = cause.derived_cause( cause = cause.derived_cause(
parent_trait_pred, parent_trait_pred,
traits::ObligationCauseCode::DerivedObligation, traits::ObligationCauseCode::WellFormedDerivedObligation,
); );
} }
extend_cause_with_original_assoc_item_obligation(tcx, item, &mut cause, predicate); extend_cause_with_original_assoc_item_obligation(tcx, item, &mut cause, predicate);