Skip to content

Commit 0e68bb9

Browse files
committed
Update tests
1 parent 48ba50e commit 0e68bb9

8 files changed

+61
-13
lines changed

src/test/compile-fail/inner-static-type-parameter.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ enum Bar<T> { What } //~ ERROR parameter `T` is never used
1414

1515
fn foo<T>() {
1616
static a: Bar<T> = Bar::What;
17-
//~^ ERROR can't use type parameters from outer function; try using a local type parameter instead
17+
//~^ ERROR can't use type parameters from outer function
1818
}
1919

2020
fn main() {

src/test/compile-fail/issue-3021-c.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,8 @@
1111
fn siphash<T>() {
1212

1313
trait t {
14-
fn g(&self, x: T) -> T; //~ ERROR can't use type parameters from outer function; try using
15-
//~^ ERROR can't use type parameters from outer function; try using
14+
fn g(&self, x: T) -> T; //~ ERROR can't use type parameters from outer function
15+
//~^ ERROR can't use type parameters from outer function
1616
}
1717
}
1818

src/test/compile-fail/issue-3214.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010

1111
fn foo<T>() {
1212
struct foo {
13-
x: T, //~ ERROR can't use type parameters from outer function;
13+
x: T, //~ ERROR can't use type parameters from outer function
1414
}
1515

1616
impl<T> Drop for foo<T> {

src/test/compile-fail/issue-5997-struct.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
// except according to those terms.
1010

1111
fn f<T>() -> bool {
12-
struct S(T); //~ ERROR can't use type parameters from outer function; try using
12+
struct S(T); //~ ERROR can't use type parameters from outer function
1313

1414
true
1515
}

src/test/compile-fail/nested-ty-params.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
// option. This file may not be copied, modified, or distributed
99
// except according to those terms.
1010

11-
// error-pattern:can't use type parameters from outer function; try using
11+
// error-pattern:can't use type parameters from outer function
1212
fn hd<U>(v: Vec<U> ) -> U {
1313
fn hd1(w: [U]) -> U { return w[0]; }
1414

src/test/compile-fail/type-arg-out-of-scope.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
// option. This file may not be copied, modified, or distributed
99
// except according to those terms.
1010

11-
// error-pattern:can't use type parameters from outer function; try using
11+
// error-pattern:can't use type parameters from outer function
1212
fn foo<T>(x: T) {
1313
fn bar(f: Box<FnMut(T) -> T>) { }
1414
}

src/test/ui/error-codes/E0401.rs

+23-1
Original file line numberDiff line numberDiff line change
@@ -8,11 +8,33 @@
88
// option. This file may not be copied, modified, or distributed
99
// except according to those terms.
1010

11+
trait Baz<T> {}
12+
1113
fn foo<T>(x: T) {
12-
fn bar(y: T) { //~ ERROR E0401
14+
fn bar<U, V: Baz<U>, W: Fn()>(y: T) { //~ ERROR E0401
15+
}
16+
fn baz<U,
17+
V: Baz<U>,
18+
W: Fn()>
19+
(y: T) { //~ ERROR E0401
1320
}
1421
bar(x);
1522
}
1623

24+
25+
struct A<T> {
26+
inner: T,
27+
}
28+
29+
impl<T> Iterator for A<T> {
30+
type Item = u8;
31+
fn next(&mut self) -> Option<u8> {
32+
fn helper(sel: &Self) -> u8 { //~ ERROR E0401
33+
unimplemented!();
34+
}
35+
Some(helper(self))
36+
}
37+
}
38+
1739
fn main() {
1840
}

src/test/ui/error-codes/E0401.stderr

+31-5
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,35 @@
1-
error[E0401]: can't use type parameters from outer function; try using a local type parameter instead
2-
--> $DIR/E0401.rs:12:15
1+
error[E0401]: can't use type parameters from outer function
2+
--> $DIR/E0401.rs:14:38
33
|
4-
LL | fn bar(y: T) { //~ ERROR E0401
5-
| ^ use of type variable from outer function
4+
LL | fn foo<T>(x: T) {
5+
| - type variable from outer function
6+
LL | fn bar<U, V: Baz<U>, W: Fn()>(y: T) { //~ ERROR E0401
7+
| -------------------------- ^ use of type variable from outer function
8+
| |
9+
| help: try using a local type parameter instead: `bar<U, V: Baz<U>, W: Fn(), T>`
610

7-
error: aborting due to previous error
11+
error[E0401]: can't use type parameters from outer function
12+
--> $DIR/E0401.rs:19:16
13+
|
14+
LL | fn foo<T>(x: T) {
15+
| - type variable from outer function
16+
...
17+
LL | (y: T) { //~ ERROR E0401
18+
| ^ use of type variable from outer function
19+
|
20+
= help: try using a local type parameter instead
21+
22+
error[E0401]: can't use type parameters from outer function
23+
--> $DIR/E0401.rs:32:25
24+
|
25+
LL | impl<T> Iterator for A<T> {
26+
| ---- `Self` type implicitely declared here, on the `impl`
27+
...
28+
LL | fn helper(sel: &Self) -> u8 { //~ ERROR E0401
29+
| ------ ^^^^ use of type variable from outer function
30+
| |
31+
| help: try using a local type parameter instead: `helper<Self>`
32+
33+
error: aborting due to 3 previous errors
834

935
If you want more information on this error, try using "rustc --explain E0401"

0 commit comments

Comments
 (0)