mirror of
https://github.com/rust-lang/rust.git
synced 2025-04-17 06:26:55 +00:00
Add AscribeUserTypeProvePredicate
This commit is contained in:
parent
ec17be2656
commit
9929c0ac76
@ -110,6 +110,7 @@ infer_relate_param_bound = ...so that the type `{$name}` will meet its required
|
||||
infer_relate_param_bound_2 = ...that is required by this bound
|
||||
infer_relate_region_param_bound = ...so that the declared lifetime parameter bounds are satisfied
|
||||
infer_compare_impl_item_obligation = ...so that the definition in impl matches the definition from the trait
|
||||
infer_ascribe_user_type_prove_predicate = ...so that the where clause holds
|
||||
|
||||
infer_nothing = {""}
|
||||
|
||||
|
@ -77,6 +77,13 @@ impl<'a, 'tcx> InferCtxt<'a, 'tcx> {
|
||||
infer::CheckAssociatedTypeBounds { ref parent, .. } => {
|
||||
self.note_region_origin(err, &parent);
|
||||
}
|
||||
infer::AscribeUserTypeProvePredicate(span) => {
|
||||
RegionOriginNote::Plain {
|
||||
span,
|
||||
msg: fluent::infer::ascribe_user_type_prove_predicate,
|
||||
}
|
||||
.add_to_diagnostic(err);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -356,6 +363,27 @@ impl<'a, 'tcx> InferCtxt<'a, 'tcx> {
|
||||
|
||||
err
|
||||
}
|
||||
infer::AscribeUserTypeProvePredicate(span) => {
|
||||
let mut err =
|
||||
struct_span_err!(self.tcx.sess, span, E0478, "lifetime bound not satisfied");
|
||||
note_and_explain_region(
|
||||
self.tcx,
|
||||
&mut err,
|
||||
"lifetime instantiated with ",
|
||||
sup,
|
||||
"",
|
||||
None,
|
||||
);
|
||||
note_and_explain_region(
|
||||
self.tcx,
|
||||
&mut err,
|
||||
"but lifetime must outlive ",
|
||||
sub,
|
||||
"",
|
||||
None,
|
||||
);
|
||||
err
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -409,7 +409,11 @@ pub enum SubregionOrigin<'tcx> {
|
||||
|
||||
/// Comparing the signature and requirements of an impl method against
|
||||
/// the containing trait.
|
||||
CompareImplItemObligation { span: Span, impl_item_def_id: LocalDefId, trait_item_def_id: DefId },
|
||||
CompareImplItemObligation {
|
||||
span: Span,
|
||||
impl_item_def_id: LocalDefId,
|
||||
trait_item_def_id: DefId,
|
||||
},
|
||||
|
||||
/// Checking that the bounds of a trait's associated type hold for a given impl
|
||||
CheckAssociatedTypeBounds {
|
||||
@ -417,6 +421,8 @@ pub enum SubregionOrigin<'tcx> {
|
||||
impl_item_def_id: LocalDefId,
|
||||
trait_item_def_id: DefId,
|
||||
},
|
||||
|
||||
AscribeUserTypeProvePredicate(Span),
|
||||
}
|
||||
|
||||
// `SubregionOrigin` is used a lot. Make sure it doesn't unintentionally get bigger.
|
||||
@ -2001,6 +2007,7 @@ impl<'tcx> SubregionOrigin<'tcx> {
|
||||
DataBorrowed(_, a) => a,
|
||||
ReferenceOutlivesReferent(_, a) => a,
|
||||
CompareImplItemObligation { span, .. } => span,
|
||||
AscribeUserTypeProvePredicate(span) => span,
|
||||
CheckAssociatedTypeBounds { ref parent, .. } => parent.span(),
|
||||
}
|
||||
}
|
||||
@ -2033,6 +2040,10 @@ impl<'tcx> SubregionOrigin<'tcx> {
|
||||
parent: Box::new(default()),
|
||||
},
|
||||
|
||||
traits::ObligationCauseCode::AscribeUserTypeProvePredicate(span) => {
|
||||
SubregionOrigin::AscribeUserTypeProvePredicate(span)
|
||||
}
|
||||
|
||||
_ => default(),
|
||||
}
|
||||
}
|
||||
|
@ -188,6 +188,9 @@ impl<'tcx> ObligationCause<'tcx> {
|
||||
pub fn to_constraint_category(&self) -> ConstraintCategory<'tcx> {
|
||||
match self.code() {
|
||||
MatchImpl(cause, _) => cause.to_constraint_category(),
|
||||
AscribeUserTypeProvePredicate(predicate_span) => {
|
||||
ConstraintCategory::Predicate(*predicate_span)
|
||||
}
|
||||
_ => ConstraintCategory::BoringNoLocation,
|
||||
}
|
||||
}
|
||||
@ -426,6 +429,8 @@ pub enum ObligationCauseCode<'tcx> {
|
||||
is_lit: bool,
|
||||
output_ty: Option<Ty<'tcx>>,
|
||||
},
|
||||
|
||||
AscribeUserTypeProvePredicate(Span),
|
||||
}
|
||||
|
||||
/// The 'location' at which we try to perform HIR-based wf checking.
|
||||
|
@ -2256,7 +2256,8 @@ impl<'a, 'tcx> InferCtxtExt<'tcx> for InferCtxt<'a, 'tcx> {
|
||||
| ObligationCauseCode::QuestionMark
|
||||
| ObligationCauseCode::CheckAssociatedTypeBounds { .. }
|
||||
| ObligationCauseCode::LetElse
|
||||
| ObligationCauseCode::BinOp { .. } => {}
|
||||
| ObligationCauseCode::BinOp { .. }
|
||||
| ObligationCauseCode::AscribeUserTypeProvePredicate(..) => {}
|
||||
ObligationCauseCode::SliceOrArrayElem => {
|
||||
err.note("slice and array elements must have `Sized` type");
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user