]> git.lizzy.rs Git - rust.git/commitdiff
Change error for out of scope type params to be more helpful.
authorKevin Butler <haqkrs@gmail.com>
Wed, 16 Apr 2014 22:32:00 +0000 (23:32 +0100)
committerKevin Butler <haqkrs@gmail.com>
Thu, 17 Apr 2014 17:24:52 +0000 (18:24 +0100)
src/librustc/middle/resolve.rs
src/librustc/middle/subst.rs
src/test/compile-fail/bad-type-env-capture.rs
src/test/compile-fail/issue-3021-c.rs
src/test/compile-fail/issue-3214.rs
src/test/compile-fail/issue-5997-enum.rs
src/test/compile-fail/issue-5997-struct.rs
src/test/compile-fail/nested-ty-params.rs
src/test/compile-fail/type-arg-out-of-scope.rs

index 9c00b8adfa3311da96c389aeec09d8905a3aa54f..5831ab850d393f3cc893525a10ff63531626badf 100644 (file)
@@ -3507,8 +3507,9 @@ fn upvarify(&mut self,
                         // 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 @@ fn upvarify(&mut self,
                         // 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;
index 7500c23e006a2e69de06860cd56a2182815e68df..c9539b1d9a3f93a781acd2dc9153ff5fb51e2301 100644 (file)
@@ -95,8 +95,9 @@ fn fold_ty(&mut self, t: ty::t) -> ty::t {
                                               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)
index f03665febd22b4e7a1cef5d114c9c16ede314bb6..4e5dc652fb5d61df1f7e2ef3ee404b4d5ce07e53 100644 (file)
@@ -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() { }
index 1fb71f01d06d32367ae76c831a72253818d57b6e..5b3e343deeaaf00f38be0e845001a62d29272e73 100644 (file)
@@ -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`
     }
index 5be0a1e708babe6a4a6976e9087206b78595a6dc..be49ca1fe06a73742a8fa5f086b2629736695d2d 100644 (file)
@@ -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
     }
 
index 951f991f106969c8a3539beba9f1ce59eb8fdf50..7be01b4abb4b9950d21cbb8e81314f0999eb0e8f 100644 (file)
@@ -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
 }
index ad31b851024eab833027808802cfcdcb35766d5d..b2a63ed1c7b8f7f6360a135fc7211a76f81f4b64 100644 (file)
@@ -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
 }
index 7b7ce6bee2ffbb8ac71cfa153d26bbb72d455394..0ee2a3add8721252294946f5ad0492c5bdfe67cd 100644 (file)
@@ -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]; }
 
index 240b1aa06d472853d02ba0850fe9a035895c9e9e..ac2f9d0379f64d1a63bd3c468ceb032e53bca8c6 100644 (file)
@@ -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) { }
 }