diff options
| author | bors <bors@rust-lang.org> | 2013-07-14 10:19:21 -0700 |
|---|---|---|
| committer | bors <bors@rust-lang.org> | 2013-07-14 10:19:21 -0700 |
| commit | 1c35ab322ff2f26962a3550fffc2fa4154224b64 (patch) | |
| tree | d95eb9acc27f980f2365330b3aa9566e8eec2010 /src/libsyntax/parse/token.rs | |
| parent | 66e2857253ff9bc8ce299398ad5bb346d64e3fc3 (diff) | |
| parent | 9fd2ac7428afa4f414f32b8b4876ca817ee85f16 (diff) | |
| download | rust-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/libsyntax/parse/token.rs')
| -rw-r--r-- | src/libsyntax/parse/token.rs | 24 |
1 files changed, 11 insertions, 13 deletions
diff --git a/src/libsyntax/parse/token.rs b/src/libsyntax/parse/token.rs index 46e0ef32321..01860c3ae99 100644 --- a/src/libsyntax/parse/token.rs +++ b/src/libsyntax/parse/token.rs @@ -15,7 +15,6 @@ use parse::token; use util::interner::StrInterner; use util::interner; -use std::cast; use std::cmp::Equiv; use std::local_data; use std::rand; @@ -485,18 +484,17 @@ fn mk_fresh_ident_interner() -> @ident_interner { // if an interner exists in TLS, return it. Otherwise, prepare a // fresh one. pub fn get_ident_interner() -> @ident_interner { - unsafe { - let key = - (cast::transmute::<(uint, uint), - &fn:Copy(v: @@::parse::token::ident_interner)>( - (-3 as uint, 0u))); - match local_data::get(key, |k| k.map(|&k| *k)) { - Some(interner) => *interner, - None => { - let interner = mk_fresh_ident_interner(); - local_data::set(key, @interner); - interner - } + #[cfg(not(stage0))] + static key: local_data::Key<@@::parse::token::ident_interner> = + &local_data::Key; + #[cfg(stage0)] + fn key(_: @@::parse::token::ident_interner) {} + match local_data::get(key, |k| k.map(|&k| *k)) { + Some(interner) => *interner, + None => { + let interner = mk_fresh_ident_interner(); + local_data::set(key, @interner); + interner } } } |
