Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
int
Rust
提交
01615b04
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,发现更多精彩内容 >>
提交
01615b04
编写于
2月 17, 2015
作者:
N
Niko Matsakis
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Convert required suffixes into a use of `as`.
上级
2b5720a1
变更
13
隐藏空白更改
内联
并排
Showing
13 changed file
with
102 addition
and
102 deletion
+102
-102
src/libcoretest/any.rs
src/libcoretest/any.rs
+5
-5
src/libcoretest/fmt/num.rs
src/libcoretest/fmt/num.rs
+13
-13
src/libcoretest/hash/mod.rs
src/libcoretest/hash/mod.rs
+13
-13
src/librustc/lint/builtin.rs
src/librustc/lint/builtin.rs
+1
-2
src/libserialize/json.rs
src/libserialize/json.rs
+11
-11
src/libstd/num/mod.rs
src/libstd/num/mod.rs
+39
-39
src/test/compile-fail/asm-in-bad-modifier.rs
src/test/compile-fail/asm-in-bad-modifier.rs
+2
-2
src/test/compile-fail/asm-misplaced-option.rs
src/test/compile-fail/asm-misplaced-option.rs
+1
-1
src/test/compile-fail/asm-out-assign-imm.rs
src/test/compile-fail/asm-out-assign-imm.rs
+2
-1
src/test/compile-fail/asm-out-no-modifier.rs
src/test/compile-fail/asm-out-no-modifier.rs
+1
-1
src/test/compile-fail/issue-13058.rs
src/test/compile-fail/issue-13058.rs
+1
-1
src/test/pretty/issue-4264.pp
src/test/pretty/issue-4264.pp
+1
-1
src/test/run-pass/numeric-method-autoexport.rs
src/test/run-pass/numeric-method-autoexport.rs
+12
-12
未找到文件。
src/libcoretest/any.rs
浏览文件 @
01615b04
...
...
@@ -35,7 +35,7 @@ fn any_referenced() {
#[test]
fn
any_owning
()
{
let
(
a
,
b
,
c
)
=
(
box
5
u
s
as
Box
<
Any
>
,
box
TEST
as
Box
<
Any
>
,
box
Test
as
Box
<
Any
>
);
let
(
a
,
b
,
c
)
=
(
box
5
_u
size
as
Box
<
Any
>
,
box
TEST
as
Box
<
Any
>
,
box
Test
as
Box
<
Any
>
);
assert
!
(
a
.is
::
<
uint
>
());
assert
!
(
!
b
.is
::
<
uint
>
());
...
...
@@ -52,7 +52,7 @@ fn any_owning() {
#[test]
fn
any_downcast_ref
()
{
let
a
=
&
5
u
s
as
&
Any
;
let
a
=
&
5
_u
size
as
&
Any
;
match
a
.downcast_ref
::
<
uint
>
()
{
Some
(
&
5
)
=>
{}
...
...
@@ -67,8 +67,8 @@ fn any_downcast_ref() {
#[test]
fn
any_downcast_mut
()
{
let
mut
a
=
5
u
s
;
let
mut
b
=
box
7
u
s
;
let
mut
a
=
5
_u
size
;
let
mut
b
=
box
7
_u
size
;
let
a_r
=
&
mut
a
as
&
mut
Any
;
let
tmp
:
&
mut
uint
=
&
mut
*
b
;
...
...
@@ -113,7 +113,7 @@ fn any_downcast_mut() {
#[test]
fn
any_fixed_vec
()
{
let
test
=
[
0
u
s
;
8
];
let
test
=
[
0
_u
size
;
8
];
let
test
=
&
test
as
&
Any
;
assert
!
(
test
.is
::
<
[
uint
;
8
]
>
());
assert
!
(
!
test
.is
::
<
[
uint
;
10
]
>
());
...
...
src/libcoretest/fmt/num.rs
浏览文件 @
01615b04
...
...
@@ -16,68 +16,68 @@ fn test_format_int() {
// Formatting integers should select the right implementation based off
// the type of the argument. Also, hex/octal/binary should be defined
// for integers, but they shouldn't emit the negative sign.
assert
!
(
format!
(
"{}"
,
1
is
)
==
"1"
);
assert
!
(
format!
(
"{}"
,
1
is
ize
)
==
"1"
);
assert
!
(
format!
(
"{}"
,
1i8
)
==
"1"
);
assert
!
(
format!
(
"{}"
,
1i16
)
==
"1"
);
assert
!
(
format!
(
"{}"
,
1i32
)
==
"1"
);
assert
!
(
format!
(
"{}"
,
1i64
)
==
"1"
);
assert
!
(
format!
(
"{}"
,
-
1
is
)
==
"-1"
);
assert
!
(
format!
(
"{}"
,
-
1
is
ize
)
==
"-1"
);
assert
!
(
format!
(
"{}"
,
-
1i8
)
==
"-1"
);
assert
!
(
format!
(
"{}"
,
-
1i16
)
==
"-1"
);
assert
!
(
format!
(
"{}"
,
-
1i32
)
==
"-1"
);
assert
!
(
format!
(
"{}"
,
-
1i64
)
==
"-1"
);
assert
!
(
format!
(
"{:?}"
,
1
is
)
==
"1"
);
assert
!
(
format!
(
"{:?}"
,
1
is
ize
)
==
"1"
);
assert
!
(
format!
(
"{:?}"
,
1i8
)
==
"1"
);
assert
!
(
format!
(
"{:?}"
,
1i16
)
==
"1"
);
assert
!
(
format!
(
"{:?}"
,
1i32
)
==
"1"
);
assert
!
(
format!
(
"{:?}"
,
1i64
)
==
"1"
);
assert
!
(
format!
(
"{:b}"
,
1
is
)
==
"1"
);
assert
!
(
format!
(
"{:b}"
,
1
is
ize
)
==
"1"
);
assert
!
(
format!
(
"{:b}"
,
1i8
)
==
"1"
);
assert
!
(
format!
(
"{:b}"
,
1i16
)
==
"1"
);
assert
!
(
format!
(
"{:b}"
,
1i32
)
==
"1"
);
assert
!
(
format!
(
"{:b}"
,
1i64
)
==
"1"
);
assert
!
(
format!
(
"{:x}"
,
1
is
)
==
"1"
);
assert
!
(
format!
(
"{:x}"
,
1
is
ize
)
==
"1"
);
assert
!
(
format!
(
"{:x}"
,
1i8
)
==
"1"
);
assert
!
(
format!
(
"{:x}"
,
1i16
)
==
"1"
);
assert
!
(
format!
(
"{:x}"
,
1i32
)
==
"1"
);
assert
!
(
format!
(
"{:x}"
,
1i64
)
==
"1"
);
assert
!
(
format!
(
"{:X}"
,
1
is
)
==
"1"
);
assert
!
(
format!
(
"{:X}"
,
1
is
ize
)
==
"1"
);
assert
!
(
format!
(
"{:X}"
,
1i8
)
==
"1"
);
assert
!
(
format!
(
"{:X}"
,
1i16
)
==
"1"
);
assert
!
(
format!
(
"{:X}"
,
1i32
)
==
"1"
);
assert
!
(
format!
(
"{:X}"
,
1i64
)
==
"1"
);
assert
!
(
format!
(
"{:o}"
,
1
is
)
==
"1"
);
assert
!
(
format!
(
"{:o}"
,
1
is
ize
)
==
"1"
);
assert
!
(
format!
(
"{:o}"
,
1i8
)
==
"1"
);
assert
!
(
format!
(
"{:o}"
,
1i16
)
==
"1"
);
assert
!
(
format!
(
"{:o}"
,
1i32
)
==
"1"
);
assert
!
(
format!
(
"{:o}"
,
1i64
)
==
"1"
);
assert
!
(
format!
(
"{}"
,
1u
s
)
==
"1"
);
assert
!
(
format!
(
"{}"
,
1u
s
ize
)
==
"1"
);
assert
!
(
format!
(
"{}"
,
1u8
)
==
"1"
);
assert
!
(
format!
(
"{}"
,
1u16
)
==
"1"
);
assert
!
(
format!
(
"{}"
,
1u32
)
==
"1"
);
assert
!
(
format!
(
"{}"
,
1u64
)
==
"1"
);
assert
!
(
format!
(
"{:?}"
,
1u
s
)
==
"1"
);
assert
!
(
format!
(
"{:?}"
,
1u
s
ize
)
==
"1"
);
assert
!
(
format!
(
"{:?}"
,
1u8
)
==
"1"
);
assert
!
(
format!
(
"{:?}"
,
1u16
)
==
"1"
);
assert
!
(
format!
(
"{:?}"
,
1u32
)
==
"1"
);
assert
!
(
format!
(
"{:?}"
,
1u64
)
==
"1"
);
assert
!
(
format!
(
"{:b}"
,
1u
s
)
==
"1"
);
assert
!
(
format!
(
"{:b}"
,
1u
s
ize
)
==
"1"
);
assert
!
(
format!
(
"{:b}"
,
1u8
)
==
"1"
);
assert
!
(
format!
(
"{:b}"
,
1u16
)
==
"1"
);
assert
!
(
format!
(
"{:b}"
,
1u32
)
==
"1"
);
assert
!
(
format!
(
"{:b}"
,
1u64
)
==
"1"
);
assert
!
(
format!
(
"{:x}"
,
1u
s
)
==
"1"
);
assert
!
(
format!
(
"{:x}"
,
1u
s
ize
)
==
"1"
);
assert
!
(
format!
(
"{:x}"
,
1u8
)
==
"1"
);
assert
!
(
format!
(
"{:x}"
,
1u16
)
==
"1"
);
assert
!
(
format!
(
"{:x}"
,
1u32
)
==
"1"
);
assert
!
(
format!
(
"{:x}"
,
1u64
)
==
"1"
);
assert
!
(
format!
(
"{:X}"
,
1u
s
)
==
"1"
);
assert
!
(
format!
(
"{:X}"
,
1u
s
ize
)
==
"1"
);
assert
!
(
format!
(
"{:X}"
,
1u8
)
==
"1"
);
assert
!
(
format!
(
"{:X}"
,
1u16
)
==
"1"
);
assert
!
(
format!
(
"{:X}"
,
1u32
)
==
"1"
);
assert
!
(
format!
(
"{:X}"
,
1u64
)
==
"1"
);
assert
!
(
format!
(
"{:o}"
,
1u
s
)
==
"1"
);
assert
!
(
format!
(
"{:o}"
,
1u
s
ize
)
==
"1"
);
assert
!
(
format!
(
"{:o}"
,
1u8
)
==
"1"
);
assert
!
(
format!
(
"{:o}"
,
1u16
)
==
"1"
);
assert
!
(
format!
(
"{:o}"
,
1u32
)
==
"1"
);
...
...
src/libcoretest/hash/mod.rs
浏览文件 @
01615b04
...
...
@@ -46,17 +46,17 @@ fn hash<T: Hash<MyHasher>>(t: &T) -> u64 {
assert_eq!
(
hash
(
&
()),
0
);
assert_eq!
(
hash
(
&
5u8
),
5
);
assert_eq!
(
hash
(
&
5u16
),
5
);
assert_eq!
(
hash
(
&
5u32
),
5
);
assert_eq!
(
hash
(
&
5u64
),
5
);
assert_eq!
(
hash
(
&
5
u
s
),
5
);
assert_eq!
(
hash
(
&
5i8
),
5
);
assert_eq!
(
hash
(
&
5i16
),
5
);
assert_eq!
(
hash
(
&
5i32
),
5
);
assert_eq!
(
hash
(
&
5i64
),
5
);
assert_eq!
(
hash
(
&
5
is
),
5
);
assert_eq!
(
hash
(
&
5
_
u8
),
5
);
assert_eq!
(
hash
(
&
5
_
u16
),
5
);
assert_eq!
(
hash
(
&
5
_
u32
),
5
);
assert_eq!
(
hash
(
&
5
_
u64
),
5
);
assert_eq!
(
hash
(
&
5
_u
size
),
5
);
assert_eq!
(
hash
(
&
5
_
i8
),
5
);
assert_eq!
(
hash
(
&
5
_
i16
),
5
);
assert_eq!
(
hash
(
&
5
_
i32
),
5
);
assert_eq!
(
hash
(
&
5
_
i64
),
5
);
assert_eq!
(
hash
(
&
5
_
isize
),
5
);
assert_eq!
(
hash
(
&
false
),
0
);
assert_eq!
(
hash
(
&
true
),
1
);
...
...
@@ -76,12 +76,12 @@ fn hash<T: Hash<MyHasher>>(t: &T) -> u64 {
// FIXME (#18248) Add tests for hashing Rc<str> and Rc<[T]>
unsafe
{
let
ptr
:
*
const
i32
=
mem
::
transmute
(
5
u
s
);
let
ptr
:
*
const
i32
=
mem
::
transmute
(
5
_u
size
);
assert_eq!
(
hash
(
&
ptr
),
5
);
}
unsafe
{
let
ptr
:
*
mut
i32
=
mem
::
transmute
(
5
u
s
);
let
ptr
:
*
mut
i32
=
mem
::
transmute
(
5
_u
size
);
assert_eq!
(
hash
(
&
ptr
),
5
);
}
}
...
...
src/librustc/lint/builtin.rs
浏览文件 @
01615b04
...
...
@@ -494,13 +494,12 @@ fn check_foreign_fn(cx: &Context, decl: &ast::FnDecl) {
impl
BoxPointers
{
fn
check_heap_type
<
'a
,
'tcx
>
(
&
self
,
cx
:
&
Context
<
'a
,
'tcx
>
,
span
:
Span
,
ty
:
Ty
<
'tcx
>
)
{
let
mut
n_uniq
=
0u
s
;
let
mut
n_uniq
:
usize
=
0
;
ty
::
fold_ty
(
cx
.tcx
,
ty
,
|
t
|
{
match
t
.sty
{
ty
::
ty_uniq
(
_
)
=>
{
n_uniq
+=
1
;
}
_
=>
()
};
t
...
...
src/libserialize/json.rs
浏览文件 @
01615b04
...
...
@@ -3905,12 +3905,12 @@ fn test_to_json() {
assert_eq!
(
array2
.to_json
(),
array2
);
assert_eq!
(
object
.to_json
(),
object
);
assert_eq!
(
3_
i
.to_json
(),
I64
(
3
));
assert_eq!
(
3_
i
size
.to_json
(),
I64
(
3
));
assert_eq!
(
4_i8
.to_json
(),
I64
(
4
));
assert_eq!
(
5_i16
.to_json
(),
I64
(
5
));
assert_eq!
(
6_i32
.to_json
(),
I64
(
6
));
assert_eq!
(
7_i64
.to_json
(),
I64
(
7
));
assert_eq!
(
8_u
.to_json
(),
U64
(
8
));
assert_eq!
(
8_u
size
.to_json
(),
U64
(
8
));
assert_eq!
(
9_u8
.to_json
(),
U64
(
9
));
assert_eq!
(
10_u16
.to_json
(),
U64
(
10
));
assert_eq!
(
11_u32
.to_json
(),
U64
(
11
));
...
...
@@ -3924,22 +3924,22 @@ fn test_to_json() {
assert_eq!
(
false
.to_json
(),
Boolean
(
false
));
assert_eq!
(
"abc"
.to_json
(),
String
(
"abc"
.to_string
()));
assert_eq!
(
"abc"
.to_string
()
.to_json
(),
String
(
"abc"
.to_string
()));
assert_eq!
((
1
u
s
,
2u
s
)
.to_json
(),
array2
);
assert_eq!
((
1
u
s
,
2u
s
,
3u
s
)
.to_json
(),
array3
);
assert_eq!
([
1
u
s
,
2u
s
]
.to_json
(),
array2
);
assert_eq!
((
&
[
1
u
s
,
2u
s
,
3u
s
])
.to_json
(),
array3
);
assert_eq!
((
vec!
[
1
u
s
,
2u
s
])
.to_json
(),
array2
);
assert_eq!
(
vec!
(
1
u
s
,
2u
s
,
3u
s
)
.to_json
(),
array3
);
assert_eq!
((
1
_u
size
,
2_u
size
)
.to_json
(),
array2
);
assert_eq!
((
1
_u
size
,
2_u
size
,
3_u
size
)
.to_json
(),
array3
);
assert_eq!
([
1
_u
size
,
2_u
size
]
.to_json
(),
array2
);
assert_eq!
((
&
[
1
_u
size
,
2_u
size
,
3_u
size
])
.to_json
(),
array3
);
assert_eq!
((
vec!
[
1
_u
size
,
2_u
size
])
.to_json
(),
array2
);
assert_eq!
(
vec!
(
1
_u
size
,
2_u
size
,
3_u
size
)
.to_json
(),
array3
);
let
mut
tree_map
=
BTreeMap
::
new
();
tree_map
.insert
(
"a"
.to_string
(),
1
u
s
);
tree_map
.insert
(
"a"
.to_string
(),
1
as
usize
);
tree_map
.insert
(
"b"
.to_string
(),
2
);
assert_eq!
(
tree_map
.to_json
(),
object
);
let
mut
hash_map
=
HashMap
::
new
();
hash_map
.insert
(
"a"
.to_string
(),
1
u
s
);
hash_map
.insert
(
"a"
.to_string
(),
1
as
usize
);
hash_map
.insert
(
"b"
.to_string
(),
2
);
assert_eq!
(
hash_map
.to_json
(),
object
);
assert_eq!
(
Some
(
15
)
.to_json
(),
I64
(
15
));
assert_eq!
(
Some
(
15
u
s
)
.to_json
(),
U64
(
15
));
assert_eq!
(
Some
(
15
as
usize
)
.to_json
(),
U64
(
15
));
assert_eq!
(
None
::
<
int
>
.to_json
(),
Null
);
}
...
...
src/libstd/num/mod.rs
浏览文件 @
01615b04
...
...
@@ -1123,20 +1123,20 @@ mod tests {
(
$_20:expr
)
=>
({
let
_20
=
$_20
;
assert_eq!
(
20u
,
_20
.to_uint
()
.unwrap
());
assert_eq!
(
20u8
,
_20
.to_u8
()
.unwrap
());
assert_eq!
(
20u16
,
_20
.to_u16
()
.unwrap
());
assert_eq!
(
20u32
,
_20
.to_u32
()
.unwrap
());
assert_eq!
(
20u64
,
_20
.to_u64
()
.unwrap
());
assert_eq!
(
20
,
_20
.to_int
()
.unwrap
());
assert_eq!
(
20i8
,
_20
.to_i8
()
.unwrap
());
assert_eq!
(
20i16
,
_20
.to_i16
()
.unwrap
());
assert_eq!
(
20i32
,
_20
.to_i32
()
.unwrap
());
assert_eq!
(
20i64
,
_20
.to_i64
()
.unwrap
());
assert_eq!
(
20f32
,
_20
.to_f32
()
.unwrap
());
assert_eq!
(
20f64
,
_20
.to_f64
()
.unwrap
());
assert_eq!
(
_20
,
NumCast
::
from
(
20u
)
.unwrap
());
assert_eq!
(
20u
size
,
_20
.to_uint
()
.unwrap
());
assert_eq!
(
20u8
,
_20
.to_u8
()
.unwrap
());
assert_eq!
(
20u16
,
_20
.to_u16
()
.unwrap
());
assert_eq!
(
20u32
,
_20
.to_u32
()
.unwrap
());
assert_eq!
(
20u64
,
_20
.to_u64
()
.unwrap
());
assert_eq!
(
20
,
_20
.to_int
()
.unwrap
());
assert_eq!
(
20i8
,
_20
.to_i8
()
.unwrap
());
assert_eq!
(
20i16
,
_20
.to_i16
()
.unwrap
());
assert_eq!
(
20i32
,
_20
.to_i32
()
.unwrap
());
assert_eq!
(
20i64
,
_20
.to_i64
()
.unwrap
());
assert_eq!
(
20f32
,
_20
.to_f32
()
.unwrap
());
assert_eq!
(
20f64
,
_20
.to_f64
()
.unwrap
());
assert_eq!
(
_20
,
NumCast
::
from
(
20u
size
)
.unwrap
());
assert_eq!
(
_20
,
NumCast
::
from
(
20u8
)
.unwrap
());
assert_eq!
(
_20
,
NumCast
::
from
(
20u16
)
.unwrap
());
assert_eq!
(
_20
,
NumCast
::
from
(
20u32
)
.unwrap
());
...
...
@@ -1164,18 +1164,18 @@ mod tests {
})
}
#[test]
fn
test_u8_cast
()
{
test_cast_20!
(
20u8
)
}
#[test]
fn
test_u16_cast
()
{
test_cast_20!
(
20u16
)
}
#[test]
fn
test_u32_cast
()
{
test_cast_20!
(
20u32
)
}
#[test]
fn
test_u64_cast
()
{
test_cast_20!
(
20u64
)
}
#[test]
fn
test_uint_cast
()
{
test_cast_20!
(
20u
)
}
#[test]
fn
test_i8_cast
()
{
test_cast_20!
(
20i8
)
}
#[test]
fn
test_i16_cast
()
{
test_cast_20!
(
20i16
)
}
#[test]
fn
test_i32_cast
()
{
test_cast_20!
(
20i32
)
}
#[test]
fn
test_i64_cast
()
{
test_cast_20!
(
20i64
)
}
#[test]
fn
test_int_cast
()
{
test_cast_20!
(
20
)
}
#[test]
fn
test_f32_cast
()
{
test_cast_20!
(
20f32
)
}
#[test]
fn
test_f64_cast
()
{
test_cast_20!
(
20f64
)
}
#[test]
fn
test_u8_cast
()
{
test_cast_20!
(
20u8
)
}
#[test]
fn
test_u16_cast
()
{
test_cast_20!
(
20u16
)
}
#[test]
fn
test_u32_cast
()
{
test_cast_20!
(
20u32
)
}
#[test]
fn
test_u64_cast
()
{
test_cast_20!
(
20u64
)
}
#[test]
fn
test_uint_cast
()
{
test_cast_20!
(
20u
size
)
}
#[test]
fn
test_i8_cast
()
{
test_cast_20!
(
20i8
)
}
#[test]
fn
test_i16_cast
()
{
test_cast_20!
(
20i16
)
}
#[test]
fn
test_i32_cast
()
{
test_cast_20!
(
20i32
)
}
#[test]
fn
test_i64_cast
()
{
test_cast_20!
(
20i64
)
}
#[test]
fn
test_int_cast
()
{
test_cast_20!
(
20
)
}
#[test]
fn
test_f32_cast
()
{
test_cast_20!
(
20f32
)
}
#[test]
fn
test_f64_cast
()
{
test_cast_20!
(
20f64
)
}
#[test]
fn
test_cast_range_int_min
()
{
...
...
@@ -1548,8 +1548,8 @@ fn check_word_size() {
#[test]
fn
test_saturating_add_uint
()
{
use
uint
::
MAX
;
assert_eq!
(
3
u
.saturating_add
(
5u
),
8u
);
assert_eq!
(
3
u
.saturating_add
(
MAX
-
1
),
MAX
);
assert_eq!
(
3
_u
size
.saturating_add
(
5_u
size
),
8_u
size
);
assert_eq!
(
3
_u
size
.saturating_add
(
MAX
-
1
),
MAX
);
assert_eq!
(
MAX
.saturating_add
(
MAX
),
MAX
);
assert_eq!
((
MAX
-
2
)
.saturating_add
(
1
),
MAX
-
1
);
}
...
...
@@ -1557,9 +1557,9 @@ fn test_saturating_add_uint() {
#[test]
fn
test_saturating_sub_uint
()
{
use
uint
::
MAX
;
assert_eq!
(
5
u
.saturating_sub
(
3u
),
2u
);
assert_eq!
(
3
u
.saturating_sub
(
5u
),
0u
);
assert_eq!
(
0
u
.saturating_sub
(
1u
),
0u
);
assert_eq!
(
5
_u
size
.saturating_sub
(
3_u
size
),
2_u
size
);
assert_eq!
(
3
_u
size
.saturating_sub
(
5_u
size
),
0_u
size
);
assert_eq!
(
0
_u
size
.saturating_sub
(
1_u
size
),
0_u
size
);
assert_eq!
((
MAX
-
1
)
.saturating_sub
(
MAX
),
0
);
}
...
...
@@ -1602,14 +1602,14 @@ fn test_checked_add() {
#[test]
fn
test_checked_sub
()
{
assert_eq!
(
5
u
.checked_sub
(
0
),
Some
(
5
));
assert_eq!
(
5
u
.checked_sub
(
1
),
Some
(
4
));
assert_eq!
(
5
u
.checked_sub
(
2
),
Some
(
3
));
assert_eq!
(
5
u
.checked_sub
(
3
),
Some
(
2
));
assert_eq!
(
5
u
.checked_sub
(
4
),
Some
(
1
));
assert_eq!
(
5
u
.checked_sub
(
5
),
Some
(
0
));
assert_eq!
(
5
u
.checked_sub
(
6
),
None
);
assert_eq!
(
5
u
.checked_sub
(
7
),
None
);
assert_eq!
(
5
_u
size
.checked_sub
(
0
),
Some
(
5
));
assert_eq!
(
5
_u
size
.checked_sub
(
1
),
Some
(
4
));
assert_eq!
(
5
_u
size
.checked_sub
(
2
),
Some
(
3
));
assert_eq!
(
5
_u
size
.checked_sub
(
3
),
Some
(
2
));
assert_eq!
(
5
_u
size
.checked_sub
(
4
),
Some
(
1
));
assert_eq!
(
5
_u
size
.checked_sub
(
5
),
Some
(
0
));
assert_eq!
(
5
_u
size
.checked_sub
(
6
),
None
);
assert_eq!
(
5
_u
size
.checked_sub
(
7
),
None
);
}
#[test]
...
...
src/test/compile-fail/asm-in-bad-modifier.rs
浏览文件 @
01615b04
...
...
@@ -20,8 +20,8 @@ pub fn main() {
let
x
:
isize
;
let
y
:
isize
;
unsafe
{
asm!
(
"mov $1, $0"
:
"=r"
(
x
)
:
"=r"
(
5
u
s
));
//~ ERROR input
operand constraint contains '='
asm!
(
"mov $1, $0"
:
"=r"
(
y
)
:
"+r"
(
5
u
s
));
//~ ERROR input
operand constraint contains '+'
asm!
(
"mov $1, $0"
:
"=r"
(
x
)
:
"=r"
(
5
_u
size
));
//~ ERROR
operand constraint contains '='
asm!
(
"mov $1, $0"
:
"=r"
(
y
)
:
"+r"
(
5
_u
size
));
//~ ERROR
operand constraint contains '+'
}
foo
(
x
);
foo
(
y
);
...
...
src/test/compile-fail/asm-misplaced-option.rs
浏览文件 @
01615b04
...
...
@@ -21,7 +21,7 @@ pub fn main() {
let
mut
x
:
isize
=
0
;
unsafe
{
// extra colon
asm!
(
"mov $1, $0"
:
"=r"
(
x
)
:
"r"
(
5
u
s
),
"0"
(
x
)
:
:
"cc"
);
asm!
(
"mov $1, $0"
:
"=r"
(
x
)
:
"r"
(
5
_u
size
),
"0"
(
x
)
:
:
"cc"
);
//~^ WARNING unrecognized option
}
assert_eq!
(
x
,
5
);
...
...
src/test/compile-fail/asm-out-assign-imm.rs
浏览文件 @
01615b04
...
...
@@ -21,7 +21,8 @@ pub fn main() {
x
=
1
;
//~ NOTE prior assignment occurs here
foo
(
x
);
unsafe
{
asm!
(
"mov $1, $0"
:
"=r"
(
x
)
:
"r"
(
5u
s
));
//~ ERROR re-assignment of immutable variable `x`
asm!
(
"mov $1, $0"
:
"=r"
(
x
)
:
"r"
(
5_u
size
));
//~^ ERROR re-assignment of immutable variable `x`
}
foo
(
x
);
}
...
...
src/test/compile-fail/asm-out-no-modifier.rs
浏览文件 @
01615b04
...
...
@@ -19,7 +19,7 @@
pub
fn
main
()
{
let
x
:
isize
;
unsafe
{
asm!
(
"mov $1, $0"
:
"r"
(
x
)
:
"r"
(
5
u
s
));
//~ ERROR output operand constraint lacks '='
asm!
(
"mov $1, $0"
:
"r"
(
x
)
:
"r"
(
5
_u
size
));
//~ ERROR output operand constraint lacks '='
}
foo
(
x
);
}
...
...
src/test/compile-fail/issue-13058.rs
浏览文件 @
01615b04
...
...
@@ -34,7 +34,7 @@ fn check<'r, I: Iterator<Item=usize>, T: Itble<'r, usize, I>>(cont: &T) -> bool
}
fn
main
()
{
check
((
3
u
s
,
5u
s
));
check
((
3
_u
size
,
5_u
size
));
//~^ ERROR mismatched types
//~| expected `&_`
//~| found `(usize, usize)`
...
...
src/test/pretty/issue-4264.pp
浏览文件 @
01615b04
...
...
@@ -23,7 +23,7 @@ extern crate "std" as std;
pub
fn
foo
(
_
:
[
i32
;
(
3
as
usize
)])
{
}
pub
fn
bar
()
{
const
FOO
:
usize
=
((
5
us
as
usize
)
-
(
4
us
as
usize
)
as
usize
);
const
FOO
:
usize
=
((
5
us
ize
as
usize
)
-
(
4
usize
as
usize
)
as
usize
);
let
_
:
[();
(
FOO
as
usize
)]
=
([(()
as
())]
as
[();
1
]);
let
_
:
[();
(
1
us
as
usize
)]
=
([(()
as
())]
as
[();
1
]);
...
...
src/test/run-pass/numeric-method-autoexport.rs
浏览文件 @
01615b04
...
...
@@ -21,22 +21,22 @@
pub
fn
main
()
{
// ints
// num
assert_eq!
(
15
is
.add
(
6
is
),
21
is
);
assert_eq!
(
15
i8
.add
(
6i8
),
21
i8
);
assert_eq!
(
15
i16
.add
(
6i16
),
21
i16
);
assert_eq!
(
15
i32
.add
(
6i32
),
21
i32
);
assert_eq!
(
15
i64
.add
(
6i64
),
21
i64
);
assert_eq!
(
15
_
isize
.add
(
6_
isize
),
21_
isize
);
assert_eq!
(
15
_i8
.add
(
6i8
),
21_
i8
);
assert_eq!
(
15
_i16
.add
(
6i16
),
21_
i16
);
assert_eq!
(
15
_i32
.add
(
6i32
),
21_
i32
);
assert_eq!
(
15
_i64
.add
(
6i64
),
21_
i64
);
// uints
// num
assert_eq!
(
15
u
s
.add
(
6u
s
),
21u
s
);
assert_eq!
(
15
u8
.add
(
6u8
),
21
u8
);
assert_eq!
(
15
u16
.add
(
6u16
),
21
u16
);
assert_eq!
(
15
u32
.add
(
6u32
),
21
u32
);
assert_eq!
(
15
u64
.add
(
6u64
),
21
u64
);
assert_eq!
(
15
_u
size
.add
(
6u
s
),
21_u
size
);
assert_eq!
(
15
_u8
.add
(
6u8
),
21_
u8
);
assert_eq!
(
15
_u16
.add
(
6u16
),
21_
u16
);
assert_eq!
(
15
_u32
.add
(
6u32
),
21_
u32
);
assert_eq!
(
15
_u64
.add
(
6u64
),
21_
u64
);
// floats
// num
assert_eq!
(
10f32
.to_i32
()
.unwrap
(),
10
);
assert_eq!
(
10f64
.to_i32
()
.unwrap
(),
10
);
assert_eq!
(
10
_
f32
.to_i32
()
.unwrap
(),
10
);
assert_eq!
(
10
_
f64
.to_i32
()
.unwrap
(),
10
);
}
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录