1
Fork 0

Suggest copying trait associated type bounds on lifetime error

This commit is contained in:
Jack Huey 2022-01-08 23:30:19 -05:00
parent 30b3f35c42
commit 3d19c8defd
12 changed files with 163 additions and 28 deletions

View file

@ -438,6 +438,13 @@ pub enum SubregionOrigin<'tcx> {
/// Comparing the signature and requirements of an impl associated type
/// against the containing trait
CompareImplTypeObligation { span: Span, impl_item_def_id: DefId, trait_item_def_id: DefId },
/// Checking that the bounds of a trait's associated type hold for a given impl
CheckAssociatedTypeBounds {
parent: Box<SubregionOrigin<'tcx>>,
impl_item_def_id: DefId,
trait_item_def_id: DefId,
},
}
// `SubregionOrigin` is used a lot. Make sure it doesn't unintentionally get bigger.
@ -1832,6 +1839,7 @@ impl<'tcx> SubregionOrigin<'tcx> {
ReferenceOutlivesReferent(_, a) => a,
CompareImplMethodObligation { span, .. } => span,
CompareImplTypeObligation { span, .. } => span,
CheckAssociatedTypeBounds { ref parent, .. } => parent.span(),
}
}
@ -1862,6 +1870,15 @@ impl<'tcx> SubregionOrigin<'tcx> {
trait_item_def_id,
},
traits::ObligationCauseCode::CheckAssociatedTypeBounds {
impl_item_def_id,
trait_item_def_id,
} => SubregionOrigin::CheckAssociatedTypeBounds {
impl_item_def_id,
trait_item_def_id,
parent: Box::new(default()),
},
_ => default(),
}
}