diff --git a/src/test/compile-fail/inner-static-type-parameter.rs b/src/test/compile-fail/inner-static-type-parameter.rs index 6fb497092d217..4d763017c0f8b 100644 --- a/src/test/compile-fail/inner-static-type-parameter.rs +++ b/src/test/compile-fail/inner-static-type-parameter.rs @@ -14,7 +14,7 @@ enum Bar { What } //~ ERROR parameter `T` is never used fn foo() { static a: Bar = Bar::What; -//~^ ERROR can't use type parameters from outer function; try using a local type parameter instead +//~^ ERROR can't use type parameters from outer function } fn main() { diff --git a/src/test/compile-fail/issue-3021-c.rs b/src/test/compile-fail/issue-3021-c.rs index 635006a3b4dad..55975cc8e8645 100644 --- a/src/test/compile-fail/issue-3021-c.rs +++ b/src/test/compile-fail/issue-3021-c.rs @@ -11,8 +11,8 @@ fn siphash() { trait t { - fn g(&self, x: T) -> T; //~ ERROR can't use type parameters from outer function; try using - //~^ ERROR can't use type parameters from outer function; try using + fn g(&self, x: T) -> T; //~ ERROR can't use type parameters from outer function + //~^ ERROR can't use type parameters from outer function } } diff --git a/src/test/compile-fail/issue-3214.rs b/src/test/compile-fail/issue-3214.rs index 010cfb54c1ae9..9a769c39eca12 100644 --- a/src/test/compile-fail/issue-3214.rs +++ b/src/test/compile-fail/issue-3214.rs @@ -10,7 +10,7 @@ fn foo() { struct foo { - x: T, //~ ERROR can't use type parameters from outer function; + x: T, //~ ERROR can't use type parameters from outer function } impl Drop for foo { diff --git a/src/test/compile-fail/issue-5997-struct.rs b/src/test/compile-fail/issue-5997-struct.rs index e9cfafc98df0e..af9e66b770bba 100644 --- a/src/test/compile-fail/issue-5997-struct.rs +++ b/src/test/compile-fail/issue-5997-struct.rs @@ -9,7 +9,7 @@ // except according to those terms. fn f() -> bool { - struct S(T); //~ ERROR can't use type parameters from outer function; try using + struct S(T); //~ ERROR can't use type parameters from outer function true } diff --git a/src/test/compile-fail/nested-ty-params.rs b/src/test/compile-fail/nested-ty-params.rs index 0ee2a3add8721..aac37289bb749 100644 --- a/src/test/compile-fail/nested-ty-params.rs +++ b/src/test/compile-fail/nested-ty-params.rs @@ -8,7 +8,7 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -// error-pattern:can't use type parameters from outer function; try using +// error-pattern:can't use type parameters from outer function fn hd(v: Vec ) -> U { fn hd1(w: [U]) -> U { return w[0]; } diff --git a/src/test/compile-fail/type-arg-out-of-scope.rs b/src/test/compile-fail/type-arg-out-of-scope.rs index 3249794e5c822..04cd961e97ff7 100644 --- a/src/test/compile-fail/type-arg-out-of-scope.rs +++ b/src/test/compile-fail/type-arg-out-of-scope.rs @@ -8,7 +8,7 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -// error-pattern:can't use type parameters from outer function; try using +// error-pattern:can't use type parameters from outer function fn foo(x: T) { fn bar(f: Box T>) { } } diff --git a/src/test/ui/error-codes/E0401.rs b/src/test/ui/error-codes/E0401.rs index 09bc950efd2d6..15b946625778c 100644 --- a/src/test/ui/error-codes/E0401.rs +++ b/src/test/ui/error-codes/E0401.rs @@ -8,11 +8,33 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. +trait Baz {} + fn foo(x: T) { - fn bar(y: T) { //~ ERROR E0401 + fn bar, W: Fn()>(y: T) { //~ ERROR E0401 + } + fn baz, + W: Fn()> + (y: T) { //~ ERROR E0401 } bar(x); } + +struct A { + inner: T, +} + +impl Iterator for A { + type Item = u8; + fn next(&mut self) -> Option { + fn helper(sel: &Self) -> u8 { //~ ERROR E0401 + unimplemented!(); + } + Some(helper(self)) + } +} + fn main() { } diff --git a/src/test/ui/error-codes/E0401.stderr b/src/test/ui/error-codes/E0401.stderr index 15e1eda7722da..c306ff4a04f6a 100644 --- a/src/test/ui/error-codes/E0401.stderr +++ b/src/test/ui/error-codes/E0401.stderr @@ -1,9 +1,35 @@ -error[E0401]: can't use type parameters from outer function; try using a local type parameter instead - --> $DIR/E0401.rs:12:15 +error[E0401]: can't use type parameters from outer function + --> $DIR/E0401.rs:14:38 | -LL | fn bar(y: T) { //~ ERROR E0401 - | ^ use of type variable from outer function +LL | fn foo(x: T) { + | - type variable from outer function +LL | fn bar, W: Fn()>(y: T) { //~ ERROR E0401 + | -------------------------- ^ use of type variable from outer function + | | + | help: try using a local type parameter instead: `bar, W: Fn(), T>` -error: aborting due to previous error +error[E0401]: can't use type parameters from outer function + --> $DIR/E0401.rs:19:16 + | +LL | fn foo(x: T) { + | - type variable from outer function +... +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 + | +LL | impl Iterator for A { + | ---- `Self` type implicitely declared here, on the `impl` +... +LL | fn helper(sel: &Self) -> u8 { //~ ERROR E0401 + | ------ ^^^^ use of type variable from outer function + | | + | help: try using a local type parameter instead: `helper` + +error: aborting due to 3 previous errors If you want more information on this error, try using "rustc --explain E0401"