Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
int
Rust
提交
55464ebc
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,发现更多精彩内容 >>
提交
55464ebc
编写于
4月 12, 2020
作者:
Y
Yashhwanth Ram
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Fix order of comparison and remove incorrect case for ints in typeck/demand.rs
Add tests for *size
上级
b3c9912d
变更
2
隐藏空白更改
内联
并排
Showing
2 changed file
with
64 addition
and
6 deletion
+64
-6
src/librustc_typeck/check/demand.rs
src/librustc_typeck/check/demand.rs
+6
-6
src/test/ui/integer-literal-suffix-inference.rs
src/test/ui/integer-literal-suffix-inference.rs
+58
-0
未找到文件。
src/librustc_typeck/check/demand.rs
浏览文件 @
55464ebc
...
...
@@ -753,9 +753,9 @@ pub fn check_for_cast(
match
(
&
expected_ty
.kind
,
&
checked_ty
.kind
)
{
(
&
ty
::
Int
(
ref
exp
),
&
ty
::
Int
(
ref
found
))
=>
{
let
is_fallible
=
match
(
found
.bit_width
(),
exp
.bit_width
())
{
(
Some
(
found
),
Some
(
exp
))
if
found
>
exp
=>
true
,
(
None
,
Some
(
8
|
16
))
|
(
Some
(
8
|
16
),
None
)
=>
false
,
let
is_fallible
=
match
(
exp
.bit_width
(),
found
.bit_width
())
{
(
Some
(
exp
),
Some
(
found
))
if
exp
<
found
=>
true
,
(
None
,
Some
(
8
|
16
))
=>
false
,
(
None
,
_
)
|
(
_
,
None
)
=>
true
,
_
=>
false
,
};
...
...
@@ -763,9 +763,9 @@ pub fn check_for_cast(
true
}
(
&
ty
::
Uint
(
ref
exp
),
&
ty
::
Uint
(
ref
found
))
=>
{
let
is_fallible
=
match
(
found
.bit_width
(),
exp
.bit_width
())
{
(
Some
(
found
),
Some
(
exp
))
if
found
>
exp
=>
true
,
(
None
,
Some
(
8
|
16
))
|
(
Some
(
8
|
16
),
None
)
=>
false
,
let
is_fallible
=
match
(
exp
.bit_width
(),
found
.bit_width
())
{
(
Some
(
exp
),
Some
(
found
))
if
exp
<
found
=>
true
,
(
None
,
Some
(
8
|
16
))
=>
false
,
(
None
,
_
)
|
(
_
,
None
)
=>
true
,
_
=>
false
,
};
...
...
src/test/ui/integer-literal-suffix-inference.rs
浏览文件 @
55464ebc
...
...
@@ -16,6 +16,7 @@ fn id_i8(n: i8) -> i8 { n }
fn
id_i16
(
n
:
i16
)
->
i16
{
n
}
fn
id_i32
(
n
:
i32
)
->
i32
{
n
}
fn
id_i64
(
n
:
i64
)
->
i64
{
n
}
fn
id_isize
(
n
:
isize
)
->
isize
{
n
}
// the smallest values that need these types
let
b8
:
u8
=
16
;
...
...
@@ -27,6 +28,11 @@ fn id_u8(n: u8) -> u8 { n }
fn
id_u16
(
n
:
u16
)
->
u16
{
n
}
fn
id_u32
(
n
:
u32
)
->
u32
{
n
}
fn
id_u64
(
n
:
u64
)
->
u64
{
n
}
fn
id_usize
(
n
:
usize
)
->
usize
{
n
}
// Values for testing *size
let
asize
:
isize
=
1
;
let
bsize
:
usize
=
3
;
id_i8
(
a8
);
// ok
id_i8
(
a16
);
...
...
@@ -38,6 +44,9 @@ fn id_u64(n: u64) -> u64 { n }
id_i8
(
a64
);
//~^ ERROR mismatched types
//~| expected `i8`, found `i64`
id_i8
(
asize
);
//~^ ERROR mismatched types
//~| expected `i8`, found `isize`
id_i16
(
a8
);
//~^ ERROR mismatched types
...
...
@@ -49,6 +58,9 @@ fn id_u64(n: u64) -> u64 { n }
id_i16
(
a64
);
//~^ ERROR mismatched types
//~| expected `i16`, found `i64`
id_i16
(
asize
);
//~^ ERROR mismatched types
//~| expected `i16`, found `isize`
id_i32
(
a8
);
//~^ ERROR mismatched types
...
...
@@ -60,6 +72,9 @@ fn id_u64(n: u64) -> u64 { n }
id_i32
(
a64
);
//~^ ERROR mismatched types
//~| expected `i32`, found `i64`
id_i32
(
asize
);
//~^ ERROR mismatched types
//~| expected `i32`, found `isize`
id_i64
(
a8
);
//~^ ERROR mismatched types
...
...
@@ -71,6 +86,23 @@ fn id_u64(n: u64) -> u64 { n }
//~^ ERROR mismatched types
//~| expected `i64`, found `i32`
id_i64
(
a64
);
// ok
id_i64
(
asize
);
//~^ ERROR mismatched types
//~| expected `i64`, found `isize`
id_isize
(
a8
);
//~^ ERROR mismatched types
//~| expected `isize`, found `i8`
id_isize
(
a16
);
//~^ ERROR mismatched types
//~| expected `isize`, found `i16`
id_isize
(
a32
);
//~^ ERROR mismatched types
//~| expected `isize`, found `i32`
id_isize
(
a64
);
//~^ ERROR mismatched types
//~| expected `isize`, found `i64`
id_isize
(
asize
);
//ok
id_i8
(
c8
);
// ok
id_i8
(
c16
);
...
...
@@ -126,6 +158,9 @@ fn id_u64(n: u64) -> u64 { n }
id_u8
(
b64
);
//~^ ERROR mismatched types
//~| expected `u8`, found `u64`
id_u8
(
bsize
);
//~^ ERROR mismatched types
//~| expected `u8`, found `usize`
id_u16
(
b8
);
//~^ ERROR mismatched types
...
...
@@ -137,6 +172,9 @@ fn id_u64(n: u64) -> u64 { n }
id_u16
(
b64
);
//~^ ERROR mismatched types
//~| expected `u16`, found `u64`
id_u16
(
bsize
);
//~^ ERROR mismatched types
//~| expected `u16`, found `usize`
id_u32
(
b8
);
//~^ ERROR mismatched types
...
...
@@ -148,6 +186,9 @@ fn id_u64(n: u64) -> u64 { n }
id_u32
(
b64
);
//~^ ERROR mismatched types
//~| expected `u32`, found `u64`
id_u32
(
bsize
);
//~^ ERROR mismatched types
//~| expected `u32`, found `usize`
id_u64
(
b8
);
//~^ ERROR mismatched types
...
...
@@ -159,4 +200,21 @@ fn id_u64(n: u64) -> u64 { n }
//~^ ERROR mismatched types
//~| expected `u64`, found `u32`
id_u64
(
b64
);
// ok
id_u64
(
bsize
);
//~^ ERROR mismatched types
//~| expected `u64`, found `usize`
id_usize
(
b8
);
//~^ ERROR mismatched types
//~| expected `usize`, found `u8`
id_usize
(
b16
);
//~^ ERROR mismatched types
//~| expected `usize`, found `u16`
id_usize
(
b32
);
//~^ ERROR mismatched types
//~| expected `usize`, found `u32`
id_usize
(
b64
);
//~^ ERROR mismatched types
//~| expected `usize`, found `u64`
id_usize
(
bsize
);
//ok
}
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录