Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
int
Rust
提交
0c02f8ae
R
Rust
项目概览
int
/
Rust
11 个月 前同步成功
通知
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,发现更多精彩内容 >>
未验证
提交
0c02f8ae
编写于
6月 11, 2020
作者:
A
Ayaz Hafiz
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
fixup! Provide suggestion to convert numeric op LHS rather than unwrapping RHS
上级
e243f623
变更
3
展开全部
隐藏空白更改
内联
并排
Showing
3 changed file
with
463 addition
and
138 deletion
+463
-138
src/test/ui/numeric/numeric-cast-binop.fixed
src/test/ui/numeric/numeric-cast-binop.fixed
+320
-0
src/test/ui/numeric/numeric-cast-binop.rs
src/test/ui/numeric/numeric-cast-binop.rs
+11
-6
src/test/ui/numeric/numeric-cast-binop.stderr
src/test/ui/numeric/numeric-cast-binop.stderr
+132
-132
未找到文件。
src/test/ui/numeric/numeric-cast-binop.fixed
0 → 100644
浏览文件 @
0c02f8ae
// run-rustfix
// The `try_into` suggestion doesn't include this, but we do suggest it after applying it
use std::convert::TryInto;
#[allow(unused_must_use)]
fn main() {
let x_usize: usize = 1;
let x_u128: u128 = 2;
let x_u64: u64 = 3;
let x_u32: u32 = 4;
let x_u16: u16 = 5;
let x_u8: u8 = 6;
let x_isize: isize = 7;
let x_i64: i64 = 8;
let x_i32: i32 = 9;
let x_i16: i16 = 10;
let x_i8: i8 = 11;
let x_i128: i128 = 12;
/* u<->u */
{
u16::from(x_u8) > x_u16;
//~^ ERROR mismatched types
u32::from(x_u8) > x_u32;
//~^ ERROR mismatched types
u64::from(x_u8) > x_u64;
//~^ ERROR mismatched types
u128::from(x_u8) > x_u128;
//~^ ERROR mismatched types
usize::from(x_u8) > x_usize;
//~^ ERROR mismatched types
x_u16 > x_u8.into();
//~^ ERROR mismatched types
u32::from(x_u16) > x_u32;
//~^ ERROR mismatched types
u64::from(x_u16) > x_u64;
//~^ ERROR mismatched types
u128::from(x_u16) > x_u128;
//~^ ERROR mismatched types
usize::from(x_u16) > x_usize;
//~^ ERROR mismatched types
x_u32 > x_u8.into();
//~^ ERROR mismatched types
x_u32 > x_u16.into();
//~^ ERROR mismatched types
u64::from(x_u32) > x_u64;
//~^ ERROR mismatched types
u128::from(x_u32) > x_u128;
//~^ ERROR mismatched types
x_u32 > x_usize.try_into().unwrap();
//~^ ERROR mismatched types
x_u64 > x_u8.into();
//~^ ERROR mismatched types
x_u64 > x_u16.into();
//~^ ERROR mismatched types
x_u64 > x_u32.into();
//~^ ERROR mismatched types
u128::from(x_u64) > x_u128;
//~^ ERROR mismatched types
x_u64 > x_usize.try_into().unwrap();
//~^ ERROR mismatched types
x_u128 > x_u8.into();
//~^ ERROR mismatched types
x_u128 > x_u16.into();
//~^ ERROR mismatched types
x_u128 > x_u32.into();
//~^ ERROR mismatched types
x_u128 > x_u64.into();
//~^ ERROR mismatched types
x_u128 > x_usize.try_into().unwrap();
//~^ ERROR mismatched types
x_usize > x_u8.into();
//~^ ERROR mismatched types
x_usize > x_u16.into();
//~^ ERROR mismatched types
x_usize > x_u32.try_into().unwrap();
//~^ ERROR mismatched types
x_usize > x_u64.try_into().unwrap();
//~^ ERROR mismatched types
x_usize > x_u128.try_into().unwrap();
//~^ ERROR mismatched types
}
/* i<->i */
{
i16::from(x_i8) > x_i16;
//~^ ERROR mismatched types
i32::from(x_i8) > x_i32;
//~^ ERROR mismatched types
i64::from(x_i8) > x_i64;
//~^ ERROR mismatched types
i128::from(x_i8) > x_i128;
//~^ ERROR mismatched types
isize::from(x_i8) > x_isize;
//~^ ERROR mismatched types
x_i16 > x_i8.into();
//~^ ERROR mismatched types
i32::from(x_i16) > x_i32;
//~^ ERROR mismatched types
i64::from(x_i16) > x_i64;
//~^ ERROR mismatched types
i128::from(x_i16) > x_i128;
//~^ ERROR mismatched types
isize::from(x_i16) > x_isize;
//~^ ERROR mismatched types
x_i32 > x_i8.into();
//~^ ERROR mismatched types
x_i32 > x_i16.into();
//~^ ERROR mismatched types
i64::from(x_i32) > x_i64;
//~^ ERROR mismatched types
i128::from(x_i32) > x_i128;
//~^ ERROR mismatched types
x_i32 > x_isize.try_into().unwrap();
//~^ ERROR mismatched types
x_i64 > x_i8.into();
//~^ ERROR mismatched types
x_i64 > x_i16.into();
//~^ ERROR mismatched types
x_i64 > x_i32.into();
//~^ ERROR mismatched types
i128::from(x_i64) > x_i128;
//~^ ERROR mismatched types
x_i64 > x_isize.try_into().unwrap();
//~^ ERROR mismatched types
x_i128 > x_i8.into();
//~^ ERROR mismatched types
x_i128 > x_i16.into();
//~^ ERROR mismatched types
x_i128 > x_i32.into();
//~^ ERROR mismatched types
x_i128 > x_i64.into();
//~^ ERROR mismatched types
x_i128 > x_isize.try_into().unwrap();
//~^ ERROR mismatched types
x_isize > x_i8.into();
//~^ ERROR mismatched types
x_isize > x_i16.into();
//~^ ERROR mismatched types
x_isize > x_i32.try_into().unwrap();
//~^ ERROR mismatched types
x_isize > x_i64.try_into().unwrap();
//~^ ERROR mismatched types
x_isize > x_i128.try_into().unwrap();
//~^ ERROR mismatched types
}
/* u<->i */
{
x_u8 > x_i8.try_into().unwrap();
//~^ ERROR mismatched types
i16::from(x_u8) > x_i16;
//~^ ERROR mismatched types
i32::from(x_u8) > x_i32;
//~^ ERROR mismatched types
i64::from(x_u8) > x_i64;
//~^ ERROR mismatched types
i128::from(x_u8) > x_i128;
//~^ ERROR mismatched types
isize::from(x_u8) > x_isize;
//~^ ERROR mismatched types
x_u16 > x_i8.try_into().unwrap();
//~^ ERROR mismatched types
x_u16 > x_i16.try_into().unwrap();
//~^ ERROR mismatched types
i32::from(x_u16) > x_i32;
//~^ ERROR mismatched types
i64::from(x_u16) > x_i64;
//~^ ERROR mismatched types
i128::from(x_u16) > x_i128;
//~^ ERROR mismatched types
x_u16 > x_isize.try_into().unwrap();
//~^ ERROR mismatched types
x_u32 > x_i8.try_into().unwrap();
//~^ ERROR mismatched types
x_u32 > x_i16.try_into().unwrap();
//~^ ERROR mismatched types
x_u32 > x_i32.try_into().unwrap();
//~^ ERROR mismatched types
i64::from(x_u32) > x_i64;
//~^ ERROR mismatched types
i128::from(x_u32) > x_i128;
//~^ ERROR mismatched types
x_u32 > x_isize.try_into().unwrap();
//~^ ERROR mismatched types
x_u64 > x_i8.try_into().unwrap();
//~^ ERROR mismatched types
x_u64 > x_i16.try_into().unwrap();
//~^ ERROR mismatched types
x_u64 > x_i32.try_into().unwrap();
//~^ ERROR mismatched types
x_u64 > x_i64.try_into().unwrap();
//~^ ERROR mismatched types
i128::from(x_u64) > x_i128;
//~^ ERROR mismatched types
x_u64 > x_isize.try_into().unwrap();
//~^ ERROR mismatched types
x_u128 > x_i8.try_into().unwrap();
//~^ ERROR mismatched types
x_u128 > x_i16.try_into().unwrap();
//~^ ERROR mismatched types
x_u128 > x_i32.try_into().unwrap();
//~^ ERROR mismatched types
x_u128 > x_i64.try_into().unwrap();
//~^ ERROR mismatched types
x_u128 > x_i128.try_into().unwrap();
//~^ ERROR mismatched types
x_u128 > x_isize.try_into().unwrap();
//~^ ERROR mismatched types
x_usize > x_i8.try_into().unwrap();
//~^ ERROR mismatched types
x_usize > x_i16.try_into().unwrap();
//~^ ERROR mismatched types
x_usize > x_i32.try_into().unwrap();
//~^ ERROR mismatched types
x_usize > x_i64.try_into().unwrap();
//~^ ERROR mismatched types
x_usize > x_i128.try_into().unwrap();
//~^ ERROR mismatched types
x_usize > x_isize.try_into().unwrap();
//~^ ERROR mismatched types
}
/* i<->u */
{
x_i8 > x_u8.try_into().unwrap();
//~^ ERROR mismatched types
x_i8 > x_u16.try_into().unwrap();
//~^ ERROR mismatched types
x_i8 > x_u32.try_into().unwrap();
//~^ ERROR mismatched types
x_i8 > x_u64.try_into().unwrap();
//~^ ERROR mismatched types
x_i8 > x_u128.try_into().unwrap();
//~^ ERROR mismatched types
x_i8 > x_usize.try_into().unwrap();
//~^ ERROR mismatched types
x_i16 > x_u8.into();
//~^ ERROR mismatched types
x_i16 > x_u16.try_into().unwrap();
//~^ ERROR mismatched types
x_i16 > x_u32.try_into().unwrap();
//~^ ERROR mismatched types
x_i16 > x_u64.try_into().unwrap();
//~^ ERROR mismatched types
x_i16 > x_u128.try_into().unwrap();
//~^ ERROR mismatched types
x_i16 > x_usize.try_into().unwrap();
//~^ ERROR mismatched types
x_i32 > x_u8.into();
//~^ ERROR mismatched types
x_i32 > x_u16.into();
//~^ ERROR mismatched types
x_i32 > x_u32.try_into().unwrap();
//~^ ERROR mismatched types
x_i32 > x_u64.try_into().unwrap();
//~^ ERROR mismatched types
x_i32 > x_u128.try_into().unwrap();
//~^ ERROR mismatched types
x_i32 > x_usize.try_into().unwrap();
//~^ ERROR mismatched types
x_i64 > x_u8.into();
//~^ ERROR mismatched types
x_i64 > x_u16.into();
//~^ ERROR mismatched types
x_i64 > x_u32.into();
//~^ ERROR mismatched types
x_i64 > x_u64.try_into().unwrap();
//~^ ERROR mismatched types
x_i64 > x_u128.try_into().unwrap();
//~^ ERROR mismatched types
x_i64 > x_usize.try_into().unwrap();
//~^ ERROR mismatched types
x_i128 > x_u8.into();
//~^ ERROR mismatched types
x_i128 > x_u16.into();
//~^ ERROR mismatched types
x_i128 > x_u32.into();
//~^ ERROR mismatched types
x_i128 > x_u64.into();
//~^ ERROR mismatched types
x_i128 > x_u128.try_into().unwrap();
//~^ ERROR mismatched types
x_i128 > x_usize.try_into().unwrap();
//~^ ERROR mismatched types
x_isize > x_u8.into();
//~^ ERROR mismatched types
x_isize > x_u16.try_into().unwrap();
//~^ ERROR mismatched types
x_isize > x_u32.try_into().unwrap();
//~^ ERROR mismatched types
x_isize > x_u64.try_into().unwrap();
//~^ ERROR mismatched types
x_isize > x_u128.try_into().unwrap();
//~^ ERROR mismatched types
x_isize > x_usize.try_into().unwrap();
//~^ ERROR mismatched types
}
}
src/test/ui/numeric/numeric-cast-binop.rs
浏览文件 @
0c02f8ae
// run-rustfix
// The `try_into` suggestion doesn't include this, but we do suggest it after applying it
use
std
::
convert
::
TryInto
;
#[allow(unused_must_use)]
fn
main
()
{
let
x_usize
:
usize
=
1
;
let
x_u128
:
u128
=
2
;
...
...
@@ -6,12 +12,11 @@ fn main() {
let
x_u16
:
u16
=
5
;
let
x_u8
:
u8
=
6
;
let
x_isize
:
isize
=
7
;
let
x_i128
:
i128
=
8
;
let
x_i64
:
i64
=
9
;
let
x_i32
:
i32
=
10
;
let
x_i16
:
i16
=
11
;
let
x_i8
:
i8
=
12
;
let
x_i128
:
i128
=
13
;
let
x_i64
:
i64
=
8
;
let
x_i32
:
i32
=
9
;
let
x_i16
:
i16
=
10
;
let
x_i8
:
i8
=
11
;
let
x_i128
:
i128
=
12
;
/* u<->u */
{
...
...
src/test/ui/numeric/numeric-cast-binop.stderr
浏览文件 @
0c02f8ae
此差异已折叠。
点击以展开。
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录