1
Fork 0

Annotate derived spans and move span suggestion code

* Annotate `derive`d spans from the user's code with the appropciate context
* Add `Span::can_be_used_for_suggestion` to query if the underlying span
  at the users' code
This commit is contained in:
Esteban Kuber 2021-11-20 18:46:36 +00:00
parent 8bee2b88c0
commit 962b2197a5
8 changed files with 112 additions and 90 deletions

View file

@ -1735,7 +1735,7 @@ impl<'a: 'ast, 'ast> LateResolutionVisitor<'a, '_, 'ast> {
(generics.span, format!("<{}>", ident))
};
// Do not suggest if this is coming from macro expansion.
if !span.from_expansion() {
if span.can_be_used_for_suggestions() {
return Some((
span.shrink_to_hi(),
msg,
@ -1825,7 +1825,7 @@ impl<'tcx> LifetimeContext<'_, 'tcx> {
continue;
}
suggested_spans.push(span);
if !span.from_expansion() {
if span.can_be_used_for_suggestions() {
err.span_suggestion(
span,
&format!("consider introducing lifetime `{}` here", lifetime_ref),