Fix placement of suggested generic param when bounds are present
This commit is contained in:
parent
374ab25585
commit
cfeedec823
2 changed files with 7 additions and 5 deletions
|
|
@ -162,8 +162,10 @@ crate fn placeholder_type_error(
|
|||
// `struct S<T>(T);` instead of `struct S<_, T>(T);`.
|
||||
sugg.push((arg.span, (*type_name).to_string()));
|
||||
} else {
|
||||
let last = generics.iter().last().unwrap();
|
||||
sugg.push((
|
||||
generics.iter().last().unwrap().span.shrink_to_hi(),
|
||||
// Account for bounds, we want `fn foo<T: E, K>(_: K)` not `fn foo<T, K: E>(_: K)`.
|
||||
last.bounds_span().unwrap_or(last.span).shrink_to_hi(),
|
||||
format!(", {}", type_name),
|
||||
));
|
||||
}
|
||||
|
|
|
|||
|
|
@ -145,8 +145,8 @@ LL | fn foo<X: K<_, _>>(x: X) {}
|
|||
|
|
||||
help: use type parameters instead
|
||||
|
|
||||
LL | fn foo<X, T: K<T, T>>(x: X) {}
|
||||
| ^^^ ^ ^
|
||||
LL | fn foo<X: K<T, T>, T>(x: X) {}
|
||||
| ^ ^ ^^^
|
||||
|
||||
error[E0121]: the type placeholder `_` is not allowed within types on item signatures
|
||||
--> $DIR/bad-assoc-ty.rs:52:34
|
||||
|
|
@ -167,8 +167,8 @@ LL | fn baz<F: Fn() -> _>(_: F) {}
|
|||
|
|
||||
help: use type parameters instead
|
||||
|
|
||||
LL | fn baz<F, T: Fn() -> T>(_: F) {}
|
||||
| ^^^ ^
|
||||
LL | fn baz<F: Fn() -> T, T>(_: F) {}
|
||||
| ^^^^
|
||||
|
||||
error[E0121]: the type placeholder `_` is not allowed within types on item signatures
|
||||
--> $DIR/bad-assoc-ty.rs:58:33
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue