Skip to content

Commit b6f9295

Browse files
committed
auto merge of #6317 : brson/rust/durable, r=z0w0
#6312
2 parents 83838aa + 3df7ed1 commit b6f9295

File tree

12 files changed

+144
-123
lines changed

12 files changed

+144
-123
lines changed

src/libcore/core.rc

+1-1
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ they contained the following prologue:
7272

7373
/* Reexported core operators */
7474

75-
pub use kinds::{Const, Copy, Owned, Durable};
75+
pub use kinds::{Const, Copy, Owned};
7676
pub use ops::{Drop};
7777
pub use ops::{Add, Sub, Mul, Div, Rem, Neg, Not};
7878
pub use ops::{BitAnd, BitOr, BitXor};

src/libcore/kinds.rs

+1-2
Original file line numberDiff line numberDiff line change
@@ -30,8 +30,6 @@ The 4 kinds are
3030
* Const - types that are deeply immutable. Const types are used for
3131
freezable data structures.
3232
33-
* Durable - types that do not contain borrowed pointers.
34-
3533
`Copy` types include both implicitly copyable types that the compiler
3634
will copy automatically and non-implicitly copyable types that require
3735
the `copy` keyword to copy. Types that do not implement `Copy` may
@@ -55,6 +53,7 @@ pub trait Const {
5553
}
5654

5755
#[lang="durable"]
56+
#[cfg(stage0)]
5857
pub trait Durable {
5958
// Empty.
6059
}

src/libcore/prelude.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
/* Reexported core operators */
1414

1515
pub use either::{Either, Left, Right};
16-
pub use kinds::{Const, Copy, Owned, Durable};
16+
pub use kinds::{Const, Copy, Owned};
1717
pub use ops::{Add, Sub, Mul, Div, Rem, Neg, Not};
1818
pub use ops::{BitAnd, BitOr, BitXor};
1919
pub use ops::{Drop};

src/libcore/task/local_data.rs

