Skip to content

Commit 6d81307

Browse files
committed
librustc: Add explicit lifetime binders and new lifetime notation in core/std/syntax/rustc
1 parent 68cb536 commit 6d81307

File tree

16 files changed

+135
-116
lines changed

16 files changed

+135
-116
lines changed

src/libcore/condition.rs

+7-7
Original file line numberDiff line numberDiff line change
@@ -22,11 +22,11 @@ pub struct Handler<T, U> {
2222

2323
pub struct Condition<T, U> {
2424
name: &'static str,
25-
key: task::local_data::LocalDataKey/&self<Handler<T, U>>
25+
key: task::local_data::LocalDataKey<'self, Handler<T, U>>
2626
}
2727

28-
pub impl<T, U> Condition/&self<T, U> {
29-
fn trap(&self, h: &'self fn(T) -> U) -> Trap/&self<T, U> {
28+
pub impl<T, U> Condition<'self, T, U> {
29+
fn trap(&self, h: &'self fn(T) -> U) -> Trap<'self, T, U> {
3030
unsafe {
3131
let p : *RustClosure = ::cast::transmute(&h);
3232
let prev = task::local_data::local_data_get(self.key);
@@ -65,11 +65,11 @@ pub impl<T, U> Condition/&self<T, U> {
6565
}
6666

6767
struct Trap<T, U> {
68-
cond: &'self Condition/&self<T, U>,
68+
cond: &'self Condition<'self, T, U>,
6969
handler: @Handler<T, U>
7070
}
7171

72-
pub impl<T, U> Trap/&self<T, U> {
72+
pub impl<T, U> Trap<'self, T, U> {
7373
fn in<V>(&self, inner: &'self fn() -> V) -> V {
7474
unsafe {
7575
let _g = Guard { cond: self.cond };
@@ -81,11 +81,11 @@ pub impl<T, U> Trap/&self<T, U> {
8181
}
8282

8383
struct Guard<T, U> {
84-
cond: &'self Condition/&self<T, U>
84+
cond: &'self Condition<'self, T, U>
8585
}
8686

8787
#[unsafe_destructor]
88-
impl<T, U> Drop for Guard/&self<T, U> {
88+
impl<T, U> Drop for Guard<'self, T, U> {
8989
fn finalize(&self) {
9090
unsafe {
9191
debug!("Guard: popping handler from TLS");

src/libcore/unstable/finally.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -41,12 +41,12 @@ impl<T> Finally<T> for &'self fn() -> T {
4141
}
4242
}
4343

44-
struct Finallyalizer {
44+
struct Finallyalizer<'self> {
4545
dtor: &'self fn()
4646
}
4747

4848
#[unsafe_destructor]
49-
impl Drop for Finallyalizer/&self {
49+
impl<'self> Drop for Finallyalizer<'self> {
5050
fn finalize(&self) {
5151
(self.dtor)();
5252
}

src/librustc/middle/borrowck/preserve.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@ struct PreserveCtxt {
7979
root_managed_data: bool
8080
}
8181

82-
pub impl PreserveCtxt/&self {
82+
pub impl<'self> PreserveCtxt<'self> {
8383
fn tcx(&self) -> ty::ctxt { self.bccx.tcx }
8484

8585
fn preserve(&self, cmt: cmt) -> bckres<PreserveCondition> {

src/librustc/middle/kind.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -481,7 +481,7 @@ pub fn check_durable(tcx: ty::ctxt, ty: ty::t, sp: span) -> bool {
481481
}
482482

483483
/// This is rather subtle. When we are casting a value to a
484-
/// instantiated trait like `a as trait/&r`, regionck already ensures
484+
/// instantiated trait like `a as trait<'r>`, regionck already ensures
485485
/// that any borrowed pointers that appear in the type of `a` are
486486
/// bounded by `&r`. However, it is possible that there are *type
487487
/// parameters* in the type of `a`, and those *type parameters* may

src/librustc/middle/lang_items.rs

+5-5
Original file line numberDiff line numberDiff line change
@@ -255,10 +255,10 @@ pub impl LanguageItems {
255255
}
256256
}
257257

258-
fn LanguageItemCollector(crate: @crate,
259-
session: Session,
260-
items: &'r mut LanguageItems)
261-
-> LanguageItemCollector/&r {
258+
fn LanguageItemCollector<'r>(crate: @crate,
259+
session: Session,
260+
items: &'r mut LanguageItems)
261+
-> LanguageItemCollector<'r> {
262262
let item_refs = HashMap();
263263

264264
item_refs.insert(@~"const", ConstTraitLangItem as uint);
@@ -320,7 +320,7 @@ struct LanguageItemCollector {
320320
item_refs: HashMap<@~str, uint>,
321321
}
322322

323-
pub impl LanguageItemCollector/&self {
323+
pub impl<'self> LanguageItemCollector<'self> {
324324
fn match_and_collect_meta_item(&self, item_def_id: def_id,
325325
meta_item: @meta_item) {
326326
match meta_item.node {

src/librustc/middle/trans/_match.rs

+61-44
Original file line numberDiff line numberDiff line change
@@ -331,9 +331,9 @@ pub struct ArmData {
331331
bindings_map: BindingsMap
332332
}
333333
334-
pub struct Match {
334+
pub struct Match<'self> {
335335
pats: ~[@ast::pat],
336-
data: @ArmData/&self
336+
data: @ArmData<'self>
337337
}
338338
339339
pub fn match_to_str(bcx: block, m: &Match) -> ~str {
@@ -359,9 +359,11 @@ pub fn has_nested_bindings(m: &[@Match], col: uint) -> bool {
359359
return false;
360360
}
361361
362-
pub fn expand_nested_bindings(bcx: block, m: &[@Match/&r],
363-
col: uint, val: ValueRef)
364-
-> ~[@Match/&r] {
362+
pub fn expand_nested_bindings<'r>(bcx: block,
363+
m: &[@Match<'r>],
364+
col: uint,
365+
val: ValueRef)
366+
-> ~[@Match<'r>] {
365367
debug!("expand_nested_bindings(bcx=%s, m=%s, col=%u, val=%?)",
366368
bcx.to_str(),
367369
matches_to_str(bcx, m),
@@ -402,9 +404,13 @@ pub fn assert_is_binding_or_wild(bcx: block, p: @ast::pat) {
402404
}
403405
}
404406
405-
pub fn enter_match(bcx: block, dm: DefMap, m: &[@Match/&r],
406-
col: uint, val: ValueRef, e: enter_pat)
407-
-> ~[@Match/&r] {
407+
pub fn enter_match<'r>(bcx: block,
408+
dm: DefMap,
409+
m: &[@Match<'r>],
410+
col: uint,
411+
val: ValueRef,
412+
e: enter_pat)
413+
-> ~[@Match<'r>] {
408414
debug!("enter_match(bcx=%s, m=%s, col=%u, val=%?)",
409415
bcx.to_str(),
410416
matches_to_str(bcx, m),
@@ -445,9 +451,12 @@ pub fn enter_match(bcx: block, dm: DefMap, m: &[@Match/&r],
445451
return result;
446452
}
447453
448-
pub fn enter_default(bcx: block, dm: DefMap, m: &[@Match/&r],
449-
col: uint, val: ValueRef)
450-
-> ~[@Match/&r] {
454+
pub fn enter_default<'r>(bcx: block,
455+
dm: DefMap,
456+
m: &[@Match<'r>],
457+
col: uint,
458+
val: ValueRef)
459+
-> ~[@Match<'r>] {
451460
debug!("enter_default(bcx=%s, m=%s, col=%u, val=%?)",
452461
bcx.to_str(),
453462
matches_to_str(bcx, m),
@@ -488,9 +497,13 @@ pub fn enter_default(bcx: block, dm: DefMap, m: &[@Match/&r],
488497
// <nmatsakis> so all patterns must either be records (resp. tuples) or
489498
// wildcards
490499
491-
pub fn enter_opt(bcx: block, m: &[@Match/&r], opt: &Opt, col: uint,
492-
variant_size: uint, val: ValueRef)
493-
-> ~[@Match/&r] {
500+
pub fn enter_opt<'r>(bcx: block,
501+
m: &[@Match<'r>],
502+
opt: &Opt,
503+
col: uint,
504+
variant_size: uint,
505+
val: ValueRef)
506+
-> ~[@Match<'r>] {
494507
debug!("enter_opt(bcx=%s, m=%s, col=%u, val=%?)",
495508
bcx.to_str(),
496509
matches_to_str(bcx, m),
@@ -599,11 +612,11 @@ pub fn enter_opt(bcx: block, m: &[@Match/&r], opt: &Opt, col: uint,
599612
600613
pub fn enter_rec_or_struct(bcx: block,
601614
dm: DefMap,
602-
m: &[@Match/&r],
615+
m: &[@Match<'r>],
603616
col: uint,
604617
fields: &[ast::ident],
605618
val: ValueRef)
606-
-> ~[@Match/&r] {
619+
-> ~[@Match<'r>] {
607620
debug!("enter_rec_or_struct(bcx=%s, m=%s, col=%u, val=%?)",
608621
bcx.to_str(),
609622
matches_to_str(bcx, m),
@@ -632,9 +645,13 @@ pub fn enter_rec_or_struct(bcx: block,
632645
}
633646
}
634647
635-
pub fn enter_tup(bcx: block, dm: DefMap, m: &[@Match/&r],
636-
col: uint, val: ValueRef, n_elts: uint)
637-
-> ~[@Match/&r] {
648+
pub fn enter_tup<'r>(bcx: block,
649+
dm: DefMap,
650+
m: &[@Match<'r>],
651+
col: uint,
652+
val: ValueRef,
653+
n_elts: uint)
654+
-> ~[@Match<'r>] {
638655
debug!("enter_tup(bcx=%s, m=%s, col=%u, val=%?)",
639656
bcx.to_str(),
640657
matches_to_str(bcx, m),
@@ -656,13 +673,13 @@ pub fn enter_tup(bcx: block, dm: DefMap, m: &[@Match/&r],
656673
}
657674
}
658675
659-
pub fn enter_tuple_struct(bcx: block,
660-
dm: DefMap,
661-
m: &[@Match/&r],
662-
col: uint,
663-
val: ValueRef,
664-
n_elts: uint)
665-
-> ~[@Match/&r] {
676+
pub fn enter_tuple_struct<'r>(bcx: block,
677+
dm: DefMap,
678+
m: &[@Match<'r>],
679+
col: uint,
680+
val: ValueRef,
681+
n_elts: uint)
682+
-> ~[@Match<'r>] {
666683
debug!("enter_tuple_struct(bcx=%s, m=%s, col=%u, val=%?)",
667684
bcx.to_str(),
668685
matches_to_str(bcx, m),
@@ -682,12 +699,12 @@ pub fn enter_tuple_struct(bcx: block,
682699
}
683700
}
684701
685-
pub fn enter_box(bcx: block,
686-
dm: DefMap,
687-
m: &[@Match/&r],
688-
col: uint,
689-
val: ValueRef)
690-
-> ~[@Match/&r] {
702+
pub fn enter_box<'r>(bcx: block,
703+
dm: DefMap,
704+
m: &[@Match<'r>],
705+
col: uint,
706+
val: ValueRef)
707+
-> ~[@Match<'r>] {
691708
debug!("enter_box(bcx=%s, m=%s, col=%u, val=%?)",
692709
bcx.to_str(),
693710
matches_to_str(bcx, m),
@@ -709,12 +726,12 @@ pub fn enter_box(bcx: block,
709726
}
710727
}
711728
712-
pub fn enter_uniq(bcx: block,
713-
dm: DefMap,
714-
m: &[@Match/&r],
715-
col: uint,
716-
val: ValueRef)
717-
-> ~[@Match/&r] {
729+
pub fn enter_uniq<'r>(bcx: block,
730+
dm: DefMap,
731+
m: &[@Match<'r>],
732+
col: uint,
733+
val: ValueRef)
734+
-> ~[@Match<'r>] {
718735
debug!("enter_uniq(bcx=%s, m=%s, col=%u, val=%?)",
719736
bcx.to_str(),
720737
matches_to_str(bcx, m),
@@ -736,12 +753,12 @@ pub fn enter_uniq(bcx: block,
736753
}
737754
}
738755
739-
pub fn enter_region(bcx: block,
740-
dm: DefMap,
741-
m: &[@Match/&r],
742-
col: uint,
743-
val: ValueRef)
744-
-> ~[@Match/&r] {
756+
pub fn enter_region<'r>(bcx: block,
757+
dm: DefMap,
758+
m: &[@Match<'r>],
759+
col: uint,
760+
val: ValueRef)
761+
-> ~[@Match<'r>] {
745762
debug!("enter_region(bcx=%s, m=%s, col=%u, val=%?)",
746763
bcx.to_str(),
747764
matches_to_str(bcx, m),

src/librustc/middle/typeck/check/method.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -192,7 +192,7 @@ pub enum TransformTypeFlag {
192192
TransformTypeForObject,
193193
}
194194

195-
pub impl LookupContext/&self {
195+
pub impl<'self> LookupContext<'self> {
196196
fn do_lookup(&self, self_ty: ty::t) -> Option<method_map_entry> {
197197
let mut self_ty = structurally_resolved_type(self.fcx,
198198
self.self_expr.span,

src/libstd/arc.rs

+6-6
Original file line numberDiff line numberDiff line change
@@ -25,13 +25,13 @@ use core::ptr;
2525
use core::task;
2626

2727
/// As sync::condvar, a mechanism for unlock-and-descheduling and signalling.
28-
pub struct Condvar {
28+
pub struct Condvar<'self> {
2929
is_mutex: bool,
3030
failed: &'self mut bool,
31-
cond: &'self sync::Condvar/&self
31+
cond: &'self sync::Condvar<'self>
3232
}
3333

34-
pub impl Condvar/&self {
34+
pub impl<'self> Condvar<'self> {
3535
/// Atomically exit the associated ARC and block until a signal is sent.
3636
#[inline(always)]
3737
fn wait(&self) { self.wait_on(0) }
@@ -375,7 +375,7 @@ pub impl<T:Const + Owned> RWARC<T> {
375375
}
376376
377377
/// To be called inside of the write_downgrade block.
378-
fn downgrade(&self, token: RWWriteMode/&a<T>) -> RWReadMode/&a<T> {
378+
fn downgrade(&self, token: RWWriteMode<'a, T>) -> RWReadMode<'a, T> {
379379
// The rwlock should assert that the token belongs to us for us.
380380
let state = unsafe { get_shared_immutable_state(&self.x) };
381381
let RWWriteMode {
@@ -420,7 +420,7 @@ pub struct RWReadMode<'self, T> {
420420
token: sync::RWlockReadMode<'self>,
421421
}
422422

423-
pub impl<T:Const + Owned> RWWriteMode/&self<T> {
423+
pub impl<T:Const + Owned> RWWriteMode<'self, T> {
424424
/// Access the pre-downgrade RWARC in write mode.
425425
fn write<U>(&self, blk: &fn(x: &mut T) -> U) -> U {
426426
match *self {
@@ -458,7 +458,7 @@ pub impl<T:Const + Owned> RWWriteMode/&self<T> {
458458
}
459459
}
460460

461-
pub impl<T:Const + Owned> RWReadMode/&self<T> {
461+
pub impl<T:Const + Owned> RWReadMode<'self, T> {
462462
/// Access the post-downgrade rwlock in read mode.
463463
fn read<U>(&self, blk: &fn(x: &T) -> U) -> U {
464464
match *self {

src/libstd/flatpipes.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -466,8 +466,8 @@ pub mod flatteners {
466466
fn from_writer(w: @Writer) -> Self;
467467
}
468468
469-
impl FromReader for json::Decoder/&self {
470-
fn from_reader(r: @Reader) -> json::Decoder/&self {
469+
impl FromReader for json::Decoder<'self> {
470+
fn from_reader(r: @Reader) -> json::Decoder<'self> {
471471
match json::from_reader(r) {
472472
Ok(json) => {
473473
json::Decoder(json)

src/libstd/json.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -749,7 +749,7 @@ pub fn Decoder(json: Json) -> Decoder {
749749
Decoder { json: json, stack: ~[] }
750750
}
751751

752-
priv impl Decoder/&self {
752+
priv impl Decoder<'self> {
753753
fn peek(&self) -> &'self Json {
754754
if vec::uniq_len(&const self.stack) == 0 {
755755
self.stack.push(&self.json);
@@ -765,7 +765,7 @@ priv impl Decoder/&self {
765765
}
766766
}
767767

768-
impl serialize::Decoder for Decoder/&self {
768+
impl serialize::Decoder for Decoder<'self> {
769769
fn read_nil(&self) -> () {
770770
debug!("read_nil");
771771
match *self.pop() {

src/libstd/sort.rs

+6-6
Original file line numberDiff line numberDiff line change
@@ -1191,7 +1191,7 @@ mod big_tests {
11911191
}
11921192
11931193
#[unsafe_destructor]
1194-
impl Drop for LVal/&self {
1194+
impl<'self> Drop for LVal<'self> {
11951195
fn finalize(&self) {
11961196
let x = unsafe { task::local_data::local_data_get(self.key) };
11971197
match x {
@@ -1205,17 +1205,17 @@ mod big_tests {
12051205
}
12061206
}
12071207

1208-
impl Ord for LVal/&self {
1209-
fn lt(&self, other: &'a LVal/&self) -> bool {
1208+
impl<'self> Ord for LVal<'self> {
1209+
fn lt(&self, other: &'a LVal<'self>) -> bool {
12101210
(*self).val < other.val
12111211
}
1212-
fn le(&self, other: &'a LVal/&self) -> bool {
1212+
fn le(&self, other: &'a LVal<'self>) -> bool {
12131213
(*self).val <= other.val
12141214
}
1215-
fn gt(&self, other: &'a LVal/&self) -> bool {
1215+
fn gt(&self, other: &'a LVal<'self>) -> bool {
12161216
(*self).val > other.val
12171217
}
1218-
fn ge(&self, other: &'a LVal/&self) -> bool {
1218+
fn ge(&self, other: &'a LVal<'self>) -> bool {
12191219
(*self).val >= other.val
12201220
}
12211221
}

0 commit comments

Comments
 (0)