Skip to content

Commit

Permalink
auto merge of #6329 : sonwow/rust/issue-6306, r=ILyoan
Browse files Browse the repository at this point in the history
Fix for #6306
  • Loading branch information
bors committed May 10, 2013
2 parents e9d0018 + 4400bbd commit 6da2c98
Show file tree
Hide file tree
Showing 16 changed files with 24 additions and 23 deletions.
6 changes: 3 additions & 3 deletions src/libcore/condition.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@

use prelude::*;
use task;
use task::local_data::{local_data_pop, local_data_set};
use local_data::{local_data_pop, local_data_set};

// helper for transmutation, shown below.
type RustClosure = (int, int);
Expand All @@ -24,14 +24,14 @@ pub struct Handler<T, U> {

pub struct Condition<'self, T, U> {
name: &'static str,
key: task::local_data::LocalDataKey<'self, Handler<T, U>>
key: local_data::LocalDataKey<'self, Handler<T, U>>
}

pub impl<'self, T, U> Condition<'self, T, U> {
fn trap(&'self self, h: &'self fn(T) -> U) -> Trap<'self, T, U> {
unsafe {
let p : *RustClosure = ::cast::transmute(&h);
let prev = task::local_data::local_data_get(self.key);
let prev = local_data::local_data_get(self.key);
let h = @Handler { handle: *p, prev: prev };
Trap { cond: self, handler: h }
}
Expand Down
1 change: 1 addition & 0 deletions src/libcore/core.rc
Original file line number Diff line number Diff line change
Expand Up @@ -215,6 +215,7 @@ pub mod trie;
pub mod task;
pub mod comm;
pub mod pipes;
pub mod local_data;


/* Runtime and platform support */
Expand Down
File renamed without changes.
4 changes: 2 additions & 2 deletions src/libcore/os.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1208,7 +1208,7 @@ fn overridden_arg_key(_v: @OverriddenArgs) {}
pub fn args() -> ~[~str] {
unsafe {
match task::local_data::local_data_get(overridden_arg_key) {
match local_data::local_data_get(overridden_arg_key) {
None => real_args(),
Some(args) => copy args.val
}
Expand All @@ -1218,7 +1218,7 @@ pub fn args() -> ~[~str] {
pub fn set_args(new_args: ~[~str]) {
unsafe {
let overridden_args = @OverriddenArgs { val: copy new_args };
task::local_data::local_data_set(overridden_arg_key, overridden_args);
local_data::local_data_set(overridden_arg_key, overridden_args);
}
}
Expand Down
1 change: 1 addition & 0 deletions src/libcore/prelude.rs
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,7 @@ pub use io;
pub use iter;
pub use old_iter;
pub use libc;
pub use local_data;
pub use num;
pub use ops;
pub use option;
Expand Down
4 changes: 2 additions & 2 deletions src/libcore/rand.rs
Original file line number Diff line number Diff line change
Expand Up @@ -836,13 +836,13 @@ fn tls_rng_state(_v: @@mut IsaacRng) {}
pub fn task_rng() -> @@mut IsaacRng {
let r : Option<@@mut IsaacRng>;
unsafe {
r = task::local_data::local_data_get(tls_rng_state);
r = local_data::local_data_get(tls_rng_state);
}
match r {
None => {
unsafe {
let rng = @@mut IsaacRng::new_seeded(seed());
task::local_data::local_data_set(tls_rng_state, rng);
local_data::local_data_set(tls_rng_state, rng);
rng
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/libcore/rt/local_services.rs
Original file line number Diff line number Diff line change
Expand Up @@ -198,7 +198,7 @@ mod test {
#[test]
fn tls() {
use task::local_data::*;
use local_data::*;
do run_in_newsched_task() {
unsafe {
fn key(_x: @~str) { }
Expand Down
2 changes: 1 addition & 1 deletion src/libcore/task/local_data_priv.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ use cmp::Eq;
use libc;
use prelude::*;
use task::rt;
use task::local_data::LocalDataKey;
use local_data::LocalDataKey;

use super::rt::rust_task;
use rt::local_services::LocalStorage;
Expand Down
1 change: 0 additions & 1 deletion src/libcore/task/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,6 @@ use unstable::finally::Finally;
#[cfg(test)] use comm::SharedChan;

mod local_data_priv;
pub mod local_data;
pub mod rt;
pub mod spawn;

Expand Down
2 changes: 1 addition & 1 deletion src/librustdoc/extract.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ use astsrv;
use doc::ItemUtils;
use doc;

use core::task::local_data::local_data_get;
use core::local_data::local_data_get;
use syntax::ast;
use syntax;

Expand Down
4 changes: 2 additions & 2 deletions src/libstd/rl.rs
Original file line number Diff line number Diff line change
Expand Up @@ -69,11 +69,11 @@ fn complete_key(_v: @CompletionCb) {}

/// Bind to the main completion callback
pub unsafe fn complete(cb: CompletionCb) {
task::local_data::local_data_set(complete_key, @(cb));
local_data::local_data_set(complete_key, @(cb));

extern fn callback(line: *c_char, completions: *()) {
unsafe {
let cb = *task::local_data::local_data_get(complete_key)
let cb = *local_data::local_data_get(complete_key)
.get();

do cb(str::raw::from_c_str(line)) |suggestion| {
Expand Down
4 changes: 2 additions & 2 deletions src/libstd/sort.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1211,11 +1211,11 @@ mod big_tests {
#[unsafe_destructor]
impl<'self> Drop for LVal<'self> {
fn finalize(&self) {
let x = unsafe { task::local_data::local_data_get(self.key) };
let x = unsafe { local_data::local_data_get(self.key) };
match x {
Some(@y) => {
unsafe {
task::local_data::local_data_set(self.key, @(y+1));
local_data::local_data_set(self.key, @(y+1));
}
}
_ => fail!(~"Expected key to work"),
Expand Down
4 changes: 2 additions & 2 deletions src/libstd/sort_stage0.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1202,11 +1202,11 @@ mod big_tests {
#[unsafe_destructor]
impl<'self> Drop for LVal<'self> {
fn finalize(&self) {
let x = unsafe { task::local_data::local_data_get(self.key) };
let x = unsafe { local_data::local_data_get(self.key) };
match x {
Some(@y) => {
unsafe {
task::local_data::local_data_set(self.key, @(y+1));
local_data::local_data_set(self.key, @(y+1));
}
}
_ => fail!(~"Expected key to work"),
Expand Down
4 changes: 2 additions & 2 deletions src/libsyntax/ast.rs
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ impl<S:Encoder> Encodable<S> for ident {
fn encode(&self, s: &mut S) {
unsafe {
let intr =
match task::local_data::local_data_get(interner_key!()) {
match local_data::local_data_get(interner_key!()) {
None => fail!(~"encode: TLS interner not set up"),
Some(intr) => intr
};
Expand All @@ -87,7 +87,7 @@ impl<S:Encoder> Encodable<S> for ident {
impl<D:Decoder> Decodable<D> for ident {
fn decode(d: &mut D) -> ident {
let intr = match unsafe {
task::local_data::local_data_get(interner_key!())
local_data::local_data_get(interner_key!())
} {
None => fail!(~"decode: TLS interner not set up"),
Some(intr) => intr
Expand Down
4 changes: 2 additions & 2 deletions src/libsyntax/parse/token.rs
Original file line number Diff line number Diff line change
Expand Up @@ -462,7 +462,7 @@ pub fn mk_fresh_ident_interner() -> @ident_interner {
interner: interner::StrInterner::prefill(init_vec)
};
unsafe {
task::local_data::local_data_set(interner_key!(), @rv);
local_data::local_data_set(interner_key!(), @rv);
}
rv
}
Expand All @@ -471,7 +471,7 @@ pub fn mk_fresh_ident_interner() -> @ident_interner {
// fresh one.
pub fn mk_ident_interner() -> @ident_interner {
unsafe {
match task::local_data::local_data_get(interner_key!()) {
match local_data::local_data_get(interner_key!()) {
Some(interner) => *interner,
None => {
mk_fresh_ident_interner()
Expand Down
4 changes: 2 additions & 2 deletions src/test/compile-fail/core-tls-store-pointer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,12 @@

// Testing that we can't store a borrowed pointer it task-local storage

use core::task::local_data::*;
use core::local_data::*;

fn key(_x: @&int) { }

fn main() {
unsafe {
local_data_set(key, @&0); //~ ERROR does not fulfill `'static`
}
}
}

0 comments on commit 6da2c98

Please sign in to comment.