Refactor FulfillmentError
to track less data
Move the information about pointing at the call argument expression in an unmet obligation span from the `FulfillmentError` to a new `ObligationCauseCode`.
This commit is contained in:
parent
284a8a9ce7
commit
8a3f712518
11 changed files with 86 additions and 57 deletions
|
@ -29,7 +29,13 @@ impl<'a, 'tcx> NiceRegionError<'a, 'tcx> {
|
|||
SubregionOrigin::Subtype(box TypeTrace { ref cause, .. }) => cause,
|
||||
_ => return None,
|
||||
};
|
||||
let (parent, impl_def_id) = match &cause.code {
|
||||
// If we added a "points at argument expression" obligation, we remove it here, we care
|
||||
// about the original obligation only.
|
||||
let code = match &cause.code {
|
||||
ObligationCauseCode::FunctionArgumentObligation { parent_code, .. } => &*parent_code,
|
||||
_ => &cause.code,
|
||||
};
|
||||
let (parent, impl_def_id) = match code {
|
||||
ObligationCauseCode::MatchImpl(parent, impl_def_id) => (parent, impl_def_id),
|
||||
_ => return None,
|
||||
};
|
||||
|
|
|
@ -66,10 +66,6 @@ pub type Selection<'tcx> = ImplSource<'tcx, PredicateObligation<'tcx>>;
|
|||
pub struct FulfillmentError<'tcx> {
|
||||
pub obligation: PredicateObligation<'tcx>,
|
||||
pub code: FulfillmentErrorCode<'tcx>,
|
||||
/// Diagnostics only: we opportunistically change the `code.span` when we encounter an
|
||||
/// obligation error caused by a call argument. When this is the case, we also signal that in
|
||||
/// this field to ensure accuracy of suggestions.
|
||||
pub points_at_arg_span: bool,
|
||||
/// Diagnostics only: the 'root' obligation which resulted in
|
||||
/// the failure to process `obligation`. This is the obligation
|
||||
/// that was initially passed to `register_predicate_obligation`
|
||||
|
@ -128,7 +124,7 @@ impl<'tcx> FulfillmentError<'tcx> {
|
|||
code: FulfillmentErrorCode<'tcx>,
|
||||
root_obligation: PredicateObligation<'tcx>,
|
||||
) -> FulfillmentError<'tcx> {
|
||||
FulfillmentError { obligation, code, points_at_arg_span: false, root_obligation }
|
||||
FulfillmentError { obligation, code, root_obligation }
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue