Skip to content

Commit 0ea9024

Browse files
committed
---
yaml --- r: 146508 b: refs/heads/try2 c: 5e54a73 h: refs/heads/master v: v3
1 parent 65c899a commit 0ea9024

32 files changed

+157
-109
lines changed

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ refs/heads/snap-stage3: 78a7676898d9f80ab540c6df5d4c9ce35bb50463
55
refs/heads/try: 519addf6277dbafccbb4159db4b710c37eaa2ec5
66
refs/tags/release-0.1: 1f5c5126e96c79d22cb7862f75304136e204f105
77
refs/heads/ndm: f3868061cd7988080c30d6d5bf352a5a5fe2460b
8-
refs/heads/try2: f57a28b2dbb1823b88b5db270145a4f324820390
8+
refs/heads/try2: 5e54a7323dc3cc8b121de313b9af2d16424b086e
99
refs/heads/dist-snap: ba4081a5a8573875fed17545846f6f6902c8ba8d
1010
refs/tags/release-0.2: c870d2dffb391e14efb05aa27898f1f6333a9596
1111
refs/tags/release-0.3: b5f0d0f648d9a6153664837026ba1be43d3e2503

branches/try2/Makefile.in

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -125,6 +125,7 @@ ifdef TRACE
125125
CFG_RUSTC_FLAGS += -Z trace
126126
endif
127127
ifndef DEBUG_BORROWS
128+
RUSTFLAGS_STAGE0 += -Z no-debug-borrows
128129
RUSTFLAGS_STAGE1 += -Z no-debug-borrows
129130
RUSTFLAGS_STAGE2 += -Z no-debug-borrows
130131
endif

branches/try2/src/libextra/arc.rs

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -233,10 +233,10 @@ impl<T:Send> MutexArc<T> {
233233

234234
/// As unsafe_access(), but with a condvar, as sync::mutex.lock_cond().
235235
#[inline]
236-
pub unsafe fn unsafe_access_cond<'x, 'c, U>(&self,
237-
blk: &fn(x: &'x mut T,
238-
c: &'c Condvar) -> U)
239-
-> U {
236+
pub unsafe fn unsafe_access_cond<U>(&self,
237+
blk: &fn(x: &mut T,
238+
c: &Condvar) -> U)
239+
-> U {
240240
let state = self.x.get();
241241
do (&(*state).lock).lock_cond |cond| {
242242
check_poison(true, (*state).failed);
@@ -290,10 +290,10 @@ impl<T:Freeze + Send> MutexArc<T> {
290290

291291
/// As unsafe_access_cond but safe and Freeze.
292292
#[inline]
293-
pub fn access_cond<'x, 'c, U>(&self,
294-
blk: &fn(x: &'x mut T,
295-
c: &'c Condvar) -> U)
296-
-> U {
293+
pub fn access_cond<U>(&self,
294+
blk: &fn(x: &mut T,
295+
c: &Condvar) -> U)
296+
-> U {
297297
unsafe { self.unsafe_access_cond(blk) }
298298
}
299299
}
@@ -402,9 +402,9 @@ impl<T:Freeze + Send> RWArc<T> {
402402

403403
/// As write(), but with a condvar, as sync::rwlock.write_cond().
404404
#[inline]
405-
pub fn write_cond<'x, 'c, U>(&self,
406-
blk: &fn(x: &'x mut T, c: &'c Condvar) -> U)
407-
-> U {
405+
pub fn write_cond<U>(&self,
406+
blk: &fn(x: &mut T, c: &Condvar) -> U)
407+
-> U {
408408
unsafe {
409409
let state = self.x.get();
410410
do (*borrow_rwlock(state)).write_cond |cond| {
@@ -554,9 +554,9 @@ impl<'self, T:Freeze + Send> RWWriteMode<'self, T> {
554554
}
555555

556556
/// Access the pre-downgrade RWArc in write mode with a condvar.
557-
pub fn write_cond<'x, 'c, U>(&mut self,
558-
blk: &fn(x: &'x mut T, c: &'c Condvar) -> U)
559-
-> U {
557+
pub fn write_cond<U>(&mut self,
558+
blk: &fn(x: &mut T, c: &Condvar) -> U)
559+
-> U {
560560
match *self {
561561
RWWriteMode {
562562
data: &ref mut data,

branches/try2/src/librustc/driver/driver.rs

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -249,10 +249,7 @@ pub fn phase_3_run_analysis_passes(sess: Session,
249249
freevars::annotate_freevars(def_map, crate));
250250

251251
let region_map = time(time_passes, "region resolution", (), |_|
252-
middle::region::resolve_crate(sess, def_map, crate));
253-
254-
let rp_set = time(time_passes, "region parameterization inference", (), |_|
255-
middle::region::determine_rp_in_crate(sess, ast_map, def_map, crate));
252+
middle::region::resolve_crate(sess, crate));
256253

257254
let ty_cx = ty::mk_ctxt(sess, def_map, named_region_map, ast_map, freevars,
258255
region_map, lang_items);

branches/try2/src/librustc/metadata/tydecode.rs

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -363,18 +363,18 @@ fn parse_ty(st: &mut PState, conv: conv_did) -> ty::t {
363363
return ty::mk_param(st.tcx, parse_uint(st), did);
364364
}
365365
's' => {
366-
let did = parse_def(st, TypeParameter, conv);
366+
let did = parse_def(st, TypeParameter, |x,y| conv(x,y));
367367
return ty::mk_self(st.tcx, did);
368368
}
369-
'@' => return ty::mk_box(st.tcx, parse_mt(st, conv)),
370-
'~' => return ty::mk_uniq(st.tcx, parse_mt(st, conv)),
371-
'*' => return ty::mk_ptr(st.tcx, parse_mt(st, conv)),
369+
'@' => return ty::mk_box(st.tcx, parse_mt(st, |x,y| conv(x,y))),
370+
'~' => return ty::mk_uniq(st.tcx, parse_mt(st, |x,y| conv(x,y))),
371+
'*' => return ty::mk_ptr(st.tcx, parse_mt(st, |x,y| conv(x,y))),
372372
'&' => {
373-
let r = parse_region(st);
374-
let mt = parse_mt(st, conv);
373+
let r = parse_region(st, |x,y| conv(x,y));
374+
let mt = parse_mt(st, |x,y| conv(x,y));
375375
return ty::mk_rptr(st.tcx, r, mt);
376376
}
377-
'U' => return ty::mk_unboxed_vec(st.tcx, parse_mt(st, conv)),
377+
'U' => return ty::mk_unboxed_vec(st.tcx, parse_mt(st, |x,y| conv(x,y))),
378378
'V' => {
379379
let mt = parse_mt(st, |x,y| conv(x,y));
380380
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 {
392392
return ty::mk_tup(st.tcx, params);
393393
}
394394
'f' => {
395-
return ty::mk_closure(st.tcx, parse_closure_ty(st, conv));
395+
return ty::mk_closure(st.tcx, parse_closure_ty(st, |x,y| conv(x,y)));
396396
}
397397
'F' => {
398-
return ty::mk_bare_fn(st.tcx, parse_bare_fn_ty(st, conv));
398+
return ty::mk_bare_fn(st.tcx, parse_bare_fn_ty(st, |x,y| conv(x,y)));
399399
}
400400
'Y' => return ty::mk_type(st.tcx),
401401
'C' => {
@@ -417,7 +417,7 @@ fn parse_ty(st: &mut PState, conv: conv_did) -> ty::t {
417417
pos: pos,
418418
.. *st
419419
};
420-
let tt = parse_ty(&mut ps, conv);
420+
let tt = parse_ty(&mut ps, |x,y| conv(x,y));
421421
st.tcx.rcache.insert(key, tt);
422422
return tt;
423423
}
@@ -449,7 +449,7 @@ fn parse_mutability(st: &mut PState) -> ast::Mutability {
449449

450450
fn parse_mt(st: &mut PState, conv: conv_did) -> ty::mt {
451451
let m = parse_mutability(st);
452-
ty::mt { ty: parse_ty(st, conv), mutbl: m }
452+
ty::mt { ty: parse_ty(st, |x,y| conv(x,y)), mutbl: m }
453453
}
454454

455455
fn parse_def(st: &mut PState, source: DefIdSource,

branches/try2/src/librustc/middle/trans/type_of.rs

Lines changed: 16 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ use middle::trans::common::*;
1414
use middle::trans::foreign;
1515
use middle::ty;
1616
use util::ppaux;
17+
use util::ppaux::Repr;
1718

1819
use middle::trans::type_::Type;
1920

@@ -172,14 +173,16 @@ pub fn sizing_type_of(cx: &mut CrateContext, t: ty::t) -> Type {
172173

173174
// NB: If you update this, be sure to update `sizing_type_of()` as well.
174175
pub fn type_of(cx: &mut CrateContext, t: ty::t) -> Type {
175-
debug!("type_of {:?}: {:?}", t, ty::get(t));
176-
177176
// Check the cache.
178177
match cx.lltypes.find(&t) {
179-
Some(&t) => return t,
178+
Some(&llty) => {
179+
return llty;
180+
}
180181
None => ()
181182
}
182183

184+
debug!("type_of {} {:?}", t.repr(cx.tcx), t);
185+
183186
// Replace any typedef'd types with their equivalent non-typedef
184187
// type. This ensures that all LLVM nominal types that contain
185188
// 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 {
189192

190193
if t != t_norm {
191194
let llty = type_of(cx, t_norm);
195+
debug!("--> normalized {} {:?} to {} {:?} llty={}",
196+
t.repr(cx.tcx),
197+
t,
198+
t_norm.repr(cx.tcx),
199+
t_norm,
200+
cx.tn.type_to_str(llty));
192201
cx.lltypes.insert(t, llty);
193202
return llty;
194203
}
@@ -299,6 +308,10 @@ pub fn type_of(cx: &mut CrateContext, t: ty::t) -> Type {
299308
ty::ty_err(*) => cx.tcx.sess.bug("type_of with ty_err")
300309
};
301310

311+
debug!("--> mapped t={} {:?} to llty={}",
312+
t.repr(cx.tcx),
313+
t,
314+
cx.tn.type_to_str(llty));
302315
cx.lltypes.insert(t, llty);
303316

304317
// If this was an enum or struct, fill in the type now.

branches/try2/src/test/compile-fail/bad-mid-path-type-params.rs

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -28,10 +28,11 @@ impl Trait<int> for S2 {
2828
}
2929
}
3030

31-
fn main() {
31+
fn foo<'a>() {
3232
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
33-
let _ = S::<'self,int>::new::<f64>(1, 1.0); //~ ERROR this impl has no lifetime parameter
33+
let _ = S::<'a,int>::new::<f64>(1, 1.0); //~ ERROR expected 0 lifetime parameter(s)
3434
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
35-
let _: S2 = Trait::<'self,int>::new::<f64>(1, 1.0); //~ ERROR this trait has no lifetime parameter
35+
let _: S2 = Trait::<'a,int>::new::<f64>(1, 1.0); //~ ERROR expected 0 lifetime parameter(s)
3636
}
3737

38+
fn main() {}

branches/try2/src/test/compile-fail/core-tls-store-pointer.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,6 @@
1313
use std::local_data;
1414

1515
local_data_key!(key: @&int)
16-
//~^ ERROR only 'static is allowed
16+
//~^ ERROR missing lifetime specifier
1717

1818
fn main() {}

branches/try2/src/test/compile-fail/issue-4335.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010

1111
fn id<T>(t: T) -> T { t }
1212

13-
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
13+
fn f<'r, T>(v: &'r T) -> &'r fn()->T { id::<&'r fn()->T>(|| *v) } //~ ERROR cannot infer an appropriate lifetime
1414

1515
fn main() {
1616
let v = &5;

branches/try2/src/test/compile-fail/issue-5216.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,12 +9,12 @@
99
// except according to those terms.
1010

1111
fn f() { }
12-
struct S(&fn()); //~ ERROR Illegal anonymous lifetime
13-
pub static C: S = S(f); //~ ERROR Illegal anonymous lifetime
12+
struct S(&fn()); //~ ERROR missing lifetime specifier
13+
pub static C: S = S(f);
1414

1515

1616
fn g() { }
17-
type T = &fn(); //~ ERROR Illegal anonymous lifetime
18-
pub static D: T = g; //~ ERROR Illegal anonymous lifetime
17+
type T = &fn(); //~ ERROR missing lifetime specifier
18+
pub static D: T = g;
1919

2020
fn main() {}

branches/try2/src/test/compile-fail/kindck-owned-trait-contains.rs

Lines changed: 10 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -8,29 +8,24 @@
88
// option. This file may not be copied, modified, or distributed
99
// except according to those terms.
1010

11-
#[feature(managed_boxes)];
11+
trait Repeat<A> { fn get(&self) -> A; }
1212

13-
trait repeat<A> { fn get(&self) -> A; }
14-
15-
impl<A:Clone> repeat<A> for @A {
16-
fn get(&self) -> A { **self }
13+
impl<A:Clone> Repeat<A> for A {
14+
fn get(&self) -> A { self.clone() }
1715
}
1816

19-
fn repeater<A:Clone>(v: @A) -> @repeat<A> {
20-
// Note: owned kind is not necessary as A appears in the trait type
21-
@v as @repeat<A> // No
17+
fn repeater<A:Clone>(v: A) -> ~Repeat:<A> {
18+
~v as ~Repeat:<A> // No
2219
}
2320

2421
fn main() {
2522
// Error results because the type of is inferred to be
26-
// @repeat<&'blk int> where blk is the lifetime of the block below.
23+
// ~Repeat<&'blk int> where blk is the lifetime of the block below.
2724

28-
let y = { //~ ERROR lifetime of variable does not enclose its declaration
29-
let x: &'blk int = &3;
30-
repeater(@x)
25+
let y = {
26+
let tmp0 = 3;
27+
let tmp1 = &tmp0; //~ ERROR borrowed value does not live long enough
28+
repeater(tmp1)
3129
};
3230
assert!(3 == *(y.get()));
33-
//~^ ERROR dereference of reference outside its lifetime
34-
//~^^ ERROR automatically borrowed pointer is not valid at the time of borrow
35-
//~^^^ ERROR lifetime of return value does not outlive the function call
3631
}

branches/try2/src/test/compile-fail/regions-addr-of-arg.rs

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,12 +8,19 @@
88
// option. This file may not be copied, modified, or distributed
99
// except according to those terms.
1010

11+
// Check that taking the address of an argument yields a lifetime
12+
// bounded by the current function call.
13+
1114
fn foo(a: int) {
1215
let _p: &'static int = &a; //~ ERROR borrowed value does not live long enough
1316
}
1417

1518
fn bar(a: int) {
16-
let _q: &'blk int = &a;
19+
let _q: &int = &a;
20+
}
21+
22+
fn zed<'a>(a: int) -> &'a int {
23+
&a //~ ERROR borrowed value does not live long enough
1724
}
1825

1926
fn main() {

branches/try2/src/test/compile-fail/regions-addr-of-self.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,12 +14,12 @@ struct dog {
1414

1515
impl dog {
1616
pub fn chase_cat(&mut self) {
17-
let p: &'static mut uint = &mut self.cats_chased; //~ ERROR cannot infer an appropriate lifetime due to conflicting requirements
17+
let p: &'static mut uint = &mut self.cats_chased; //~ ERROR cannot infer an appropriate lifetime
1818
*p += 1u;
1919
}
2020

2121
pub fn chase_cat_2(&mut self) {
22-
let p: &'blk mut uint = &mut self.cats_chased;
22+
let p: &mut uint = &mut self.cats_chased;
2323
*p += 1u;
2424
}
2525
}

branches/try2/src/test/compile-fail/regions-addr-of-upvar-self.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ struct dog {
1717
impl dog {
1818
pub fn chase_cat(&mut self) {
1919
let _f = || {
20-
let p: &'static mut uint = &mut self.food; //~ ERROR cannot infer an appropriate lifetime due to conflicting requirements
20+
let p: &'static mut uint = &mut self.food; //~ ERROR cannot infer an appropriate lifetime
2121
*p = 3u;
2222
};
2323
}

branches/try2/src/test/compile-fail/regions-fn-subtyping.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -24,9 +24,9 @@ fn test_fn<'x,'y,'z,T>(_x: &'x T, _y: &'y T, _z: &'z T) {
2424
of::<&fn<'b>(&'b T)>());
2525

2626
subtype::<&fn<'b>(&'b T)>(
27-
of::<&fn<'x>(&'x T)>());
27+
of::<&fn(&'x T)>());
2828

29-
subtype::<&fn<'x>(&'x T)>(
29+
subtype::<&fn(&'x T)>(
3030
of::<&fn<'b>(&'b T)>()); //~ ERROR mismatched types
3131

3232
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) {
3636
of::<&fn<'a,'b>(&'a T, &'b T)>()); //~ ERROR mismatched types
3737

3838
subtype::<&fn<'a,'b>(&'a T, &'b T)>(
39-
of::<&fn<'x,'y>(&'x T, &'y T)>());
39+
of::<&fn(&'x T, &'y T)>());
4040

41-
subtype::<&fn<'x,'y>(&'x T, &'y T)>(
41+
subtype::<&fn(&'x T, &'y T)>(
4242
of::<&fn<'a,'b>(&'a T, &'b T)>()); //~ ERROR mismatched types
4343
}
4444

branches/try2/src/test/compile-fail/regions-free-region-ordering-callee.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ fn ordering2<'a, 'b>(x: &'a &'b uint, y: &'a uint) -> &'b uint {
2626
fn ordering3<'a, 'b>(x: &'a uint, y: &'b uint) -> &'a &'b uint {
2727
// Do not infer an ordering from the return value.
2828
let z: &'b uint = &*x;
29-
//~^ ERROR cannot infer an appropriate lifetime due to conflicting requirements
29+
//~^ ERROR cannot infer an appropriate lifetime
3030
fail!();
3131
}
3232

branches/try2/src/test/compile-fail/regions-free-region-ordering-caller.rs

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -14,12 +14,6 @@
1414

1515
struct Paramd<'self> { x: &'self uint }
1616

17-
fn call1<'a>(x: &'a uint) {
18-
let y: uint = 3;
19-
let z: &'a &'blk uint = &(&y);
20-
//~^ ERROR pointer has a longer lifetime than the data it references
21-
}
22-
2317
fn call2<'a, 'b>(a: &'a uint, b: &'b uint) {
2418
let z: Option<&'b &'a uint> = None;
2519
//~^ ERROR pointer has a longer lifetime than the data it references
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
// Copyright 2012 The Rust Project Developers. See the COPYRIGHT
2+
// file at the top-level directory of this distribution and at
3+
// http://rust-lang.org/COPYRIGHT.
4+
//
5+
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
6+
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
7+
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
8+
// option. This file may not be copied, modified, or distributed
9+
// except according to those terms.
10+
11+
// Test various ways to construct a pointer with a longer lifetime
12+
// than the thing it points at and ensure that they result in
13+
// errors. See also regions-free-region-ordering-callee.rs
14+
15+
fn call1<'a>(x: &'a uint) {
16+
// Test that creating a pointer like
17+
// &'a &'z uint requires that 'a <= 'z:
18+
let y: uint = 3;
19+
let z: &'a & uint = &(&y);
20+
//~^ ERROR borrowed value does not live long enough
21+
//~^^ ERROR borrowed value does not live long enough
22+
}
23+
24+
fn main() {}

0 commit comments

Comments
 (0)