]> git.lizzy.rs Git - rust.git/commitdiff
Update various tests and libraries that were incorrectly
authorNiko Matsakis <niko@alum.mit.edu>
Tue, 29 Oct 2013 10:14:59 +0000 (06:14 -0400)
committerNiko Matsakis <niko@alum.mit.edu>
Sat, 9 Nov 2013 00:45:50 +0000 (19:45 -0500)
annotated.

37 files changed:
Makefile.in
src/libextra/arc.rs
src/librustc/driver/driver.rs
src/librustc/metadata/tydecode.rs
src/librustc/middle/trans/type_of.rs
src/test/compile-fail/bad-mid-path-type-params.rs
src/test/compile-fail/core-tls-store-pointer.rs
src/test/compile-fail/issue-4335.rs
src/test/compile-fail/issue-5216.rs
src/test/compile-fail/kindck-owned-trait-contains.rs
src/test/compile-fail/regions-addr-of-arg.rs
src/test/compile-fail/regions-addr-of-self.rs
src/test/compile-fail/regions-addr-of-upvar-self.rs
src/test/compile-fail/regions-blk.rs [deleted file]
src/test/compile-fail/regions-fn-subtyping.rs
src/test/compile-fail/regions-free-region-ordering-callee.rs
src/test/compile-fail/regions-free-region-ordering-caller.rs
src/test/compile-fail/regions-free-region-ordering-caller1.rs [new file with mode: 0644]
src/test/compile-fail/regions-in-consts.rs
src/test/compile-fail/regions-in-enums-anon.rs [new file with mode: 0644]
src/test/compile-fail/regions-in-enums.rs
src/test/compile-fail/regions-in-structs-anon.rs [new file with mode: 0644]
src/test/compile-fail/regions-in-structs.rs
src/test/compile-fail/regions-in-type-items.rs [deleted file]
src/test/compile-fail/regions-infer-region-in-fn-but-not-type.rs
src/test/compile-fail/regions-ret-borrowed-1.rs
src/test/compile-fail/regions-undeclared.rs [new file with mode: 0644]
src/test/compile-fail/trait-impl-different-num-params.rs
src/test/run-pass/region-dependent-addr-of.rs [deleted file]
src/test/run-pass/region-dependent-autofn.rs [deleted file]
src/test/run-pass/region-dependent-autoslice.rs [deleted file]
src/test/run-pass/region-return-interior-of-option.rs [deleted file]
src/test/run-pass/regions-dependent-addr-of.rs [new file with mode: 0644]
src/test/run-pass/regions-dependent-autofn.rs [new file with mode: 0644]
src/test/run-pass/regions-dependent-autoslice.rs [new file with mode: 0644]
src/test/run-pass/regions-mock-trans.rs
src/test/run-pass/regions-return-interior-of-option.rs [new file with mode: 0644]

index b927c805220f40cc79c5877bf43a87e5abb495f5..f5bb3cb2ed00fcdacc16ea594ac04f11a60d005c 100644 (file)
@@ -125,6 +125,7 @@ ifdef TRACE
   CFG_RUSTC_FLAGS += -Z trace
 endif
 ifndef DEBUG_BORROWS
+  RUSTFLAGS_STAGE0 += -Z no-debug-borrows
   RUSTFLAGS_STAGE1 += -Z no-debug-borrows
   RUSTFLAGS_STAGE2 += -Z no-debug-borrows
 endif
