Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
int
Rust
提交
b181ea41
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,发现更多精彩内容 >>
提交
b181ea41
编写于
3月 20, 2012
作者:
B
Brian Anderson
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
core: Rename unsafe::leak to unsafe::forget. Closes #2031
上级
56828d49
变更
11
隐藏空白更改
内联
并排
Showing
11 changed file
with
20 addition
and
20 deletion
+20
-20
src/libcore/comm.rs
src/libcore/comm.rs
+1
-1
src/libcore/option.rs
src/libcore/option.rs
+1
-1
src/libcore/run.rs
src/libcore/run.rs
+1
-1
src/libcore/str.rs
src/libcore/str.rs
+6
-6
src/libcore/task.rs
src/libcore/task.rs
+1
-1
src/libcore/unsafe.rs
src/libcore/unsafe.rs
+3
-3
src/libcore/vec.rs
src/libcore/vec.rs
+2
-2
src/libstd/rope.rs
src/libstd/rope.rs
+2
-2
src/rustc/middle/trans/debuginfo.rs
src/rustc/middle/trans/debuginfo.rs
+1
-1
src/rustc/middle/ty.rs
src/rustc/middle/ty.rs
+1
-1
src/test/run-pass/rt-sched-1.rs
src/test/run-pass/rt-sched-1.rs
+1
-1
未找到文件。
src/libcore/comm.rs
浏览文件 @
b181ea41
...
...
@@ -119,7 +119,7 @@ fn send<T: send>(ch: chan<T>, -data: T) {
let
res
=
rustrt
::
rust_port_id_send
(
sys
::
get_type_desc
::
<
T
>
(),
p
,
data
);
if
res
!=
0u
unsafe
{
// Data sent successfully
unsafe
::
leak
(
data
);
unsafe
::
forget
(
data
);
}
task
::
yield
();
}
...
...
src/libcore/option.rs
浏览文件 @
b181ea41
...
...
@@ -83,7 +83,7 @@ fn unwrap<T>(-opt: option<T>) -> T unsafe {
none
{
fail
"option none"
}
};
let
liberated_value
=
unsafe
::
reinterpret_cast
(
*
addr
);
unsafe
::
leak
(
opt
);
unsafe
::
forget
(
opt
);
ret
liberated_value
;
}
...
...
src/libcore/run.rs
浏览文件 @
b181ea41
...
...
@@ -129,7 +129,7 @@ fn with_envp<T>(env: option<[(str,str)]>,
let
t
=
#
fmt
(
"%s=%s"
,
k
,
v
);
let
mut
v
:
[
u8
]
=
::
unsafe
::
reinterpret_cast
(
t
);
blk
+=
v
;
::
unsafe
::
leak
(
v
);
::
unsafe
::
forget
(
v
);
}
blk
+=
[
0_u8
];
vec
::
as_buf
(
blk
)
{|
p
|
cb
(::
unsafe
::
reinterpret_cast
(
p
))
}
...
...
src/libcore/str.rs
浏览文件 @
b181ea41
...
...
@@ -129,7 +129,7 @@ fn from_byte(b: u8) -> str unsafe {
assert
b
<
128u8
;
let
mut
v
=
[
b
,
0u8
];
let
s
:
str
=
::
unsafe
::
reinterpret_cast
(
v
);
::
unsafe
::
leak
(
v
);
::
unsafe
::
forget
(
v
);
s
}
...
...
@@ -273,7 +273,7 @@ fn trim(+s: str) -> str { trim_left(trim_right(s)) }
fn
bytes
(
s
:
str
)
->
[
u8
]
unsafe
{
let
mut
s_copy
=
s
;
let
mut
v
:
[
u8
]
=
::
unsafe
::
reinterpret_cast
(
s_copy
);
::
unsafe
::
leak
(
s_copy
);
::
unsafe
::
forget
(
s_copy
);
vec
::
unsafe
::
set_len
(
v
,
len
(
s
));
ret
v
;
}
...
...
@@ -1445,7 +1445,7 @@ fn any_between(s: str, start: uint, end: uint, it: fn(char) -> bool) -> bool {
fn
as_bytes
<
T
>
(
s
:
str
,
f
:
fn
([
u8
])
->
T
)
->
T
unsafe
{
let
mut
v
:
[
u8
]
=
::
unsafe
::
reinterpret_cast
(
s
);
let
r
=
f
(
v
);
::
unsafe
::
leak
(
v
);
::
unsafe
::
forget
(
v
);
r
}
...
...
@@ -1517,7 +1517,7 @@ unsafe fn from_buf_len(buf: *u8, len: uint) -> str {
assert
is_utf8
(
v
);
let
s
:
str
=
::
unsafe
::
reinterpret_cast
(
v
);
::
unsafe
::
leak
(
v
);
::
unsafe
::
forget
(
v
);
ret
s
;
}
...
...
@@ -1541,7 +1541,7 @@ unsafe fn from_c_str_len(c_str: *libc::c_char, len: uint) -> str {
unsafe
fn
from_bytes
(
v
:
[
const
u8
])
->
str
unsafe
{
let
mut
vcopy
:
[
u8
]
=
v
+
[
0u8
];
let
scopy
:
str
=
::
unsafe
::
reinterpret_cast
(
vcopy
);
::
unsafe
::
leak
(
vcopy
);
::
unsafe
::
forget
(
vcopy
);
ret
scopy
;
}
...
...
@@ -1578,7 +1578,7 @@ unsafe fn slice_bytes(s: str, begin: uint, end: uint) -> str unsafe {
};
v
+=
[
0u8
];
let
s
:
str
=
::
unsafe
::
reinterpret_cast
(
v
);
::
unsafe
::
leak
(
v
);
::
unsafe
::
forget
(
v
);
ret
s
;
}
...
...
src/libcore/task.rs
浏览文件 @
b181ea41
...
...
@@ -504,7 +504,7 @@ fn spawn_raw(opts: task_opts, +f: fn~()) unsafe {
}
rustrt
::
start_task
(
new_task
,
closure
);
unsafe
::
leak
(
f
);
unsafe
::
forget
(
f
);
fn
new_task_in_new_sched
(
opts
:
sched_opts
)
->
*
rust_task
{
if
opts
.native_stack_size
!=
none
{
...
...
src/libcore/unsafe.rs
浏览文件 @
b181ea41
#[doc
=
"Unsafe operations"
]
;
export
reinterpret_cast
,
leak
;
export
reinterpret_cast
,
forget
;
#[abi
=
"rust-intrinsic"
]
native
mod
rusti
{
...
...
@@ -24,13 +24,13 @@ unsafe fn reinterpret_cast<T, U>(src: T) -> U {
#[doc
=
"
Move a thing into the void
The
leak
function will take ownership of the provided value but neglect
The
forget
function will take ownership of the provided value but neglect
to run any required cleanup or memory-management operations on it. This
can be used for various acts of magick, particularly when using
reinterpret_cast on managed pointer types.
"
]
#[inline(always)]
unsafe
fn
leak
<
T
>
(
-
thing
:
T
)
{
rusti
::
leak
(
thing
);
}
unsafe
fn
forget
<
T
>
(
-
thing
:
T
)
{
rusti
::
leak
(
thing
);
}
#[cfg(test)]
mod
tests
{
...
...
src/libcore/vec.rs
浏览文件 @
b181ea41
...
...
@@ -155,14 +155,14 @@ fn from_elem<T: copy>(n_elts: uint, t: T) -> [T] {
#[doc
=
"Produces a mutable vector from an immutable vector."
]
fn
to_mut
<
T
>
(
+
v
:
[
T
])
->
[
mutable
T
]
unsafe
{
let
r
=
::
unsafe
::
reinterpret_cast
(
v
);
::
unsafe
::
leak
(
v
);
::
unsafe
::
forget
(
v
);
r
}
#[doc
=
"Produces an immutable vector from a mutable vector."
]
fn
from_mut
<
T
>
(
+
v
:
[
mutable
T
])
->
[
T
]
unsafe
{
let
r
=
::
unsafe
::
reinterpret_cast
(
v
);
::
unsafe
::
leak
(
v
);
::
unsafe
::
forget
(
v
);
r
}
...
...
src/libstd/rope.rs
浏览文件 @
b181ea41
...
...
@@ -813,12 +813,12 @@ fn serialize_node(node: @node) -> str unsafe {
offset
+=
1u
;
i
+=
1u
;
}
unsafe
::
leak
(
local_buf
);
unsafe
::
forget
(
local_buf
);
}
}
}
let
str
:
str
=
unsafe
::
reinterpret_cast
(
buf
);
unsafe
::
leak
(
buf
);
//TODO: Check if this is correct
unsafe
::
forget
(
buf
);
//TODO: Check if this is correct
ret
str
;
}
...
...
src/rustc/middle/trans/debuginfo.rs
浏览文件 @
b181ea41
...
...
@@ -123,7 +123,7 @@ enum debug_metadata {
fn
cast_safely
<
T
:
copy
,
U
>
(
val
:
T
)
->
U
unsafe
{
let
val2
=
val
;
let
val3
=
unsafe
::
reinterpret_cast
(
val2
);
unsafe
::
leak
(
val2
);
unsafe
::
forget
(
val2
);
ret
val3
;
}
...
...
src/rustc/middle/ty.rs
浏览文件 @
b181ea41
...
...
@@ -220,7 +220,7 @@ enum t_opaque {}
pure
fn
get
(
t
:
t
)
->
t_box
unsafe
{
let
t2
=
unsafe
::
reinterpret_cast
::
<
t
,
t_box
>
(
t
);
let
t3
=
t2
;
unsafe
::
leak
(
t2
);
unsafe
::
forget
(
t2
);
t3
}
...
...
src/test/run-pass/rt-sched-1.rs
浏览文件 @
b181ea41
...
...
@@ -31,6 +31,6 @@ fn main() unsafe {
};
let
fptr
=
unsafe
::
reinterpret_cast
(
ptr
::
addr_of
(
f
));
rustrt
::
start_task
(
new_task_id
,
fptr
);
unsafe
::
leak
(
f
);
unsafe
::
forget
(
f
);
comm
::
recv
(
po
);
}
\ No newline at end of file
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录