Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
int
Rust
提交
dabd4762
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,发现更多精彩内容 >>
提交
dabd4762
编写于
7月 31, 2013
作者:
D
Daniel Micay
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
make `in` and `foreach` get treated as keywords
上级
c47be692
变更
30
隐藏空白更改
内联
并排
Showing
30 changed file
with
184 addition
and
184 deletion
+184
-184
src/libextra/crypto/digest.rs
src/libextra/crypto/digest.rs
+3
-3
src/libextra/crypto/sha2.rs
src/libextra/crypto/sha2.rs
+50
-50
src/libextra/fileinput.rs
src/libextra/fileinput.rs
+11
-11
src/libextra/flate.rs
src/libextra/flate.rs
+7
-7
src/libextra/semver.rs
src/libextra/semver.rs
+1
-1
src/libextra/url.rs
src/libextra/url.rs
+11
-11
src/librustc/middle/lint.rs
src/librustc/middle/lint.rs
+2
-2
src/librustc/middle/liveness.rs
src/librustc/middle/liveness.rs
+2
-2
src/librustc/middle/trans/asm.rs
src/librustc/middle/trans/asm.rs
+3
-3
src/librustc/middle/trans/type_use.rs
src/librustc/middle/trans/type_use.rs
+2
-2
src/librustc/middle/typeck/check/mod.rs
src/librustc/middle/typeck/check/mod.rs
+2
-2
src/librusti/rusti.rs
src/librusti/rusti.rs
+5
-5
src/librustpkg/tests.rs
src/librustpkg/tests.rs
+4
-4
src/libstd/condition.rs
src/libstd/condition.rs
+7
-7
src/libstd/os.rs
src/libstd/os.rs
+17
-17
src/libstd/rt/io/extensions.rs
src/libstd/rt/io/extensions.rs
+5
-5
src/libstd/rt/io/net/tcp.rs
src/libstd/rt/io/net/tcp.rs
+4
-4
src/libstd/rt/io/net/udp.rs
src/libstd/rt/io/net/udp.rs
+1
-1
src/libstd/rt/io/option.rs
src/libstd/rt/io/option.rs
+4
-4
src/libstd/run.rs
src/libstd/run.rs
+8
-8
src/libstd/str.rs
src/libstd/str.rs
+1
-1
src/libsyntax/ext/asm.rs
src/libsyntax/ext/asm.rs
+2
-2
src/libsyntax/ext/expand.rs
src/libsyntax/ext/expand.rs
+6
-6
src/libsyntax/fold.rs
src/libsyntax/fold.rs
+1
-1
src/libsyntax/parse/token.rs
src/libsyntax/parse/token.rs
+13
-13
src/libsyntax/print/pprust.rs
src/libsyntax/print/pprust.rs
+2
-2
src/libsyntax/visit.rs
src/libsyntax/visit.rs
+2
-2
src/test/run-pass/issue-2904.rs
src/test/run-pass/issue-2904.rs
+3
-3
src/test/run-pass/option_addition.rs
src/test/run-pass/option_addition.rs
+3
-3
src/test/run-pass/record-pat.rs
src/test/run-pass/record-pat.rs
+2
-2
未找到文件。
src/libextra/crypto/digest.rs
浏览文件 @
dabd4762
...
...
@@ -65,7 +65,7 @@ pub trait DigestUtil {
*
* * in The string to feed into the digest
*/
fn
input_str
(
&
mut
self
,
in
:
&
str
);
fn
input_str
(
&
mut
self
,
in
put
:
&
str
);
/**
* Convenience functon that retrieves the result of a digest as a
...
...
@@ -75,8 +75,8 @@ pub trait DigestUtil {
}
impl
<
D
:
Digest
>
DigestUtil
for
D
{
fn
input_str
(
&
mut
self
,
in
:
&
str
)
{
self
.input
(
in
.as_bytes
());
fn
input_str
(
&
mut
self
,
in
put
:
&
str
)
{
self
.input
(
in
put
.as_bytes
());
}
fn
result_str
(
&
mut
self
)
->
~
str
{
...
...
src/libextra/crypto/sha2.rs
浏览文件 @
dabd4762
...
...
@@ -66,34 +66,34 @@ struct Engine512 {
}
// Convert a [u8] to a u64 in big-endian format
fn
to_u64
(
in
:
&
[
u8
])
->
u64
{
(
in
[
0
]
as
u64
)
<<
56
|
(
in
[
1
]
as
u64
)
<<
48
|
(
in
[
2
]
as
u64
)
<<
40
|
(
in
[
3
]
as
u64
)
<<
32
|
(
in
[
4
]
as
u64
)
<<
24
|
(
in
[
5
]
as
u64
)
<<
16
|
(
in
[
6
]
as
u64
)
<<
8
|
(
in
[
7
]
as
u64
)
fn
to_u64
(
in
put
:
&
[
u8
])
->
u64
{
(
in
put
[
0
]
as
u64
)
<<
56
|
(
in
put
[
1
]
as
u64
)
<<
48
|
(
in
put
[
2
]
as
u64
)
<<
40
|
(
in
put
[
3
]
as
u64
)
<<
32
|
(
in
put
[
4
]
as
u64
)
<<
24
|
(
in
put
[
5
]
as
u64
)
<<
16
|
(
in
put
[
6
]
as
u64
)
<<
8
|
(
in
put
[
7
]
as
u64
)
}
// Convert a u64 to a [u8] in big endian format
fn
from_u64
(
in
:
u64
,
out
:
&
mut
[
u8
])
{
out
[
0
]
=
(
in
>>
56
)
as
u8
;
out
[
1
]
=
(
in
>>
48
)
as
u8
;
out
[
2
]
=
(
in
>>
40
)
as
u8
;
out
[
3
]
=
(
in
>>
32
)
as
u8
;
out
[
4
]
=
(
in
>>
24
)
as
u8
;
out
[
5
]
=
(
in
>>
16
)
as
u8
;
out
[
6
]
=
(
in
>>
8
)
as
u8
;
out
[
7
]
=
in
as
u8
;
fn
from_u64
(
in
put
:
u64
,
out
:
&
mut
[
u8
])
{
out
[
0
]
=
(
in
put
>>
56
)
as
u8
;
out
[
1
]
=
(
in
put
>>
48
)
as
u8
;
out
[
2
]
=
(
in
put
>>
40
)
as
u8
;
out
[
3
]
=
(
in
put
>>
32
)
as
u8
;
out
[
4
]
=
(
in
put
>>
24
)
as
u8
;
out
[
5
]
=
(
in
put
>>
16
)
as
u8
;
out
[
6
]
=
(
in
put
>>
8
)
as
u8
;
out
[
7
]
=
in
put
as
u8
;
}
impl
Engine512
{
fn
input_byte
(
&
mut
self
,
in
:
u8
)
{
fn
input_byte
(
&
mut
self
,
in
put
:
u8
)
{
assert
!
(
!
self
.finished
)
self
.input_buffer
[
self
.input_buffer_idx
]
=
in
;
self
.input_buffer
[
self
.input_buffer_idx
]
=
in
put
;
self
.input_buffer_idx
+=
1
;
if
(
self
.input_buffer_idx
==
8
)
{
...
...
@@ -105,25 +105,25 @@ fn input_byte(&mut self, in: u8) {
self
.bit_counter
.add_bytes
(
1
);
}
fn
input_vec
(
&
mut
self
,
in
:
&
[
u8
])
{
fn
input_vec
(
&
mut
self
,
in
put
:
&
[
u8
])
{
assert
!
(
!
self
.finished
)
let
mut
i
=
0
;
while
i
<
in
.len
()
&&
self
.input_buffer_idx
!=
0
{
self
.input_byte
(
in
[
i
]);
while
i
<
in
put
.len
()
&&
self
.input_buffer_idx
!=
0
{
self
.input_byte
(
in
put
[
i
]);
i
+=
1
;
}
while
in
.len
()
-
i
>=
8
{
let
w
=
to_u64
(
in
.slice
(
i
,
i
+
8
));
while
in
put
.len
()
-
i
>=
8
{
let
w
=
to_u64
(
in
put
.slice
(
i
,
i
+
8
));
self
.process_word
(
w
);
self
.bit_counter
.add_bytes
(
8
);
i
+=
8
;
}
while
i
<
in
.len
()
{
self
.input_byte
(
in
[
i
]);
while
i
<
in
put
.len
()
{
self
.input_byte
(
in
put
[
i
]);
i
+=
1
;
}
}
...
...
@@ -135,8 +135,8 @@ fn reset(&mut self) {
self
.W_idx
=
0
;
}
fn
process_word
(
&
mut
self
,
in
:
u64
)
{
self
.W
[
self
.W_idx
]
=
in
;
fn
process_word
(
&
mut
self
,
in
put
:
u64
)
{
self
.W
[
self
.W_idx
]
=
in
put
;
self
.W_idx
+=
1
;
if
(
self
.W_idx
==
16
)
{
self
.W_idx
=
0
;
...
...
@@ -356,26 +356,26 @@ struct Engine256 {
}
// Convert a [u8] to a u32 in big endian format
fn
to_u32
(
in
:
&
[
u8
])
->
u32
{
(
in
[
0
]
as
u32
)
<<
24
|
(
in
[
1
]
as
u32
)
<<
16
|
(
in
[
2
]
as
u32
)
<<
8
|
(
in
[
3
]
as
u32
)
fn
to_u32
(
in
put
:
&
[
u8
])
->
u32
{
(
in
put
[
0
]
as
u32
)
<<
24
|
(
in
put
[
1
]
as
u32
)
<<
16
|
(
in
put
[
2
]
as
u32
)
<<
8
|
(
in
put
[
3
]
as
u32
)
}
// Convert a u32 to a [u8] in big endian format
fn
from_u32
(
in
:
u32
,
out
:
&
mut
[
u8
])
{
out
[
0
]
=
(
in
>>
24
)
as
u8
;
out
[
1
]
=
(
in
>>
16
)
as
u8
;
out
[
2
]
=
(
in
>>
8
)
as
u8
;
out
[
3
]
=
in
as
u8
;
fn
from_u32
(
in
put
:
u32
,
out
:
&
mut
[
u8
])
{
out
[
0
]
=
(
in
put
>>
24
)
as
u8
;
out
[
1
]
=
(
in
put
>>
16
)
as
u8
;
out
[
2
]
=
(
in
put
>>
8
)
as
u8
;
out
[
3
]
=
in
put
as
u8
;
}
impl
Engine256
{
fn
input_byte
(
&
mut
self
,
in
:
u8
)
{
fn
input_byte
(
&
mut
self
,
in
put
:
u8
)
{
assert
!
(
!
self
.finished
)
self
.input_buffer
[
self
.input_buffer_idx
]
=
in
;
self
.input_buffer
[
self
.input_buffer_idx
]
=
in
put
;
self
.input_buffer_idx
+=
1
;
if
(
self
.input_buffer_idx
==
4
)
{
...
...
@@ -387,25 +387,25 @@ fn input_byte(&mut self, in: u8) {
self
.length_bytes
+=
1
;
}
fn
input_vec
(
&
mut
self
,
in
:
&
[
u8
])
{
fn
input_vec
(
&
mut
self
,
in
put
:
&
[
u8
])
{
assert
!
(
!
self
.finished
)
let
mut
i
=
0
;
while
i
<
in
.len
()
&&
self
.input_buffer_idx
!=
0
{
self
.input_byte
(
in
[
i
]);
while
i
<
in
put
.len
()
&&
self
.input_buffer_idx
!=
0
{
self
.input_byte
(
in
put
[
i
]);
i
+=
1
;
}
while
in
.len
()
-
i
>=
4
{
let
w
=
to_u32
(
in
.slice
(
i
,
i
+
4
));
while
in
put
.len
()
-
i
>=
4
{
let
w
=
to_u32
(
in
put
.slice
(
i
,
i
+
4
));
self
.process_word
(
w
);
self
.length_bytes
+=
4
;
i
+=
4
;
}
while
i
<
in
.len
()
{
self
.input_byte
(
in
[
i
]);
while
i
<
in
put
.len
()
{
self
.input_byte
(
in
put
[
i
]);
i
+=
1
;
}
...
...
@@ -418,8 +418,8 @@ fn reset(&mut self) {
self
.W_idx
=
0
;
}
fn
process_word
(
&
mut
self
,
in
:
u32
)
{
self
.W
[
self
.W_idx
]
=
in
;
fn
process_word
(
&
mut
self
,
in
put
:
u32
)
{
self
.W
[
self
.W_idx
]
=
in
put
;
self
.W_idx
+=
1
;
if
(
self
.W_idx
==
16
)
{
self
.W_idx
=
0
;
...
...
src/libextra/fileinput.rs
浏览文件 @
dabd4762
...
...
@@ -72,10 +72,10 @@
(where the numbers are from the start of each file, rather than the
total line count).
let in = FileInput::from_vec(pathify([~"a.txt", ~"b.txt", ~"c.txt"],
let in
put
= FileInput::from_vec(pathify([~"a.txt", ~"b.txt", ~"c.txt"],
true));
for in.each_line |line| {
for in
put
.each_line |line| {
if line.is_empty() {
break
}
...
...
@@ -85,9 +85,9 @@
io::println("Continue?");
if io::stdin().read_line() == ~"yes" {
in.next_file(); // skip!
in
put
.next_file(); // skip!
for in.each_line_state |line, state| {
for in
put
.each_line_state |line, state| {
io::println(fmt!("%u: %s", state.line_num_file,
line))
}
...
...
@@ -589,29 +589,29 @@ fn test_next_file() {
make_file
(
filename
.get_ref
(),
contents
);
}
let
in
=
FileInput
::
from_vec
(
filenames
);
let
in
put
=
FileInput
::
from_vec
(
filenames
);
// read once from 0
assert_eq!
(
in
.read_line
(),
~
"0 1"
);
in
.next_file
();
// skip the rest of 1
assert_eq!
(
in
put
.read_line
(),
~
"0 1"
);
in
put
.next_file
();
// skip the rest of 1
// read all lines from 1 (but don't read any from 2),
for
uint
::
range
(
1
,
4
)
|
i
|
{
assert_eq!
(
in
.read_line
(),
fmt!
(
"1 %u"
,
i
));
assert_eq!
(
in
put
.read_line
(),
fmt!
(
"1 %u"
,
i
));
}
// 1 is finished, but 2 hasn't been started yet, so this will
// just "skip" to the beginning of 2 (Python's fileinput does
// the same)
in
.next_file
();
in
put
.next_file
();
assert_eq!
(
in
.read_line
(),
~
"2 1"
);
assert_eq!
(
in
put
.read_line
(),
~
"2 1"
);
}
#[test]
#[should_fail]
fn
test_input_vec_missing_file
()
{
for
input_vec
(
pathify
([
~
"this/file/doesnt/exist"
],
true
))
|
line
|
{
io
::
println
(
line
);
println
(
line
);
}
}
}
src/libextra/flate.rs
浏览文件 @
dabd4762
...
...
@@ -95,18 +95,18 @@ fn test_flate_round_trip() {
words
.push
(
r
.gen_bytes
(
range
));
}
for
20
.times
{
let
mut
in
=
~
[];
let
mut
in
put
=
~
[];
for
2000
.times
{
in
.push_all
(
r
.choose
(
words
));
in
put
.push_all
(
r
.choose
(
words
));
}
debug!
(
"de/inflate of %u bytes of random word-sequences"
,
in
.len
());
let
cmp
=
deflate_bytes
(
in
);
in
put
.len
());
let
cmp
=
deflate_bytes
(
in
put
);
let
out
=
inflate_bytes
(
cmp
);
debug!
(
"%u bytes deflated to %u (%.1f%% size)"
,
in
.len
(),
cmp
.len
(),
100.0
*
((
cmp
.len
()
as
float
)
/
(
in
.len
()
as
float
)));
assert_eq!
(
in
,
out
);
in
put
.len
(),
cmp
.len
(),
100.0
*
((
cmp
.len
()
as
float
)
/
(
in
put
.len
()
as
float
)));
assert_eq!
(
in
put
,
out
);
}
}
}
src/libextra/semver.rs
浏览文件 @
dabd4762
...
...
@@ -221,7 +221,7 @@ pub fn parse(s: &str) -> Option<Version> {
}
let
s
=
s
.trim
();
let
mut
bad
=
false
;
do
bad_parse
::
cond
.trap
(|
_
|
{
debug!
(
"bad"
);
bad
=
true
})
.in
{
do
bad_parse
::
cond
.trap
(|
_
|
{
debug!
(
"bad"
);
bad
=
true
})
.in
side
{
do
io
::
with_str_reader
(
s
)
|
rdr
|
{
let
v
=
parse_reader
(
rdr
);
if
bad
||
v
.to_str
()
!=
s
.to_owned
()
{
...
...
src/libextra/url.rs
浏览文件 @
dabd4762
...
...
@@ -407,7 +407,7 @@ enum State {
let
len
=
rawurl
.len
();
let
mut
st
=
Start
;
let
mut
in
=
Digit
;
// most restricted, start here.
let
mut
in
put
=
Digit
;
// most restricted, start here.
let
mut
userinfo
=
None
;
let
mut
host
=
~
""
;
...
...
@@ -425,13 +425,13 @@ enum State {
match
c
{
'0'
..
'9'
=>
(),
'A'
..
'F'
|
'a'
..
'f'
=>
{
if
in
==
Digit
{
in
=
Hex
;
if
in
put
==
Digit
{
in
put
=
Hex
;
}
}
'G'
..
'Z'
|
'g'
..
'z'
|
'-'
|
'.'
|
'_'
|
'~'
|
'%'
|
'&'
|
'\''
|
'('
|
')'
|
'+'
|
'!'
|
'*'
|
','
|
';'
|
'='
=>
{
in
=
Unreserved
;
in
put
=
Unreserved
;
}
':'
|
'@'
|
'?'
|
'#'
|
'/'
=>
{
// separators, don't change anything
...
...
@@ -452,7 +452,7 @@ enum State {
}
PassHostPort
=>
{
// multiple colons means ipv6 address.
if
in
==
Unreserved
{
if
in
put
==
Unreserved
{
return
Err
(
~
"Illegal characters in IPv6 address."
);
}
...
...
@@ -461,13 +461,13 @@ enum State {
InHost
=>
{
pos
=
i
;
// can't be sure whether this is an ipv6 address or a port
if
in
==
Unreserved
{
if
in
put
==
Unreserved
{
return
Err
(
~
"Illegal characters in authority."
);
}
st
=
Ip6Port
;
}
Ip6Port
=>
{
if
in
==
Unreserved
{
if
in
put
==
Unreserved
{
return
Err
(
~
"Illegal characters in authority."
);
}
st
=
Ip6Host
;
...
...
@@ -483,11 +483,11 @@ enum State {
return
Err
(
~
"Invalid ':' in authority."
);
}
}
in
=
Digit
;
// reset input class
in
put
=
Digit
;
// reset input class
}
'@'
=>
{
in
=
Digit
;
// reset input class
in
put
=
Digit
;
// reset input class
colon_count
=
0
;
// reset count
match
st
{
Start
=>
{
...
...
@@ -535,7 +535,7 @@ enum State {
}
}
PassHostPort
|
Ip6Port
=>
{
if
in
!=
Digit
{
if
in
put
!=
Digit
{
return
Err
(
~
"Non-digit characters in port."
);
}
host
=
rawurl
.slice
(
begin
,
pos
)
.to_owned
();
...
...
@@ -545,7 +545,7 @@ enum State {
host
=
rawurl
.slice
(
begin
,
end
)
.to_owned
();
}
InPort
=>
{
if
in
!=
Digit
{
if
in
put
!=
Digit
{
return
Err
(
~
"Non-digit characters in port."
);
}
port
=
Some
(
rawurl
.slice
(
pos
+
1
,
end
)
.to_owned
());
...
...
src/librustc/middle/lint.rs
浏览文件 @
dabd4762
...
...
@@ -706,8 +706,8 @@ fn check_ty(cx: &Context, ty: &ast::Ty) {
}
fn
check_foreign_fn
(
cx
:
&
Context
,
decl
:
&
ast
::
fn_decl
)
{
for
decl
.inputs
.iter
()
.advance
|
in
|
{
check_ty
(
cx
,
&
in
.ty
);
for
decl
.inputs
.iter
()
.advance
|
in
put
|
{
check_ty
(
cx
,
&
in
put
.ty
);
}
check_ty
(
cx
,
&
decl
.output
)
}
...
...
src/librustc/middle/liveness.rs
浏览文件 @
dabd4762
...
...
@@ -1461,8 +1461,8 @@ fn check_expr(expr: @expr, (this, vt): (@Liveness, vt<@Liveness>)) {
}
expr_inline_asm
(
ref
ia
)
=>
{
for
ia
.inputs
.iter
()
.advance
|
&
(
_
,
in
)|
{
(
vt
.visit_expr
)(
in
,
(
this
,
vt
));
for
ia
.inputs
.iter
()
.advance
|
&
(
_
,
in
put
)|
{
(
vt
.visit_expr
)(
in
put
,
(
this
,
vt
));
}
// Output operands must be lvalues
...
...
src/librustc/middle/trans/asm.rs
浏览文件 @
dabd4762
...
...
@@ -68,14 +68,14 @@ pub fn trans_inline_asm(bcx: @mut Block, ia: &ast::inline_asm) -> @mut Block {
cleanups
.clear
();
// Now the input operands
let
inputs
=
do
ia
.inputs.map
|
&
(
c
,
in
)|
{
let
inputs
=
do
ia
.inputs.map
|
&
(
c
,
in
put
)|
{
constraints
.push
(
c
);
unpack_result!
(
bcx
,
{
callee
::
trans_arg_expr
(
bcx
,
expr_ty
(
bcx
,
in
),
expr_ty
(
bcx
,
in
put
),
ty
::
ByCopy
,
in
,
in
put
,
&
mut
cleanups
,
None
,
callee
::
DontAutorefArg
)
...
...
src/librustc/middle/trans/type_use.rs
浏览文件 @
dabd4762
...
...
@@ -388,8 +388,8 @@ pub fn mark_for_expr(cx: &Context, e: &expr) {
}
expr_inline_asm
(
ref
ia
)
=>
{
for
ia
.inputs
.iter
()
.advance
|
&
(
_
,
in
)|
{
node_type_needs
(
cx
,
use_repr
,
in
.id
);
for
ia
.inputs
.iter
()
.advance
|
&
(
_
,
in
put
)|
{
node_type_needs
(
cx
,
use_repr
,
in
put
.id
);
}
for
ia
.outputs
.iter
()
.advance
|
&
(
_
,
out
)|
{
node_type_needs
(
cx
,
use_repr
,
out
.id
);
...
...
src/librustc/middle/typeck/check/mod.rs
浏览文件 @
dabd4762
...
...
@@ -2478,8 +2478,8 @@ fn check_loop_body(fcx: @mut FnCtxt,
fcx
.write_ty
(
id
,
ty_param_bounds_and_ty
.ty
);
}
ast
::
expr_inline_asm
(
ref
ia
)
=>
{
for
ia
.inputs
.iter
()
.advance
|
&
(
_
,
in
)|
{
check_expr
(
fcx
,
in
);
for
ia
.inputs
.iter
()
.advance
|
&
(
_
,
in
put
)|
{
check_expr
(
fcx
,
in
put
);
}
for
ia
.outputs
.iter
()
.advance
|
&
(
_
,
out
)|
{
check_expr
(
fcx
,
out
);
...
...
src/librusti/rusti.rs
浏览文件 @
dabd4762
...
...
@@ -447,7 +447,7 @@ fn run_cmd(repl: &mut Repl, _in: @io::Reader, _out: @io::Writer,
/// Executes a line of input, which may either be rust code or a
/// :command. Returns a new Repl if it has changed.
pub
fn
run_line
(
repl
:
&
mut
Repl
,
in
:
@
io
::
Reader
,
out
:
@
io
::
Writer
,
line
:
~
str
,
pub
fn
run_line
(
repl
:
&
mut
Repl
,
in
put
:
@
io
::
Reader
,
out
:
@
io
::
Writer
,
line
:
~
str
,
use_rl
:
bool
)
->
bool
{
if
line
.starts_with
(
":"
)
{
...
...
@@ -464,11 +464,11 @@ pub fn run_line(repl: &mut Repl, in: @io::Reader, out: @io::Writer, line: ~str,
split
.slice
(
1
,
len
)
.to_owned
()
}
else
{
~
[]
};
match
run_cmd
(
repl
,
in
,
out
,
cmd
,
args
,
use_rl
)
{
match
run_cmd
(
repl
,
in
put
,
out
,
cmd
,
args
,
use_rl
)
{
action_none
=>
{
}
action_run_line
(
multiline_cmd
)
=>
{
if
!
multiline_cmd
.is_empty
()
{
return
run_line
(
repl
,
in
,
out
,
multiline_cmd
,
use_rl
);
return
run_line
(
repl
,
in
put
,
out
,
multiline_cmd
,
use_rl
);
}
}
}
...
...
@@ -500,7 +500,7 @@ pub fn run_line(repl: &mut Repl, in: @io::Reader, out: @io::Writer, line: ~str,
pub
fn
main
()
{
let
args
=
os
::
args
();
let
in
=
io
::
stdin
();
let
in
put
=
io
::
stdin
();
let
out
=
io
::
stdout
();
let
mut
repl
=
Repl
{
prompt
:
~
"rusti> "
,
...
...
@@ -542,7 +542,7 @@ pub fn main() {
}
loop
;
}
run_line
(
&
mut
repl
,
in
,
out
,
line
,
istty
);
run_line
(
&
mut
repl
,
in
put
,
out
,
line
,
istty
);
}
}
}
...
...
src/librustpkg/tests.rs
浏览文件 @
dabd4762
...
...
@@ -485,11 +485,11 @@ fn test_install_invalid() {
let
mut
error1_occurred
=
false
;
do
cond1
.trap
(|
_
|
{
error1_occurred
=
true
;
})
.in
{
})
.in
side
{
do
cond
.trap
(|
_
|
{
error_occurred
=
true
;
temp_workspace
.clone
()
})
.in
{
})
.in
side
{
ctxt
.install
(
&
temp_workspace
,
&
pkgid
);
}
}
...
...
@@ -573,7 +573,7 @@ fn test_package_ids_must_be_relative_path_like() {
assert
!
(
""
==
p
.to_str
());
assert
!
(
"0-length pkgid"
==
e
);
whatever
.clone
()
})
.in
{
})
.in
side
{
let
x
=
PkgId
::
new
(
""
,
&
os
::
getcwd
());
assert_eq!
(
~
"foo-0.1"
,
x
.to_str
());
}
...
...
@@ -582,7 +582,7 @@ fn test_package_ids_must_be_relative_path_like() {
assert_eq!
(
p
.to_str
(),
os
::
make_absolute
(
&
Path
(
"foo/bar/quux"
))
.to_str
());
assert
!
(
"absolute pkgid"
==
e
);
whatever
.clone
()
})
.in
{
})
.in
side
{
let
z
=
PkgId
::
new
(
os
::
make_absolute
(
&
Path
(
"foo/bar/quux"
))
.to_str
(),
&
os
::
getcwd
());
assert_eq!
(
~
"foo-0.1"
,
z
.to_str
());
...
...
src/libstd/condition.rs
浏览文件 @
dabd4762
...
...
@@ -73,7 +73,7 @@ struct Trap<'self, T, U> {
}
impl
<
'self
,
T
,
U
>
Trap
<
'self
,
T
,
U
>
{
pub
fn
in
<
V
>
(
&
self
,
inner
:
&
'self
fn
()
->
V
)
->
V
{
pub
fn
in
side
<
V
>
(
&
self
,
inner
:
&
'self
fn
()
->
V
)
->
V
{
let
_
g
=
Guard
{
cond
:
self
.cond
};
debug!
(
"Trap: pushing handler to TLS"
);
local_data
::
set
(
self
.cond.key
,
self
.handler
);
...
...
@@ -119,7 +119,7 @@ fn nested_trap_test_inner() {
debug!
(
"nested_trap_test_inner: in handler"
);
inner_trapped
=
true
;
0
})
.in
{
})
.in
side
{
debug!
(
"nested_trap_test_inner: in protected block"
);
trouble
(
1
);
}
...
...
@@ -134,7 +134,7 @@ fn nested_trap_test_outer() {
do
sadness
::
cond
.trap
(|
_
j
|
{
debug!
(
"nested_trap_test_outer: in handler"
);
outer_trapped
=
true
;
0
})
.in
{
})
.in
side
{
debug!
(
"nested_guard_test_outer: in protected block"
);
nested_trap_test_inner
();
trouble
(
1
);
...
...
@@ -152,7 +152,7 @@ fn nested_reraise_trap_test_inner() {
let
i
=
10
;
debug!
(
"nested_reraise_trap_test_inner: handler re-raising"
);
sadness
::
cond
.raise
(
i
)
})
.in
{
})
.in
side
{
debug!
(
"nested_reraise_trap_test_inner: in protected block"
);
trouble
(
1
);
}
...
...
@@ -167,7 +167,7 @@ fn nested_reraise_trap_test_outer() {
do
sadness
::
cond
.trap
(|
_
j
|
{
debug!
(
"nested_reraise_trap_test_outer: in handler"
);
outer_trapped
=
true
;
0
})
.in
{
})
.in
side
{
debug!
(
"nested_reraise_trap_test_outer: in protected block"
);
nested_reraise_trap_test_inner
();
}
...
...
@@ -182,7 +182,7 @@ fn test_default() {
do
sadness
::
cond
.trap
(|
j
|
{
debug!
(
"test_default: in handler"
);
sadness
::
cond
.raise_default
(
j
,
||
{
trapped
=
true
;
5
})
})
.in
{
})
.in
side
{
debug!
(
"test_default: in protected block"
);
trouble
(
1
);
}
...
...
@@ -205,7 +205,7 @@ fn test_conditions_are_public() {
do
sadness
::
cond
.trap
(|
_
|
{
trapped
=
true
;
0
})
.in
{
})
.in
side
{
sadness
::
cond
.raise
(
0
);
}
assert
!
(
trapped
);
...
...
src/libstd/os.rs
浏览文件 @
dabd4762
...
...
@@ -389,17 +389,17 @@ pub fn fsync_fd(fd: c_int, _l: io::fsync::Level) -> c_int {
}
pub
struct
Pipe
{
in
:
c_int
,
in
put
:
c_int
,
out
:
c_int
}
#[cfg(unix)]
pub
fn
pipe
()
->
Pipe
{
unsafe
{
let
mut
fds
=
Pipe
{
in
:
0
as
c_int
,
let
mut
fds
=
Pipe
{
in
put
:
0
as
c_int
,
out
:
0
as
c_int
};
assert_eq!
(
libc
::
pipe
(
&
mut
fds
.in
),
(
0
as
c_int
));
return
Pipe
{
in
:
fds
.in
,
out
:
fds
.out
};
assert_eq!
(
libc
::
pipe
(
&
mut
fds
.in
put
),
(
0
as
c_int
));
return
Pipe
{
in
put
:
fds
.input
,
out
:
fds
.out
};
}
}
...
...
@@ -413,14 +413,14 @@ pub fn pipe() -> Pipe {
// fully understand. Here we explicitly make the pipe non-inheritable,
// which means to pass it to a subprocess they need to be duplicated
// first, as in core::run.
let
mut
fds
=
Pipe
{
in
:
0
as
c_int
,
let
mut
fds
=
Pipe
{
in
put
:
0
as
c_int
,
out
:
0
as
c_int
};
let
res
=
libc
::
pipe
(
&
mut
fds
.in
,
1024
as
::
libc
::
c_uint
,
let
res
=
libc
::
pipe
(
&
mut
fds
.in
put
,
1024
as
::
libc
::
c_uint
,
(
libc
::
O_BINARY
|
libc
::
O_NOINHERIT
)
as
c_int
);
assert_eq!
(
res
,
0
as
c_int
);
assert
!
((
fds
.in
!=
-
1
as
c_int
&&
fds
.in
!=
0
as
c_int
));
assert
!
((
fds
.out
!=
-
1
as
c_int
&&
fds
.in
!=
0
as
c_int
));
return
Pipe
{
in
:
fds
.in
,
out
:
fds
.out
};
assert
!
((
fds
.in
put
!=
-
1
as
c_int
&&
fds
.input
!=
0
as
c_int
));
assert
!
((
fds
.out
!=
-
1
as
c_int
&&
fds
.in
put
!=
0
as
c_int
));
return
Pipe
{
in
put
:
fds
.input
,
out
:
fds
.out
};
}
}
...
...
@@ -1931,11 +1931,11 @@ fn copy_file_ok() {
let
tempdir
=
getcwd
();
// would like to use $TMPDIR,
// doesn't seem to work on Linux
assert
!
((
tempdir
.to_str
()
.len
()
>
0u
));
let
in
=
tempdir
.push
(
"in.txt"
);
let
in
put
=
tempdir
.push
(
"in.txt"
);
let
out
=
tempdir
.push
(
"out.txt"
);
/* Write the temp input file */
let
ostream
=
do
in
.to_str
()
.as_c_str
|
fromp
|
{
let
ostream
=
do
in
put
.to_str
()
.as_c_str
|
fromp
|
{
do
"w+b"
.as_c_str
|
modebuf
|
{
libc
::
fopen
(
fromp
,
modebuf
)
}
...
...
@@ -1950,16 +1950,16 @@ fn copy_file_ok() {
len
as
size_t
)
}
assert_eq!
(
libc
::
fclose
(
ostream
),
(
0u
as
c_int
));
let
in_mode
=
in
.get_mode
();
let
rs
=
os
::
copy_file
(
&
in
,
&
out
);
if
(
!
os
::
path_exists
(
&
in
))
{
fail
!
(
"%s doesn't exist"
,
in
.to_str
());
let
in_mode
=
in
put
.get_mode
();
let
rs
=
os
::
copy_file
(
&
in
put
,
&
out
);
if
(
!
os
::
path_exists
(
&
in
put
))
{
fail
!
(
"%s doesn't exist"
,
in
put
.to_str
());
}
assert
!
((
rs
));
let
rslt
=
run
::
process_status
(
"diff"
,
[
in
.to_str
(),
out
.to_str
()]);
let
rslt
=
run
::
process_status
(
"diff"
,
[
in
put
.to_str
(),
out
.to_str
()]);
assert_eq!
(
rslt
,
0
);
assert_eq!
(
out
.get_mode
(),
in_mode
);
assert
!
((
remove_file
(
&
in
)));
assert
!
((
remove_file
(
&
in
put
)));
assert
!
((
remove_file
(
&
out
)));
}
}
...
...
src/libstd/rt/io/extensions.rs
浏览文件 @
dabd4762
...
...
@@ -330,7 +330,7 @@ fn read_to_end(&mut self) -> ~[u8] {
}
else
{
read_error
::
cond
.raise
(
e
)
}
})
.in
{
})
.in
side
{
while
keep_reading
{
self
.push_bytes
(
&
mut
buf
,
DEFAULT_BUF_SIZE
)
}
...
...
@@ -640,7 +640,7 @@ fn read_byte_error() {
None
};
do
read_error
::
cond
.trap
(|
_
|
{
})
.in
{
})
.in
side
{
let
byte
=
reader
.read_byte
();
assert
!
(
byte
==
None
);
}
...
...
@@ -679,7 +679,7 @@ fn read_bytes_partial() {
fn
read_bytes_eof
()
{
let
mut
reader
=
MemReader
::
new
(
~
[
10
,
11
]);
do
read_error
::
cond
.trap
(|
_
|
{
})
.in
{
})
.in
side
{
assert
!
(
reader
.read_bytes
(
4
)
==
~
[
10
,
11
]);
}
}
...
...
@@ -720,7 +720,7 @@ fn push_bytes_eof() {
let
mut
reader
=
MemReader
::
new
(
~
[
10
,
11
]);
let
mut
buf
=
~
[
8
,
9
];
do
read_error
::
cond
.trap
(|
_
|
{
})
.in
{
})
.in
side
{
reader
.push_bytes
(
&
mut
buf
,
4
);
assert
!
(
buf
==
~
[
8
,
9
,
10
,
11
]);
}
...
...
@@ -743,7 +743,7 @@ fn push_bytes_error() {
}
};
let
mut
buf
=
~
[
8
,
9
];
do
read_error
::
cond
.trap
(|
_
|
{
}
)
.in
{
do
read_error
::
cond
.trap
(|
_
|
{
}
)
.in
side
{
reader
.push_bytes
(
&
mut
buf
,
4
);
}
assert
!
(
buf
==
~
[
8
,
9
,
10
]);
...
...
src/libstd/rt/io/net/tcp.rs
浏览文件 @
dabd4762
...
...
@@ -156,7 +156,7 @@ fn bind_error() {
do
io_error
::
cond
.trap
(|
e
|
{
assert
!
(
e
.kind
==
PermissionDenied
);
called
=
true
;
})
.in
{
})
.in
side
{
let
addr
=
Ipv4
(
0
,
0
,
0
,
0
,
1
);
let
listener
=
TcpListener
::
bind
(
addr
);
assert
!
(
listener
.is_none
());
...
...
@@ -172,7 +172,7 @@ fn connect_error() {
do
io_error
::
cond
.trap
(|
e
|
{
assert
!
(
e
.kind
==
ConnectionRefused
);
called
=
true
;
})
.in
{
})
.in
side
{
let
addr
=
Ipv4
(
0
,
0
,
0
,
0
,
1
);
let
stream
=
TcpStream
::
connect
(
addr
);
assert
!
(
stream
.is_none
());
...
...
@@ -320,7 +320,7 @@ fn write_close_ip4() {
// NB: ECONNRESET on linux, EPIPE on mac
assert
!
(
e
.kind
==
ConnectionReset
||
e
.kind
==
BrokenPipe
);
stop
=
true
;
})
.in
{
})
.in
side
{
stream
.write
(
buf
);
}
if
stop
{
break
}
...
...
@@ -349,7 +349,7 @@ fn write_close_ip6() {
// NB: ECONNRESET on linux, EPIPE on mac
assert
!
(
e
.kind
==
ConnectionReset
||
e
.kind
==
BrokenPipe
);
stop
=
true
;
})
.in
{
})
.in
side
{
stream
.write
(
buf
);
}
if
stop
{
break
}
...
...
src/libstd/rt/io/net/udp.rs
浏览文件 @
dabd4762
...
...
@@ -117,7 +117,7 @@ fn bind_error() {
do
io_error
::
cond
.trap
(|
e
|
{
assert
!
(
e
.kind
==
PermissionDenied
);
called
=
true
;
})
.in
{
})
.in
side
{
let
addr
=
Ipv4
(
0
,
0
,
0
,
0
,
1
);
let
socket
=
UdpSocket
::
bind
(
addr
);
assert
!
(
socket
.is_none
());
...
...
src/libstd/rt/io/option.rs
浏览文件 @
dabd4762
...
...
@@ -100,7 +100,7 @@ fn test_option_writer_error() {
do
io_error
::
cond
.trap
(|
err
|
{
assert_eq!
(
err
.kind
,
PreviousIoError
);
called
=
true
;
})
.in
{
})
.in
side
{
writer
.write
([
0
,
0
,
0
]);
}
assert
!
(
called
);
...
...
@@ -109,7 +109,7 @@ fn test_option_writer_error() {
do
io_error
::
cond
.trap
(|
err
|
{
assert_eq!
(
err
.kind
,
PreviousIoError
);
called
=
true
;
})
.in
{
})
.in
side
{
writer
.flush
();
}
assert
!
(
called
);
...
...
@@ -136,7 +136,7 @@ fn test_option_reader_error() {
do
read_error
::
cond
.trap
(|
err
|
{
assert_eq!
(
err
.kind
,
PreviousIoError
);
called
=
true
;
})
.in
{
})
.in
side
{
reader
.read
(
buf
);
}
assert
!
(
called
);
...
...
@@ -145,7 +145,7 @@ fn test_option_reader_error() {
do
io_error
::
cond
.trap
(|
err
|
{
assert_eq!
(
err
.kind
,
PreviousIoError
);
called
=
true
;
})
.in
{
})
.in
side
{
assert
!
(
reader
.eof
());
}
assert
!
(
called
);
...
...
src/libstd/run.rs
浏览文件 @
dabd4762
...
...
@@ -152,7 +152,7 @@ pub fn new(prog: &str, args: &[~str], options: ProcessOptions)
let
(
in_pipe
,
in_fd
)
=
match
options
.in_fd
{
None
=>
{
let
pipe
=
os
::
pipe
();
(
Some
(
pipe
),
pipe
.in
)
(
Some
(
pipe
),
pipe
.in
put
)
},
Some
(
fd
)
=>
(
None
,
fd
)
};
...
...
@@ -175,7 +175,7 @@ pub fn new(prog: &str, args: &[~str], options: ProcessOptions)
in_fd
,
out_fd
,
err_fd
);
unsafe
{
for
in_pipe
.iter
()
.advance
|
pipe
|
{
libc
::
close
(
pipe
.in
);
}
for
in_pipe
.iter
()
.advance
|
pipe
|
{
libc
::
close
(
pipe
.in
put
);
}
for
out_pipe
.iter
()
.advance
|
pipe
|
{
libc
::
close
(
pipe
.out
);
}
for
err_pipe
.iter
()
.advance
|
pipe
|
{
libc
::
close
(
pipe
.out
);
}
}
...
...
@@ -184,8 +184,8 @@ pub fn new(prog: &str, args: &[~str], options: ProcessOptions)
pid
:
res
.pid
,
handle
:
res
.handle
,
input
:
in_pipe
.map
(|
pipe
|
pipe
.out
),
output
:
out_pipe
.map
(|
pipe
|
os
::
fdopen
(
pipe
.in
)),
error
:
err_pipe
.map
(|
pipe
|
os
::
fdopen
(
pipe
.in
)),
output
:
out_pipe
.map
(|
pipe
|
os
::
fdopen
(
pipe
.in
put
)),
error
:
err_pipe
.map
(|
pipe
|
os
::
fdopen
(
pipe
.in
put
)),
exit_code
:
None
,
}
}
...
...
@@ -1025,7 +1025,7 @@ fn test_pipes() {
let
mut
proc
=
run
::
Process
::
new
(
"cat"
,
[],
run
::
ProcessOptions
{
dir
:
None
,
env
:
None
,
in_fd
:
Some
(
pipe_in
.in
),
in_fd
:
Some
(
pipe_in
.in
put
),
out_fd
:
Some
(
pipe_out
.out
),
err_fd
:
Some
(
pipe_err
.out
)
});
...
...
@@ -1034,14 +1034,14 @@ fn test_pipes() {
assert
!
(
proc
.output_redirected
());
assert
!
(
proc
.error_redirected
());
os
::
close
(
pipe_in
.in
);
os
::
close
(
pipe_in
.in
put
);
os
::
close
(
pipe_out
.out
);
os
::
close
(
pipe_err
.out
);
let
expected
=
~
"test"
;
writeclose
(
pipe_in
.out
,
expected
);
let
actual
=
readclose
(
pipe_out
.in
);
readclose
(
pipe_err
.in
);
let
actual
=
readclose
(
pipe_out
.in
put
);
readclose
(
pipe_err
.in
put
);
proc
.finish
();
assert_eq!
(
expected
,
actual
);
...
...
src/libstd/str.rs
浏览文件 @
dabd4762
...
...
@@ -2863,7 +2863,7 @@ fn test_from_bytes_fail() {
assert_eq!
(
err
,
~
"from_bytes: input is not UTF-8; first bad byte is 255"
);
error_happened
=
true
;
~
""
})
.in
{
})
.in
side
{
from_bytes
(
bb
)
};
assert
!
(
error_happened
);
...
...
src/libsyntax/ext/asm.rs
浏览文件 @
dabd4762
...
...
@@ -95,10 +95,10 @@ pub fn expand_asm(cx: @ExtCtxt, sp: span, tts: &[ast::token_tree])
let
constraint
=
p
.parse_str
();
p
.expect
(
&
token
::
LPAREN
);
let
in
=
p
.parse_expr
();
let
in
put
=
p
.parse_expr
();
p
.expect
(
&
token
::
RPAREN
);
inputs
.push
((
constraint
,
in
));
inputs
.push
((
constraint
,
in
put
));
}
}
Clobbers
=>
{
...
...
src/libsyntax/ext/expand.rs
浏览文件 @
dabd4762
...
...
@@ -750,16 +750,16 @@ mod debug_macro {
macro_rules! condition (
{ pub $c:ident: $in:ty -> $out:ty; } => {
{ pub $c:ident: $in
put
:ty -> $out:ty; } => {
pub mod $c {
#[allow(non_uppercase_statics)];
static key: ::std::local_data::Key<
@::std::condition::Handler<$in, $out>> =
@::std::condition::Handler<$in
put
, $out>> =
&::std::local_data::Key;
pub static cond :
::std::condition::Condition<$in,$out> =
::std::condition::Condition<$in
put
,$out> =
::std::condition::Condition {
name: stringify!($c),
key: key
...
...
@@ -767,17 +767,17 @@ pub mod $c {
}
};
{ $c:ident: $in:ty -> $out:ty; } => {
{ $c:ident: $in
put
:ty -> $out:ty; } => {
// FIXME (#6009): remove mod's `pub` below once variant above lands.
pub mod $c {
#[allow(non_uppercase_statics)];
static key: ::std::local_data::Key<
@::std::condition::Handler<$in, $out>> =
@::std::condition::Handler<$in
put
, $out>> =
&::std::local_data::Key;
pub static cond :
::std::condition::Condition<$in,$out> =
::std::condition::Condition<$in
put
,$out> =
::std::condition::Condition {
name: stringify!($c),
key: key
...
...
src/libsyntax/fold.rs
浏览文件 @
dabd4762
...
...
@@ -626,7 +626,7 @@ fn fold_field_(field: Field, fld: @ast_fold) -> Field {
}
expr_inline_asm
(
ref
a
)
=>
{
expr_inline_asm
(
inline_asm
{
inputs
:
a
.inputs
.map
(|
&
(
c
,
in
)|
(
c
,
fld
.fold_expr
(
in
))),
inputs
:
a
.inputs
.map
(|
&
(
c
,
in
put
)|
(
c
,
fld
.fold_expr
(
input
))),
outputs
:
a
.outputs
.map
(|
&
(
c
,
out
)|
(
c
,
fld
.fold_expr
(
out
))),
..
(
*
a
)
.clone
()
})
...
...
src/libsyntax/parse/token.rs
浏览文件 @
dabd4762
...
...
@@ -125,7 +125,7 @@ pub fn binop_to_str(o: binop) -> ~str {
}
}
pub
fn
to_str
(
in
:
@
ident_interner
,
t
:
&
Token
)
->
~
str
{
pub
fn
to_str
(
in
put
:
@
ident_interner
,
t
:
&
Token
)
->
~
str
{
match
*
t
{
EQ
=>
~
"="
,
LT
=>
~
"<"
,
...
...
@@ -195,8 +195,8 @@ pub fn to_str(in: @ident_interner, t: &Token) -> ~str {
LIT_STR
(
ref
s
)
=>
{
fmt!
(
"
\"
%s
\"
"
,
ident_to_str
(
s
)
.escape_default
())
}
/* Name components */
IDENT
(
s
,
_
)
=>
in
.get
(
s
.name
)
.to_owned
(),
LIFETIME
(
s
)
=>
fmt!
(
"'%s"
,
in
.get
(
s
.name
)),
IDENT
(
s
,
_
)
=>
in
put
.get
(
s
.name
)
.to_owned
(),
LIFETIME
(
s
)
=>
fmt!
(
"'%s"
,
in
put
.get
(
s
.name
)),
UNDERSCORE
=>
~
"_"
,
/* Other */
...
...
@@ -204,7 +204,7 @@ pub fn to_str(in: @ident_interner, t: &Token) -> ~str {
EOF
=>
~
"<eof>"
,
INTERPOLATED
(
ref
nt
)
=>
{
match
nt
{
&
nt_expr
(
e
)
=>
::
print
::
pprust
::
expr_to_str
(
e
,
in
),
&
nt_expr
(
e
)
=>
::
print
::
pprust
::
expr_to_str
(
e
,
in
put
),
_
=>
{
~
"an interpolated "
+
match
(
*
nt
)
{
...
...
@@ -471,10 +471,10 @@ fn mk_fresh_ident_interner() -> @ident_interner {
"unsafe"
,
// 61
"use"
,
// 62
"while"
,
// 63
"in"
,
// 64
"foreach"
,
// 65
"be"
,
// 64
"in"
,
// 65
"foreach"
,
// 66
"be"
,
// 66
];
@
ident_interner
{
...
...
@@ -615,10 +615,10 @@ pub fn to_ident(&self) -> ident {
False
=>
ident
{
name
:
39
,
ctxt
:
0
},
Fn
=>
ident
{
name
:
40
,
ctxt
:
0
},
For
=>
ident
{
name
:
41
,
ctxt
:
0
},
ForEach
=>
ident
{
name
:
6
6
,
ctxt
:
0
},
ForEach
=>
ident
{
name
:
6
5
,
ctxt
:
0
},
If
=>
ident
{
name
:
42
,
ctxt
:
0
},
Impl
=>
ident
{
name
:
43
,
ctxt
:
0
},
In
=>
ident
{
name
:
6
5
,
ctxt
:
0
},
In
=>
ident
{
name
:
6
4
,
ctxt
:
0
},
Let
=>
ident
{
name
:
44
,
ctxt
:
0
},
__
Log
=>
ident
{
name
:
45
,
ctxt
:
0
},
Loop
=>
ident
{
name
:
46
,
ctxt
:
0
},
...
...
@@ -641,7 +641,7 @@ pub fn to_ident(&self) -> ident {
Unsafe
=>
ident
{
name
:
61
,
ctxt
:
0
},
Use
=>
ident
{
name
:
62
,
ctxt
:
0
},
While
=>
ident
{
name
:
63
,
ctxt
:
0
},
Be
=>
ident
{
name
:
6
4
,
ctxt
:
0
},
Be
=>
ident
{
name
:
6
6
,
ctxt
:
0
},
}
}
}
...
...
@@ -657,7 +657,7 @@ pub fn is_keyword(kw: keywords::Keyword, tok: &Token) -> bool {
pub
fn
is_any_keyword
(
tok
:
&
Token
)
->
bool
{
match
*
tok
{
token
::
IDENT
(
sid
,
false
)
=>
match
sid
.name
{
8
|
27
|
32
..
6
4
=>
true
,
8
|
27
|
32
..
6
6
=>
true
,
_
=>
false
,
},
_
=>
false
...
...
@@ -667,7 +667,7 @@ pub fn is_any_keyword(tok: &Token) -> bool {
pub
fn
is_strict_keyword
(
tok
:
&
Token
)
->
bool
{
match
*
tok
{
token
::
IDENT
(
sid
,
false
)
=>
match
sid
.name
{
8
|
27
|
32
..
6
3
=>
true
,
8
|
27
|
32
..
6
5
=>
true
,
_
=>
false
,
},
_
=>
false
,
...
...
@@ -677,7 +677,7 @@ pub fn is_strict_keyword(tok: &Token) -> bool {
pub
fn
is_reserved_keyword
(
tok
:
&
Token
)
->
bool
{
match
*
tok
{
token
::
IDENT
(
sid
,
false
)
=>
match
sid
.name
{
6
4
=>
true
,
6
6
=>
true
,
_
=>
false
,
},
_
=>
false
,
...
...
src/libsyntax/print/pprust.rs
浏览文件 @
dabd4762
...
...
@@ -108,14 +108,14 @@ pub fn print_crate(cm: @CodeMap,
span_diagnostic
:
@
diagnostic
::
span_handler
,
crate
:
&
ast
::
Crate
,
filename
:
@
str
,
in
:
@
io
::
Reader
,
in
put
:
@
io
::
Reader
,
out
:
@
io
::
Writer
,
ann
:
pp_ann
,
is_expanded
:
bool
)
{
let
(
cmnts
,
lits
)
=
comments
::
gather_comments_and_literals
(
span_diagnostic
,
filename
,
in
in
put
);
let
s
=
@
ps
{
s
:
pp
::
mk_printer
(
out
,
default_columns
),
...
...
src/libsyntax/visit.rs
浏览文件 @
dabd4762
...
...
@@ -563,8 +563,8 @@ pub fn visit_expr<E:Clone>(ex: @expr, (e, v): (E, vt<E>)) {
expr_mac
(
ref
mac
)
=>
visit_mac
(
mac
,
(
e
.clone
(),
v
)),
expr_paren
(
x
)
=>
(
v
.visit_expr
)(
x
,
(
e
.clone
(),
v
)),
expr_inline_asm
(
ref
a
)
=>
{
for
a
.inputs
.iter
()
.advance
|
&
(
_
,
in
)|
{
(
v
.visit_expr
)(
in
,
(
e
.clone
(),
v
));
for
a
.inputs
.iter
()
.advance
|
&
(
_
,
in
put
)|
{
(
v
.visit_expr
)(
in
put
,
(
e
.clone
(),
v
));
}
for
a
.outputs
.iter
()
.advance
|
&
(
_
,
out
)|
{
(
v
.visit_expr
)(
out
,
(
e
.clone
(),
v
));
...
...
src/test/run-pass/issue-2904.rs
浏览文件 @
dabd4762
...
...
@@ -62,10 +62,10 @@ fn square_from_char(c: char) -> square {
}
}
fn
read_board_grid
<
rdr
:
'static
+
io
::
Reader
>
(
in
:
rdr
)
->
~
[
~
[
square
]]
{
let
in
=
@
in
as
@
io
::
Reader
;
fn
read_board_grid
<
rdr
:
'static
+
io
::
Reader
>
(
in
put
:
rdr
)
->
~
[
~
[
square
]]
{
let
in
put
=
@
input
as
@
io
::
Reader
;
let
mut
grid
=
~
[];
for
in
.each_line
|
line
|
{
for
in
put
.each_line
|
line
|
{
let
mut
row
=
~
[];
for
line
.iter
()
.advance
|
c
|
{
row
.push
(
square_from_char
(
c
))
...
...
src/test/run-pass/option_addition.rs
浏览文件 @
dabd4762
...
...
@@ -27,11 +27,11 @@ pub fn main() {
assert_eq!
(
foobar
,
somefoobar
.get
());
}
fn
optint
(
in
:
int
)
->
Option
<
int
>
{
if
in
==
0
{
fn
optint
(
in
put
:
int
)
->
Option
<
int
>
{
if
in
put
==
0
{
return
None
;
}
else
{
return
Some
(
in
);
return
Some
(
in
put
);
}
}
src/test/run-pass/record-pat.rs
浏览文件 @
dabd4762
...
...
@@ -12,8 +12,8 @@ enum t1 { a(int), b(uint), }
struct
T2
{
x
:
t1
,
y
:
int
}
enum
t3
{
c
(
T2
,
uint
),
}
fn
m
(
in
:
t3
)
->
int
{
match
in
{
fn
m
(
in
put
:
t3
)
->
int
{
match
in
put
{
c
(
T2
{
x
:
a
(
m
),
_
},
_
)
=>
{
return
m
;
}
c
(
T2
{
x
:
b
(
m
),
y
:
y
},
z
)
=>
{
return
((
m
+
z
)
as
int
)
+
y
;
}
}
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录