1
Fork 0

Update tests

This commit is contained in:
Basile Desloges 2018-02-07 16:26:35 +01:00
parent 48ba50e10c
commit 0e68bb9728
8 changed files with 61 additions and 13 deletions

View file

@ -14,7 +14,7 @@ enum Bar<T> { What } //~ ERROR parameter `T` is never used
fn foo<T>() { fn foo<T>() {
static a: Bar<T> = Bar::What; 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() { fn main() {

View file

@ -11,8 +11,8 @@
fn siphash<T>() { fn siphash<T>() {
trait t { trait t {
fn g(&self, x: T) -> T; //~ 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; try using //~^ ERROR can't use type parameters from outer function
} }
} }

View file

@ -10,7 +10,7 @@
fn foo<T>() { fn foo<T>() {
struct 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<T> Drop for foo<T> { impl<T> Drop for foo<T> {

View file

@ -9,7 +9,7 @@
// except according to those terms. // except according to those terms.
fn f<T>() -> bool { 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 true
} }

View file

@ -8,7 +8,7 @@
// option. This file may not be copied, modified, or distributed // option. This file may not be copied, modified, or distributed
// except according to those terms. // 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 hd<U>(v: Vec<U> ) -> U {
fn hd1(w: [U]) -> U { return w[0]; } fn hd1(w: [U]) -> U { return w[0]; }

View file

@ -8,7 +8,7 @@
// option. This file may not be copied, modified, or distributed // option. This file may not be copied, modified, or distributed
// except according to those terms. // 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 foo<T>(x: T) {
fn bar(f: Box<FnMut(T) -> T>) { } fn bar(f: Box<FnMut(T) -> T>) { }
} }

View file

@ -8,11 +8,33 @@
// option. This file may not be copied, modified, or distributed // option. This file may not be copied, modified, or distributed
// except according to those terms. // except according to those terms.
trait Baz<T> {}
fn foo<T>(x: 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); 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() { fn main() {
} }

View file

@ -1,9 +1,35 @@
error[E0401]: can't use type parameters from outer function; try using a local type parameter instead error[E0401]: can't use type parameters from outer function
--> $DIR/E0401.rs:12:15 --> $DIR/E0401.rs:14:38
| |
LL | fn bar(y: T) { //~ ERROR E0401 LL | fn foo<T>(x: T) {
| ^ use of type variable from outer function | - 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" If you want more information on this error, try using "rustc --explain E0401"