mirror of https://github.com/rust-lang/rust.git
Change error for out of scope type params to be more helpful.
This commit is contained in:
parent
14e1fd4629
commit
52a53e8ae7
|
@ -3507,8 +3507,9 @@ impl<'a> Resolver<'a> {
|
|||
// its scope.
|
||||
|
||||
self.resolve_error(span,
|
||||
"attempt to use a type \
|
||||
argument out of scope");
|
||||
"can't use type parameters from \
|
||||
outer function; try using a local \
|
||||
type parameter instead");
|
||||
}
|
||||
|
||||
return None;
|
||||
|
@ -3530,8 +3531,9 @@ impl<'a> Resolver<'a> {
|
|||
// its scope.
|
||||
|
||||
self.resolve_error(span,
|
||||
"attempt to use a type \
|
||||
argument out of scope");
|
||||
"can't use type parameters from \
|
||||
outer function; try using a local \
|
||||
type parameter instead");
|
||||
}
|
||||
|
||||
return None;
|
||||
|
|
|
@ -95,8 +95,9 @@ impl<'a> TypeFolder for SubstFolder<'a> {
|
|||
root.repr(self.tcx)),
|
||||
None => ~""
|
||||
};
|
||||
let m = format!("missing type param `{}`{}",
|
||||
t.repr(self.tcx), root_msg);
|
||||
let m = format!("can't use type parameters from outer \
|
||||
function{}; try using a local type \
|
||||
parameter instead", root_msg);
|
||||
match self.span {
|
||||
Some(span) => self.tcx.sess.span_err(span, m),
|
||||
None => self.tcx.sess.err(m)
|
||||
|
|
|
@ -9,7 +9,7 @@
|
|||
// except according to those terms.
|
||||
|
||||
fn foo<T>() {
|
||||
fn bar(b: T) { } //~ ERROR attempt to use a type argument out of scope
|
||||
fn bar(b: T) { } //~ ERROR can't use type parameters from outer
|
||||
//~^ ERROR use of undeclared type name
|
||||
}
|
||||
fn main() { }
|
||||
|
|
|
@ -11,8 +11,8 @@
|
|||
fn siphash<T>() {
|
||||
|
||||
trait t {
|
||||
fn g(&self, x: T) -> T; //~ ERROR attempt to use a type argument out of scope
|
||||
//~^ ERROR attempt to use a type argument out of scope
|
||||
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
|
||||
//~^^ ERROR use of undeclared type name `T`
|
||||
//~^^^ ERROR use of undeclared type name `T`
|
||||
}
|
||||
|
|
|
@ -10,7 +10,7 @@
|
|||
|
||||
fn foo<T>() {
|
||||
struct foo {
|
||||
x: T, //~ ERROR attempt to use a type argument out of scope
|
||||
x: T, //~ ERROR can't use type parameters from outer function;
|
||||
//~^ ERROR use of undeclared type name
|
||||
}
|
||||
|
||||
|
|
|
@ -10,7 +10,7 @@
|
|||
|
||||
fn f<Z>() -> bool {
|
||||
enum E { V(Z) }
|
||||
//~^ ERROR missing type param `Z` in the substitution of `Z`
|
||||
//~^ ERROR can't use type parameters from outer function in the
|
||||
|
||||
true
|
||||
}
|
||||
|
|
|
@ -10,7 +10,7 @@
|
|||
|
||||
fn f<T>() -> bool {
|
||||
struct S(T); //~ ERROR use of undeclared type name `T`
|
||||
//~^ ERROR attempt to use a type argument out of scope
|
||||
//~^ ERROR can't use type parameters from outer function; try using
|
||||
|
||||
true
|
||||
}
|
||||
|
|
|
@ -8,7 +8,7 @@
|
|||
// option. This file may not be copied, modified, or distributed
|
||||
// except according to those terms.
|
||||
|
||||
// error-pattern:attempt to use a type argument out of scope
|
||||
// error-pattern:can't use type parameters from outer function; try using
|
||||
fn hd<U>(v: Vec<U> ) -> U {
|
||||
fn hd1(w: [U]) -> U { return w[0]; }
|
||||
|
||||
|
|
|
@ -8,7 +8,7 @@
|
|||
// option. This file may not be copied, modified, or distributed
|
||||
// except according to those terms.
|
||||
|
||||
// error-pattern:attempt to use a type argument out of scope
|
||||
// error-pattern:can't use type parameters from outer function; try using
|
||||
fn foo<T>(x: T) {
|
||||
fn bar(f: |T| -> T) { }
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue