Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
int
Rust
提交
f9bf69d2
R
Rust
项目概览
int
/
Rust
大约 1 年 前同步成功
通知
1
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
DevOps
流水线
流水线任务
计划
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
R
Rust
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
DevOps
DevOps
流水线
流水线任务
计划
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
流水线任务
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
f9bf69d2
编写于
7月 11, 2013
作者:
A
Alex Crichton
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Remove all external requirements of `@` from TLS
Closes #6004
上级
11c63eaa
变更
12
隐藏空白更改
内联
并排
Showing
12 changed file
with
23 addition
and
23 deletion
+23
-23
src/libextra/rl.rs
src/libextra/rl.rs
+1
-1
src/libextra/sort.rs
src/libextra/sort.rs
+1
-1
src/librustc/middle/trans/base.rs
src/librustc/middle/trans/base.rs
+1
-1
src/librustc/middle/trans/context.rs
src/librustc/middle/trans/context.rs
+1
-1
src/librusti/program.rs
src/librusti/program.rs
+1
-1
src/libstd/condition.rs
src/libstd/condition.rs
+1
-1
src/libstd/local_data.rs
src/libstd/local_data.rs
+11
-11
src/libstd/os.rs
src/libstd/os.rs
+1
-1
src/libstd/rand.rs
src/libstd/rand.rs
+1
-1
src/libstd/rt/task.rs
src/libstd/rt/task.rs
+2
-2
src/libsyntax/ast_util.rs
src/libsyntax/ast_util.rs
+1
-1
src/libsyntax/parse/token.rs
src/libsyntax/parse/token.rs
+1
-1
未找到文件。
src/libextra/rl.rs
浏览文件 @
f9bf69d2
...
...
@@ -76,7 +76,7 @@ pub unsafe fn complete(cb: CompletionCb) {
extern
fn
callback
(
line
:
*
c_char
,
completions
:
*
())
{
unsafe
{
let
cb
=
*
local_data
::
get
(
complete_key
)
let
cb
=
*
local_data
::
get
(
complete_key
,
|
k
|
k
.map
(|
&
k
|
*
k
)
)
.get
();
do
cb
(
str
::
raw
::
from_c_str
(
line
))
|
suggestion
|
{
...
...
src/libextra/sort.rs
浏览文件 @
f9bf69d2
...
...
@@ -1204,7 +1204,7 @@ struct LVal<'self> {
#[unsafe_destructor]
impl
<
'self
>
Drop
for
LVal
<
'self
>
{
fn
drop
(
&
self
)
{
let
x
=
unsafe
{
local_data
::
get
(
self
.key
)
};
let
x
=
unsafe
{
local_data
::
get
(
self
.key
,
|
k
|
k
.map
(|
&
k
|
*
k
)
)
};
match
x
{
Some
(
@
y
)
=>
{
unsafe
{
...
...
src/librustc/middle/trans/base.rs
浏览文件 @
f9bf69d2
...
...
@@ -92,7 +92,7 @@ fn task_local_insn_key(_v: @~[&'static str]) {}
pub
fn
with_insn_ctxt
(
blk
:
&
fn
(
&
[
&
'static
str
]))
{
unsafe
{
let
opt
=
local_data
::
get
(
task_local_insn_key
);
let
opt
=
local_data
::
get
(
task_local_insn_key
,
|
k
|
k
.map
(|
&
k
|
*
k
)
);
if
opt
.is_some
()
{
blk
(
*
opt
.unwrap
());
}
...
...
src/librustc/middle/trans/context.rs
浏览文件 @
f9bf69d2
...
...
@@ -241,7 +241,7 @@ fn drop(&self) {
fn
task_local_llcx_key
(
_
v
:
@
ContextRef
)
{}
pub
fn
task_llcx
()
->
ContextRef
{
let
opt
=
unsafe
{
local_data
::
get
(
task_local_llcx_key
)
};
let
opt
=
unsafe
{
local_data
::
get
(
task_local_llcx_key
,
|
k
|
k
.map
(|
&
k
|
*
k
)
)
};
*
opt
.expect
(
"task-local LLVMContextRef wasn't ever set!"
)
}
...
...
src/librusti/program.rs
浏览文件 @
f9bf69d2
...
...
@@ -144,7 +144,7 @@ fn main() {
let key = ::std::sys::Closure{ code: %? as *(),
env: ::std::ptr::null() };
let key = ::std::cast::transmute(key);
*::std::local_data::get(key).unwrap()
*::std::local_data::get(key
, |k| k.map(|&x| *x)
).unwrap()
};
\n
"
,
key
.code
as
uint
));
// Using this __tls_map handle, deserialize each variable binding that
...
...
src/libstd/condition.rs
浏览文件 @
f9bf69d2
...
...
@@ -32,7 +32,7 @@ impl<'self, T, U> Condition<'self, T, U> {
pub
fn
trap
(
&
'self
self
,
h
:
&
'self
fn
(
T
)
->
U
)
->
Trap
<
'self
,
T
,
U
>
{
unsafe
{
let
p
:
*
RustClosure
=
::
cast
::
transmute
(
&
h
);
let
prev
=
local_data
::
get
(
self
.key
);
let
prev
=
local_data
::
get
(
self
.key
,
|
k
|
k
.map
(|
&
x
|
*
x
)
);
let
h
=
@
Handler
{
handle
:
*
p
,
prev
:
prev
};
Trap
{
cond
:
self
,
handler
:
h
}
}
...
...
src/libstd/local_data.rs
浏览文件 @
f9bf69d2
...
...
@@ -83,16 +83,16 @@ pub unsafe fn pop<T: 'static>(key: Key<T>) -> Option<T> {
* table until explicitly removed.
*/
#[cfg(stage0)]
pub
unsafe
fn
get
<
T
:
'static
>
(
key
:
Key
<@
T
>
)
->
Option
<@
T
>
{
local_get
(
Handle
::
new
(),
key
,
|
loc
|
loc
.map
(|
&
x
|
*
x
)
)
pub
unsafe
fn
get
<
T
:
'static
,
U
>
(
key
:
Key
<@
T
>
,
f
:
&
fn
(
Option
<&@
T
>
)
->
U
)
->
U
{
local_get
(
Handle
::
new
(),
key
,
f
)
}
/**
* Retrieve a task-local data value. It will also be kept alive in the
* table until explicitly removed.
*/
#[cfg(not(stage0))]
pub
unsafe
fn
get
<
T
:
'static
>
(
key
:
Key
<@
T
>
)
->
Option
<@
T
>
{
local_get
(
Handle
::
new
(),
key
,
|
loc
|
loc
.map
(|
&
x
|
*
x
)
)
pub
unsafe
fn
get
<
T
:
'static
,
U
>
(
key
:
Key
<
T
>
,
f
:
&
fn
(
Option
<&
T
>
)
->
U
)
->
U
{
local_get
(
Handle
::
new
(),
key
,
f
)
}
/**
* Store a value in task-local data. If this key already has a value,
...
...
@@ -142,16 +142,16 @@ fn my_key(_x: @~str) { }
set
(
my_key
,
@~
"parent data"
);
do
task
::
spawn
{
// TLS shouldn't carry over.
assert
!
(
get
(
my_key
)
.is_none
());
assert
!
(
get
(
my_key
,
|
k
|
k
.map
(|
&
k
|
*
k
)
)
.is_none
());
set
(
my_key
,
@~
"child data"
);
assert
!
(
*
(
get
(
my_key
)
.get
())
==
assert
!
(
*
(
get
(
my_key
,
|
k
|
k
.map
(|
&
k
|
*
k
)
)
.get
())
==
~
"child data"
);
// should be cleaned up for us
}
// Must work multiple times
assert
!
(
*
(
get
(
my_key
)
.get
())
==
~
"parent data"
);
assert
!
(
*
(
get
(
my_key
)
.get
())
==
~
"parent data"
);
assert
!
(
*
(
get
(
my_key
)
.get
())
==
~
"parent data"
);
assert
!
(
*
(
get
(
my_key
,
|
k
|
k
.map
(|
&
k
|
*
k
)
)
.get
())
==
~
"parent data"
);
assert
!
(
*
(
get
(
my_key
,
|
k
|
k
.map
(|
&
k
|
*
k
)
)
.get
())
==
~
"parent data"
);
assert
!
(
*
(
get
(
my_key
,
|
k
|
k
.map
(|
&
k
|
*
k
)
)
.get
())
==
~
"parent data"
);
}
}
...
...
@@ -161,7 +161,7 @@ fn test_tls_overwrite() {
fn
my_key
(
_
x
:
@~
str
)
{
}
set
(
my_key
,
@~
"first data"
);
set
(
my_key
,
@~
"next data"
);
// Shouldn't leak.
assert
!
(
*
(
get
(
my_key
)
.get
())
==
~
"next data"
);
assert
!
(
*
(
get
(
my_key
,
|
k
|
k
.map
(|
&
k
|
*
k
)
)
.get
())
==
~
"next data"
);
}
}
...
...
@@ -170,7 +170,7 @@ fn test_tls_pop() {
unsafe
{
fn
my_key
(
_
x
:
@~
str
)
{
}
set
(
my_key
,
@~
"weasel"
);
assert
!
(
*
(
pop
(
my_key
)
.get
())
==
~
"weasel"
);
assert
!
(
*
(
pop
(
my_key
,
|
k
|
k
.map
(|
&
k
|
*
k
)
)
.get
())
==
~
"weasel"
);
// Pop must remove the data from the map.
assert
!
(
pop
(
my_key
)
.is_none
());
}
...
...
src/libstd/os.rs
浏览文件 @
f9bf69d2
...
...
@@ -1230,7 +1230,7 @@ fn overridden_arg_key(_v: @OverriddenArgs) {}
/// `os::set_args` function.
pub
fn
args
()
->
~
[
~
str
]
{
unsafe
{
match
local_data
::
get
(
overridden_arg_key
)
{
match
local_data
::
get
(
overridden_arg_key
,
|
k
|
k
.map
(|
&
k
|
*
k
)
)
{
None
=>
real_args
(),
Some
(
args
)
=>
copy
args
.val
}
...
...
src/libstd/rand.rs
浏览文件 @
f9bf69d2
...
...
@@ -850,7 +850,7 @@ fn tls_rng_state(_v: @@mut IsaacRng) {}
pub
fn
task_rng
()
->
@
mut
IsaacRng
{
let
r
:
Option
<@@
mut
IsaacRng
>
;
unsafe
{
r
=
local_data
::
get
(
tls_rng_state
);
r
=
local_data
::
get
(
tls_rng_state
,
|
k
|
k
.map
(|
&
k
|
*
k
)
);
}
match
r
{
None
=>
{
...
...
src/libstd/rt/task.rs
浏览文件 @
f9bf69d2
...
...
@@ -172,10 +172,10 @@ fn tls() {
unsafe
{
fn
key
(
_
x
:
@~
str
)
{
}
local_data
::
set
(
key
,
@~
"data"
);
assert
!
(
*
local_data
::
get
(
key
)
.get
()
==
~
"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
)
.get
()
==
~
"data"
);
assert
!
(
*
local_data
::
get
(
key2
,
|
k
|
k
.map
(|
&
k
|
*
k
)
)
.get
()
==
~
"data"
);
}
}
}
...
...
src/libsyntax/ast_util.rs
浏览文件 @
f9bf69d2
...
...
@@ -698,7 +698,7 @@ pub fn get_sctable() -> @mut SCTable {
let
sctable_key
=
(
cast
::
transmute
::
<
(
uint
,
uint
),
&
fn
:
Copy
(
v
:
@@
mut
SCTable
)
>
(
(
-
4
as
uint
,
0u
)));
match
local_data
::
get
(
sctable_key
)
{
match
local_data
::
get
(
sctable_key
,
|
k
|
k
.map
(|
&
k
|
*
k
)
)
{
None
=>
{
let
new_table
=
@@
mut
new_sctable_internal
();
local_data
::
set
(
sctable_key
,
new_table
);
...
...
src/libsyntax/parse/token.rs
浏览文件 @
f9bf69d2
...
...
@@ -490,7 +490,7 @@ pub fn get_ident_interner() -> @ident_interner {
(
cast
::
transmute
::
<
(
uint
,
uint
),
&
fn
:
Copy
(
v
:
@@
::
parse
::
token
::
ident_interner
)
>
(
(
-
3
as
uint
,
0u
)));
match
local_data
::
get
(
key
)
{
match
local_data
::
get
(
key
,
|
k
|
k
.map
(|
&
k
|
*
k
)
)
{
Some
(
interner
)
=>
*
interner
,
None
=>
{
let
interner
=
mk_fresh_ident_interner
();
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录