index df67b1c9cc1df6a3119ec48ea2c3263f62a2b6fa..b3da9b4f16b889f270f1dacedb061d120bc2018e 100644 (file)
@@ -233,10 +233,10 @@ pub unsafe fn unsafe_access<U>(&self, blk: &fn(x: &mut T) -> U) -> U {
 
     /// As unsafe_access(), but with a condvar, as sync::mutex.lock_cond().
     #[inline]
-    pub unsafe fn unsafe_access_cond<'x, 'c, U>(&self,
-                                         blk: &fn(x: &'x mut T,
-                                                  c: &'c Condvar) -> U)
-                                         -> U {
+    pub unsafe fn unsafe_access_cond<U>(&self,
+                                        blk: &fn(x: &mut T,
+                                                 c: &Condvar) -> U)
+                                        -> U {
         let state = self.x.get();
         do (&(*state).lock).lock_cond |cond| {
             check_poison(true, (*state).failed);
@@ -290,10 +290,10 @@ pub fn access<U>(&self, blk: &fn(x: &mut T) -> U) -> U {
 
     /// As unsafe_access_cond but safe and Freeze.
     #[inline]
-    pub fn access_cond<'x, 'c, U>(&self,
-                                  blk: &fn(x: &'x mut T,
-                                           c: &'c Condvar) -> U)
-                                  -> U {
+    pub fn access_cond<U>(&self,
+                          blk: &fn(x: &mut T,
+                                   c: &Condvar) -> U)
+                          -> U {
         unsafe { self.unsafe_access_cond(blk) }
     }
 }
@@ -402,9 +402,9 @@ pub fn write<U>(&self, blk: &fn(x: &mut T) -> U) -> U {
 
     /// As write(), but with a condvar, as sync::rwlock.write_cond().
     #[inline]
-    pub fn write_cond<'x, 'c, U>(&self,
-                                 blk: &fn(x: &'x mut T, c: &'c Condvar) -> U)
-                                 -> U {
+    pub fn write_cond<U>(&self,
+                         blk: &fn(x: &mut T, c: &Condvar) -> U)
+                         -> U {
         unsafe {
             let state = self.x.get();
             do (*borrow_rwlock(state)).write_cond |cond| {
@@ -554,9 +554,9 @@ pub fn write<U>(&mut self, blk: &fn(x: &mut T) -> U) -> U {
     }
 
     /// Access the pre-downgrade RWArc in write mode with a condvar.
-    pub fn write_cond<'x, 'c, U>(&mut self,
-                                 blk: &fn(x: &'x mut T, c: &'c Condvar) -> U)
-                                 -> U {
+    pub fn write_cond<U>(&mut self,
+                         blk: &fn(x: &mut T, c: &Condvar) -> U)
+                         -> U {
         match *self {
             RWWriteMode {
                 data: &ref mut data,
index 380991266822ca217a6e12979b9736443b86de41..6346e4856f2d1a57a310f3e96cfb7ffb96751df9 100644 (file)
@@ -249,10 +249,7 @@ pub fn phase_3_run_analysis_passes(sess: Session,
                         freevars::annotate_freevars(def_map, crate));
 
     let region_map = time(time_passes, "region resolution", (), |_|
-                          middle::region::resolve_crate(sess, def_map, crate));
-
-    let rp_set = time(time_passes, "region parameterization inference", (), |_|
-                      middle::region::determine_rp_in_crate(sess, ast_map, def_map, crate));
+                          middle::region::resolve_crate(sess, crate));
 
     let ty_cx = ty::mk_ctxt(sess, def_map, named_region_map, ast_map, freevars,
                             region_map, lang_items);
index 1636205c76d626ccde8cde1ad2311c8599aea8b2..6e06cef55ee22b89d2cc4cb57dc70b84b3729edd 100644 (file)
@@ -363,18 +363,18 @@ fn parse_ty(st: &mut PState, conv: conv_did) -> ty::t {
         return ty::mk_param(st.tcx, parse_uint(st), did);
       }
       's' => {
-        let did = parse_def(st, TypeParameter, conv);
+        let did = parse_def(st, TypeParameter, |x,y| conv(x,y));
         return ty::mk_self(st.tcx, did);
       }
-      '@' => return ty::mk_box(st.tcx, parse_mt(st, conv)),
-      '~' => return ty::mk_uniq(st.tcx, parse_mt(st, conv)),
-      '*' => return ty::mk_ptr(st.tcx, parse_mt(st, conv)),
+      '@' => return ty::mk_box(st.tcx, parse_mt(st, |x,y| conv(x,y))),
+      '~' => return ty::mk_uniq(st.tcx, parse_mt(st, |x,y| conv(x,y))),
+      '*' => return ty::mk_ptr(st.tcx, parse_mt(st, |x,y| conv(x,y))),
       '&' => {
-        let r = parse_region(st);
-        let mt = parse_mt(st, conv);
+        let r = parse_region(st, |x,y| conv(x,y));
+        let mt = parse_mt(st, |x,y| conv(x,y));
         return ty::mk_rptr(st.tcx, r, mt);
       }
-      'U' => return ty::mk_unboxed_vec(st.tcx, parse_mt(st, conv)),
+      'U' => return ty::mk_unboxed_vec(st.tcx, parse_mt(st, |x,y| conv(x,y))),
       'V' => {
         let mt = parse_mt(st, |x,y| conv(x,y));
         let v = parse_vstore(st, |x,y| conv(x,y));
@@ -392,10 +392,10 @@ fn parse_ty(st: &mut PState, conv: conv_did) -> ty::t {
         return ty::mk_tup(st.tcx, params);
       }
       'f' => {
-        return ty::mk_closure(st.tcx, parse_closure_ty(st, conv));
+        return ty::mk_closure(st.tcx, parse_closure_ty(st, |x,y| conv(x,y)));
       }
       'F' => {
-        return ty::mk_bare_fn(st.tcx, parse_bare_fn_ty(st, conv));
+        return ty::mk_bare_fn(st.tcx, parse_bare_fn_ty(st, |x,y| conv(x,y)));
       }
       'Y' => return ty::mk_type(st.tcx),
       'C' => {
@@ -417,7 +417,7 @@ fn parse_ty(st: &mut PState, conv: conv_did) -> ty::t {
                 pos: pos,
                 .. *st
             };
-            let tt = parse_ty(&mut ps, conv);
+            let tt = parse_ty(&mut ps, |x,y| conv(x,y));
             st.tcx.rcache.insert(key, tt);
             return tt;
           }
@@ -449,7 +449,7 @@ fn parse_mutability(st: &mut PState) -> ast::Mutability {
 
 fn parse_mt(st: &mut PState, conv: conv_did) -> ty::mt {
     let m = parse_mutability(st);
-    ty::mt { ty: parse_ty(st, conv), mutbl: m }
+    ty::mt { ty: parse_ty(st, |x,y| conv(x,y)), mutbl: m }
 }
 
 fn parse_def(st: &mut PState, source: DefIdSource,
index 604321a0492a117728db3772764cd95152b20109..36af13d34e6565a35bb92bb50d7029d3b62c617f 100644 (file)
@@ -14,6 +14,7 @@
 use middle::trans::foreign;
 use middle::ty;
 use util::ppaux;
+use util::ppaux::Repr;
 
 use middle::trans::type_::Type;
 
@@ -172,14 +173,16 @@ pub fn sizing_type_of(cx: &mut CrateContext, t: ty::t) -> Type {
 
 // NB: If you update this, be sure to update `sizing_type_of()` as well.
 pub fn type_of(cx: &mut CrateContext, t: ty::t) -> Type {
-    debug!("type_of {:?}: {:?}", t, ty::get(t));
-
     // Check the cache.
     match cx.lltypes.find(&t) {
-        Some(&t) => return t,
+        Some(&llty) => {
+            return llty;
+        }
         None => ()
     }
 
+    debug!("type_of {} {:?}", t.repr(cx.tcx), t);
+
     // Replace any typedef'd types with their equivalent non-typedef
     // type. This ensures that all LLVM nominal types that contain
     // Rust types are defined as the same LLVM types.  If we don't do
@@ -189,6 +192,12 @@ pub fn type_of(cx: &mut CrateContext, t: ty::t) -> Type {
 
     if t != t_norm {
         let llty = type_of(cx, t_norm);
+        debug!("--> normalized {} {:?} to {} {:?} llty={}",
+                t.repr(cx.tcx),
+                t,
+                t_norm.repr(cx.tcx),
+                t_norm,
+                cx.tn.type_to_str(llty));
         cx.lltypes.insert(t, llty);
         return llty;
     }
@@ -299,6 +308,10 @@ pub fn type_of(cx: &mut CrateContext, t: ty::t) -> Type {
       ty::ty_err(*) => cx.tcx.sess.bug("type_of with ty_err")
     };
 
+    debug!("--> mapped t={} {:?} to llty={}",
+            t.repr(cx.tcx),
+            t,
+            cx.tn.type_to_str(llty));
     cx.lltypes.insert(t, llty);
 
     // If this was an enum or struct, fill in the type now.
index f9f4ccf0f07519e9a0e7a2fe1286de1cb4d184b3..90d6147f0eda3416956c715d62251930a2cafd76 100644 (file)
@@ -28,10 +28,11 @@ fn new<U>(x: int, _: U) -> S2 {
     }
 }
 
-fn main() {
+fn foo<'a>() {
     let _ = S::new::<int,f64>(1, 1.0);    //~ ERROR the impl referenced by this path has 1 type parameter, but 0 type parameters were supplied
-    let _ = S::<'self,int>::new::<f64>(1, 1.0);  //~ ERROR this impl has no lifetime parameter
+    let _ = S::<'a,int>::new::<f64>(1, 1.0);  //~ ERROR expected 0 lifetime parameter(s)
     let _: S2 = Trait::new::<int,f64>(1, 1.0);    //~ ERROR the trait referenced by this path has 1 type parameter, but 0 type parameters were supplied
-    let _: S2 = Trait::<'self,int>::new::<f64>(1, 1.0);   //~ ERROR this trait has no lifetime parameter
+    let _: S2 = Trait::<'a,int>::new::<f64>(1, 1.0);   //~ ERROR expected 0 lifetime parameter(s)
 }
 
+fn main() {}
index 4f60391892da37439f1fe84fc20ddd15c086e6ed..70573ca4f180cd3ff660e85eef31d1aff9f56f66 100644 (file)
@@ -13,6 +13,6 @@
 use std::local_data;
 
 local_data_key!(key: @&int)
-//~^ ERROR only 'static is allowed
+//~^ ERROR missing lifetime specifier
 
 fn main() {}
index 5b6240d8ac83b5457ee57e2e3841ab0babd9fa65..032b2564f4fb2d5ea3b12d827bf6ff95cb96c8e9 100644 (file)
@@ -10,7 +10,7 @@
 
 fn id<T>(t: T) -> T { t }
 
-fn f<'r, T>(v: &'r T) -> &'r fn()->T { id::<&'r fn()->T>(|| *v) } //~ ERROR cannot infer an appropriate lifetime due to conflicting requirements
+fn f<'r, T>(v: &'r T) -> &'r fn()->T { id::<&'r fn()->T>(|| *v) } //~ ERROR cannot infer an appropriate lifetime
 
 fn main() {
     let v = &5;
index 9f88ba72f059aff0fd5c1554f11f59946d3c1005..8205a6dae64704714081991b0dfd2d5f0f6f0180 100644 (file)
@@ -9,12 +9,12 @@
 // except according to those terms.
 
 fn f() { }
-struct S(&fn()); //~ ERROR Illegal anonymous lifetime
-pub static C: S = S(f); //~ ERROR Illegal anonymous lifetime
+struct S(&fn()); //~ ERROR missing lifetime specifier
+pub static C: S = S(f);
 
 
 fn g() { }
-type T = &fn(); //~ ERROR Illegal anonymous lifetime
-pub static D: T = g; //~ ERROR Illegal anonymous lifetime
+type T = &fn();  //~ ERROR missing lifetime specifier
+pub static D: T = g;
 
 fn main() {}
index fb85edf699a9bd15313d18a69aee373dfc82affc..5fe9b13f83befeb30a22a18d99ac7be3510fc3bb 100644 (file)
@@ -8,29 +8,24 @@
 // option. This file may not be copied, modified, or distributed
 // except according to those terms.
 
-#[feature(managed_boxes)];
+trait Repeat<A> { fn get(&self) -> A; }
 
-trait repeat<A> { fn get(&self) -> A; }
-
-impl<A:Clone> repeat<A> for @A {
-    fn get(&self) -> A { **self }
+impl<A:Clone> Repeat<A> for A {
+    fn get(&self) -> A { self.clone() }
 }
 
-fn repeater<A:Clone>(v: @A) -> @repeat<A> {
-    // Note: owned kind is not necessary as A appears in the trait type
-    @v as @repeat<A> // No
+fn repeater<A:Clone>(v: A) -> ~Repeat:<A> {
+    ~v as ~Repeat:<A> // No
 }
 
 fn main() {
     // Error results because the type of is inferred to be
-    // @repeat<&'blk int> where blk is the lifetime of the block below.
+    // ~Repeat<&'blk int> where blk is the lifetime of the block below.
 
-    let y = { //~ ERROR lifetime of variable does not enclose its declaration
-        let x: &'blk int = &3;
-        repeater(@x)
+    let y = {
+        let tmp0 = 3;
+        let tmp1 = &tmp0; //~ ERROR borrowed value does not live long enough
+        repeater(tmp1)
     };
     assert!(3 == *(y.get()));
-    //~^ ERROR dereference of reference outside its lifetime
-    //~^^ ERROR automatically borrowed pointer is not valid at the time of borrow
-    //~^^^ ERROR lifetime of return value does not outlive the function call
 }
index 4fff5a6f87c786ea5047bacbeabefc30f275044a..ff13548b4946f9417e655dc7950799fa90dbc022 100644 (file)
@@ -8,12 +8,19 @@
 // option. This file may not be copied, modified, or distributed
 // except according to those terms.
 
+// Check that taking the address of an argument yields a lifetime
+// bounded by the current function call.
+
 fn foo(a: int) {
     let _p: &'static int = &a; //~ ERROR borrowed value does not live long enough
 }
 
 fn bar(a: int) {
-    let _q: &'blk int = &a;
+    let _q: &int = &a;
+}
+
+fn zed<'a>(a: int) -> &'a int {
+    &a //~ ERROR borrowed value does not live long enough
 }
 
 fn main() {
index 3a480a7e9631c1cdad3f300c5cd357bdaf126e28..b7be0dd7b9b1e65365a445f8acb12cd8dd8a82f3 100644 (file)
@@ -14,12 +14,12 @@ struct dog {
 
 impl dog {
     pub fn chase_cat(&mut self) {
-        let p: &'static mut uint = &mut self.cats_chased; //~ ERROR cannot infer an appropriate lifetime due to conflicting requirements
+        let p: &'static mut uint = &mut self.cats_chased; //~ ERROR cannot infer an appropriate lifetime
         *p += 1u;
     }
 
     pub fn chase_cat_2(&mut self) {
-        let p: &'blk mut uint = &mut self.cats_chased;
+        let p: &mut uint = &mut self.cats_chased;
         *p += 1u;
     }
 }
index 9cedf86f35056aaed7b313a2fe03b9a6575bb651..2f60898cfeef152e094dc9b02ad9199c14e81115 100644 (file)
@@ -17,7 +17,7 @@ struct dog {
 impl dog {
     pub fn chase_cat(&mut self) {
         let _f = || {
-            let p: &'static mut uint = &mut self.food; //~ ERROR cannot infer an appropriate lifetime due to conflicting requirements
+            let p: &'static mut uint = &mut self.food; //~ ERROR cannot infer an appropriate lifetime
             *p = 3u;
         };
     }
diff --git a/src/test/compile-fail/regions-blk.rs b/src/test/compile-fail/regions-blk.rs
deleted file mode 100644 (file)
index 893e4c4..0000000
+++ /dev/null
@@ -1,25 +0,0 @@
-// Copyright 2012 The Rust Project Developers. See the COPYRIGHT
-// file at the top-level directory of this distribution and at
-// http://rust-lang.org/COPYRIGHT.
-//
-// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
-// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
-// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
-// option. This file may not be copied, modified, or distributed
-// except according to those terms.
-
-fn foo(cond: bool) {
-    let x = 5;
-    let mut y: &'blk int = &x;
-
-    let mut z: &'blk int;
-    if cond {
-        z = &x; //~ ERROR cannot infer an appropriate lifetime due to conflicting requirements
-    } else {
-        let w: &'blk int = &x;
-        z = w;
-    }
-}
-
-fn main() {
-}
index 5928d31a66860479ad0b0523a4cb8e946c8cbf96..cad73daa46b157f7806fd93a099cbc6a80f8204e 100644 (file)
@@ -24,9 +24,9 @@ fn test_fn<'x,'y,'z,T>(_x: &'x T, _y: &'y T, _z: &'z T) {
         of::<&fn<'b>(&'b T)>());
 
     subtype::<&fn<'b>(&'b T)>(
-        of::<&fn<'x>(&'x T)>());
+        of::<&fn(&'x T)>());
 
-    subtype::<&fn<'x>(&'x T)>(
+    subtype::<&fn(&'x T)>(
         of::<&fn<'b>(&'b T)>());  //~ ERROR mismatched types
 
     subtype::<&fn<'a,'b>(&'a T, &'b T)>(
@@ -36,9 +36,9 @@ fn test_fn<'x,'y,'z,T>(_x: &'x T, _y: &'y T, _z: &'z T) {
         of::<&fn<'a,'b>(&'a T, &'b T)>()); //~ ERROR mismatched types
 
     subtype::<&fn<'a,'b>(&'a T, &'b T)>(
-        of::<&fn<'x,'y>(&'x T, &'y T)>());
+        of::<&fn(&'x T, &'y T)>());
 
-    subtype::<&fn<'x,'y>(&'x T, &'y T)>(
+    subtype::<&fn(&'x T, &'y T)>(
         of::<&fn<'a,'b>(&'a T, &'b T)>()); //~ ERROR mismatched types
 }
 
index 66ab4b7705433851896c2f167a315e05bac63d9e..fb31e477ba279658a8e85e6a0ff73eb6aa019c3c 100644 (file)
@@ -26,7 +26,7 @@ fn ordering2<'a, 'b>(x: &'a &'b uint, y: &'a uint) -> &'b uint {
 fn ordering3<'a, 'b>(x: &'a uint, y: &'b uint) -> &'a &'b uint {
     // Do not infer an ordering from the return value.
     let z: &'b uint = &*x;
-    //~^ ERROR cannot infer an appropriate lifetime due to conflicting requirements
+    //~^ ERROR cannot infer an appropriate lifetime
     fail!();
 }
 
index c9859899ea4f1132349beea335a804839711b4bb..58fa437a6a365b2c5947005756ff1339a11d3b0a 100644 (file)
 
 struct Paramd<'self> { x: &'self uint }
 
-fn call1<'a>(x: &'a uint) {
-    let y: uint = 3;
-    let z: &'a &'blk uint = &(&y);
-    //~^ ERROR pointer has a longer lifetime than the data it references
-}
-
 fn call2<'a, 'b>(a: &'a uint, b: &'b uint) {
     let z: Option<&'b &'a uint> = None;
     //~^ ERROR pointer has a longer lifetime than the data it references
diff --git a/src/test/compile-fail/regions-free-region-ordering-caller1.rs b/src/test/compile-fail/regions-free-region-ordering-caller1.rs
new file mode 100644 (file)
index 0000000..1408f75
--- /dev/null
@@ -0,0 +1,24 @@
+// Copyright 2012 The Rust Project Developers. See the COPYRIGHT
+// file at the top-level directory of this distribution and at
+// http://rust-lang.org/COPYRIGHT.
+//
+// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
+// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
+// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
+// option. This file may not be copied, modified, or distributed
+// except according to those terms.
+
+// Test various ways to construct a pointer with a longer lifetime
+// than the thing it points at and ensure that they result in
+// errors. See also regions-free-region-ordering-callee.rs
+
+fn call1<'a>(x: &'a uint) {
+    // Test that creating a pointer like
+    // &'a &'z uint requires that 'a <= 'z:
+    let y: uint = 3;
+    let z: &'a & uint = &(&y);
+    //~^ ERROR borrowed value does not live long enough
+    //~^^ ERROR borrowed value does not live long enough
+}
+
+fn main() {}
index c34e5fb29de5ac71fffa5b992542145c172e3d90..9f2facf4e1f9f35ea91031aa66c50f42efe29af5 100644 (file)
@@ -8,8 +8,7 @@
 // option. This file may not be copied, modified, or distributed
 // except according to those terms.
 
-static c_x: &'blk int = &22; //~ ERROR Illegal lifetime 'blk: only 'static is allowed here
-static c_y: &int = &22; //~ ERROR Illegal anonymous lifetime: only 'static is allowed here
+static c_y: &int = &22; //~ ERROR missing lifetime specifier
 static c_z: &'static int = &22;
 
 fn main() {
diff --git a/src/test/compile-fail/regions-in-enums-anon.rs b/src/test/compile-fail/regions-in-enums-anon.rs
new file mode 100644 (file)
index 0000000..5c7a37d
--- /dev/null
@@ -0,0 +1,17 @@
+// Copyright 2012 The Rust Project Developers. See the COPYRIGHT
+// file at the top-level directory of this distribution and at
+// http://rust-lang.org/COPYRIGHT.
+//
+// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
+// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
+// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
+// option. This file may not be copied, modified, or distributed
+// except according to those terms.
+
+// Test that anonymous lifetimes are not permitted in enum declarations
+
+enum Foo {
+    Bar(&int) //~ ERROR missing lifetime specifier
+}
+
+fn main() {}
index f189deef32e5de08a468429288efb264ec4d0bd4..0a221b9a533909f563dc374dfc4a728a537e37b2 100644 (file)
@@ -8,17 +8,23 @@
 // option. This file may not be copied, modified, or distributed
 // except according to those terms.
 
+// Test that lifetimes must be declared for use on enums.
+// See also regions-undeclared.rs
+
 enum yes0<'lt> {
-    // This will eventually be legal (and in fact the only way):
-    X3(&'lt uint) //~ ERROR Illegal lifetime 'lt: only 'self is allowed
+    X3(&'lt uint)
 }
 
 enum yes1<'self> {
     X4(&'self uint)
 }
 
-enum yes2 {
-    X5(&'foo uint) //~ ERROR Illegal lifetime 'foo: only 'self is allowed
+enum no0 {
+    X5(&'foo uint) //~ ERROR use of undeclared lifetime name `'foo`
+}
+
+enum no1 {
+    X6(&'self uint) //~ ERROR use of undeclared lifetime name `'self`
 }
 
 fn main() {}
diff --git a/src/test/compile-fail/regions-in-structs-anon.rs b/src/test/compile-fail/regions-in-structs-anon.rs
new file mode 100644 (file)
index 0000000..0f2036a
--- /dev/null
@@ -0,0 +1,17 @@
+// Copyright 2012 The Rust Project Developers. See the COPYRIGHT
+// file at the top-level directory of this distribution and at
+// http://rust-lang.org/COPYRIGHT.
+//
+// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
+// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
+// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
+// option. This file may not be copied, modified, or distributed
+// except according to those terms.
+
+// Test that anonymous lifetimes are not permitted in struct declarations
+
+struct Foo {
+    x: &int //~ ERROR missing lifetime specifier
+}
+
+fn main() {}
index c4f1a8ae465eccc788eb7aaad182458cba72f6be..1e74fa4adb9f6288229f4a0cb6d4e4c3abfe872f 100644 (file)
@@ -8,16 +8,18 @@
 // option. This file may not be copied, modified, or distributed
 // except according to those terms.
 
-struct yes0<'self> {
-  x: &uint, //~ ERROR Illegal anonymous lifetime: anonymous lifetimes are not permitted here
-}
-
 struct yes1<'self> {
   x: &'self uint,
 }
 
-struct yes2<'self> {
-  x: &'foo uint, //~ ERROR Illegal lifetime 'foo: only 'self is allowed
+struct yes2<'a> {
+  x: &'a uint,
 }
 
+struct StructDecl {
+    a: &'a int, //~ ERROR use of undeclared lifetime name `'a`
+    b: &'self int, //~ ERROR use of undeclared lifetime name `'self`
+}
+
+
 fn main() {}
diff --git a/src/test/compile-fail/regions-in-type-items.rs b/src/test/compile-fail/regions-in-type-items.rs
deleted file mode 100644 (file)
index a30a677..0000000
+++ /dev/null
@@ -1,23 +0,0 @@
-// Copyright 2012 The Rust Project Developers. See the COPYRIGHT
-// file at the top-level directory of this distribution and at
-// http://rust-lang.org/COPYRIGHT.
-//
-// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
-// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
-// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
-// option. This file may not be copied, modified, or distributed
-// except according to those terms.
-
-struct item_ty_yes0<'self> {
-    x: &'self uint
-}
-
-struct item_ty_yes1<'self> {
-    x: &'self uint
-}
-
-struct item_ty_yes2 {
-    x: &'a uint //~ ERROR only 'self is allowed
-}
-
-fn main() {}
index 4c3338d2e1d0c52afc968d4f5cb2e588780279f5..5c979955ec9ae4fdab6282a1232292170b27c91a 100644 (file)
@@ -13,7 +13,7 @@
 // contains region pointers
 struct foo(~fn(x: &int));
 
-fn take_foo(x: foo<'static>) {} //~ ERROR no region bound is allowed on `foo`
+fn take_foo(x: foo<'static>) {} //~ ERROR wrong number of lifetime parameters
 
 fn main() {
 }
index df7831e905056fab4372e4e5f52a6b1085c09101..ee6ed3b0d76f631f872a8993a91541f02a62d1af 100644 (file)
@@ -12,7 +12,7 @@
 // some point regions-ret-borrowed reported an error but this file did
 // not, due to special hardcoding around the anonymous region.
 
-fn with<'a, R>(f: &fn(x: &'a int) -> R) -> R {
+fn with<R>(f: &fn<'a>(x: &'a int) -> R) -> R {
     f(&3)
 }
 
diff --git a/src/test/compile-fail/regions-undeclared.rs b/src/test/compile-fail/regions-undeclared.rs
new file mode 100644 (file)
index 0000000..fcf3a73
--- /dev/null
@@ -0,0 +1,23 @@
+// Copyright 2012 The Rust Project Developers. See the COPYRIGHT
+// file at the top-level directory of this distribution and at
+// http://rust-lang.org/COPYRIGHT.
+//
+// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
+// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
+// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
+// option. This file may not be copied, modified, or distributed
+// except according to those terms.
+
+static c_x: &'blk int = &22; //~ ERROR use of undeclared lifetime name `'blk`
+
+enum EnumDecl {
+    Foo(&'a int), //~ ERROR use of undeclared lifetime name `'a`
+    Bar(&'self int), //~ ERROR use of undeclared lifetime name `'self`
+}
+
+fn fnDecl(x: &'a int, //~ ERROR use of undeclared lifetime name `'a`
+          y: &'self int) //~ ERROR use of undeclared lifetime name `'self`
+{}
+
+fn main() {
+}
index 7039e050199587ff4a54c2ea00ccb607bae3e739..940c1b3a237b8bbd9d20065008e60831f2c4de93 100644 (file)
@@ -13,7 +13,7 @@ trait foo {
 }
 impl foo for int {
     fn bar(&self) -> int {
-        //~^ ERROR method `bar` has 0 parameters but the trait has 1
+        //~^ ERROR method `bar` has 0 parameter(s) but the trait has 1
         *self
     }
 }
diff --git a/src/test/run-pass/region-dependent-addr-of.rs b/src/test/run-pass/region-dependent-addr-of.rs
deleted file mode 100644 (file)
index d8076f5..0000000
+++ /dev/null
@@ -1,118 +0,0 @@
-// Copyright 2012 The Rust Project Developers. See the COPYRIGHT
-// file at the top-level directory of this distribution and at
-// http://rust-lang.org/COPYRIGHT.
-//
-// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
-// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
-// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
-// option. This file may not be copied, modified, or distributed
-// except according to those terms.
-
-// Test lifetimes are linked properly when we create dependent region pointers.
-// Issue #3148.
-
-struct A {
-    value: B
-}
-
-struct B {
-    v1: int,
-    v2: [int, ..3],
-    v3: ~[int],
-    v4: C,
-    v5: ~C,
-    v6: Option<C>
-}
-
-struct C {
-    f: int
-}
-
-fn get_v1<'v>(a: &'v A) -> &'v int {
-    // Region inferencer must deduce that &v < L2 < L1
-    let foo = &a.value; // L1
-    &foo.v1             // L2
-}
-
-fn get_v2<'v>(a: &'v A, i: uint) -> &'v int {
-    let foo = &a.value;
-    &foo.v2[i]
-}
-
-fn get_v3<'v>(a: &'v A, i: uint) -> &'v int {
-    let foo = &a.value;
-    &foo.v3[i]
-}
-
-fn get_v4<'v>(a: &'v A, _i: uint) -> &'v int {
-    let foo = &a.value;
-    &foo.v4.f
-}
-
-fn get_v5<'v>(a: &'v A, _i: uint) -> &'v int {
-    let foo = &a.value;
-    &foo.v5.f
-}
-
-fn get_v6_a<'v>(a: &'v A, _i: uint) -> &'v int {
-    match a.value.v6 {
-        Some(ref v) => &v.f,
-        None => fail!()
-    }
-}
-
-fn get_v6_b<'v>(a: &'v A, _i: uint) -> &'v int {
-    match *a {
-        A { value: B { v6: Some(ref v), _ } } => &v.f,
-        _ => fail!()
-    }
-}
-
-fn get_v6_c<'v>(a: &'v A, _i: uint) -> &'v int {
-    match a {
-        &A { value: B { v6: Some(ref v), _ } } => &v.f,
-        _ => fail!()
-    }
-}
-
-fn get_v5_ref<'v>(a: &'v A, _i: uint) -> &'v int {
-    match &a.value {
-        &B {v5: ~C {f: ref v}, _} => v
-    }
-}
-
-pub fn main() {
-    let a = A {value: B {v1: 22,
-                         v2: [23, 24, 25],
-                         v3: ~[26, 27, 28],
-                         v4: C { f: 29 },
-                         v5: ~C { f: 30 },
-                         v6: Some(C { f: 31 })}};
-
-    let p = get_v1(&a);
-    assert_eq!(*p, a.value.v1);
-
-    let p = get_v2(&a, 1);
-    assert_eq!(*p, a.value.v2[1]);
-
-    let p = get_v3(&a, 1);
-    assert_eq!(*p, a.value.v3[1]);
-
-    let p = get_v4(&a, 1);
-    assert_eq!(*p, a.value.v4.f);
-
-    let p = get_v5(&a, 1);
-    assert_eq!(*p, a.value.v5.f);
-
-    let p = get_v6_a(&a, 1);
-    assert_eq!(*p, a.value.v6.unwrap().f);
-
-    let p = get_v6_b(&a, 1);
-    assert_eq!(*p, a.value.v6.unwrap().f);
-
-    let p = get_v6_c(&a, 1);
-    assert_eq!(*p, a.value.v6.unwrap().f);
-
-    let p = get_v5_ref(&a, 1);
-    assert_eq!(*p, a.value.v5.f);
-}
diff --git a/src/test/run-pass/region-dependent-autofn.rs b/src/test/run-pass/region-dependent-autofn.rs
deleted file mode 100644 (file)
index bce2159..0000000
+++ /dev/null
@@ -1,22 +0,0 @@
-// Copyright 2012 The Rust Project Developers. See the COPYRIGHT
-// file at the top-level directory of this distribution and at
-// http://rust-lang.org/COPYRIGHT.
-//
-// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
-// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
-// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
-// option. This file may not be copied, modified, or distributed
-// except according to those terms.
-
-// Test lifetimes are linked properly when we autoslice a vector.
-// Issue #3148.
-
-fn subslice<'r>(v: &'r fn()) -> &'r fn() { v }
-
-fn both<'r>(v: &'r fn()) -> &'r fn() {
-    subslice(subslice(v))
-}
-
-pub fn main() {
-    both(main);
-}
diff --git a/src/test/run-pass/region-dependent-autoslice.rs b/src/test/run-pass/region-dependent-autoslice.rs
deleted file mode 100644 (file)
index dab8815..0000000
+++ /dev/null
@@ -1,23 +0,0 @@
-// Copyright 2012 The Rust Project Developers. See the COPYRIGHT
-// file at the top-level directory of this distribution and at
-// http://rust-lang.org/COPYRIGHT.
-//
-// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
-// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
-// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
-// option. This file may not be copied, modified, or distributed
-// except according to those terms.
-
-// Test lifetimes are linked properly when we autoslice a vector.
-// Issue #3148.
-
-fn subslice1<'r>(v: &'r [uint]) -> &'r [uint] { v }
-
-fn both<'r>(v: &'r [uint]) -> &'r [uint] {
-    subslice1(subslice1(v))
-}
-
-pub fn main() {
-    let v = ~[1,2,3];
-    both(v);
-}
diff --git a/src/test/run-pass/region-return-interior-of-option.rs b/src/test/run-pass/region-return-interior-of-option.rs
deleted file mode 100644 (file)
index aa46307..0000000
+++ /dev/null
@@ -1,32 +0,0 @@
-// Copyright 2012 The Rust Project Developers. See the COPYRIGHT
-// file at the top-level directory of this distribution and at
-// http://rust-lang.org/COPYRIGHT.
-//
-// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
-// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
-// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
-// option. This file may not be copied, modified, or distributed
-// except according to those terms.
-
-fn get<'r, T>(opt: &'r Option<T>) -> &'r T {
-    match *opt {
-      Some(ref v) => v,
-      None => fail!("none")
-    }
-}
-
-pub fn main() {
-    let mut x = Some(23);
-
-    {
-        let y = get(&x);
-        assert_eq!(*y, 23);
-    }
-
-    x = Some(24);
-
-    {
-        let y = get(&x);
-        assert_eq!(*y, 24);
-    }
-}
diff --git a/src/test/run-pass/regions-dependent-addr-of.rs b/src/test/run-pass/regions-dependent-addr-of.rs
new file mode 100644 (file)
index 0000000..d8076f5
--- /dev/null
@@ -0,0 +1,118 @@
+// Copyright 2012 The Rust Project Developers. See the COPYRIGHT
+// file at the top-level directory of this distribution and at
+// http://rust-lang.org/COPYRIGHT.
+//
+// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
+// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
+// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
+// option. This file may not be copied, modified, or distributed
+// except according to those terms.
+
+// Test lifetimes are linked properly when we create dependent region pointers.
+// Issue #3148.
+
+struct A {
+    value: B
+}
+
+struct B {
+    v1: int,
+    v2: [int, ..3],
+    v3: ~[int],
+    v4: C,
+    v5: ~C,
+    v6: Option<C>
+}
+
+struct C {
+    f: int
+}
+
+fn get_v1<'v>(a: &'v A) -> &'v int {
+    // Region inferencer must deduce that &v < L2 < L1
+    let foo = &a.value; // L1
+    &foo.v1             // L2
+}
+
+fn get_v2<'v>(a: &'v A, i: uint) -> &'v int {
+    let foo = &a.value;
+    &foo.v2[i]
+}
+
+fn get_v3<'v>(a: &'v A, i: uint) -> &'v int {
+    let foo = &a.value;
+    &foo.v3[i]
+}
+
+fn get_v4<'v>(a: &'v A, _i: uint) -> &'v int {
+    let foo = &a.value;
+    &foo.v4.f
+}
+
+fn get_v5<'v>(a: &'v A, _i: uint) -> &'v int {
+    let foo = &a.value;
+    &foo.v5.f
+}
+
+fn get_v6_a<'v>(a: &'v A, _i: uint) -> &'v int {
+    match a.value.v6 {
+        Some(ref v) => &v.f,
+        None => fail!()
+    }
+}
+
+fn get_v6_b<'v>(a: &'v A, _i: uint) -> &'v int {
+    match *a {
+        A { value: B { v6: Some(ref v), _ } } => &v.f,
+        _ => fail!()
+    }
+}
+
+fn get_v6_c<'v>(a: &'v A, _i: uint) -> &'v int {
+    match a {
+        &A { value: B { v6: Some(ref v), _ } } => &v.f,
+        _ => fail!()
+    }
+}
+
+fn get_v5_ref<'v>(a: &'v A, _i: uint) -> &'v int {
+    match &a.value {
+        &B {v5: ~C {f: ref v}, _} => v
+    }
+}
+
+pub fn main() {
+    let a = A {value: B {v1: 22,
+                         v2: [23, 24, 25],
+                         v3: ~[26, 27, 28],
+                         v4: C { f: 29 },
+                         v5: ~C { f: 30 },
+                         v6: Some(C { f: 31 })}};
+
+    let p = get_v1(&a);
+    assert_eq!(*p, a.value.v1);
+
+    let p = get_v2(&a, 1);
+    assert_eq!(*p, a.value.v2[1]);
+
+    let p = get_v3(&a, 1);
+    assert_eq!(*p, a.value.v3[1]);
+
+    let p = get_v4(&a, 1);
+    assert_eq!(*p, a.value.v4.f);
+
+    let p = get_v5(&a, 1);
+    assert_eq!(*p, a.value.v5.f);
+
+    let p = get_v6_a(&a, 1);
+    assert_eq!(*p, a.value.v6.unwrap().f);
+
+    let p = get_v6_b(&a, 1);
+    assert_eq!(*p, a.value.v6.unwrap().f);
+
+    let p = get_v6_c(&a, 1);
+    assert_eq!(*p, a.value.v6.unwrap().f);
+
+    let p = get_v5_ref(&a, 1);
+    assert_eq!(*p, a.value.v5.f);
+}
diff --git a/src/test/run-pass/regions-dependent-autofn.rs b/src/test/run-pass/regions-dependent-autofn.rs
new file mode 100644 (file)
index 0000000..bce2159
--- /dev/null
@@ -0,0 +1,22 @@
+// Copyright 2012 The Rust Project Developers. See the COPYRIGHT
+// file at the top-level directory of this distribution and at
+// http://rust-lang.org/COPYRIGHT.
+//
+// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
+// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
+// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
+// option. This file may not be copied, modified, or distributed
+// except according to those terms.
+
+// Test lifetimes are linked properly when we autoslice a vector.
+// Issue #3148.
+
+fn subslice<'r>(v: &'r fn()) -> &'r fn() { v }
+
+fn both<'r>(v: &'r fn()) -> &'r fn() {
+    subslice(subslice(v))
+}
+
+pub fn main() {
+    both(main);
+}
diff --git a/src/test/run-pass/regions-dependent-autoslice.rs b/src/test/run-pass/regions-dependent-autoslice.rs
new file mode 100644 (file)
index 0000000..dab8815
--- /dev/null
@@ -0,0 +1,23 @@
+// Copyright 2012 The Rust Project Developers. See the COPYRIGHT
+// file at the top-level directory of this distribution and at
+// http://rust-lang.org/COPYRIGHT.
+//
+// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
+// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
+// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
+// option. This file may not be copied, modified, or distributed
+// except according to those terms.
+
+// Test lifetimes are linked properly when we autoslice a vector.
+// Issue #3148.
+
+fn subslice1<'r>(v: &'r [uint]) -> &'r [uint] { v }
+
+fn both<'r>(v: &'r [uint]) -> &'r [uint] {
+    subslice1(subslice1(v))
+}
+
+pub fn main() {
+    let v = ~[1,2,3];
+    both(v);
+}
index e66a34b47bce044aa8faaba445120a485107ff5d..6740230728c6c9692fc7007603cca8fdcc0fb5b9 100644 (file)
@@ -30,7 +30,7 @@ struct Ccx {
 #[fixed_stack_segment] #[inline(never)]
 fn alloc<'a>(_bcx : &'a arena) -> &'a Bcx<'a> {
     unsafe {
-        cast::transmute(libc::malloc(mem::size_of::<Bcx<'blk>>()
+        cast::transmute(libc::malloc(mem::size_of::<Bcx<'a>>()
             as libc::size_t))
     }
 }
diff --git a/src/test/run-pass/regions-return-interior-of-option.rs b/src/test/run-pass/regions-return-interior-of-option.rs
new file mode 100644 (file)
index 0000000..aa46307
--- /dev/null
@@ -0,0 +1,32 @@
+// Copyright 2012 The Rust Project Developers. See the COPYRIGHT
+// file at the top-level directory of this distribution and at
+// http://rust-lang.org/COPYRIGHT.
+//
+// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
+// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
+// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
+// option. This file may not be copied, modified, or distributed
+// except according to those terms.
+
+fn get<'r, T>(opt: &'r Option<T>) -> &'r T {
+    match *opt {
+      Some(ref v) => v,
+      None => fail!("none")
+    }
+}
+
+pub fn main() {
+    let mut x = Some(23);
+
+    {
+        let y = get(&x);
+        assert_eq!(*y, 23);
+    }
+
+    x = Some(24);
+
+    {
+        let y = get(&x);
+        assert_eq!(*y, 24);
+    }
+}