Skip to content

Commit

Permalink
Update tests
Browse files Browse the repository at this point in the history
  • Loading branch information
zilbuz committed Mar 8, 2018
1 parent 48ba50e commit 0e68bb9
Show file tree
Hide file tree
Showing 8 changed files with 61 additions and 13 deletions.
2 changes: 1 addition & 1 deletion src/test/compile-fail/inner-static-type-parameter.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ enum Bar<T> { What } //~ ERROR parameter `T` is never used

fn foo<T>() {
static a: Bar<T> = 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() {
Expand Down
4 changes: 2 additions & 2 deletions src/test/compile-fail/issue-3021-c.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@
fn siphash<T>() {

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
}
}

Expand Down
2 changes: 1 addition & 1 deletion src/test/compile-fail/issue-3214.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@

fn foo<T>() {
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<T> Drop for foo<T> {
Expand Down
2 changes: 1 addition & 1 deletion src/test/compile-fail/issue-5997-struct.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
// except according to those terms.

fn f<T>() -> 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
}
Expand Down
2 changes: 1 addition & 1 deletion src/test/compile-fail/nested-ty-params.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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<U>(v: Vec<U> ) -> U {
fn hd1(w: [U]) -> U { return w[0]; }

Expand Down
2 changes: 1 addition & 1 deletion src/test/compile-fail/type-arg-out-of-scope.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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<T>(x: T) {
fn bar(f: Box<FnMut(T) -> T>) { }
}
Expand Down
24 changes: 23 additions & 1 deletion src/test/ui/error-codes/E0401.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,33 @@
// option. This file may not be copied, modified, or distributed
// except according to those terms.

trait Baz<T> {}

fn foo<T>(x: T) {
fn bar(y: T) { //~ ERROR E0401
fn bar<U, V: Baz<U>, W: Fn()>(y: T) { //~ ERROR E0401
}
fn baz<U,
V: Baz<U>,
W: Fn()>
(y: T) { //~ ERROR E0401
}
bar(x);
}


struct A<T> {
inner: T,
}

impl<T> Iterator for A<T> {
type Item = u8;
fn next(&mut self) -> Option<u8> {
fn helper(sel: &Self) -> u8 { //~ ERROR E0401
unimplemented!();
}
Some(helper(self))
}
}

fn main() {
}
36 changes: 31 additions & 5 deletions src/test/ui/error-codes/E0401.stderr
Original file line number Diff line number Diff line change
@@ -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<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
| |
| help: try using a local type parameter instead: `bar<U, V: Baz<U>, 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<T>(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<T> Iterator for A<T> {
| ---- `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<Self>`

error: aborting due to 3 previous errors

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

0 comments on commit 0e68bb9

Please sign in to comment.