Auto merge of #116497 - compiler-errors:impl-span, r=cjgillot
Extend `impl`'s `def_span` to include its where clauses Typically, we highlight the def-span of an impl in a diagnostic due to either: 1. coherence error 2. trait evaluation cycle 3. invalid implementation of built-in trait I find that an impl's where clauses are very often required to understanding why these errors come about, which is unfortunate since where clauses may be located on different lines and don't show up in the error. This PR expands the def-span of impls to include these where clauses. r? cjgillot since you've touched this code a while back to make some spans shorter, but you can also reassign to wg-diagnostics or compiler if you're busy or have no strong opinions.
This commit is contained in:
commit
59edd67056
30 changed files with 122 additions and 69 deletions
|
@ -970,12 +970,15 @@ impl<'hir> Map<'hir> {
|
|||
// SyntaxContext of the visibility.
|
||||
sig.span.find_ancestor_in_same_ctxt(*outer_span).unwrap_or(*outer_span)
|
||||
}
|
||||
// Impls, including their where clauses.
|
||||
Node::Item(Item {
|
||||
kind: ItemKind::Impl(Impl { generics, .. }),
|
||||
span: outer_span,
|
||||
..
|
||||
}) => until_within(*outer_span, generics.where_clause_span),
|
||||
// Constants and Statics.
|
||||
Node::Item(Item {
|
||||
kind:
|
||||
ItemKind::Const(ty, ..)
|
||||
| ItemKind::Static(ty, ..)
|
||||
| ItemKind::Impl(Impl { self_ty: ty, .. }),
|
||||
kind: ItemKind::Const(ty, ..) | ItemKind::Static(ty, ..),
|
||||
span: outer_span,
|
||||
..
|
||||
})
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue