Improve cause information for NLL higher-ranked errors
This PR has several interconnected pieces: 1. In some of the NLL region error code, we now pass around an `ObligationCause`, instead of just a plain `Span`. This gets forwarded into `fulfill_cx.register_predicate_obligation` during error reporting. 2. The general InferCtxt error reporting code is extended to handle `ObligationCauseCode::BindingObligation` 3. A new enum variant `ConstraintCategory::Predicate` is added. We try to avoid using this as the 'best blame constraint' - instead, we use it to enhance the `ObligationCause` of the `BlameConstraint` that we do end up choosing. As a result, several NLL error messages now contain the same "the lifetime requirement is introduced here" message as non-NLL errors. Having an `ObligationCause` available will likely prove useful for future improvements to NLL error messages.
This commit is contained in:
parent
3e8f32e1c5
commit
93ab12eeab
16 changed files with 194 additions and 82 deletions
|
@ -338,6 +338,11 @@ pub enum ConstraintCategory {
|
|||
OpaqueType,
|
||||
ClosureUpvar(hir::HirId),
|
||||
|
||||
/// A constraint from a user-written predicate
|
||||
/// with the provided span, written on the item
|
||||
/// with the given `DefId`
|
||||
Predicate(DefId, Span),
|
||||
|
||||
/// A "boring" constraint (caused by the given location) is one that
|
||||
/// the user probably doesn't want to see described in diagnostics,
|
||||
/// because it is kind of an artifact of the type system setup.
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue