提交 3d16c228 编写于 作者: M Michael Goulet

Be more hygenic with spans

上级 52c9906c
......@@ -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 {
......
......@@ -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
......
......@@ -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
......
......@@ -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.
先完成此消息的编辑!
想要评论请 注册