Add a machine-applicable suggestion to "unreachable pattern"
This commit is contained in:
parent
0307e401c2
commit
1f69638400
@ -338,6 +338,7 @@ mir_build_unreachable_pattern = unreachable pattern
|
||||
.unreachable_covered_by_catchall = matches any value
|
||||
.unreachable_covered_by_one = matches all the relevant values
|
||||
.unreachable_covered_by_many = multiple earlier patterns match some of the same values
|
||||
.suggestion = remove the match arm
|
||||
|
||||
mir_build_unsafe_fn_safe_body = an unsafe function restricts its caller, but its body is safe by default
|
||||
mir_build_unsafe_not_inherited = items do not inherit unsafety from separate enclosing items
|
||||
|
@ -598,6 +598,8 @@ pub(crate) struct UnreachablePattern<'tcx> {
|
||||
#[note(mir_build_unreachable_covered_by_many)]
|
||||
pub(crate) covered_by_many: Option<MultiSpan>,
|
||||
pub(crate) covered_by_many_n_more_count: usize,
|
||||
#[suggestion(code = "", applicability = "machine-applicable")]
|
||||
pub(crate) suggest_remove: Option<Span>,
|
||||
}
|
||||
|
||||
#[derive(Diagnostic)]
|
||||
|
@ -413,7 +413,7 @@ fn analyze_patterns(
|
||||
// Emit lints in the order in which they occur in the file.
|
||||
redundant_subpats.sort_unstable_by_key(|(pat, _)| pat.data().span);
|
||||
for (pat, explanation) in redundant_subpats {
|
||||
report_unreachable_pattern(cx, arm.arm_data, pat, &explanation)
|
||||
report_unreachable_pattern(cx, arm.arm_data, pat, &explanation, None)
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -474,7 +474,11 @@ fn check_match(
|
||||
hir::MatchSource::ForLoopDesugar
|
||||
| hir::MatchSource::Postfix
|
||||
| hir::MatchSource::Normal
|
||||
| hir::MatchSource::FormatArgs => report_arm_reachability(&cx, &report),
|
||||
| hir::MatchSource::FormatArgs => {
|
||||
let is_match_arm =
|
||||
matches!(source, hir::MatchSource::Postfix | hir::MatchSource::Normal);
|
||||
report_arm_reachability(&cx, &report, is_match_arm);
|
||||
}
|
||||
// Unreachable patterns in try and await expressions occur when one of
|
||||
// the arms are an uninhabited type. Which is OK.
|
||||
hir::MatchSource::AwaitDesugar | hir::MatchSource::TryDesugar(_) => {}
|
||||
@ -626,7 +630,7 @@ fn is_let_irrefutable(
|
||||
) -> Result<RefutableFlag, ErrorGuaranteed> {
|
||||
let (cx, report) = self.analyze_binding(pat, Refutable, scrut)?;
|
||||
// Report if the pattern is unreachable, which can only occur when the type is uninhabited.
|
||||
report_arm_reachability(&cx, &report);
|
||||
report_arm_reachability(&cx, &report, false);
|
||||
// If the list of witnesses is empty, the match is exhaustive, i.e. the `if let` pattern is
|
||||
// irrefutable.
|
||||
Ok(if report.non_exhaustiveness_witnesses.is_empty() { Irrefutable } else { Refutable })
|
||||
@ -916,6 +920,7 @@ fn report_unreachable_pattern<'p, 'tcx>(
|
||||
hir_id: HirId,
|
||||
pat: &DeconstructedPat<'p, 'tcx>,
|
||||
explanation: &RedundancyExplanation<'p, 'tcx>,
|
||||
whole_arm_span: Option<Span>,
|
||||
) {
|
||||
static CAP_COVERED_BY_MANY: usize = 4;
|
||||
let pat_span = pat.data().span;
|
||||
@ -928,6 +933,7 @@ fn report_unreachable_pattern<'p, 'tcx>(
|
||||
covered_by_one: None,
|
||||
covered_by_many: None,
|
||||
covered_by_many_n_more_count: 0,
|
||||
suggest_remove: None,
|
||||
};
|
||||
match explanation.covered_by.as_slice() {
|
||||
[] => {
|
||||
@ -935,6 +941,7 @@ fn report_unreachable_pattern<'p, 'tcx>(
|
||||
lint.span = None; // Don't label the pattern itself
|
||||
lint.uninhabited_note = Some(()); // Give a link about empty types
|
||||
lint.matches_no_values = Some(pat_span);
|
||||
lint.suggest_remove = whole_arm_span; // Suggest to remove the match arm
|
||||
pat.walk(&mut |subpat| {
|
||||
let ty = **subpat.ty();
|
||||
if cx.is_uninhabited(ty) {
|
||||
@ -982,10 +989,28 @@ fn report_unreachable_pattern<'p, 'tcx>(
|
||||
}
|
||||
|
||||
/// Report unreachable arms, if any.
|
||||
fn report_arm_reachability<'p, 'tcx>(cx: &PatCtxt<'p, 'tcx>, report: &UsefulnessReport<'p, 'tcx>) {
|
||||
fn report_arm_reachability<'p, 'tcx>(
|
||||
cx: &PatCtxt<'p, 'tcx>,
|
||||
report: &UsefulnessReport<'p, 'tcx>,
|
||||
is_match_arm: bool,
|
||||
) {
|
||||
let sm = cx.tcx.sess.source_map();
|
||||
for (arm, is_useful) in report.arm_usefulness.iter() {
|
||||
if let Usefulness::Redundant(explanation) = is_useful {
|
||||
report_unreachable_pattern(cx, arm.arm_data, arm.pat, explanation)
|
||||
let hir_id = arm.arm_data;
|
||||
let arm_span = cx.tcx.hir().span(hir_id);
|
||||
let whole_arm_span = if is_match_arm {
|
||||
// If the arm is followed by a comma, extend the span to include it.
|
||||
let with_whitespace = sm.span_extend_while_whitespace(arm_span);
|
||||
if let Some(comma) = sm.span_look_ahead(with_whitespace, ",", Some(1)) {
|
||||
Some(arm_span.to(comma))
|
||||
} else {
|
||||
Some(arm_span)
|
||||
}
|
||||
} else {
|
||||
None
|
||||
};
|
||||
report_unreachable_pattern(cx, hir_id, arm.pat, explanation, whole_arm_span)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -2,7 +2,10 @@ error: unreachable pattern
|
||||
--> $DIR/empty-match-check-notes.rs:17:9
|
||||
|
|
||||
LL | _ => {}
|
||||
| ^ matches no values because `EmptyEnum` is uninhabited
|
||||
| ^------
|
||||
| |
|
||||
| matches no values because `EmptyEnum` is uninhabited
|
||||
| help: remove the match arm
|
||||
|
|
||||
= note: to learn more about uninhabited types, see https://doc.rust-lang.org/nomicon/exotic-sizes.html#empty-types
|
||||
note: the lint level is defined here
|
||||
@ -15,7 +18,10 @@ error: unreachable pattern
|
||||
--> $DIR/empty-match-check-notes.rs:22:9
|
||||
|
|
||||
LL | _ if false => {}
|
||||
| ^ matches no values because `EmptyEnum` is uninhabited
|
||||
| ^---------------
|
||||
| |
|
||||
| matches no values because `EmptyEnum` is uninhabited
|
||||
| help: remove the match arm
|
||||
|
|
||||
= note: to learn more about uninhabited types, see https://doc.rust-lang.org/nomicon/exotic-sizes.html#empty-types
|
||||
|
||||
@ -23,7 +29,10 @@ error: unreachable pattern
|
||||
--> $DIR/empty-match-check-notes.rs:31:9
|
||||
|
|
||||
LL | _ => {}
|
||||
| ^ matches no values because `EmptyForeignEnum` is uninhabited
|
||||
| ^------
|
||||
| |
|
||||
| matches no values because `EmptyForeignEnum` is uninhabited
|
||||
| help: remove the match arm
|
||||
|
|
||||
= note: to learn more about uninhabited types, see https://doc.rust-lang.org/nomicon/exotic-sizes.html#empty-types
|
||||
|
||||
@ -31,7 +40,10 @@ error: unreachable pattern
|
||||
--> $DIR/empty-match-check-notes.rs:36:9
|
||||
|
|
||||
LL | _ if false => {}
|
||||
| ^ matches no values because `EmptyForeignEnum` is uninhabited
|
||||
| ^---------------
|
||||
| |
|
||||
| matches no values because `EmptyForeignEnum` is uninhabited
|
||||
| help: remove the match arm
|
||||
|
|
||||
= note: to learn more about uninhabited types, see https://doc.rust-lang.org/nomicon/exotic-sizes.html#empty-types
|
||||
|
||||
|
@ -2,7 +2,10 @@ error: unreachable pattern
|
||||
--> $DIR/empty-match-check-notes.rs:17:9
|
||||
|
|
||||
LL | _ => {}
|
||||
| ^ matches no values because `EmptyEnum` is uninhabited
|
||||
| ^------
|
||||
| |
|
||||
| matches no values because `EmptyEnum` is uninhabited
|
||||
| help: remove the match arm
|
||||
|
|
||||
= note: to learn more about uninhabited types, see https://doc.rust-lang.org/nomicon/exotic-sizes.html#empty-types
|
||||
note: the lint level is defined here
|
||||
@ -15,7 +18,10 @@ error: unreachable pattern
|
||||
--> $DIR/empty-match-check-notes.rs:22:9
|
||||
|
|
||||
LL | _ if false => {}
|
||||
| ^ matches no values because `EmptyEnum` is uninhabited
|
||||
| ^---------------
|
||||
| |
|
||||
| matches no values because `EmptyEnum` is uninhabited
|
||||
| help: remove the match arm
|
||||
|
|
||||
= note: to learn more about uninhabited types, see https://doc.rust-lang.org/nomicon/exotic-sizes.html#empty-types
|
||||
|
||||
@ -23,7 +29,10 @@ error: unreachable pattern
|
||||
--> $DIR/empty-match-check-notes.rs:31:9
|
||||
|
|
||||
LL | _ => {}
|
||||
| ^ matches no values because `EmptyForeignEnum` is uninhabited
|
||||
| ^------
|
||||
| |
|
||||
| matches no values because `EmptyForeignEnum` is uninhabited
|
||||
| help: remove the match arm
|
||||
|
|
||||
= note: to learn more about uninhabited types, see https://doc.rust-lang.org/nomicon/exotic-sizes.html#empty-types
|
||||
|
||||
@ -31,7 +40,10 @@ error: unreachable pattern
|
||||
--> $DIR/empty-match-check-notes.rs:36:9
|
||||
|
|
||||
LL | _ if false => {}
|
||||
| ^ matches no values because `EmptyForeignEnum` is uninhabited
|
||||
| ^---------------
|
||||
| |
|
||||
| matches no values because `EmptyForeignEnum` is uninhabited
|
||||
| help: remove the match arm
|
||||
|
|
||||
= note: to learn more about uninhabited types, see https://doc.rust-lang.org/nomicon/exotic-sizes.html#empty-types
|
||||
|
||||
|
@ -2,7 +2,10 @@ error: unreachable pattern
|
||||
--> $DIR/empty-types.rs:49:9
|
||||
|
|
||||
LL | _ => {}
|
||||
| ^ matches no values because `!` is uninhabited
|
||||
| ^------
|
||||
| |
|
||||
| matches no values because `!` is uninhabited
|
||||
| help: remove the match arm
|
||||
|
|
||||
= note: to learn more about uninhabited types, see https://doc.rust-lang.org/nomicon/exotic-sizes.html#empty-types
|
||||
note: the lint level is defined here
|
||||
@ -15,7 +18,10 @@ error: unreachable pattern
|
||||
--> $DIR/empty-types.rs:52:9
|
||||
|
|
||||
LL | _x => {}
|
||||
| ^^ matches no values because `!` is uninhabited
|
||||
| ^^------
|
||||
| |
|
||||
| matches no values because `!` is uninhabited
|
||||
| help: remove the match arm
|
||||
|
|
||||
= note: to learn more about uninhabited types, see https://doc.rust-lang.org/nomicon/exotic-sizes.html#empty-types
|
||||
|
||||
@ -38,7 +44,10 @@ error: unreachable pattern
|
||||
--> $DIR/empty-types.rs:70:9
|
||||
|
|
||||
LL | (_, _) => {}
|
||||
| ^^^^^^ matches no values because `(u32, !)` is uninhabited
|
||||
| ^^^^^^------
|
||||
| |
|
||||
| matches no values because `(u32, !)` is uninhabited
|
||||
| help: remove the match arm
|
||||
|
|
||||
= note: to learn more about uninhabited types, see https://doc.rust-lang.org/nomicon/exotic-sizes.html#empty-types
|
||||
|
||||
@ -46,7 +55,10 @@ error: unreachable pattern
|
||||
--> $DIR/empty-types.rs:76:9
|
||||
|
|
||||
LL | _ => {}
|
||||
| ^ matches no values because `(!, !)` is uninhabited
|
||||
| ^------
|
||||
| |
|
||||
| matches no values because `(!, !)` is uninhabited
|
||||
| help: remove the match arm
|
||||
|
|
||||
= note: to learn more about uninhabited types, see https://doc.rust-lang.org/nomicon/exotic-sizes.html#empty-types
|
||||
|
||||
@ -54,7 +66,10 @@ error: unreachable pattern
|
||||
--> $DIR/empty-types.rs:79:9
|
||||
|
|
||||
LL | (_, _) => {}
|
||||
| ^^^^^^ matches no values because `(!, !)` is uninhabited
|
||||
| ^^^^^^------
|
||||
| |
|
||||
| matches no values because `(!, !)` is uninhabited
|
||||
| help: remove the match arm
|
||||
|
|
||||
= note: to learn more about uninhabited types, see https://doc.rust-lang.org/nomicon/exotic-sizes.html#empty-types
|
||||
|
||||
@ -62,7 +77,10 @@ error: unreachable pattern
|
||||
--> $DIR/empty-types.rs:83:9
|
||||
|
|
||||
LL | _ => {}
|
||||
| ^ matches no values because `!` is uninhabited
|
||||
| ^------
|
||||
| |
|
||||
| matches no values because `!` is uninhabited
|
||||
| help: remove the match arm
|
||||
|
|
||||
= note: to learn more about uninhabited types, see https://doc.rust-lang.org/nomicon/exotic-sizes.html#empty-types
|
||||
|
||||
@ -89,7 +107,10 @@ error: unreachable pattern
|
||||
--> $DIR/empty-types.rs:94:9
|
||||
|
|
||||
LL | Err(_) => {}
|
||||
| ^^^^^^ matches no values because `!` is uninhabited
|
||||
| ^^^^^^------
|
||||
| |
|
||||
| matches no values because `!` is uninhabited
|
||||
| help: remove the match arm
|
||||
|
|
||||
= note: to learn more about uninhabited types, see https://doc.rust-lang.org/nomicon/exotic-sizes.html#empty-types
|
||||
|
||||
@ -97,7 +118,10 @@ error: unreachable pattern
|
||||
--> $DIR/empty-types.rs:99:9
|
||||
|
|
||||
LL | Err(_) => {}
|
||||
| ^^^^^^ matches no values because `!` is uninhabited
|
||||
| ^^^^^^------
|
||||
| |
|
||||
| matches no values because `!` is uninhabited
|
||||
| help: remove the match arm
|
||||
|
|
||||
= note: to learn more about uninhabited types, see https://doc.rust-lang.org/nomicon/exotic-sizes.html#empty-types
|
||||
|
||||
@ -137,7 +161,10 @@ error: unreachable pattern
|
||||
--> $DIR/empty-types.rs:112:9
|
||||
|
|
||||
LL | _ => {}
|
||||
| ^ matches no values because `Result<!, !>` is uninhabited
|
||||
| ^------
|
||||
| |
|
||||
| matches no values because `Result<!, !>` is uninhabited
|
||||
| help: remove the match arm
|
||||
|
|
||||
= note: to learn more about uninhabited types, see https://doc.rust-lang.org/nomicon/exotic-sizes.html#empty-types
|
||||
|
||||
@ -145,7 +172,10 @@ error: unreachable pattern
|
||||
--> $DIR/empty-types.rs:115:9
|
||||
|
|
||||
LL | Ok(_) => {}
|
||||
| ^^^^^ matches no values because `Result<!, !>` is uninhabited
|
||||
| ^^^^^------
|
||||
| |
|
||||
| matches no values because `Result<!, !>` is uninhabited
|
||||
| help: remove the match arm
|
||||
|
|
||||
= note: to learn more about uninhabited types, see https://doc.rust-lang.org/nomicon/exotic-sizes.html#empty-types
|
||||
|
||||
@ -153,7 +183,10 @@ error: unreachable pattern
|
||||
--> $DIR/empty-types.rs:118:9
|
||||
|
|
||||
LL | Ok(_) => {}
|
||||
| ^^^^^ matches no values because `Result<!, !>` is uninhabited
|
||||
| ^^^^^------
|
||||
| |
|
||||
| matches no values because `Result<!, !>` is uninhabited
|
||||
| help: remove the match arm
|
||||
|
|
||||
= note: to learn more about uninhabited types, see https://doc.rust-lang.org/nomicon/exotic-sizes.html#empty-types
|
||||
|
||||
@ -161,7 +194,10 @@ error: unreachable pattern
|
||||
--> $DIR/empty-types.rs:119:9
|
||||
|
|
||||
LL | _ => {}
|
||||
| ^ matches no values because `Result<!, !>` is uninhabited
|
||||
| ^------
|
||||
| |
|
||||
| matches no values because `Result<!, !>` is uninhabited
|
||||
| help: remove the match arm
|
||||
|
|
||||
= note: to learn more about uninhabited types, see https://doc.rust-lang.org/nomicon/exotic-sizes.html#empty-types
|
||||
|
||||
@ -169,7 +205,10 @@ error: unreachable pattern
|
||||
--> $DIR/empty-types.rs:122:9
|
||||
|
|
||||
LL | Ok(_) => {}
|
||||
| ^^^^^ matches no values because `Result<!, !>` is uninhabited
|
||||
| ^^^^^------
|
||||
| |
|
||||
| matches no values because `Result<!, !>` is uninhabited
|
||||
| help: remove the match arm
|
||||
|
|
||||
= note: to learn more about uninhabited types, see https://doc.rust-lang.org/nomicon/exotic-sizes.html#empty-types
|
||||
|
||||
@ -177,7 +216,10 @@ error: unreachable pattern
|
||||
--> $DIR/empty-types.rs:123:9
|
||||
|
|
||||
LL | Err(_) => {}
|
||||
| ^^^^^^ matches no values because `Result<!, !>` is uninhabited
|
||||
| ^^^^^^------
|
||||
| |
|
||||
| matches no values because `Result<!, !>` is uninhabited
|
||||
| help: remove the match arm
|
||||
|
|
||||
= note: to learn more about uninhabited types, see https://doc.rust-lang.org/nomicon/exotic-sizes.html#empty-types
|
||||
|
||||
@ -185,7 +227,10 @@ error: unreachable pattern
|
||||
--> $DIR/empty-types.rs:132:13
|
||||
|
|
||||
LL | _ => {}
|
||||
| ^ matches no values because `Void` is uninhabited
|
||||
| ^------
|
||||
| |
|
||||
| matches no values because `Void` is uninhabited
|
||||
| help: remove the match arm
|
||||
|
|
||||
= note: to learn more about uninhabited types, see https://doc.rust-lang.org/nomicon/exotic-sizes.html#empty-types
|
||||
|
||||
@ -193,7 +238,10 @@ error: unreachable pattern
|
||||
--> $DIR/empty-types.rs:135:13
|
||||
|
|
||||
LL | _ if false => {}
|
||||
| ^ matches no values because `Void` is uninhabited
|
||||
| ^---------------
|
||||
| |
|
||||
| matches no values because `Void` is uninhabited
|
||||
| help: remove the match arm
|
||||
|
|
||||
= note: to learn more about uninhabited types, see https://doc.rust-lang.org/nomicon/exotic-sizes.html#empty-types
|
||||
|
||||
@ -201,7 +249,10 @@ error: unreachable pattern
|
||||
--> $DIR/empty-types.rs:143:13
|
||||
|
|
||||
LL | Some(_) => {}
|
||||
| ^^^^^^^ matches no values because `Void` is uninhabited
|
||||
| ^^^^^^^------
|
||||
| |
|
||||
| matches no values because `Void` is uninhabited
|
||||
| help: remove the match arm
|
||||
|
|
||||
= note: to learn more about uninhabited types, see https://doc.rust-lang.org/nomicon/exotic-sizes.html#empty-types
|
||||
|
||||
@ -217,7 +268,10 @@ error: unreachable pattern
|
||||
--> $DIR/empty-types.rs:199:13
|
||||
|
|
||||
LL | _ => {}
|
||||
| ^ matches no values because `!` is uninhabited
|
||||
| ^------
|
||||
| |
|
||||
| matches no values because `!` is uninhabited
|
||||
| help: remove the match arm
|
||||
|
|
||||
= note: to learn more about uninhabited types, see https://doc.rust-lang.org/nomicon/exotic-sizes.html#empty-types
|
||||
|
||||
@ -225,7 +279,10 @@ error: unreachable pattern
|
||||
--> $DIR/empty-types.rs:204:13
|
||||
|
|
||||
LL | _ => {}
|
||||
| ^ matches no values because `!` is uninhabited
|
||||
| ^------
|
||||
| |
|
||||
| matches no values because `!` is uninhabited
|
||||
| help: remove the match arm
|
||||
|
|
||||
= note: to learn more about uninhabited types, see https://doc.rust-lang.org/nomicon/exotic-sizes.html#empty-types
|
||||
|
||||
@ -233,7 +290,10 @@ error: unreachable pattern
|
||||
--> $DIR/empty-types.rs:209:13
|
||||
|
|
||||
LL | _ => {}
|
||||
| ^ matches no values because `!` is uninhabited
|
||||
| ^------
|
||||
| |
|
||||
| matches no values because `!` is uninhabited
|
||||
| help: remove the match arm
|
||||
|
|
||||
= note: to learn more about uninhabited types, see https://doc.rust-lang.org/nomicon/exotic-sizes.html#empty-types
|
||||
|
||||
@ -241,7 +301,10 @@ error: unreachable pattern
|
||||
--> $DIR/empty-types.rs:214:13
|
||||
|
|
||||
LL | _ => {}
|
||||
| ^ matches no values because `!` is uninhabited
|
||||
| ^------
|
||||
| |
|
||||
| matches no values because `!` is uninhabited
|
||||
| help: remove the match arm
|
||||
|
|
||||
= note: to learn more about uninhabited types, see https://doc.rust-lang.org/nomicon/exotic-sizes.html#empty-types
|
||||
|
||||
@ -249,7 +312,10 @@ error: unreachable pattern
|
||||
--> $DIR/empty-types.rs:220:13
|
||||
|
|
||||
LL | _ => {}
|
||||
| ^ matches no values because `!` is uninhabited
|
||||
| ^------
|
||||
| |
|
||||
| matches no values because `!` is uninhabited
|
||||
| help: remove the match arm
|
||||
|
|
||||
= note: to learn more about uninhabited types, see https://doc.rust-lang.org/nomicon/exotic-sizes.html#empty-types
|
||||
|
||||
@ -257,7 +323,10 @@ error: unreachable pattern
|
||||
--> $DIR/empty-types.rs:281:9
|
||||
|
|
||||
LL | _ => {}
|
||||
| ^ matches no values because `!` is uninhabited
|
||||
| ^------
|
||||
| |
|
||||
| matches no values because `!` is uninhabited
|
||||
| help: remove the match arm
|
||||
|
|
||||
= note: to learn more about uninhabited types, see https://doc.rust-lang.org/nomicon/exotic-sizes.html#empty-types
|
||||
|
||||
@ -265,7 +334,10 @@ error: unreachable pattern
|
||||
--> $DIR/empty-types.rs:284:9
|
||||
|
|
||||
LL | (_, _) => {}
|
||||
| ^^^^^^ matches no values because `(!, !)` is uninhabited
|
||||
| ^^^^^^------
|
||||
| |
|
||||
| matches no values because `(!, !)` is uninhabited
|
||||
| help: remove the match arm
|
||||
|
|
||||
= note: to learn more about uninhabited types, see https://doc.rust-lang.org/nomicon/exotic-sizes.html#empty-types
|
||||
|
||||
@ -273,7 +345,10 @@ error: unreachable pattern
|
||||
--> $DIR/empty-types.rs:287:9
|
||||
|
|
||||
LL | Ok(_) => {}
|
||||
| ^^^^^ matches no values because `Result<!, !>` is uninhabited
|
||||
| ^^^^^------
|
||||
| |
|
||||
| matches no values because `Result<!, !>` is uninhabited
|
||||
| help: remove the match arm
|
||||
|
|
||||
= note: to learn more about uninhabited types, see https://doc.rust-lang.org/nomicon/exotic-sizes.html#empty-types
|
||||
|
||||
@ -281,7 +356,10 @@ error: unreachable pattern
|
||||
--> $DIR/empty-types.rs:288:9
|
||||
|
|
||||
LL | Err(_) => {}
|
||||
| ^^^^^^ matches no values because `Result<!, !>` is uninhabited
|
||||
| ^^^^^^------
|
||||
| |
|
||||
| matches no values because `Result<!, !>` is uninhabited
|
||||
| help: remove the match arm
|
||||
|
|
||||
= note: to learn more about uninhabited types, see https://doc.rust-lang.org/nomicon/exotic-sizes.html#empty-types
|
||||
|
||||
@ -344,7 +422,10 @@ error: unreachable pattern
|
||||
--> $DIR/empty-types.rs:368:9
|
||||
|
|
||||
LL | _ => {}
|
||||
| ^ matches no values because `[!; 3]` is uninhabited
|
||||
| ^------
|
||||
| |
|
||||
| matches no values because `[!; 3]` is uninhabited
|
||||
| help: remove the match arm
|
||||
|
|
||||
= note: to learn more about uninhabited types, see https://doc.rust-lang.org/nomicon/exotic-sizes.html#empty-types
|
||||
|
||||
@ -352,7 +433,10 @@ error: unreachable pattern
|
||||
--> $DIR/empty-types.rs:371:9
|
||||
|
|
||||
LL | [_, _, _] => {}
|
||||
| ^^^^^^^^^ matches no values because `[!; 3]` is uninhabited
|
||||
| ^^^^^^^^^------
|
||||
| |
|
||||
| matches no values because `[!; 3]` is uninhabited
|
||||
| help: remove the match arm
|
||||
|
|
||||
= note: to learn more about uninhabited types, see https://doc.rust-lang.org/nomicon/exotic-sizes.html#empty-types
|
||||
|
||||
@ -360,7 +444,10 @@ error: unreachable pattern
|
||||
--> $DIR/empty-types.rs:374:9
|
||||
|
|
||||
LL | [_, ..] => {}
|
||||
| ^^^^^^^ matches no values because `[!; 3]` is uninhabited
|
||||
| ^^^^^^^------
|
||||
| |
|
||||
| matches no values because `[!; 3]` is uninhabited
|
||||
| help: remove the match arm
|
||||
|
|
||||
= note: to learn more about uninhabited types, see https://doc.rust-lang.org/nomicon/exotic-sizes.html#empty-types
|
||||
|
||||
@ -404,7 +491,10 @@ error: unreachable pattern
|
||||
--> $DIR/empty-types.rs:416:9
|
||||
|
|
||||
LL | Some(_) => {}
|
||||
| ^^^^^^^ matches no values because `!` is uninhabited
|
||||
| ^^^^^^^------
|
||||
| |
|
||||
| matches no values because `!` is uninhabited
|
||||
| help: remove the match arm
|
||||
|
|
||||
= note: to learn more about uninhabited types, see https://doc.rust-lang.org/nomicon/exotic-sizes.html#empty-types
|
||||
|
||||
@ -412,7 +502,10 @@ error: unreachable pattern
|
||||
--> $DIR/empty-types.rs:421:9
|
||||
|
|
||||
LL | Some(_a) => {}
|
||||
| ^^^^^^^^ matches no values because `!` is uninhabited
|
||||
| ^^^^^^^^------
|
||||
| |
|
||||
| matches no values because `!` is uninhabited
|
||||
| help: remove the match arm
|
||||
|
|
||||
= note: to learn more about uninhabited types, see https://doc.rust-lang.org/nomicon/exotic-sizes.html#empty-types
|
||||
|
||||
@ -438,7 +531,10 @@ error: unreachable pattern
|
||||
--> $DIR/empty-types.rs:603:9
|
||||
|
|
||||
LL | _ => {}
|
||||
| ^ matches no values because `!` is uninhabited
|
||||
| ^------
|
||||
| |
|
||||
| matches no values because `!` is uninhabited
|
||||
| help: remove the match arm
|
||||
|
|
||||
= note: to learn more about uninhabited types, see https://doc.rust-lang.org/nomicon/exotic-sizes.html#empty-types
|
||||
|
||||
@ -446,7 +542,10 @@ error: unreachable pattern
|
||||
--> $DIR/empty-types.rs:606:9
|
||||
|
|
||||
LL | _x => {}
|
||||
| ^^ matches no values because `!` is uninhabited
|
||||
| ^^------
|
||||
| |
|
||||
| matches no values because `!` is uninhabited
|
||||
| help: remove the match arm
|
||||
|
|
||||
= note: to learn more about uninhabited types, see https://doc.rust-lang.org/nomicon/exotic-sizes.html#empty-types
|
||||
|
||||
@ -454,7 +553,10 @@ error: unreachable pattern
|
||||
--> $DIR/empty-types.rs:609:9
|
||||
|
|
||||
LL | _ if false => {}
|
||||
| ^ matches no values because `!` is uninhabited
|
||||
| ^---------------
|
||||
| |
|
||||
| matches no values because `!` is uninhabited
|
||||
| help: remove the match arm
|
||||
|
|
||||
= note: to learn more about uninhabited types, see https://doc.rust-lang.org/nomicon/exotic-sizes.html#empty-types
|
||||
|
||||
@ -462,7 +564,10 @@ error: unreachable pattern
|
||||
--> $DIR/empty-types.rs:612:9
|
||||
|
|
||||
LL | _x if false => {}
|
||||
| ^^ matches no values because `!` is uninhabited
|
||||
| ^^---------------
|
||||
| |
|
||||
| matches no values because `!` is uninhabited
|
||||
| help: remove the match arm
|
||||
|
|
||||
= note: to learn more about uninhabited types, see https://doc.rust-lang.org/nomicon/exotic-sizes.html#empty-types
|
||||
|
||||
|
@ -11,7 +11,10 @@ error: unreachable pattern
|
||||
--> $DIR/empty-types.rs:49:9
|
||||
|
|
||||
LL | _ => {}
|
||||
| ^ matches no values because `!` is uninhabited
|
||||
| ^------
|
||||
| |
|
||||
| matches no values because `!` is uninhabited
|
||||
| help: remove the match arm
|
||||
|
|
||||
= note: to learn more about uninhabited types, see https://doc.rust-lang.org/nomicon/exotic-sizes.html#empty-types
|
||||
note: the lint level is defined here
|
||||
@ -24,7 +27,10 @@ error: unreachable pattern
|
||||
--> $DIR/empty-types.rs:52:9
|
||||
|
|
||||
LL | _x => {}
|
||||
| ^^ matches no values because `!` is uninhabited
|
||||
| ^^------
|
||||
| |
|
||||
| matches no values because `!` is uninhabited
|
||||
| help: remove the match arm
|
||||
|
|
||||
= note: to learn more about uninhabited types, see https://doc.rust-lang.org/nomicon/exotic-sizes.html#empty-types
|
||||
|
||||
@ -47,7 +53,10 @@ error: unreachable pattern
|
||||
--> $DIR/empty-types.rs:83:9
|
||||
|
|
||||
LL | _ => {}
|
||||
| ^ matches no values because `!` is uninhabited
|
||||
| ^------
|
||||
| |
|
||||
| matches no values because `!` is uninhabited
|
||||
| help: remove the match arm
|
||||
|
|
||||
= note: to learn more about uninhabited types, see https://doc.rust-lang.org/nomicon/exotic-sizes.html#empty-types
|
||||
|
||||
@ -120,7 +129,10 @@ error: unreachable pattern
|
||||
--> $DIR/empty-types.rs:132:13
|
||||
|
|
||||
LL | _ => {}
|
||||
| ^ matches no values because `Void` is uninhabited
|
||||
| ^------
|
||||
| |
|
||||
| matches no values because `Void` is uninhabited
|
||||
| help: remove the match arm
|
||||
|
|
||||
= note: to learn more about uninhabited types, see https://doc.rust-lang.org/nomicon/exotic-sizes.html#empty-types
|
||||
|
||||
@ -128,7 +140,10 @@ error: unreachable pattern
|
||||
--> $DIR/empty-types.rs:135:13
|
||||
|
|
||||
LL | _ if false => {}
|
||||
| ^ matches no values because `Void` is uninhabited
|
||||
| ^---------------
|
||||
| |
|
||||
| matches no values because `Void` is uninhabited
|
||||
| help: remove the match arm
|
||||
|
|
||||
= note: to learn more about uninhabited types, see https://doc.rust-lang.org/nomicon/exotic-sizes.html#empty-types
|
||||
|
||||
@ -155,7 +170,10 @@ error: unreachable pattern
|
||||
--> $DIR/empty-types.rs:199:13
|
||||
|
|
||||
LL | _ => {}
|
||||
| ^ matches no values because `!` is uninhabited
|
||||
| ^------
|
||||
| |
|
||||
| matches no values because `!` is uninhabited
|
||||
| help: remove the match arm
|
||||
|
|
||||
= note: to learn more about uninhabited types, see https://doc.rust-lang.org/nomicon/exotic-sizes.html#empty-types
|
||||
|
||||
@ -163,7 +181,10 @@ error: unreachable pattern
|
||||
--> $DIR/empty-types.rs:204:13
|
||||
|
|
||||
LL | _ => {}
|
||||
| ^ matches no values because `!` is uninhabited
|
||||
| ^------
|
||||
| |
|
||||
| matches no values because `!` is uninhabited
|
||||
| help: remove the match arm
|
||||
|
|
||||
= note: to learn more about uninhabited types, see https://doc.rust-lang.org/nomicon/exotic-sizes.html#empty-types
|
||||
|
||||
@ -171,7 +192,10 @@ error: unreachable pattern
|
||||
--> $DIR/empty-types.rs:209:13
|
||||
|
|
||||
LL | _ => {}
|
||||
| ^ matches no values because `!` is uninhabited
|
||||
| ^------
|
||||
| |
|
||||
| matches no values because `!` is uninhabited
|
||||
| help: remove the match arm
|
||||
|
|
||||
= note: to learn more about uninhabited types, see https://doc.rust-lang.org/nomicon/exotic-sizes.html#empty-types
|
||||
|
||||
@ -179,7 +203,10 @@ error: unreachable pattern
|
||||
--> $DIR/empty-types.rs:214:13
|
||||
|
|
||||
LL | _ => {}
|
||||
| ^ matches no values because `!` is uninhabited
|
||||
| ^------
|
||||
| |
|
||||
| matches no values because `!` is uninhabited
|
||||
| help: remove the match arm
|
||||
|
|
||||
= note: to learn more about uninhabited types, see https://doc.rust-lang.org/nomicon/exotic-sizes.html#empty-types
|
||||
|
||||
@ -187,7 +214,10 @@ error: unreachable pattern
|
||||
--> $DIR/empty-types.rs:220:13
|
||||
|
|
||||
LL | _ => {}
|
||||
| ^ matches no values because `!` is uninhabited
|
||||
| ^------
|
||||
| |
|
||||
| matches no values because `!` is uninhabited
|
||||
| help: remove the match arm
|
||||
|
|
||||
= note: to learn more about uninhabited types, see https://doc.rust-lang.org/nomicon/exotic-sizes.html#empty-types
|
||||
|
||||
@ -195,7 +225,10 @@ error: unreachable pattern
|
||||
--> $DIR/empty-types.rs:281:9
|
||||
|
|
||||
LL | _ => {}
|
||||
| ^ matches no values because `!` is uninhabited
|
||||
| ^------
|
||||
| |
|
||||
| matches no values because `!` is uninhabited
|
||||
| help: remove the match arm
|
||||
|
|
||||
= note: to learn more about uninhabited types, see https://doc.rust-lang.org/nomicon/exotic-sizes.html#empty-types
|
||||
|
||||
@ -476,7 +509,10 @@ error: unreachable pattern
|
||||
--> $DIR/empty-types.rs:603:9
|
||||
|
|
||||
LL | _ => {}
|
||||
| ^ matches no values because `!` is uninhabited
|
||||
| ^------
|
||||
| |
|
||||
| matches no values because `!` is uninhabited
|
||||
| help: remove the match arm
|
||||
|
|
||||
= note: to learn more about uninhabited types, see https://doc.rust-lang.org/nomicon/exotic-sizes.html#empty-types
|
||||
|
||||
@ -484,7 +520,10 @@ error: unreachable pattern
|
||||
--> $DIR/empty-types.rs:606:9
|
||||
|
|
||||
LL | _x => {}
|
||||
| ^^ matches no values because `!` is uninhabited
|
||||
| ^^------
|
||||
| |
|
||||
| matches no values because `!` is uninhabited
|
||||
| help: remove the match arm
|
||||
|
|
||||
= note: to learn more about uninhabited types, see https://doc.rust-lang.org/nomicon/exotic-sizes.html#empty-types
|
||||
|
||||
@ -492,7 +531,10 @@ error: unreachable pattern
|
||||
--> $DIR/empty-types.rs:609:9
|
||||
|
|
||||
LL | _ if false => {}
|
||||
| ^ matches no values because `!` is uninhabited
|
||||
| ^---------------
|
||||
| |
|
||||
| matches no values because `!` is uninhabited
|
||||
| help: remove the match arm
|
||||
|
|
||||
= note: to learn more about uninhabited types, see https://doc.rust-lang.org/nomicon/exotic-sizes.html#empty-types
|
||||
|
||||
@ -500,7 +542,10 @@ error: unreachable pattern
|
||||
--> $DIR/empty-types.rs:612:9
|
||||
|
|
||||
LL | _x if false => {}
|
||||
| ^^ matches no values because `!` is uninhabited
|
||||
| ^^---------------
|
||||
| |
|
||||
| matches no values because `!` is uninhabited
|
||||
| help: remove the match arm
|
||||
|
|
||||
= note: to learn more about uninhabited types, see https://doc.rust-lang.org/nomicon/exotic-sizes.html#empty-types
|
||||
|
||||
|
@ -2,7 +2,10 @@ error: unreachable pattern
|
||||
--> $DIR/empty-types.rs:49:9
|
||||
|
|
||||
LL | _ => {}
|
||||
| ^ matches no values because `!` is uninhabited
|
||||
| ^------
|
||||
| |
|
||||
| matches no values because `!` is uninhabited
|
||||
| help: remove the match arm
|
||||
|
|
||||
= note: to learn more about uninhabited types, see https://doc.rust-lang.org/nomicon/exotic-sizes.html#empty-types
|
||||
note: the lint level is defined here
|
||||
@ -15,7 +18,10 @@ error: unreachable pattern
|
||||
--> $DIR/empty-types.rs:52:9
|
||||
|
|
||||
LL | _x => {}
|
||||
| ^^ matches no values because `!` is uninhabited
|
||||
| ^^------
|
||||
| |
|
||||
| matches no values because `!` is uninhabited
|
||||
| help: remove the match arm
|
||||
|
|
||||
= note: to learn more about uninhabited types, see https://doc.rust-lang.org/nomicon/exotic-sizes.html#empty-types
|
||||
|
||||
@ -38,7 +44,10 @@ error: unreachable pattern
|
||||
--> $DIR/empty-types.rs:83:9
|
||||
|
|
||||
LL | _ => {}
|
||||
| ^ matches no values because `!` is uninhabited
|
||||
| ^------
|
||||
| |
|
||||
| matches no values because `!` is uninhabited
|
||||
| help: remove the match arm
|
||||
|
|
||||
= note: to learn more about uninhabited types, see https://doc.rust-lang.org/nomicon/exotic-sizes.html#empty-types
|
||||
|
||||
@ -111,7 +120,10 @@ error: unreachable pattern
|
||||
--> $DIR/empty-types.rs:132:13
|
||||
|
|
||||
LL | _ => {}
|
||||
| ^ matches no values because `Void` is uninhabited
|
||||
| ^------
|
||||
| |
|
||||
| matches no values because `Void` is uninhabited
|
||||
| help: remove the match arm
|
||||
|
|
||||
= note: to learn more about uninhabited types, see https://doc.rust-lang.org/nomicon/exotic-sizes.html#empty-types
|
||||
|
||||
@ -119,7 +131,10 @@ error: unreachable pattern
|
||||
--> $DIR/empty-types.rs:135:13
|
||||
|
|
||||
LL | _ if false => {}
|
||||
| ^ matches no values because `Void` is uninhabited
|
||||
| ^---------------
|
||||
| |
|
||||
| matches no values because `Void` is uninhabited
|
||||
| help: remove the match arm
|
||||
|
|
||||
= note: to learn more about uninhabited types, see https://doc.rust-lang.org/nomicon/exotic-sizes.html#empty-types
|
||||
|
||||
@ -146,7 +161,10 @@ error: unreachable pattern
|
||||
--> $DIR/empty-types.rs:199:13
|
||||
|
|
||||
LL | _ => {}
|
||||
| ^ matches no values because `!` is uninhabited
|
||||
| ^------
|
||||
| |
|
||||
| matches no values because `!` is uninhabited
|
||||
| help: remove the match arm
|
||||
|
|
||||
= note: to learn more about uninhabited types, see https://doc.rust-lang.org/nomicon/exotic-sizes.html#empty-types
|
||||
|
||||
@ -154,7 +172,10 @@ error: unreachable pattern
|
||||
--> $DIR/empty-types.rs:204:13
|
||||
|
|
||||
LL | _ => {}
|
||||
| ^ matches no values because `!` is uninhabited
|
||||
| ^------
|
||||
| |
|
||||
| matches no values because `!` is uninhabited
|
||||
| help: remove the match arm
|
||||
|
|
||||
= note: to learn more about uninhabited types, see https://doc.rust-lang.org/nomicon/exotic-sizes.html#empty-types
|
||||
|
||||
@ -162,7 +183,10 @@ error: unreachable pattern
|
||||
--> $DIR/empty-types.rs:209:13
|
||||
|
|
||||
LL | _ => {}
|
||||
| ^ matches no values because `!` is uninhabited
|
||||
| ^------
|
||||
| |
|
||||
| matches no values because `!` is uninhabited
|
||||
| help: remove the match arm
|
||||
|
|
||||
= note: to learn more about uninhabited types, see https://doc.rust-lang.org/nomicon/exotic-sizes.html#empty-types
|
||||
|
||||
@ -170,7 +194,10 @@ error: unreachable pattern
|
||||
--> $DIR/empty-types.rs:214:13
|
||||
|
|
||||
LL | _ => {}
|
||||
| ^ matches no values because `!` is uninhabited
|
||||
| ^------
|
||||
| |
|
||||
| matches no values because `!` is uninhabited
|
||||
| help: remove the match arm
|
||||
|
|
||||
= note: to learn more about uninhabited types, see https://doc.rust-lang.org/nomicon/exotic-sizes.html#empty-types
|
||||
|
||||
@ -178,7 +205,10 @@ error: unreachable pattern
|
||||
--> $DIR/empty-types.rs:220:13
|
||||
|
|
||||
LL | _ => {}
|
||||
| ^ matches no values because `!` is uninhabited
|
||||
| ^------
|
||||
| |
|
||||
| matches no values because `!` is uninhabited
|
||||
| help: remove the match arm
|
||||
|
|
||||
= note: to learn more about uninhabited types, see https://doc.rust-lang.org/nomicon/exotic-sizes.html#empty-types
|
||||
|
||||
@ -186,7 +216,10 @@ error: unreachable pattern
|
||||
--> $DIR/empty-types.rs:281:9
|
||||
|
|
||||
LL | _ => {}
|
||||
| ^ matches no values because `!` is uninhabited
|
||||
| ^------
|
||||
| |
|
||||
| matches no values because `!` is uninhabited
|
||||
| help: remove the match arm
|
||||
|
|
||||
= note: to learn more about uninhabited types, see https://doc.rust-lang.org/nomicon/exotic-sizes.html#empty-types
|
||||
|
||||
@ -467,7 +500,10 @@ error: unreachable pattern
|
||||
--> $DIR/empty-types.rs:603:9
|
||||
|
|
||||
LL | _ => {}
|
||||
| ^ matches no values because `!` is uninhabited
|
||||
| ^------
|
||||
| |
|
||||
| matches no values because `!` is uninhabited
|
||||
| help: remove the match arm
|
||||
|
|
||||
= note: to learn more about uninhabited types, see https://doc.rust-lang.org/nomicon/exotic-sizes.html#empty-types
|
||||
|
||||
@ -475,7 +511,10 @@ error: unreachable pattern
|
||||
--> $DIR/empty-types.rs:606:9
|
||||
|
|
||||
LL | _x => {}
|
||||
| ^^ matches no values because `!` is uninhabited
|
||||
| ^^------
|
||||
| |
|
||||
| matches no values because `!` is uninhabited
|
||||
| help: remove the match arm
|
||||
|
|
||||
= note: to learn more about uninhabited types, see https://doc.rust-lang.org/nomicon/exotic-sizes.html#empty-types
|
||||
|
||||
@ -483,7 +522,10 @@ error: unreachable pattern
|
||||
--> $DIR/empty-types.rs:609:9
|
||||
|
|
||||
LL | _ if false => {}
|
||||
| ^ matches no values because `!` is uninhabited
|
||||
| ^---------------
|
||||
| |
|
||||
| matches no values because `!` is uninhabited
|
||||
| help: remove the match arm
|
||||
|
|
||||
= note: to learn more about uninhabited types, see https://doc.rust-lang.org/nomicon/exotic-sizes.html#empty-types
|
||||
|
||||
@ -491,7 +533,10 @@ error: unreachable pattern
|
||||
--> $DIR/empty-types.rs:612:9
|
||||
|
|
||||
LL | _x if false => {}
|
||||
| ^^ matches no values because `!` is uninhabited
|
||||
| ^^---------------
|
||||
| |
|
||||
| matches no values because `!` is uninhabited
|
||||
| help: remove the match arm
|
||||
|
|
||||
= note: to learn more about uninhabited types, see https://doc.rust-lang.org/nomicon/exotic-sizes.html#empty-types
|
||||
|
||||
|
@ -59,7 +59,10 @@ error: unreachable pattern
|
||||
--> $DIR/explain-unreachable-pats.rs:52:9
|
||||
|
|
||||
LL | Err(_) => {}
|
||||
| ^^^^^^ matches no values because `!` is uninhabited
|
||||
| ^^^^^^------
|
||||
| |
|
||||
| matches no values because `!` is uninhabited
|
||||
| help: remove the match arm
|
||||
|
|
||||
= note: to learn more about uninhabited types, see https://doc.rust-lang.org/nomicon/exotic-sizes.html#empty-types
|
||||
|
||||
@ -67,7 +70,10 @@ error: unreachable pattern
|
||||
--> $DIR/explain-unreachable-pats.rs:66:9
|
||||
|
|
||||
LL | (Err(_), Err(_)) => {}
|
||||
| ^^^^^^^^^^^^^^^^ matches no values because `Void2` is uninhabited
|
||||
| ^^^^^^^^^^^^^^^^------
|
||||
| |
|
||||
| matches no values because `Void2` is uninhabited
|
||||
| help: remove the match arm
|
||||
|
|
||||
= note: to learn more about uninhabited types, see https://doc.rust-lang.org/nomicon/exotic-sizes.html#empty-types
|
||||
|
||||
@ -75,7 +81,10 @@ error: unreachable pattern
|
||||
--> $DIR/explain-unreachable-pats.rs:73:9
|
||||
|
|
||||
LL | (Err(_), Err(_)) => {}
|
||||
| ^^^^^^^^^^^^^^^^ matches no values because `Void1` is uninhabited
|
||||
| ^^^^^^^^^^^^^^^^------
|
||||
| |
|
||||
| matches no values because `Void1` is uninhabited
|
||||
| help: remove the match arm
|
||||
|
|
||||
= note: to learn more about uninhabited types, see https://doc.rust-lang.org/nomicon/exotic-sizes.html#empty-types
|
||||
|
||||
|
@ -2,7 +2,10 @@ error: unreachable pattern
|
||||
--> $DIR/impl-trait.rs:17:13
|
||||
|
|
||||
LL | _ => {}
|
||||
| ^ matches no values because `Void` is uninhabited
|
||||
| ^------
|
||||
| |
|
||||
| matches no values because `Void` is uninhabited
|
||||
| help: remove the match arm
|
||||
|
|
||||
= note: to learn more about uninhabited types, see https://doc.rust-lang.org/nomicon/exotic-sizes.html#empty-types
|
||||
note: the lint level is defined here
|
||||
@ -15,7 +18,10 @@ error: unreachable pattern
|
||||
--> $DIR/impl-trait.rs:31:13
|
||||
|
|
||||
LL | _ => {}
|
||||
| ^ matches no values because `Void` is uninhabited
|
||||
| ^------
|
||||
| |
|
||||
| matches no values because `Void` is uninhabited
|
||||
| help: remove the match arm
|
||||
|
|
||||
= note: to learn more about uninhabited types, see https://doc.rust-lang.org/nomicon/exotic-sizes.html#empty-types
|
||||
|
||||
@ -23,7 +29,10 @@ error: unreachable pattern
|
||||
--> $DIR/impl-trait.rs:45:13
|
||||
|
|
||||
LL | Some(_) => {}
|
||||
| ^^^^^^^ matches no values because `Void` is uninhabited
|
||||
| ^^^^^^^------
|
||||
| |
|
||||
| matches no values because `Void` is uninhabited
|
||||
| help: remove the match arm
|
||||
|
|
||||
= note: to learn more about uninhabited types, see https://doc.rust-lang.org/nomicon/exotic-sizes.html#empty-types
|
||||
|
||||
@ -39,7 +48,10 @@ error: unreachable pattern
|
||||
--> $DIR/impl-trait.rs:59:13
|
||||
|
|
||||
LL | Some(_) => {}
|
||||
| ^^^^^^^ matches no values because `Void` is uninhabited
|
||||
| ^^^^^^^------
|
||||
| |
|
||||
| matches no values because `Void` is uninhabited
|
||||
| help: remove the match arm
|
||||
|
|
||||
= note: to learn more about uninhabited types, see https://doc.rust-lang.org/nomicon/exotic-sizes.html#empty-types
|
||||
|
||||
@ -55,7 +67,10 @@ error: unreachable pattern
|
||||
--> $DIR/impl-trait.rs:76:9
|
||||
|
|
||||
LL | _ => {}
|
||||
| ^ matches no values because `Void` is uninhabited
|
||||
| ^------
|
||||
| |
|
||||
| matches no values because `Void` is uninhabited
|
||||
| help: remove the match arm
|
||||
|
|
||||
= note: to learn more about uninhabited types, see https://doc.rust-lang.org/nomicon/exotic-sizes.html#empty-types
|
||||
|
||||
@ -71,7 +86,10 @@ error: unreachable pattern
|
||||
--> $DIR/impl-trait.rs:94:13
|
||||
|
|
||||
LL | _ => {}
|
||||
| ^ matches no values because `Void` is uninhabited
|
||||
| ^------
|
||||
| |
|
||||
| matches no values because `Void` is uninhabited
|
||||
| help: remove the match arm
|
||||
|
|
||||
= note: to learn more about uninhabited types, see https://doc.rust-lang.org/nomicon/exotic-sizes.html#empty-types
|
||||
|
||||
@ -95,7 +113,10 @@ error: unreachable pattern
|
||||
--> $DIR/impl-trait.rs:138:13
|
||||
|
|
||||
LL | _ => {}
|
||||
| ^ matches no values because `SecretelyVoid` is uninhabited
|
||||
| ^------
|
||||
| |
|
||||
| matches no values because `SecretelyVoid` is uninhabited
|
||||
| help: remove the match arm
|
||||
|
|
||||
= note: to learn more about uninhabited types, see https://doc.rust-lang.org/nomicon/exotic-sizes.html#empty-types
|
||||
|
||||
@ -103,7 +124,10 @@ error: unreachable pattern
|
||||
--> $DIR/impl-trait.rs:151:13
|
||||
|
|
||||
LL | _ => {}
|
||||
| ^ matches no values because `SecretelyDoubleVoid` is uninhabited
|
||||
| ^------
|
||||
| |
|
||||
| matches no values because `SecretelyDoubleVoid` is uninhabited
|
||||
| help: remove the match arm
|
||||
|
|
||||
= note: to learn more about uninhabited types, see https://doc.rust-lang.org/nomicon/exotic-sizes.html#empty-types
|
||||
|
||||
|
@ -0,0 +1,23 @@
|
||||
//@ run-rustfix
|
||||
#![feature(never_patterns)]
|
||||
#![feature(exhaustive_patterns)]
|
||||
#![allow(incomplete_features)]
|
||||
#![deny(unreachable_patterns)]
|
||||
|
||||
enum Void {}
|
||||
|
||||
#[rustfmt::skip]
|
||||
fn main() {
|
||||
let res: Result<(), Void> = Ok(());
|
||||
match res {
|
||||
Ok(_) => {}
|
||||
//~ ERROR unreachable
|
||||
//~ ERROR unreachable
|
||||
}
|
||||
|
||||
match res {
|
||||
Ok(_x) => {}
|
||||
//~ ERROR unreachable
|
||||
//~ ERROR unreachable
|
||||
}
|
||||
}
|
23
tests/ui/pattern/usefulness/rustfix-unreachable-pattern.rs
Normal file
23
tests/ui/pattern/usefulness/rustfix-unreachable-pattern.rs
Normal file
@ -0,0 +1,23 @@
|
||||
//@ run-rustfix
|
||||
#![feature(never_patterns)]
|
||||
#![feature(exhaustive_patterns)]
|
||||
#![allow(incomplete_features)]
|
||||
#![deny(unreachable_patterns)]
|
||||
|
||||
enum Void {}
|
||||
|
||||
#[rustfmt::skip]
|
||||
fn main() {
|
||||
let res: Result<(), Void> = Ok(());
|
||||
match res {
|
||||
Ok(_) => {}
|
||||
Err(_) => {} //~ ERROR unreachable
|
||||
Err(_) => {}, //~ ERROR unreachable
|
||||
}
|
||||
|
||||
match res {
|
||||
Ok(_x) => {}
|
||||
Err(!), //~ ERROR unreachable
|
||||
Err(!) //~ ERROR unreachable
|
||||
}
|
||||
}
|
@ -0,0 +1,51 @@
|
||||
error: unreachable pattern
|
||||
--> $DIR/rustfix-unreachable-pattern.rs:14:9
|
||||
|
|
||||
LL | Err(_) => {}
|
||||
| ^^^^^^------
|
||||
| |
|
||||
| matches no values because `Void` is uninhabited
|
||||
| help: remove the match arm
|
||||
|
|
||||
= note: to learn more about uninhabited types, see https://doc.rust-lang.org/nomicon/exotic-sizes.html#empty-types
|
||||
note: the lint level is defined here
|
||||
--> $DIR/rustfix-unreachable-pattern.rs:5:9
|
||||
|
|
||||
LL | #![deny(unreachable_patterns)]
|
||||
| ^^^^^^^^^^^^^^^^^^^^
|
||||
|
||||
error: unreachable pattern
|
||||
--> $DIR/rustfix-unreachable-pattern.rs:15:9
|
||||
|
|
||||
LL | Err(_) => {},
|
||||
| ^^^^^^-------
|
||||
| |
|
||||
| matches no values because `Void` is uninhabited
|
||||
| help: remove the match arm
|
||||
|
|
||||
= note: to learn more about uninhabited types, see https://doc.rust-lang.org/nomicon/exotic-sizes.html#empty-types
|
||||
|
||||
error: unreachable pattern
|
||||
--> $DIR/rustfix-unreachable-pattern.rs:20:9
|
||||
|
|
||||
LL | Err(!),
|
||||
| ^^^^^^-
|
||||
| |
|
||||
| matches no values because `Void` is uninhabited
|
||||
| help: remove the match arm
|
||||
|
|
||||
= note: to learn more about uninhabited types, see https://doc.rust-lang.org/nomicon/exotic-sizes.html#empty-types
|
||||
|
||||
error: unreachable pattern
|
||||
--> $DIR/rustfix-unreachable-pattern.rs:21:9
|
||||
|
|
||||
LL | Err(!)
|
||||
| ^^^^^^
|
||||
| |
|
||||
| matches no values because `Void` is uninhabited
|
||||
| help: remove the match arm
|
||||
|
|
||||
= note: to learn more about uninhabited types, see https://doc.rust-lang.org/nomicon/exotic-sizes.html#empty-types
|
||||
|
||||
error: aborting due to 4 previous errors
|
||||
|
@ -17,7 +17,10 @@ warning: unreachable pattern
|
||||
--> $DIR/unreachable-try-pattern.rs:19:24
|
||||
|
|
||||
LL | let y = (match x { Ok(n) => Ok(n as u32), Err(e) => Err(e) })?;
|
||||
| ^^^^^ matches no values because `!` is uninhabited
|
||||
| ^^^^^-----------------
|
||||
| |
|
||||
| matches no values because `!` is uninhabited
|
||||
| help: remove the match arm
|
||||
|
|
||||
= note: to learn more about uninhabited types, see https://doc.rust-lang.org/nomicon/exotic-sizes.html#empty-types
|
||||
note: the lint level is defined here
|
||||
@ -30,7 +33,10 @@ warning: unreachable pattern
|
||||
--> $DIR/unreachable-try-pattern.rs:30:40
|
||||
|
|
||||
LL | let y = (match x { Ok(n) => Ok(n), Err(e) => Err(e) })?;
|
||||
| ^^^^^^ matches no values because `Void` is uninhabited
|
||||
| ^^^^^^----------
|
||||
| |
|
||||
| matches no values because `Void` is uninhabited
|
||||
| help: remove the match arm
|
||||
|
|
||||
= note: to learn more about uninhabited types, see https://doc.rust-lang.org/nomicon/exotic-sizes.html#empty-types
|
||||
|
||||
|
@ -2,7 +2,10 @@ error: unreachable pattern
|
||||
--> $DIR/unreachable.rs:15:9
|
||||
|
|
||||
LL | Err(!),
|
||||
| ^^^^^^ matches no values because `Void` is uninhabited
|
||||
| ^^^^^^-
|
||||
| |
|
||||
| matches no values because `Void` is uninhabited
|
||||
| help: remove the match arm
|
||||
|
|
||||
= note: to learn more about uninhabited types, see https://doc.rust-lang.org/nomicon/exotic-sizes.html#empty-types
|
||||
note: the lint level is defined here
|
||||
|
@ -2,7 +2,10 @@ error: unreachable pattern
|
||||
--> $DIR/enum_same_crate_empty_match.rs:28:9
|
||||
|
|
||||
LL | _ => {}
|
||||
| ^ matches no values because `EmptyNonExhaustiveEnum` is uninhabited
|
||||
| ^------
|
||||
| |
|
||||
| matches no values because `EmptyNonExhaustiveEnum` is uninhabited
|
||||
| help: remove the match arm
|
||||
|
|
||||
= note: to learn more about uninhabited types, see https://doc.rust-lang.org/nomicon/exotic-sizes.html#empty-types
|
||||
note: the lint level is defined here
|
||||
|
@ -2,7 +2,10 @@ error: unreachable pattern
|
||||
--> $DIR/patterns.rs:42:9
|
||||
|
|
||||
LL | Some(_x) => (),
|
||||
| ^^^^^^^^ matches no values because `UninhabitedVariants` is uninhabited
|
||||
| ^^^^^^^^-------
|
||||
| |
|
||||
| matches no values because `UninhabitedVariants` is uninhabited
|
||||
| help: remove the match arm
|
||||
|
|
||||
= note: to learn more about uninhabited types, see https://doc.rust-lang.org/nomicon/exotic-sizes.html#empty-types
|
||||
note: the lint level is defined here
|
||||
|
@ -2,7 +2,10 @@ error: unreachable pattern
|
||||
--> $DIR/patterns_same_crate.rs:53:9
|
||||
|
|
||||
LL | Some(_x) => (),
|
||||
| ^^^^^^^^ matches no values because `UninhabitedEnum` is uninhabited
|
||||
| ^^^^^^^^-------
|
||||
| |
|
||||
| matches no values because `UninhabitedEnum` is uninhabited
|
||||
| help: remove the match arm
|
||||
|
|
||||
= note: to learn more about uninhabited types, see https://doc.rust-lang.org/nomicon/exotic-sizes.html#empty-types
|
||||
note: the lint level is defined here
|
||||
@ -15,7 +18,10 @@ error: unreachable pattern
|
||||
--> $DIR/patterns_same_crate.rs:58:9
|
||||
|
|
||||
LL | Some(_x) => (),
|
||||
| ^^^^^^^^ matches no values because `UninhabitedVariants` is uninhabited
|
||||
| ^^^^^^^^-------
|
||||
| |
|
||||
| matches no values because `UninhabitedVariants` is uninhabited
|
||||
| help: remove the match arm
|
||||
|
|
||||
= note: to learn more about uninhabited types, see https://doc.rust-lang.org/nomicon/exotic-sizes.html#empty-types
|
||||
|
||||
|
@ -2,7 +2,10 @@ error: unreachable pattern
|
||||
--> $DIR/uninhabited-patterns.rs:30:9
|
||||
|
|
||||
LL | Ok(box _) => (),
|
||||
| ^^^^^^^^^ matches no values because `NotSoSecretlyEmpty` is uninhabited
|
||||
| ^^^^^^^^^-------
|
||||
| |
|
||||
| matches no values because `NotSoSecretlyEmpty` is uninhabited
|
||||
| help: remove the match arm
|
||||
|
|
||||
= note: to learn more about uninhabited types, see https://doc.rust-lang.org/nomicon/exotic-sizes.html#empty-types
|
||||
note: the lint level is defined here
|
||||
@ -15,7 +18,10 @@ error: unreachable pattern
|
||||
--> $DIR/uninhabited-patterns.rs:39:9
|
||||
|
|
||||
LL | Err(Ok(_y)) => (),
|
||||
| ^^^^^^^^^^^ matches no values because `NotSoSecretlyEmpty` is uninhabited
|
||||
| ^^^^^^^^^^^-------
|
||||
| |
|
||||
| matches no values because `NotSoSecretlyEmpty` is uninhabited
|
||||
| help: remove the match arm
|
||||
|
|
||||
= note: to learn more about uninhabited types, see https://doc.rust-lang.org/nomicon/exotic-sizes.html#empty-types
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user