Update various tests and libraries that were incorrectly

annotated.
This commit is contained in:
Niko Matsakis 2013-10-29 06:14:59 -04:00
parent f57a28b2db
commit 5e54a7323d
31 changed files with 156 additions and 108 deletions

View 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

View File

@ -233,10 +233,10 @@ impl<T:Send> MutexArc<T> {
/// 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 @@ impl<T:Freeze + Send> MutexArc<T> {
/// 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 @@ impl<T:Freeze + Send> RWArc<T> {
/// 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 @@ impl<'self, T:Freeze + Send> RWWriteMode<'self, T> {
}
/// 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,

View 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);

View 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,

View File

@ -14,6 +14,7 @@ use middle::trans::common::*;
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.

View File

@ -28,10 +28,11 @@ impl Trait<int> for 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() {}

View 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() {}

View 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;

View 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() {}

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

View 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() {

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

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

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

View 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!();
}

View File

@ -14,12 +14,6 @@
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

View File

@ -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() {}

View 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() {

View File

@ -8,16 +8,10 @@
// option. This file may not be copied, modified, or distributed
// except according to those terms.
struct item_ty_yes0<'self> {
x: &'self uint
}
// Test that anonymous lifetimes are not permitted in enum declarations
struct item_ty_yes1<'self> {
x: &'self uint
}
struct item_ty_yes2 {
x: &'a uint //~ ERROR only 'self is allowed
enum Foo {
Bar(&int) //~ ERROR missing lifetime specifier
}
fn main() {}

View 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() {}

View File

@ -8,18 +8,10 @@
// 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;
// Test that anonymous lifetimes are not permitted in struct declarations
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;
}
struct Foo {
x: &int //~ ERROR missing lifetime specifier
}
fn main() {
}
fn main() {}

View 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() {}

View 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() {
}

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

View File

@ -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() {
}

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

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