about summary refs log tree commit diff
path: root/src/libstd/rt
diff options
context:
space:
mode:
authorbors <bors@rust-lang.org>2013-07-14 10:19:21 -0700
committerbors <bors@rust-lang.org>2013-07-14 10:19:21 -0700
commit1c35ab322ff2f26962a3550fffc2fa4154224b64 (patch)
treed95eb9acc27f980f2365330b3aa9566e8eec2010 /src/libstd/rt
parent66e2857253ff9bc8ce299398ad5bb346d64e3fc3 (diff)
parent9fd2ac7428afa4f414f32b8b4876ca817ee85f16 (diff)
downloadrust-1c35ab322ff2f26962a3550fffc2fa4154224b64.tar.gz
rust-1c35ab322ff2f26962a3550fffc2fa4154224b64.zip
auto merge of #7751 : alexcrichton/rust/finish-tls, r=pcwalton
This changes the interface to `get`, and it also changes the keys to be static slices instead of static functions.

This allows the removal of the `unsafe` interface because while functions can monomorphize from different types to the same actual function, static slices cannot do this.

From at least what I can tell, we don't need to worry about LLVM coalescing these addresses. If we ever use the `unnamed_addr` it looks like there's cause for worry, but there doesn't appear to be any coalescing atm.
Diffstat (limited to 'src/libstd/rt')
-rw-r--r--src/libstd/rt/task.rs14
1 files changed, 6 insertions, 8 deletions
diff --git a/src/libstd/rt/task.rs b/src/libstd/rt/task.rs
index c5961be40ec..17d0d59660f 100644
--- a/src/libstd/rt/task.rs
+++ b/src/libstd/rt/task.rs
@@ -348,14 +348,12 @@ mod test {
     fn tls() {
         use local_data;
         do run_in_newsched_task() {
-            unsafe {
-                fn key(_x: @~str) { }
-                local_data::set(key, @~"data");
-                assert!(*local_data::get(key, |k| k.map(|&k| *k)).get() == ~"data");
-                fn key2(_x: @~str) { }
-                local_data::set(key2, @~"data");
-                assert!(*local_data::get(key2, |k| k.map(|&k| *k)).get() == ~"data");
-            }
+            static key: local_data::Key<@~str> = &local_data::Key;
+            local_data::set(key, @~"data");
+            assert!(*local_data::get(key, |k| k.map(|&k| *k)).get() == ~"data");
+            static key2: local_data::Key<@~str> = &local_data::Key;
+            local_data::set(key2, @~"data");
+            assert!(*local_data::get(key2, |k| k.map(|&k| *k)).get() == ~"data");
         }
     }