+13-4
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ pub type LocalDataKey<'self,T> = &'self fn(v: @T);
4949
* Remove a task-local data value from the table, returning the
5050
* reference that was originally created to insert it.
5151
*/
52-
pub unsafe fn local_data_pop<T:Durable>(
52+
pub unsafe fn local_data_pop<T: 'static>(
5353
key: LocalDataKey<T>) -> Option<@T> {
5454

5555
local_pop(Handle::new(), key)
@@ -58,7 +58,7 @@ pub unsafe fn local_data_pop<T:Durable>(
5858
* Retrieve a task-local data value. It will also be kept alive in the
5959
* table until explicitly removed.
6060
*/
61-
pub unsafe fn local_data_get<T:Durable>(
61+
pub unsafe fn local_data_get<T: 'static>(
6262
key: LocalDataKey<T>) -> Option<@T> {
6363

6464
local_get(Handle::new(), key)
@@ -67,7 +67,7 @@ pub unsafe fn local_data_get<T:Durable>(
6767
* Store a value in task-local data. If this key already has a value,
6868
* that value is overwritten (and its destructor is run).
6969
*/
70-
pub unsafe fn local_data_set<T:Durable>(
70+
pub unsafe fn local_data_set<T: 'static>(
7171
key: LocalDataKey<T>, data: @T) {
7272

7373
local_set(Handle::new(), key, data)
@@ -76,7 +76,7 @@ pub unsafe fn local_data_set<T:Durable>(
7676
* Modify a task-local data value. If the function returns 'None', the
7777
* data is removed (and its reference dropped).
7878
*/
79-
pub unsafe fn local_data_modify<T:Durable>(
79+
pub unsafe fn local_data_modify<T: 'static>(
8080
key: LocalDataKey<T>,
8181
modify_fn: &fn(Option<@T>) -> Option<@T>) {
8282

@@ -215,3 +215,12 @@ fn test_tls_cleanup_on_failure() {
215215
fail!();
216216
}
217217
}
218+
219+
#[test]
220+
fn test_static_pointer() {
221+
unsafe {
222+
fn key(_x: @&'static int) { }
223+
static VALUE: int = 0;
224+
local_data_set(key, @&VALUE);
225+
}
226+
}

src/libcore/task/local_data_priv.rs

+8-8
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ impl Handle {
4444
}
4545

4646
pub trait LocalData { }
47-
impl<T:Durable> LocalData for @T { }
47+
impl<T: 'static> LocalData for @T { }
4848

4949
impl Eq for @LocalData {
5050
fn eq(&self, other: &@LocalData) -> bool {
@@ -131,15 +131,15 @@ unsafe fn get_newsched_local_map(local: *mut LocalStorage) -> TaskLocalMap {
131131
}
132132
}
133133

134-
unsafe fn key_to_key_value<T:Durable>(key: LocalDataKey<T>) -> *libc::c_void {
134+
unsafe fn key_to_key_value<T: 'static>(key: LocalDataKey<T>) -> *libc::c_void {
135135
// Keys are closures, which are (fnptr,envptr) pairs. Use fnptr.
136136
// Use reintepret_cast -- transmute would leak (forget) the closure.
137137
let pair: (*libc::c_void, *libc::c_void) = cast::transmute_copy(&key);
138138
pair.first()
139139
}
140140

141141
// If returning Some(..), returns with @T with the map's reference. Careful!
142-
unsafe fn local_data_lookup<T:Durable>(
142+
unsafe fn local_data_lookup<T: 'static>(
143143
map: TaskLocalMap, key: LocalDataKey<T>)
144144
-> Option<(uint, *libc::c_void)> {
145145

@@ -157,7 +157,7 @@ unsafe fn local_data_lookup<T:Durable>(
157157
}
158158
}
159159

160-
unsafe fn local_get_helper<T:Durable>(
160+
unsafe fn local_get_helper<T: 'static>(
161161
handle: Handle, key: LocalDataKey<T>,
162162
do_pop: bool) -> Option<@T> {
163163

@@ -179,21 +179,21 @@ unsafe fn local_get_helper<T:Durable>(
179179
}
180180

181181

182-
pub unsafe fn local_pop<T:Durable>(
182+
pub unsafe fn local_pop<T: 'static>(
183183
handle: Handle,
184184
key: LocalDataKey<T>) -> Option<@T> {
185185

186186
local_get_helper(handle, key, true)
187187
}
188188

189-
pub unsafe fn local_get<T:Durable>(
189+
pub unsafe fn local_get<T: 'static>(
190190
handle: Handle,
191191
key: LocalDataKey<T>) -> Option<@T> {
192192

193193
local_get_helper(handle, key, false)
194194
}
195195

196-
pub unsafe fn local_set<T:Durable>(
196+
pub unsafe fn local_set<T: 'static>(
197197
handle: Handle, key: LocalDataKey<T>, data: @T) {
198198

199199
let map = get_local_map(handle);
@@ -225,7 +225,7 @@ pub unsafe fn local_set<T:Durable>(
225225
}
226226
}
227227

228-
pub unsafe fn local_modify<T:Durable>(
228+
pub unsafe fn local_modify<T: 'static>(
229229
handle: Handle, key: LocalDataKey<T>,
230230
modify_fn: &fn(Option<@T>) -> Option<@T>) {
231231

src/librustc/middle/lang_items.rs

+79-85
Original file line numberDiff line numberDiff line change
@@ -34,56 +34,55 @@ pub enum LangItem {
3434
ConstTraitLangItem, // 0
3535
CopyTraitLangItem, // 1
3636
OwnedTraitLangItem, // 2
37-
DurableTraitLangItem, // 3
38-
39-
DropTraitLangItem, // 4
40-
41-
AddTraitLangItem, // 5
42-
SubTraitLangItem, // 6
43-
MulTraitLangItem, // 7
44-
DivTraitLangItem, // 8
45-
RemTraitLangItem, // 9
46-
NegTraitLangItem, // 10
47-
NotTraitLangItem, // 11
48-
BitXorTraitLangItem, // 12
49-
BitAndTraitLangItem, // 13
50-
BitOrTraitLangItem, // 14
51-
ShlTraitLangItem, // 15
52-
ShrTraitLangItem, // 16
53-
IndexTraitLangItem, // 17
54-
55-
EqTraitLangItem, // 18
56-
OrdTraitLangItem, // 19
57-
58-
StrEqFnLangItem, // 20
59-
UniqStrEqFnLangItem, // 21
60-
AnnihilateFnLangItem, // 22
61-
LogTypeFnLangItem, // 23
62-
FailFnLangItem, // 24
63-
FailBoundsCheckFnLangItem, // 25
64-
ExchangeMallocFnLangItem, // 26
65-
ExchangeFreeFnLangItem, // 27
66-
MallocFnLangItem, // 28
67-
FreeFnLangItem, // 29
68-
BorrowAsImmFnLangItem, // 30
69-
BorrowAsMutFnLangItem, // 31
70-
ReturnToMutFnLangItem, // 32
71-
CheckNotBorrowedFnLangItem, // 33
72-
StrDupUniqFnLangItem, // 34
73-
RecordBorrowFnLangItem, // 35
74-
UnrecordBorrowFnLangItem, // 36
75-
76-
StartFnLangItem, // 37
37+
38+
DropTraitLangItem, // 3
39+
40+
AddTraitLangItem, // 4
41+
SubTraitLangItem, // 5
42+
MulTraitLangItem, // 6
43+
DivTraitLangItem, // 7
44+
RemTraitLangItem, // 8
45+
NegTraitLangItem, // 9
46+
NotTraitLangItem, // 10
47+
BitXorTraitLangItem, // 11
48+
BitAndTraitLangItem, // 12
49+
BitOrTraitLangItem, // 13
50+
ShlTraitLangItem, // 14
51+
ShrTraitLangItem, // 15
52+
IndexTraitLangItem, // 16
53+
54+
EqTraitLangItem, // 17
55+
OrdTraitLangItem, // 18
56+
57+
StrEqFnLangItem, // 19
58+
UniqStrEqFnLangItem, // 20
59+
AnnihilateFnLangItem, // 21
60+
LogTypeFnLangItem, // 22
61+
FailFnLangItem, // 23
62+
FailBoundsCheckFnLangItem, // 24
63+
ExchangeMallocFnLangItem, // 25
64+
ExchangeFreeFnLangItem, // 26
65+
MallocFnLangItem, // 27
66+
FreeFnLangItem, // 28
67+
BorrowAsImmFnLangItem, // 29
68+
BorrowAsMutFnLangItem, // 30
69+
ReturnToMutFnLangItem, // 31
70+
CheckNotBorrowedFnLangItem, // 32
71+
StrDupUniqFnLangItem, // 33
72+
RecordBorrowFnLangItem, // 34
73+
UnrecordBorrowFnLangItem, // 35
74+
75+
StartFnLangItem, // 36
7776
}
7877

7978
pub struct LanguageItems {
80-
items: [Option<def_id>, ..38]
79+
items: [Option<def_id>, ..37]
8180
}
8281

8382
pub impl LanguageItems {
8483
pub fn new() -> LanguageItems {
8584
LanguageItems {
86-
items: [ None, ..38 ]
85+
items: [ None, ..37 ]
8786
}
8887
}
8988

@@ -100,45 +99,44 @@ pub impl LanguageItems {
10099
0 => "const",
101100
1 => "copy",
102101
2 => "owned",
103-
3 => "durable",
104-
105-
4 => "drop",
106-
107-
5 => "add",
108-
6 => "sub",
109-
7 => "mul",
110-
8 => "div",
111-
9 => "rem",
112-
10 => "neg",
113-
11 => "not",
114-
12 => "bitxor",
115-
13 => "bitand",
116-
14 => "bitor",
117-
15 => "shl",
118-
16 => "shr",
119-
17 => "index",
120-
18 => "eq",
121-
19 => "ord",
122-
123-
20 => "str_eq",
124-
21 => "uniq_str_eq",
125-
22 => "annihilate",
126-
23 => "log_type",
127-
24 => "fail_",
128-
25 => "fail_bounds_check",
129-
26 => "exchange_malloc",
130-
27 => "exchange_free",
131-
28 => "malloc",
132-
29 => "free",
133-
30 => "borrow_as_imm",
134-
31 => "borrow_as_mut",
135-
32 => "return_to_mut",
136-
33 => "check_not_borrowed",
137-
34 => "strdup_uniq",
138-
35 => "record_borrow",
139-
36 => "unrecord_borrow",
140-
141-
37 => "start",
102+
103+
3 => "drop",
104+
105+
4 => "add",
106+
5 => "sub",
107+
6 => "mul",
108+
7 => "div",
109+
8 => "rem",
110+
9 => "neg",
111+
10 => "not",
112+
11 => "bitxor",
113+
12 => "bitand",
114+
13 => "bitor",
115+
14 => "shl",
116+
15 => "shr",
117+
16 => "index",
118+
17 => "eq",
119+
18 => "ord",
120+
121+
19 => "str_eq",
122+
20 => "uniq_str_eq",
123+
21 => "annihilate",
124+
22 => "log_type",
125+
23 => "fail_",
126+
24 => "fail_bounds_check",
127+
25 => "exchange_malloc",
128+
26 => "exchange_free",
129+
27 => "malloc",
130+
28 => "free",
131+
29 => "borrow_as_imm",
132+
30 => "borrow_as_mut",
133+
31 => "return_to_mut",
134+
32 => "check_not_borrowed",
135+
33 => "strdup_uniq",
136+
34 => "record_borrow",
137+
35 => "unrecord_borrow",
138+
139+
36 => "start",
142140

143141
_ => "???"
144142
}
@@ -155,9 +153,6 @@ pub impl LanguageItems {
155153
pub fn owned_trait(&const self) -> def_id {
156154
self.items[OwnedTraitLangItem as uint].get()
157155
}
158-
pub fn durable_trait(&const self) -> def_id {
159-
self.items[DurableTraitLangItem as uint].get()
160-
}
161156

162157
pub fn drop_trait(&const self) -> def_id {
163158
self.items[DropTraitLangItem as uint].get()
@@ -274,7 +269,6 @@ fn LanguageItemCollector(crate: @crate,
274269
item_refs.insert(@~"const", ConstTraitLangItem as uint);
275270
item_refs.insert(@~"copy", CopyTraitLangItem as uint);
276271
item_refs.insert(@~"owned", OwnedTraitLangItem as uint);
277-
item_refs.insert(@~"durable", DurableTraitLangItem as uint);
278272

279273
item_refs.insert(@~"drop", DropTraitLangItem as uint);
280274

0 commit comments

Comments
 (0)