Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
int
Rust
提交
ca49fd40
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,发现更多精彩内容 >>
提交
ca49fd40
编写于
10月 05, 2012
作者:
T
Tim Chevalier
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
wip
上级
e16dbb78
变更
23
隐藏空白更改
内联
并排
Showing
23 changed file
with
93 addition
and
97 deletion
+93
-97
src/libcore/cmath.rs
src/libcore/cmath.rs
+8
-8
src/libstd/time.rs
src/libstd/time.rs
+29
-1
src/libsyntax/ast.rs
src/libsyntax/ast.rs
+1
-1
src/libsyntax/parse/comments.rs
src/libsyntax/parse/comments.rs
+14
-14
src/libsyntax/parse/eval.rs
src/libsyntax/parse/eval.rs
+5
-5
src/libsyntax/parse/parser.rs
src/libsyntax/parse/parser.rs
+6
-4
src/libsyntax/parse/token.rs
src/libsyntax/parse/token.rs
+1
-1
src/libsyntax/print/pprust.rs
src/libsyntax/print/pprust.rs
+0
-1
src/rustc/metadata/encoder.rs
src/rustc/metadata/encoder.rs
+1
-1
src/rustc/metadata/tydecode.rs
src/rustc/metadata/tydecode.rs
+0
-1
src/rustc/metadata/tyencode.rs
src/rustc/metadata/tyencode.rs
+0
-1
src/rustc/middle/borrowck.rs
src/rustc/middle/borrowck.rs
+3
-3
src/rustc/middle/borrowck/check_loans.rs
src/rustc/middle/borrowck/check_loans.rs
+5
-6
src/rustc/middle/borrowck/gather_loans.rs
src/rustc/middle/borrowck/gather_loans.rs
+0
-4
src/rustc/middle/kind.rs
src/rustc/middle/kind.rs
+5
-13
src/rustc/middle/liveness.rs
src/rustc/middle/liveness.rs
+8
-21
src/rustc/middle/mem_categorization.rs
src/rustc/middle/mem_categorization.rs
+0
-3
src/rustc/middle/trans/base.rs
src/rustc/middle/trans/base.rs
+1
-1
src/rustc/middle/trans/callee.rs
src/rustc/middle/trans/callee.rs
+1
-1
src/rustc/middle/trans/reflect.rs
src/rustc/middle/trans/reflect.rs
+0
-1
src/rustc/middle/trans/shape.rs
src/rustc/middle/trans/shape.rs
+4
-4
src/rustc/middle/trans/type_use.rs
src/rustc/middle/trans/type_use.rs
+1
-1
src/rustc/middle/trans/uniq.rs
src/rustc/middle/trans/uniq.rs
+0
-1
未找到文件。
src/libcore/cmath.rs
浏览文件 @
ca49fd40
...
...
@@ -40,15 +40,15 @@
#[link_name=
"fmax"
]
pure
fn
fmax
(
a
:
c_double
,
b
:
c_double
)
->
c_double
;
#[link_name=
"fmin"
]
pure
fn
fmin
(
a
:
c_double
,
b
:
c_double
)
->
c_double
;
pure
fn
nextafter
(
x
:
c_double
,
y
:
c_double
)
->
c_double
;
pure
fn
frexp
(
n
:
c_double
,
&
value
:
c_int
)
->
c_double
;
pure
fn
frexp
(
n
:
c_double
,
value
:
&
mut
c_int
)
->
c_double
;
pure
fn
hypot
(
x
:
c_double
,
y
:
c_double
)
->
c_double
;
pure
fn
ldexp
(
x
:
c_double
,
n
:
c_int
)
->
c_double
;
#[cfg(unix)]
#[link_name=
"lgamma_r"
]
pure
fn
lgamma
(
n
:
c_double
,
&
sign
:
c_int
)
->
c_double
;
sign
:
&
mut
c_int
)
->
c_double
;
#[cfg(windows)]
#[link_name=
"__lgamma_r"
]
pure
fn
lgamma
(
n
:
c_double
,
&
sign
:
c_int
)
->
c_double
;
sign
:
&
mut
c_int
)
->
c_double
;
// renamed: log is a reserved keyword; ln seems more natural, too
#[link_name=
"log"
]
pure
fn
ln
(
n
:
c_double
)
->
c_double
;
// renamed: "logb" /often/ is confused for log2 by beginners
...
...
@@ -58,7 +58,7 @@
pure
fn
log10
(
n
:
c_double
)
->
c_double
;
pure
fn
log2
(
n
:
c_double
)
->
c_double
;
#[link_name=
"ilogb"
]
pure
fn
ilog_radix
(
n
:
c_double
)
->
c_int
;
pure
fn
modf
(
n
:
c_double
,
&
iptr
:
c_double
)
->
c_double
;
pure
fn
modf
(
n
:
c_double
,
iptr
:
&
mut
c_double
)
->
c_double
;
pure
fn
pow
(
n
:
c_double
,
e
:
c_double
)
->
c_double
;
// FIXME (#1379): enable when rounding modes become available
// pure fn rint(n: c_double) -> c_double;
...
...
@@ -110,7 +110,7 @@
#[link_name=
"fdimf"
]
pure
fn
abs_sub
(
a
:
c_float
,
b
:
c_float
)
->
c_float
;
#[link_name=
"floorf"
]
pure
fn
floor
(
n
:
c_float
)
->
c_float
;
#[link_name=
"frexpf"
]
pure
fn
frexp
(
n
:
c_float
,
&
value
:
c_int
)
->
c_float
;
value
:
&
mut
c_int
)
->
c_float
;
#[link_name=
"fmaf"
]
pure
fn
mul_add
(
a
:
c_float
,
b
:
c_float
,
c
:
c_float
)
->
c_float
;
#[link_name=
"fmaxf"
]
pure
fn
fmax
(
a
:
c_float
,
b
:
c_float
)
->
c_float
;
...
...
@@ -122,11 +122,11 @@
#[cfg(unix)]
#[link_name=
"lgammaf_r"
]
pure
fn
lgamma
(
n
:
c_float
,
&
sign
:
c_int
)
->
c_float
;
sign
:
&
mut
c_int
)
->
c_float
;
#[cfg(windows)]
#[link_name=
"__lgammaf_r"
]
pure
fn
lgamma
(
n
:
c_float
,
&
sign
:
c_int
)
->
c_float
;
sign
:
&
mut
c_int
)
->
c_float
;
#[link_name=
"logf"
]
pure
fn
ln
(
n
:
c_float
)
->
c_float
;
#[link_name=
"logbf"
]
pure
fn
log_radix
(
n
:
c_float
)
->
c_float
;
...
...
@@ -135,7 +135,7 @@
#[link_name=
"log10f"
]
pure
fn
log10
(
n
:
c_float
)
->
c_float
;
#[link_name=
"ilogbf"
]
pure
fn
ilog_radix
(
n
:
c_float
)
->
c_int
;
#[link_name=
"modff"
]
pure
fn
modf
(
n
:
c_float
,
&
iptr
:
c_float
)
->
c_float
;
iptr
:
&
mut
c_float
)
->
c_float
;
#[link_name=
"powf"
]
pure
fn
pow
(
n
:
c_float
,
e
:
c_float
)
->
c_float
;
// FIXME (#1379): enable when rounding modes become available
// #[link_name="rintf"] pure fn rint(n: c_float) -> c_float;
...
...
src/libstd/time.rs
浏览文件 @
ca49fd40
...
...
@@ -7,9 +7,18 @@
#[abi
=
"cdecl"
]
extern
mod
rustrt
{
#[legacy_exports]
;
#[legacy_exports]
#[cfg(stage0)]
fn
get_time
(
&
sec
:
i64
,
&
nsec
:
i32
);
#[cfg(stage1)]
#[cfg(stage2)]
fn
get_time
(
sec
:
&
mut
i64
,
nsec
:
&
mut
i32
);
#[cfg(stage0)]
fn
precise_time_ns
(
&
ns
:
u64
);
#[cfg(stage1)]
#[cfg(stage2)]
fn
precise_time_ns
(
ns
:
&
mut
u64
);
fn
rust_tzset
();
// FIXME: The i64 values can be passed by-val when #2064 is fixed.
...
...
@@ -33,22 +42,41 @@ impl Timespec : Eq {
* Returns the current time as a `timespec` containing the seconds and
* nanoseconds since 1970-01-01T00:00:00Z.
*/
#[cfg(stage0)]
pub
fn
get_time
()
->
Timespec
{
let
mut
sec
=
0i64
;
let
mut
nsec
=
0i32
;
rustrt
::
get_time
(
sec
,
nsec
);
return
{
sec
:
sec
,
nsec
:
nsec
};
}
#[cfg(stage1)]
#[cfg(stage2)]
pub
fn
get_time
()
->
Timespec
{
let
mut
sec
=
0i64
;
let
mut
nsec
=
0i32
;
rustrt
::
get_time
(
&
mut
sec
,
&
mut
nsec
);
return
{
sec
:
sec
,
nsec
:
nsec
};
}
/**
* Returns the current value of a high-resolution performance counter
* in nanoseconds since an unspecified epoch.
*/
#[cfg(stage0)]
pub
fn
precise_time_ns
()
->
u64
{
let
mut
ns
=
0u64
;
rustrt
::
precise_time_ns
(
ns
);
ns
}
#[cfg(stage1)]
#[cfg(stage2)]
pub
fn
precise_time_ns
()
->
u64
{
let
mut
ns
=
0u64
;
rustrt
::
precise_time_ns
(
&
mut
ns
);
ns
}
/**
* Returns the current value of a high-resolution performance counter
...
...
src/libsyntax/ast.rs
浏览文件 @
ca49fd40
...
...
@@ -574,7 +574,7 @@ impl<T:cmp::Eq> inferable<T> : cmp::Eq {
// "resolved" mode: the real modes.
#[auto_serialize]
enum
rmode
{
by_ref
,
by_val
,
by_m
utbl_ref
,
by_m
ove
,
by_copy
}
enum
rmode
{
by_ref
,
by_val
,
by_move
,
by_copy
}
impl
rmode
:
to_bytes
::
IterBytes
{
pure
fn
iter_bytes
(
+
lsb0
:
bool
,
f
:
to_bytes
::
Cb
)
{
...
...
src/libsyntax/parse/comments.rs
浏览文件 @
ca49fd40
...
...
@@ -127,14 +127,14 @@ fn consume_non_eol_whitespace(rdr: string_reader) {
}
}
fn
push_blank_line_comment
(
rdr
:
string_reader
,
&
comments
:
~
[
cmnt
])
{
fn
push_blank_line_comment
(
rdr
:
string_reader
,
comments
:
&
mut
~
[
cmnt
])
{
debug!
(
">>> blank-line comment"
);
let
v
:
~
[
~
str
]
=
~
[];
comments
.push
({
style
:
blank_line
,
lines
:
v
,
pos
:
rdr
.chpos
});
}
fn
consume_whitespace_counting_blank_lines
(
rdr
:
string_reader
,
&
comments
:
~
[
cmnt
])
{
comments
:
&
mut
~
[
cmnt
])
{
while
is_whitespace
(
rdr
.curr
)
&&
!
is_eof
(
rdr
)
{
if
rdr
.col
==
0u
&&
rdr
.curr
==
'\n'
{
push_blank_line_comment
(
rdr
,
comments
);
...
...
@@ -145,7 +145,7 @@ fn consume_whitespace_counting_blank_lines(rdr: string_reader,
fn
read_shebang_comment
(
rdr
:
string_reader
,
code_to_the_left
:
bool
,
&
comments
:
~
[
cmnt
])
{
comments
:
&
mut
~
[
cmnt
])
{
debug!
(
">>> shebang comment"
);
let
p
=
rdr
.chpos
;
debug!
(
"<<< shebang comment"
);
...
...
@@ -157,7 +157,7 @@ fn read_shebang_comment(rdr: string_reader, code_to_the_left: bool,
}
fn
read_line_comments
(
rdr
:
string_reader
,
code_to_the_left
:
bool
,
&
comments
:
~
[
cmnt
])
{
comments
:
&
mut
~
[
cmnt
])
{
debug!
(
">>> line comments"
);
let
p
=
rdr
.chpos
;
let
mut
lines
:
~
[
~
str
]
=
~
[];
...
...
@@ -188,8 +188,8 @@ fn all_whitespace(s: ~str, begin: uint, end: uint) -> bool {
return
true
;
}
fn
trim_whitespace_prefix_and_push_line
(
&
lines
:
~
[
~
str
],
s
:
~
str
,
col
:
uint
)
unsafe
{
fn
trim_whitespace_prefix_and_push_line
(
lines
:
&
mut
~
[
~
str
],
s
:
~
str
,
col
:
uint
)
{
let
mut
s1
;
let
len
=
str
::
len
(
s
);
if
all_whitespace
(
s
,
0u
,
uint
::
min
(
len
,
col
))
{
...
...
@@ -202,7 +202,7 @@ fn trim_whitespace_prefix_and_push_line(&lines: ~[~str],
}
fn
read_block_comment
(
rdr
:
string_reader
,
code_to_the_left
:
bool
,
&
comments
:
~
[
cmnt
])
{
comments
:
&
mut
~
[
cmnt
])
{
debug!
(
">>> block comment"
);
let
p
=
rdr
.chpos
;
let
mut
lines
:
~
[
~
str
]
=
~
[];
...
...
@@ -228,7 +228,7 @@ fn read_block_comment(rdr: string_reader, code_to_the_left: bool,
debug!
(
"=== block comment level %d"
,
level
);
if
is_eof
(
rdr
)
{(
rdr
as
reader
)
.fatal
(
~
"unterminated block comment"
);}
if
rdr
.curr
==
'\n'
{
trim_whitespace_prefix_and_push_line
(
lines
,
curr_line
,
col
);
trim_whitespace_prefix_and_push_line
(
&
mut
lines
,
curr_line
,
col
);
curr_line
=
~
""
;
bump
(
rdr
);
}
else
{
...
...
@@ -248,8 +248,8 @@ fn read_block_comment(rdr: string_reader, code_to_the_left: bool,
}
}
}
if
str
::
len
(
curr_line
)
!=
0
u
{
trim_whitespace_prefix_and_push_line
(
lines
,
curr_line
,
col
);
if
str
::
len
(
curr_line
)
!=
0
{
trim_whitespace_prefix_and_push_line
(
&
mut
lines
,
curr_line
,
col
);
}
let
mut
style
=
if
code_to_the_left
{
trailing
}
else
{
isolated
};
consume_non_eol_whitespace
(
rdr
);
...
...
@@ -267,7 +267,7 @@ fn peeking_at_comment(rdr: string_reader) -> bool {
}
fn
consume_comment
(
rdr
:
string_reader
,
code_to_the_left
:
bool
,
&
comments
:
~
[
cmnt
])
{
comments
:
&
mut
~
[
cmnt
])
{
debug!
(
">>> consume comment"
);
if
rdr
.curr
==
'/'
&&
nextch
(
rdr
)
==
'/'
{
read_line_comments
(
rdr
,
code_to_the_left
,
comments
);
...
...
@@ -299,11 +299,11 @@ fn gather_comments_and_literals(span_diagnostic: diagnostic::span_handler,
consume_non_eol_whitespace
(
rdr
);
if
rdr
.curr
==
'\n'
{
code_to_the_left
=
false
;
consume_whitespace_counting_blank_lines
(
rdr
,
comments
);
consume_whitespace_counting_blank_lines
(
rdr
,
&
mut
comments
);
}
while
peeking_at_comment
(
rdr
)
{
consume_comment
(
rdr
,
code_to_the_left
,
comments
);
consume_whitespace_counting_blank_lines
(
rdr
,
comments
);
consume_comment
(
rdr
,
code_to_the_left
,
&
mut
comments
);
consume_whitespace_counting_blank_lines
(
rdr
,
&
mut
comments
);
}
break
;
}
...
...
src/libsyntax/parse/eval.rs
浏览文件 @
ca49fd40
...
...
@@ -10,8 +10,8 @@
fn
eval_crate_directives
(
cx
:
ctx
,
cdirs
:
~
[
@
ast
::
crate_directive
],
prefix
:
&
Path
,
&
view_items
:
~
[
@
ast
::
view_item
],
&
items
:
~
[
@
ast
::
item
])
{
view_items
:
&
mut
~
[
@
ast
::
view_item
],
items
:
&
mut
~
[
@
ast
::
item
])
{
for
cdirs
.each
|
sub_cdir
|
{
eval_crate_directive
(
cx
,
*
sub_cdir
,
prefix
,
view_items
,
items
);
}
...
...
@@ -24,7 +24,7 @@ fn eval_crate_directives_to_mod(cx: ctx, cdirs: ~[@ast::crate_directive],
=
parse_companion_mod
(
cx
,
prefix
,
suffix
);
let
mut
view_items
:
~
[
@
ast
::
view_item
]
=
~
[];
let
mut
items
:
~
[
@
ast
::
item
]
=
~
[];
eval_crate_directives
(
cx
,
cdirs
,
prefix
,
view_items
,
items
);
eval_crate_directives
(
cx
,
cdirs
,
prefix
,
&
mut
view_items
,
&
mut
items
);
return
({
view_items
:
vec
::
append
(
view_items
,
cview_items
),
items
:
vec
::
append
(
items
,
citems
)},
cattrs
);
...
...
@@ -82,8 +82,8 @@ fn cdir_path_opt(default: ~str, attrs: ~[ast::attribute]) -> ~str {
}
fn
eval_crate_directive
(
cx
:
ctx
,
cdir
:
@
ast
::
crate_directive
,
prefix
:
&
Path
,
&
view_items
:
~
[
@
ast
::
view_item
],
&
items
:
~
[
@
ast
::
item
])
{
view_items
:
&
mut
~
[
@
ast
::
view_item
],
items
:
&
mut
~
[
@
ast
::
item
])
{
match
cdir
.node
{
ast
::
cdir_src_mod
(
vis
,
id
,
attrs
)
=>
{
let
file_path
=
Path
(
cdir_path_opt
(
...
...
src/libsyntax/parse/parser.rs
浏览文件 @
ca49fd40
...
...
@@ -26,7 +26,7 @@
bind_by_ref
,
bind_by_implicit_ref
,
bind_by_value
,
bind_by_move
,
bitand
,
bitor
,
bitxor
,
blk
,
blk_check_mode
,
bound_const
,
bound_copy
,
bound_send
,
bound_trait
,
bound_owned
,
box
,
by_copy
,
by_move
,
by_
mutbl_ref
,
by_
ref
,
by_val
,
capture_clause
,
by_move
,
by_ref
,
by_val
,
capture_clause
,
capture_item
,
cdir_dir_mod
,
cdir_src_mod
,
cdir_view_item
,
class_immutable
,
class_mutable
,
crate
,
crate_cfg
,
crate_directive
,
decl
,
decl_item
,
decl_local
,
...
...
@@ -571,7 +571,7 @@ fn parse_ty(colons_before_params: bool) -> @ty {
fn
parse_arg_mode
()
->
mode
{
if
self
.eat
(
token
::
BINOP
(
token
::
AND
))
{
self
.warn
(
~
"Obsolete syntax has no effect"
);
expl
(
by_
mutbl_ref
)
expl
(
by_
val
)
}
else
if
self
.eat
(
token
::
BINOP
(
token
::
MINUS
))
{
expl
(
by_move
)
}
else
if
self
.eat
(
token
::
ANDAND
)
{
...
...
@@ -1276,7 +1276,8 @@ fn parse_tt_tok(p: parser, delim_ok: bool) -> token_tree {
return
match
self
.token
{
token
::
LPAREN
|
token
::
LBRACE
|
token
::
LBRACKET
=>
{
let
ket
=
token
::
flip_delimiter
(
self
.token
);
// tjc: ??????
let
ket
=
token
::
flip_delimiter
(
copy
self
.token
);
tt_delim
(
vec
::
append
(
~
[
parse_tt_tok
(
self
,
true
)],
vec
::
append
(
...
...
@@ -1297,7 +1298,8 @@ fn parse_matchers() -> ~[matcher] {
return
match
self
.token
{
token
::
LBRACE
|
token
::
LPAREN
|
token
::
LBRACKET
=>
{
self
.parse_matcher_subseq
(
name_idx
,
copy
self
.token
,
token
::
flip_delimiter
(
self
.token
))
// tjc: not sure why we need a copy
token
::
flip_delimiter
(
copy
self
.token
))
}
_
=>
self
.fatal
(
~
"expected open delimiter"
)
}
...
...
src/libsyntax/parse/token.rs
浏览文件 @
ca49fd40
...
...
@@ -230,7 +230,7 @@ fn to_str(in: @ident_interner, t: token) -> ~str {
}
/// what's the opposite delimiter?
fn
flip_delimiter
(
&
t
:
token
::
token
)
->
token
::
token
{
fn
flip_delimiter
(
t
:
token
::
token
)
->
token
::
token
{
match
t
{
token
::
LPAREN
=>
token
::
RPAREN
,
token
::
LBRACE
=>
token
::
RBRACE
,
...
...
src/libsyntax/print/pprust.rs
浏览文件 @
ca49fd40
...
...
@@ -1688,7 +1688,6 @@ fn print_fn_block_args(s: ps, decl: ast::fn_decl,
fn
mode_to_str
(
m
:
ast
::
mode
)
->
~
str
{
match
m
{
ast
::
expl
(
ast
::
by_mutbl_ref
)
=>
~
"&"
,
ast
::
expl
(
ast
::
by_move
)
=>
~
"-"
,
ast
::
expl
(
ast
::
by_ref
)
=>
~
"&&"
,
ast
::
expl
(
ast
::
by_val
)
=>
~
"++"
,
...
...
src/rustc/metadata/encoder.rs
浏览文件 @
ca49fd40
...
...
@@ -116,7 +116,7 @@ fn encode_mutability(ebml_w: ebml::Writer, mt: class_mutability) {
type
entry
<
T
>
=
{
val
:
T
,
pos
:
uint
};
fn
add_to_index
(
ecx
:
@
encode_ctxt
,
ebml_w
:
ebml
::
Writer
,
path
:
&
[
ident
],
&
index
:
~
[
entry
<~
str
>
],
name
:
ident
)
{
index
:
&
mut
~
[
entry
<~
str
>
],
name
:
ident
)
{
let
mut
full_path
=
~
[];
full_path
.push_all
(
path
);
full_path
.push
(
name
);
...
...
src/rustc/metadata/tydecode.rs
浏览文件 @
ca49fd40
...
...
@@ -394,7 +394,6 @@ fn parse_arg(st: @pstate, conv: conv_did) -> ty::arg {
fn
parse_mode
(
st
:
@
pstate
)
->
ast
::
mode
{
let
m
=
ast
::
expl
(
match
next
(
st
)
{
'&'
=>
ast
::
by_mutbl_ref
,
'-'
=>
ast
::
by_move
,
'+'
=>
ast
::
by_copy
,
'='
=>
ast
::
by_ref
,
...
...
src/rustc/metadata/tyencode.rs
浏览文件 @
ca49fd40
...
...
@@ -332,7 +332,6 @@ fn enc_arg(w: io::Writer, cx: @ctxt, arg: ty::arg) {
fn
enc_mode
(
w
:
io
::
Writer
,
cx
:
@
ctxt
,
m
:
mode
)
{
match
ty
::
resolved_mode
(
cx
.tcx
,
m
)
{
by_mutbl_ref
=>
w
.write_char
(
'&'
),
by_move
=>
w
.write_char
(
'-'
),
by_copy
=>
w
.write_char
(
'+'
),
by_ref
=>
w
.write_char
(
'='
),
...
...
src/rustc/middle/borrowck.rs
浏览文件 @
ca49fd40
...
...
@@ -396,10 +396,10 @@ impl bckerr : cmp::Eq {
pure_map
:
HashMap
<
ast
::
node_id
,
bckerr
>
};
fn
save_and_restore
<
T
:
Copy
,
U
>
(
&
save_and_restore_t
:
T
,
f
:
fn
()
->
U
)
->
U
{
let
old_save_and_restore_t
=
save_and_restore_t
;
fn
save_and_restore
<
T
:
Copy
,
U
>
(
save_and_restore_t
:
&
mut
T
,
f
:
fn
()
->
U
)
->
U
{
let
old_save_and_restore_t
=
*
save_and_restore_t
;
let
u
<-
f
();
save_and_restore_t
=
old_save_and_restore_t
;
*
save_and_restore_t
=
old_save_and_restore_t
;
move
u
}
...
...
src/rustc/middle/borrowck/check_loans.rs
浏览文件 @
ca49fd40
...
...
@@ -529,8 +529,7 @@ fn check_call(expr: @ast::expr,
ast
::
by_move
=>
{
self
.check_move_out
(
*
arg
);
}
ast
::
by_mutbl_ref
|
ast
::
by_ref
|
ast
::
by_copy
|
ast
::
by_val
=>
{
ast
::
by_ref
|
ast
::
by_copy
|
ast
::
by_val
=>
{
}
}
}
...
...
@@ -542,9 +541,9 @@ fn check_loans_in_fn(fk: visit::fn_kind, decl: ast::fn_decl, body: ast::blk,
visitor
:
visit
::
vt
<
check_loan_ctxt
>
)
{
debug!
(
"purity on entry=%?"
,
copy
self
.declared_purity
);
do
save_and_restore
(
self
.in_ctor
)
{
do
save_and_restore
(
self
.declared_purity
)
{
do
save_and_restore
(
self
.fn_args
)
{
do
save_and_restore
(
&
mut
(
self
.in_ctor
)
)
{
do
save_and_restore
(
&
mut
(
self
.declared_purity
)
)
{
do
save_and_restore
(
&
mut
(
self
.fn_args
)
)
{
let
is_stack_closure
=
self
.is_stack_closure
(
id
);
let
fty
=
ty
::
node_id_to_type
(
self
.tcx
(),
id
);
self
.declared_purity
=
ty
::
determine_inherited_purity
(
...
...
@@ -667,7 +666,7 @@ fn check_loans_in_expr(expr: @ast::expr,
fn
check_loans_in_block
(
blk
:
ast
::
blk
,
&&
self
:
check_loan_ctxt
,
vt
:
visit
::
vt
<
check_loan_ctxt
>
)
{
do
save_and_restore
(
self
.declared_purity
)
{
do
save_and_restore
(
&
mut
(
self
.declared_purity
)
)
{
self
.check_for_conflicting_loans
(
blk
.node.id
);
match
blk
.node.rules
{
...
...
src/rustc/middle/borrowck/gather_loans.rs
浏览文件 @
ca49fd40
...
...
@@ -115,10 +115,6 @@ fn req_loans_in_expr(ex: @ast::expr,
let
scope_r
=
ty
::
re_scope
(
ex
.id
);
for
vec
::
each2
(
args
,
arg_tys
)
|
arg
,
arg_ty
|
{
match
ty
::
resolved_mode
(
self
.tcx
(),
arg_ty
.mode
)
{
ast
::
by_mutbl_ref
=>
{
let
arg_cmt
=
self
.bccx
.cat_expr
(
*
arg
);
self
.guarantee_valid
(
arg_cmt
,
m_mutbl
,
scope_r
);
}
ast
::
by_ref
=>
{
let
arg_cmt
=
self
.bccx
.cat_expr
(
*
arg
);
self
.guarantee_valid
(
arg_cmt
,
m_imm
,
scope_r
);
...
...
src/rustc/middle/kind.rs
浏览文件 @
ca49fd40
...
...
@@ -319,13 +319,13 @@ fn check_expr(e: @expr, cx: ctx, v: visit::vt<ctx>) {
for
exprs
.each
|
expr
|
{
maybe_copy
(
cx
,
*
expr
,
None
);
}
}
expr_call
(
f
,
args
,
_
)
=>
{
let
mut
i
=
0
u
;
let
mut
i
=
0
;
for
ty
::
ty_fn_args
(
ty
::
expr_ty
(
cx
.tcx
,
f
))
.each
|
arg_t
|
{
match
ty
::
arg_mode
(
cx
.tcx
,
*
arg_t
)
{
by_copy
=>
maybe_copy
(
cx
,
args
[
i
],
None
),
by_ref
|
by_val
|
by_m
utbl_ref
|
by_m
ove
=>
()
by_ref
|
by_val
|
by_move
=>
()
}
i
+=
1
u
;
i
+=
1
;
}
}
expr_field
(
lhs
,
_
,
_
)
=>
{
...
...
@@ -335,7 +335,7 @@ fn check_expr(e: @expr, cx: ctx, v: visit::vt<ctx>) {
Some
(
ref
mme
)
=>
{
match
ty
::
arg_mode
(
cx
.tcx
,
mme
.self_arg
)
{
by_copy
=>
maybe_copy
(
cx
,
lhs
,
None
),
by_ref
|
by_val
|
by_m
utbl_ref
|
by_m
ove
=>
()
by_ref
|
by_val
|
by_move
=>
()
}
}
_
=>
()
...
...
@@ -465,18 +465,10 @@ fn check_imm_free_var(cx: ctx, def: def, sp: span) {
cx
.tcx.sess
.span_err
(
sp
,
msg
);
}
}
def_arg
(
_
,
mode
)
=>
{
match
ty
::
resolved_mode
(
cx
.tcx
,
mode
)
{
by_ref
|
by_val
|
by_move
|
by_copy
=>
{
/* ok */
}
by_mutbl_ref
=>
{
cx
.tcx.sess
.span_err
(
sp
,
msg
);
}
}
}
def_upvar
(
_
,
def1
,
_
,
_
)
=>
{
check_imm_free_var
(
cx
,
*
def1
,
sp
);
}
def_binding
(
*
)
|
def_self
(
*
)
=>
{
/*ok*/
}
def_
arg
(
*
)
|
def_
binding
(
*
)
|
def_self
(
*
)
=>
{
/*ok*/
}
_
=>
{
cx
.tcx.sess
.span_bug
(
sp
,
...
...
src/rustc/middle/liveness.rs
浏览文件 @
ca49fd40
...
...
@@ -398,8 +398,8 @@ fn add_last_use(expr_id: node_id, var: Variable) {
(
*
v
)
.push
(
id
);
}
Arg
(
_
,
_
,
by_ref
)
|
Arg
(
_
,
_
,
by_
mutbl_ref
)
|
Arg
(
_
,
_
,
by_val
)
|
Self
|
Field
(
_
)
|
ImplicitRet
|
Arg
(
_
,
_
,
by_ref
)
|
Arg
(
_
,
_
,
by_
val
)
|
Self
|
Field
(
_
)
|
ImplicitRet
|
Local
(
LocalInfo
{
kind
:
FromMatch
(
bind_by_implicit_ref
),
_
})
=>
{
debug!
(
"--but it is not owned"
);
}
...
...
@@ -831,9 +831,9 @@ fn merge_from_succ(ln: LiveNode, succ_ln: LiveNode,
let
mut
changed
=
false
;
do
self
.indices2
(
ln
,
succ_ln
)
|
idx
,
succ_idx
|
{
changed
|
=
copy_if_invalid
(
copy
self
.users
[
succ_idx
]
.reader
,
self
.users
[
idx
]
.reader
);
&
mut
self
.users
[
idx
]
.reader
);
changed
|
=
copy_if_invalid
(
copy
self
.users
[
succ_idx
]
.writer
,
self
.users
[
idx
]
.writer
);
&
mut
self
.users
[
idx
]
.writer
);
if
self
.users
[
succ_idx
]
.used
&&
!
self
.users
[
idx
]
.used
{
self
.users
[
idx
]
.used
=
true
;
changed
=
true
;
...
...
@@ -844,10 +844,10 @@ fn merge_from_succ(ln: LiveNode, succ_ln: LiveNode,
ln
.to_str
(),
self
.ln_str
(
succ_ln
),
first_merge
,
changed
);
return
changed
;
fn
copy_if_invalid
(
src
:
LiveNode
,
&
dst
:
LiveNode
)
->
bool
{
fn
copy_if_invalid
(
src
:
LiveNode
,
dst
:
&
mut
LiveNode
)
->
bool
{
if
src
.is_valid
()
{
if
!
dst
.is_valid
()
{
dst
=
src
;
*
dst
=
src
;
return
true
;
}
}
...
...
@@ -919,7 +919,7 @@ fn propagate_through_fn_block(decl: fn_decl, blk: blk) -> LiveNode {
// inputs passed by & mode should be considered live on exit:
for
decl
.inputs.each
|
arg
|
{
match
ty
::
resolved_mode
(
self
.tcx
,
arg
.mode
)
{
by_
mutbl_ref
|
by_
ref
|
by_val
=>
{
by_ref
|
by_val
=>
{
// These are "non-owned" modes, so register a read at
// the end. This will prevent us from moving out of
// such variables but also prevent us from registering
...
...
@@ -1573,7 +1573,7 @@ fn check_expr(expr: @expr, &&self: @Liveness, vt: vt<@Liveness>) {
let
targs
=
ty
::
ty_fn_args
(
ty
::
expr_ty
(
self
.tcx
,
f
));
for
vec
::
each2
(
args
,
targs
)
|
arg_expr
,
arg_ty
|
{
match
ty
::
resolved_mode
(
self
.tcx
,
arg_ty
.mode
)
{
by_val
|
by_copy
|
by_ref
|
by_mutbl_ref
=>
{}
by_val
|
by_copy
|
by_ref
=>
{}
by_move
=>
{
self
.check_move_from_expr
(
*
arg_expr
,
vt
);
}
...
...
@@ -1866,19 +1866,6 @@ fn warn_about_unused_args(sp: span, decl: fn_decl, entry_ln: LiveNode) {
for
decl
.inputs.each
|
arg
|
{
let
var
=
self
.variable
(
arg
.id
,
arg
.ty.span
);
match
ty
::
resolved_mode
(
self
.tcx
,
arg
.mode
)
{
by_mutbl_ref
=>
{
// for mutable reference arguments, something like
// x = 1;
// is not worth warning about, as it has visible
// side effects outside the fn.
match
self
.assigned_on_entry
(
entry_ln
,
var
)
{
Some
(
_
)
=>
{
/*ok*/
}
None
=>
{
// but if it is not written, it ought to be used
self
.warn_about_unused
(
sp
,
entry_ln
,
var
);
}
}
}
by_val
|
by_ref
|
by_move
|
by_copy
=>
{
self
.warn_about_unused
(
sp
,
entry_ln
,
var
);
}
...
...
src/rustc/middle/mem_categorization.rs
浏览文件 @
ca49fd40
...
...
@@ -523,9 +523,6 @@ fn cat_def(id: ast::node_id,
// m: mutability of the argument
// lp: loan path, must be none for aliasable things
let
{
m
,
lp
}
=
match
ty
::
resolved_mode
(
self
.tcx
,
mode
)
{
ast
::
by_mutbl_ref
=>
{
{
m
:
m_mutbl
,
lp
:
None
}
}
ast
::
by_move
|
ast
::
by_copy
=>
{
{
m
:
m_imm
,
lp
:
Some
(
@
lp_arg
(
vid
))}
}
...
...
src/rustc/middle/trans/base.rs
浏览文件 @
ca49fd40
...
...
@@ -1503,7 +1503,7 @@ fn copy_args_to_allocas(fcx: fn_ctxt,
// the event it's not truly needed.
let
llarg
;
match
ty
::
resolved_mode
(
tcx
,
arg_ty
.mode
)
{
ast
::
by_ref
|
ast
::
by_mutbl_ref
=>
{
ast
::
by_ref
=>
{
llarg
=
raw_llarg
;
}
ast
::
by_move
|
ast
::
by_copy
=>
{
...
...
src/rustc/middle/trans/callee.rs
浏览文件 @
ca49fd40
...
...
@@ -592,7 +592,7 @@ fn trans_arg_expr(bcx: block,
DoAutorefArg
=>
{
val
=
arg_datum
.to_ref_llval
(
bcx
);
}
DontAutorefArg
=>
{
match
arg_mode
{
ast
::
by_ref
|
ast
::
by_mutbl_ref
=>
{
ast
::
by_ref
=>
{
val
=
arg_datum
.to_ref_llval
(
bcx
);
}
...
...
src/rustc/middle/trans/reflect.rs
浏览文件 @
ca49fd40
...
...
@@ -208,7 +208,6 @@ fn visit_ty(t: ty::t) {
ast
::
expl
(
e
)
=>
match
e
{
ast
::
by_ref
=>
1u
,
ast
::
by_val
=>
2u
,
ast
::
by_mutbl_ref
=>
3u
,
ast
::
by_move
=>
4u
,
ast
::
by_copy
=>
5u
}
...
...
src/rustc/middle/trans/shape.rs
浏览文件 @
ca49fd40
...
...
@@ -49,12 +49,12 @@ fn mk_ctxt(llmod: ModuleRef) -> ctxt {
return
{
mut
next_tag_id
:
0u16
,
pad
:
0u16
,
pad2
:
0u32
};
}
fn
add_u16
(
&
dest
:
~
[
u8
],
val
:
u16
)
{
dest
+=
~
[(
val
&
0xffu16
)
as
u8
,
(
val
>>
8u16
)
as
u8
];
fn
add_u16
(
dest
:
&
mut
~
[
u8
],
val
:
u16
)
{
*
dest
+=
~
[(
val
&
0xffu16
)
as
u8
,
(
val
>>
8u16
)
as
u8
];
}
fn
add_substr
(
&
dest
:
~
[
u8
],
src
:
~
[
u8
])
{
fn
add_substr
(
dest
:
&
mut
~
[
u8
],
src
:
~
[
u8
])
{
add_u16
(
dest
,
vec
::
len
(
src
)
as
u16
);
dest
+=
src
;
*
dest
+=
src
;
}
src/rustc/middle/trans/type_use.rs
浏览文件 @
ca49fd40
...
...
@@ -53,7 +53,7 @@ fn type_uses_for(ccx: @crate_ctxt, fn_id: def_id, n_tps: uint)
by_val
|
by_move
|
by_copy
=>
{
type_needs
(
cx
,
use_repr
,
arg
.ty
);
}
by_ref
|
by_mutbl_ref
=>
{}
by_ref
=>
{}
}
}
}
...
...
src/rustc/middle/trans/uniq.rs
浏览文件 @
ca49fd40
...
...
@@ -3,7 +3,6 @@
use
common
::
*
;
use
build
::
*
;
use
base
::
*
;
use
shape
::
llsize_of
;
use
datum
::
immediate_rvalue
;
export
make_free_glue
,
autoderef
,
duplicate
;
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录