Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
int
Rust
提交
3d16c228
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,发现更多精彩内容 >>
提交
3d16c228
编写于
6月 19, 2022
作者:
M
Michael Goulet
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Be more hygenic with spans
上级
52c9906c
变更
5
展开全部
隐藏空白更改
内联
并排
Showing
5 changed file
with
181 addition
and
266 deletion
+181
-266
compiler/rustc_mir_build/src/thir/pattern/check_match.rs
compiler/rustc_mir_build/src/thir/pattern/check_match.rs
+7
-6
src/test/ui/half-open-range-patterns/half-open-range-pats-exhaustive-fail.stderr
...ange-patterns/half-open-range-pats-exhaustive-fail.stderr
+136
-204
src/test/ui/pattern/usefulness/integer-ranges/exhaustiveness.stderr
...i/pattern/usefulness/integer-ranges/exhaustiveness.stderr
+20
-30
src/test/ui/pattern/usefulness/integer-ranges/pointer-sized-int.deny.stderr
...n/usefulness/integer-ranges/pointer-sized-int.deny.stderr
+16
-24
src/test/ui/pattern/usefulness/non-exhaustive-match.stderr
src/test/ui/pattern/usefulness/non-exhaustive-match.stderr
+2
-2
未找到文件。
compiler/rustc_mir_build/src/thir/pattern/check_match.rs
浏览文件 @
3d16c228
...
...
@@ -821,16 +821,17 @@ fn non_exhaustive_match<'p, 'tcx>(
));
}
[
only
]
=>
{
let
pre_indentation
=
if
let
(
Some
(
snippet
),
true
)
=
(
sm
.indentation_before
(
only
.span
),
sm
.is_multiline
(
sp
.shrink_to_hi
()
.with_hi
(
only
.span
.lo
())),
)
{
format!
(
"
\n
{}"
,
snippet
)
let
(
pre_indentation
,
is_multiline
)
=
if
let
Some
(
snippet
)
=
sm
.indentation_before
(
only
.span
)
&&
let
Ok
(
with_trailing
)
=
sm
.span_extend_while
(
only
.span
,
|
c
|
c
.is_whitespace
()
||
c
==
','
)
&&
sm
.is_multiline
(
with_trailing
)
{
(
format!
(
"
\n
{}"
,
snippet
),
true
)
}
else
{
" "
.to_string
(
)
(
" "
.to_string
(),
false
)
};
let
comma
=
if
matches!
(
only
.body.kind
,
hir
::
ExprKind
::
Block
(
..
))
&&
only
.span
.eq_ctxt
(
only
.body.span
)
&&
is_multiline
{
""
}
else
{
...
...
src/test/ui/half-open-range-patterns/half-open-range-pats-exhaustive-fail.stderr
浏览文件 @
3d16c228
此差异已折叠。
点击以展开。
src/test/ui/pattern/usefulness/integer-ranges/exhaustiveness.stderr
浏览文件 @
3d16c228
...
...
@@ -7,9 +7,8 @@ LL | m!(0u8, 0..255);
= note: the matched value is of type `u8`
help: ensure that all possible cases are being handled by adding a match arm with a wildcard pattern or an explicit pattern as shown
|
LL ~ match $s { $($t)+ => {}
LL ~ u8::MAX => todo!() }
|
LL | match $s { $($t)+ => {}, u8::MAX => todo!() }
| ++++++++++++++++++++
error[E0004]: non-exhaustive patterns: `u8::MAX` not covered
--> $DIR/exhaustiveness.rs:48:8
...
...
@@ -20,9 +19,8 @@ LL | m!(0u8, 0..=254);
= note: the matched value is of type `u8`
help: ensure that all possible cases are being handled by adding a match arm with a wildcard pattern or an explicit pattern as shown
|
LL ~ match $s { $($t)+ => {}
LL ~ u8::MAX => todo!() }
|
LL | match $s { $($t)+ => {}, u8::MAX => todo!() }
| ++++++++++++++++++++
error[E0004]: non-exhaustive patterns: `0_u8` not covered
--> $DIR/exhaustiveness.rs:49:8
...
...
@@ -33,9 +31,8 @@ LL | m!(0u8, 1..=255);
= note: the matched value is of type `u8`
help: ensure that all possible cases are being handled by adding a match arm with a wildcard pattern or an explicit pattern as shown
|
LL ~ match $s { $($t)+ => {}
LL ~ 0_u8 => todo!() }
|
LL | match $s { $($t)+ => {}, 0_u8 => todo!() }
| +++++++++++++++++
error[E0004]: non-exhaustive patterns: `42_u8` not covered
--> $DIR/exhaustiveness.rs:50:8
...
...
@@ -46,9 +43,8 @@ LL | m!(0u8, 0..42 | 43..=255);
= note: the matched value is of type `u8`
help: ensure that all possible cases are being handled by adding a match arm with a wildcard pattern or an explicit pattern as shown
|
LL ~ match $s { $($t)+ => {}
LL ~ 42_u8 => todo!() }
|
LL | match $s { $($t)+ => {}, 42_u8 => todo!() }
| ++++++++++++++++++
error[E0004]: non-exhaustive patterns: `i8::MAX` not covered
--> $DIR/exhaustiveness.rs:51:8
...
...
@@ -59,9 +55,8 @@ LL | m!(0i8, -128..127);
= note: the matched value is of type `i8`
help: ensure that all possible cases are being handled by adding a match arm with a wildcard pattern or an explicit pattern as shown
|
LL ~ match $s { $($t)+ => {}
LL ~ i8::MAX => todo!() }
|
LL | match $s { $($t)+ => {}, i8::MAX => todo!() }
| ++++++++++++++++++++
error[E0004]: non-exhaustive patterns: `i8::MAX` not covered
--> $DIR/exhaustiveness.rs:52:8
...
...
@@ -72,9 +67,8 @@ LL | m!(0i8, -128..=126);
= note: the matched value is of type `i8`
help: ensure that all possible cases are being handled by adding a match arm with a wildcard pattern or an explicit pattern as shown
|
LL ~ match $s { $($t)+ => {}
LL ~ i8::MAX => todo!() }
|
LL | match $s { $($t)+ => {}, i8::MAX => todo!() }
| ++++++++++++++++++++
error[E0004]: non-exhaustive patterns: `i8::MIN` not covered
--> $DIR/exhaustiveness.rs:53:8
...
...
@@ -85,9 +79,8 @@ LL | m!(0i8, -127..=127);
= note: the matched value is of type `i8`
help: ensure that all possible cases are being handled by adding a match arm with a wildcard pattern or an explicit pattern as shown
|
LL ~ match $s { $($t)+ => {}
LL ~ i8::MIN => todo!() }
|
LL | match $s { $($t)+ => {}, i8::MIN => todo!() }
| ++++++++++++++++++++
error[E0004]: non-exhaustive patterns: `0_i8` not covered
--> $DIR/exhaustiveness.rs:54:11
...
...
@@ -111,9 +104,8 @@ LL | m!(0u128, 0..=ALMOST_MAX);
= note: the matched value is of type `u128`
help: ensure that all possible cases are being handled by adding a match arm with a wildcard pattern or an explicit pattern as shown
|
LL ~ match $s { $($t)+ => {}
LL ~ u128::MAX => todo!() }
|
LL | match $s { $($t)+ => {}, u128::MAX => todo!() }
| ++++++++++++++++++++++
error[E0004]: non-exhaustive patterns: `5_u128..=u128::MAX` not covered
--> $DIR/exhaustiveness.rs:60:8
...
...
@@ -124,9 +116,8 @@ LL | m!(0u128, 0..=4);
= note: the matched value is of type `u128`
help: ensure that all possible cases are being handled by adding a match arm with a wildcard pattern or an explicit pattern as shown
|
LL ~ match $s { $($t)+ => {}
LL ~ 5_u128..=u128::MAX => todo!() }
|
LL | match $s { $($t)+ => {}, 5_u128..=u128::MAX => todo!() }
| +++++++++++++++++++++++++++++++
error[E0004]: non-exhaustive patterns: `0_u128` not covered
--> $DIR/exhaustiveness.rs:61:8
...
...
@@ -137,9 +128,8 @@ LL | m!(0u128, 1..=u128::MAX);
= note: the matched value is of type `u128`
help: ensure that all possible cases are being handled by adding a match arm with a wildcard pattern or an explicit pattern as shown
|
LL ~ match $s { $($t)+ => {}
LL ~ 0_u128 => todo!() }
|
LL | match $s { $($t)+ => {}, 0_u128 => todo!() }
| +++++++++++++++++++
error[E0004]: non-exhaustive patterns: `(126_u8..=127_u8, false)` not covered
--> $DIR/exhaustiveness.rs:69:11
...
...
src/test/ui/pattern/usefulness/integer-ranges/pointer-sized-int.deny.stderr
浏览文件 @
3d16c228
...
...
@@ -39,9 +39,8 @@ LL | m!(0usize, 0..=usize::MAX);
= help: add `#![feature(precise_pointer_size_matching)]` to the crate attributes to enable precise `usize` matching
help: ensure that all possible cases are being handled by adding a match arm with a wildcard pattern or an explicit pattern as shown
|
LL ~ match $s { $($t)+ => {}
LL ~ _ => todo!() }
|
LL | match $s { $($t)+ => {}, _ => todo!() }
| ++++++++++++++
error[E0004]: non-exhaustive patterns: `_` not covered
--> $DIR/pointer-sized-int.rs:24:8
...
...
@@ -54,9 +53,8 @@ LL | m!(0usize, 0..5 | 5..=usize::MAX);
= help: add `#![feature(precise_pointer_size_matching)]` to the crate attributes to enable precise `usize` matching
help: ensure that all possible cases are being handled by adding a match arm with a wildcard pattern or an explicit pattern as shown
|
LL ~ match $s { $($t)+ => {}
LL ~ _ => todo!() }
|
LL | match $s { $($t)+ => {}, _ => todo!() }
| ++++++++++++++
error[E0004]: non-exhaustive patterns: `_` not covered
--> $DIR/pointer-sized-int.rs:26:8
...
...
@@ -69,9 +67,8 @@ LL | m!(0usize, 0..usize::MAX | usize::MAX);
= help: add `#![feature(precise_pointer_size_matching)]` to the crate attributes to enable precise `usize` matching
help: ensure that all possible cases are being handled by adding a match arm with a wildcard pattern or an explicit pattern as shown
|
LL ~ match $s { $($t)+ => {}
LL ~ _ => todo!() }
|
LL | match $s { $($t)+ => {}, _ => todo!() }
| ++++++++++++++
error[E0004]: non-exhaustive patterns: `(_, _)` not covered
--> $DIR/pointer-sized-int.rs:28:8
...
...
@@ -82,9 +79,8 @@ LL | m!((0usize, true), (0..5, true) | (5..=usize::MAX, true) | (0..=usize::
= note: the matched value is of type `(usize, bool)`
help: ensure that all possible cases are being handled by adding a match arm with a wildcard pattern or an explicit pattern as shown
|
LL ~ match $s { $($t)+ => {}
LL ~ (_, _) => todo!() }
|
LL | match $s { $($t)+ => {}, (_, _) => todo!() }
| +++++++++++++++++++
error[E0004]: non-exhaustive patterns: `_` not covered
--> $DIR/pointer-sized-int.rs:31:8
...
...
@@ -97,9 +93,8 @@ LL | m!(0isize, isize::MIN..=isize::MAX);
= help: add `#![feature(precise_pointer_size_matching)]` to the crate attributes to enable precise `isize` matching
help: ensure that all possible cases are being handled by adding a match arm with a wildcard pattern or an explicit pattern as shown
|
LL ~ match $s { $($t)+ => {}
LL ~ _ => todo!() }
|
LL | match $s { $($t)+ => {}, _ => todo!() }
| ++++++++++++++
error[E0004]: non-exhaustive patterns: `_` not covered
--> $DIR/pointer-sized-int.rs:33:8
...
...
@@ -112,9 +107,8 @@ LL | m!(0isize, isize::MIN..5 | 5..=isize::MAX);
= help: add `#![feature(precise_pointer_size_matching)]` to the crate attributes to enable precise `isize` matching
help: ensure that all possible cases are being handled by adding a match arm with a wildcard pattern or an explicit pattern as shown
|
LL ~ match $s { $($t)+ => {}
LL ~ _ => todo!() }
|
LL | match $s { $($t)+ => {}, _ => todo!() }
| ++++++++++++++
error[E0004]: non-exhaustive patterns: `_` not covered
--> $DIR/pointer-sized-int.rs:35:8
...
...
@@ -127,9 +121,8 @@ LL | m!(0isize, isize::MIN..isize::MAX | isize::MAX);
= help: add `#![feature(precise_pointer_size_matching)]` to the crate attributes to enable precise `isize` matching
help: ensure that all possible cases are being handled by adding a match arm with a wildcard pattern or an explicit pattern as shown
|
LL ~ match $s { $($t)+ => {}
LL ~ _ => todo!() }
|
LL | match $s { $($t)+ => {}, _ => todo!() }
| ++++++++++++++
error[E0004]: non-exhaustive patterns: `(_, _)` not covered
--> $DIR/pointer-sized-int.rs:37:8
...
...
@@ -140,9 +133,8 @@ LL | m!((0isize, true), (isize::MIN..5, true)
= note: the matched value is of type `(isize, bool)`
help: ensure that all possible cases are being handled by adding a match arm with a wildcard pattern or an explicit pattern as shown
|
LL ~ match $s { $($t)+ => {}
LL ~ (_, _) => todo!() }
|
LL | match $s { $($t)+ => {}, (_, _) => todo!() }
| +++++++++++++++++++
error[E0004]: non-exhaustive patterns: `_` not covered
--> $DIR/pointer-sized-int.rs:41:11
...
...
src/test/ui/pattern/usefulness/non-exhaustive-match.stderr
浏览文件 @
3d16c228
...
...
@@ -12,8 +12,8 @@ LL | enum T { A, B }
= note: the matched value is of type `T`
help: ensure that all possible cases are being handled by adding a match arm with a wildcard pattern or an explicit pattern as shown
|
LL | match x { T::B => { } A => todo!() }
|
++++++++++++
LL | match x { T::B => { }
,
A => todo!() }
|
++
++++++++++++
error[E0004]: non-exhaustive patterns: `false` not covered
--> $DIR/non-exhaustive-match.rs:8:11
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录