Rollup merge of #90519 - estebank:issue-84003, r=petrochenkov
Keep spans for generics in `#[derive(_)]` desugaring Keep the spans for generics coming from a `derive`d Item, so that errors and suggestions have better detail. Fix #84003.
This commit is contained in:
commit
0311cfa88c
14 changed files with 409 additions and 135 deletions
|
@ -262,8 +262,8 @@ fn suggest_restriction(
|
|||
match generics
|
||||
.params
|
||||
.iter()
|
||||
.map(|p| p.bounds_span().unwrap_or(p.span))
|
||||
.filter(|&span| generics.span.contains(span) && span.desugaring_kind().is_none())
|
||||
.map(|p| p.bounds_span_for_suggestions().unwrap_or(p.span.shrink_to_hi()))
|
||||
.filter(|&span| generics.span.contains(span) && span.can_be_used_for_suggestions())
|
||||
.max_by_key(|span| span.hi())
|
||||
{
|
||||
// `fn foo(t: impl Trait)`
|
||||
|
@ -271,7 +271,7 @@ fn suggest_restriction(
|
|||
None => (generics.span, format!("<{}>", type_param)),
|
||||
// `fn foo<A>(t: impl Trait)`
|
||||
// ^^^ suggest `<A, T: Trait>` here
|
||||
Some(span) => (span.shrink_to_hi(), format!(", {}", type_param)),
|
||||
Some(span) => (span, format!(", {}", type_param)),
|
||||
},
|
||||
// `fn foo(t: impl Trait)`
|
||||
// ^ suggest `where <T as Trait>::A: Bound`
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue