Some tweaks to "type parameters from outer function" diagnostic

Follow up to #47574.
This commit is contained in:
Esteban Küber 2018-03-13 22:58:45 -07:00
parent 883e74645d
commit 16d424f147
4 changed files with 42 additions and 27 deletions

View file

@ -11,14 +11,14 @@
trait Baz<T> {}
fn foo<T>(x: T) {
fn bar<U, V: Baz<U>, W: Fn()>(y: T) { //~ ERROR E0401
fn bfnr<U, V: Baz<U>, W: Fn()>(y: T) { //~ ERROR E0401
}
fn baz<U,
V: Baz<U>,
W: Fn()>
(y: T) { //~ ERROR E0401
}
bar(x);
bfnr(x);
}

View file

@ -1,12 +1,12 @@
error[E0401]: can't use type parameters from outer function
--> $DIR/E0401.rs:14:38
--> $DIR/E0401.rs:14:39
|
LL | fn foo<T>(x: T) {
| - type variable from outer function
LL | fn bar<U, V: Baz<U>, W: Fn()>(y: T) { //~ ERROR E0401
| -------------------------- ^ use of type variable from outer function
LL | fn bfnr<U, V: Baz<U>, W: Fn()>(y: T) { //~ ERROR E0401
| --------------------------- ^ use of type variable from outer function
| |
| help: try using a local type parameter instead: `bar<U, V: Baz<U>, W: Fn(), T>`
| help: try using a local type parameter instead: `bfnr<U, V: Baz<U>, W: Fn(), T>`
error[E0401]: can't use type parameters from outer function
--> $DIR/E0401.rs:19:16
@ -14,10 +14,11 @@ error[E0401]: can't use type parameters from outer function
LL | fn foo<T>(x: T) {
| - type variable from outer function
...
LL | fn baz<U,
| --- try adding a local type parameter in this method instead
...
LL | (y: T) { //~ ERROR E0401
| ^ use of type variable from outer function
|
= help: try using a local type parameter instead
error[E0401]: can't use type parameters from outer function
--> $DIR/E0401.rs:32:25