Rollup merge of #64592 - Aaron1011:feature/unreachable-span, r=Centril

Point at original span when emitting unreachable lint

Fixes #64590

When we emit an 'unreachable' lint, we now add a note pointing at the
expression that actually causes the code to be unreachable (e.g.
`return`, `break`, `panic`).

This is especially useful when macros are involved, since a diverging
expression might be hidden inside of a macro invocation.
This commit is contained in:
Mazdak Farrokhzad 2019-09-19 18:31:39 +02:00 committed by GitHub
commit 3c286826aa
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
37 changed files with 372 additions and 14 deletions

View file

@ -43,7 +43,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
// If there are no arms, that is a diverging match; a special case.
if arms.is_empty() {
self.diverges.set(self.diverges.get() | Diverges::Always);
self.diverges.set(self.diverges.get() | Diverges::always(expr.span));
return tcx.types.never;
}
@ -69,7 +69,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
// warnings).
match all_pats_diverge {
Diverges::Maybe => Diverges::Maybe,
Diverges::Always | Diverges::WarnedAlways => Diverges::WarnedAlways,
Diverges::Always { .. } | Diverges::WarnedAlways => Diverges::WarnedAlways,
}
}).collect();
@ -167,6 +167,21 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
prior_arm_ty = Some(arm_ty);
}
// If all of the arms in the `match` diverge,
// and we're dealing with an actual `match` block
// (as opposed to a `match` desugared from something else'),
// we can emit a better note. Rather than pointing
// at a diverging expression in an arbitrary arm,
// we can point at the entire `match` expression
if let (Diverges::Always { .. }, hir::MatchSource::Normal) = (all_arms_diverge, match_src) {
all_arms_diverge = Diverges::Always {
span: expr.span,
custom_note: Some(
"any code following this `match` expression is unreachable, as all arms diverge"
)
};
}
// We won't diverge unless the discriminant or all arms diverge.
self.diverges.set(discrim_diverges | all_arms_diverge);
@ -176,7 +191,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
/// When the previously checked expression (the scrutinee) diverges,
/// warn the user about the match arms being unreachable.
fn warn_arms_when_scrutinee_diverges(&self, arms: &'tcx [hir::Arm], source: hir::MatchSource) {
if self.diverges.get().always() {
if self.diverges.get().is_always() {
use hir::MatchSource::*;
let msg = match source {
IfDesugar { .. } | IfLetDesugar { .. } => "block in `if` expression",

View file

@ -170,7 +170,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
// Any expression that produces a value of type `!` must have diverged
if ty.is_never() {
self.diverges.set(self.diverges.get() | Diverges::Always);
self.diverges.set(self.diverges.get() | Diverges::always(expr.span));
}
// Record the type, which applies it effects.

View file

@ -450,7 +450,20 @@ pub enum Diverges {
/// Definitely known to diverge and therefore
/// not reach the next sibling or its parent.
Always,
Always {
/// The `Span` points to the expression
/// that caused us to diverge
/// (e.g. `return`, `break`, etc).
span: Span,
/// In some cases (e.g. a `match` expression
/// where all arms diverge), we may be
/// able to provide a more informative
/// message to the user.
/// If this is `None`, a default messsage
/// will be generated, which is suitable
/// for most cases.
custom_note: Option<&'static str>
},
/// Same as `Always` but with a reachability
/// warning already emitted.
@ -486,8 +499,22 @@ impl ops::BitOrAssign for Diverges {
}
impl Diverges {
fn always(self) -> bool {
self >= Diverges::Always
/// Creates a `Diverges::Always` with the provided `span` and the default note message.
fn always(span: Span) -> Diverges {
Diverges::Always {
span,
custom_note: None
}
}
fn is_always(self) -> bool {
// Enum comparison ignores the
// contents of fields, so we just
// fill them in with garbage here.
self >= Diverges::Always {
span: DUMMY_SP,
custom_note: None
}
}
}
@ -2307,17 +2334,25 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
/// Produces warning on the given node, if the current point in the
/// function is unreachable, and there hasn't been another warning.
fn warn_if_unreachable(&self, id: hir::HirId, span: Span, kind: &str) {
if self.diverges.get() == Diverges::Always &&
// FIXME: Combine these two 'if' expressions into one once
// let chains are implemented
if let Diverges::Always { span: orig_span, custom_note } = self.diverges.get() {
// If span arose from a desugaring of `if` or `while`, then it is the condition itself,
// which diverges, that we are about to lint on. This gives suboptimal diagnostics.
// Instead, stop here so that the `if`- or `while`-expression's block is linted instead.
!span.is_desugaring(DesugaringKind::CondTemporary) {
self.diverges.set(Diverges::WarnedAlways);
if !span.is_desugaring(DesugaringKind::CondTemporary) {
self.diverges.set(Diverges::WarnedAlways);
debug!("warn_if_unreachable: id={:?} span={:?} kind={}", id, span, kind);
debug!("warn_if_unreachable: id={:?} span={:?} kind={}", id, span, kind);
let msg = format!("unreachable {}", kind);
self.tcx().lint_hir(lint::builtin::UNREACHABLE_CODE, id, span, &msg);
let msg = format!("unreachable {}", kind);
self.tcx().struct_span_lint_hir(lint::builtin::UNREACHABLE_CODE, id, span, &msg)
.span_note(
orig_span,
custom_note.unwrap_or("any code following this expression is unreachable")
)
.emit();
}
}
}
@ -3825,7 +3860,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
//
// #41425 -- label the implicit `()` as being the
// "found type" here, rather than the "expected type".
if !self.diverges.get().always() {
if !self.diverges.get().is_always() {
// #50009 -- Do not point at the entire fn block span, point at the return type
// span, as it is the cause of the requirement, and
// `consider_hint_about_removing_semicolon` will point at the last expression

View file

@ -9,6 +9,11 @@ note: lint level defined here
|
LL | #![deny(unreachable_code)]
| ^^^^^^^^^^^^^^^^
note: any code following this expression is unreachable
--> $DIR/dead-code-ret.rs:6:5
|
LL | return;
| ^^^^^^
= note: this error originates in a macro outside of the current crate (in Nightly builds, run with -Z external-macro-backtrace for more info)
error: aborting due to previous error

View file

@ -5,4 +5,9 @@ LL | fn foo() { if (return) { } }
| ^^^
|
= note: `#[warn(unreachable_code)]` on by default
note: any code following this expression is unreachable
--> $DIR/if-ret.rs:6:15
|
LL | fn foo() { if (return) { } }
| ^^^^^^^^

View file

@ -9,6 +9,12 @@ note: lint level defined here
|
LL | #![deny(unreachable_code)]
| ^^^^^^^^^^^^^^^^
note: any code following this expression is unreachable
--> $DIR/issue-2150.rs:7:5
|
LL | panic!();
| ^^^^^^^^^
= note: this error originates in a macro outside of the current crate (in Nightly builds, run with -Z external-macro-backtrace for more info)
error: aborting due to previous error

View file

@ -9,6 +9,11 @@ note: lint level defined here
|
LL | #![deny(unreachable_code)]
| ^^^^^^^^^^^^^^^^
note: any code following this expression is unreachable
--> $DIR/issue-7246.rs:6:5
|
LL | return;
| ^^^^^^
error: aborting due to previous error

View file

@ -9,6 +9,11 @@ note: lint level defined here
|
LL | #[deny(unreachable_code)]
| ^^^^^^^^^^^^^^^^
note: any code following this expression is unreachable
--> $DIR/lint-attr-non-item-node.rs:6:9
|
LL | break;
| ^^^^^
error: aborting due to previous error

View file

@ -10,6 +10,11 @@ note: lint level defined here
LL | #![warn(unused)]
| ^^^^^^
= note: `#[warn(unreachable_code)]` implied by `#[warn(unused)]`
note: any code following this expression is unreachable
--> $DIR/liveness-unused.rs:91:9
|
LL | continue;
| ^^^^^^^^
error: unused variable: `x`
--> $DIR/liveness-unused.rs:8:7

View file

@ -9,6 +9,11 @@ note: lint level defined here
|
LL | #![deny(unreachable_code)]
| ^^^^^^^^^^^^^^^^
note: any code following this expression is unreachable
--> $DIR/match-no-arms-unreachable-after.rs:7:5
|
LL | match v { }
| ^^^^^^^^^^^
error: aborting due to previous error

View file

@ -10,12 +10,24 @@ note: lint level defined here
LL | #![warn(unused)]
| ^^^^^^
= note: `#[warn(unreachable_code)]` implied by `#[warn(unused)]`
note: any code following this expression is unreachable
--> $DIR/never-assign-dead-code.rs:9:16
|
LL | let x: ! = panic!("aah");
| ^^^^^^^^^^^^^
= note: this warning originates in a macro outside of the current crate (in Nightly builds, run with -Z external-macro-backtrace for more info)
warning: unreachable call
--> $DIR/never-assign-dead-code.rs:10:5
|
LL | drop(x);
| ^^^^
|
note: any code following this expression is unreachable
--> $DIR/never-assign-dead-code.rs:10:10
|
LL | drop(x);
| ^
warning: unused variable: `x`
--> $DIR/never-assign-dead-code.rs:9:9

View file

@ -9,6 +9,11 @@ note: lint level defined here
|
LL | #![deny(unreachable_code)]
| ^^^^^^^^^^^^^^^^
note: any code following this expression is unreachable
--> $DIR/expr_add.rs:17:19
|
LL | let x = Foo + return;
| ^^^^^^
error: aborting due to previous error

View file

@ -9,6 +9,11 @@ note: lint level defined here
|
LL | #![deny(unreachable_code)]
| ^^^^^^^^^^^^^^^^
note: any code following this expression is unreachable
--> $DIR/expr_again.rs:7:9
|
LL | continue;
| ^^^^^^^^
= note: this error originates in a macro outside of the current crate (in Nightly builds, run with -Z external-macro-backtrace for more info)
error: aborting due to previous error

View file

@ -9,12 +9,23 @@ note: lint level defined here
|
LL | #![deny(unreachable_code)]
| ^^^^^^^^^^^^^^^^
note: any code following this expression is unreachable
--> $DIR/expr_array.rs:9:26
|
LL | let x: [usize; 2] = [return, 22];
| ^^^^^^
error: unreachable expression
--> $DIR/expr_array.rs:14:25
|
LL | let x: [usize; 2] = [22, return];
| ^^^^^^^^^^^^
|
note: any code following this expression is unreachable
--> $DIR/expr_array.rs:14:30
|
LL | let x: [usize; 2] = [22, return];
| ^^^^^^
error: aborting due to 2 previous errors

View file

@ -9,18 +9,35 @@ note: lint level defined here
|
LL | #![deny(unreachable_code)]
| ^^^^^^^^^^^^^^^^
note: any code following this expression is unreachable
--> $DIR/expr_assign.rs:10:9
|
LL | x = return;
| ^^^^^^
error: unreachable expression
--> $DIR/expr_assign.rs:20:14
|
LL | *p = return;
| ^^^^^^
|
note: any code following this expression is unreachable
--> $DIR/expr_assign.rs:20:9
|
LL | *p = return;
| ^^
error: unreachable expression
--> $DIR/expr_assign.rs:26:15
|
LL | *{return; &mut i} = 22;
| ^^^^^^
|
note: any code following this expression is unreachable
--> $DIR/expr_assign.rs:26:7
|
LL | *{return; &mut i} = 22;
| ^^^^^^
error: aborting due to 3 previous errors

View file

@ -9,6 +9,11 @@ note: lint level defined here
|
LL | #![deny(unreachable_code)]
| ^^^^^^^^^^^^^^^^
note: any code following this expression is unreachable
--> $DIR/expr_block.rs:9:9
|
LL | return;
| ^^^^^^
error: unreachable statement
--> $DIR/expr_block.rs:25:9
@ -16,6 +21,11 @@ error: unreachable statement
LL | println!("foo");
| ^^^^^^^^^^^^^^^^
|
note: any code following this expression is unreachable
--> $DIR/expr_block.rs:24:9
|
LL | return;
| ^^^^^^
= note: this error originates in a macro outside of the current crate (in Nightly builds, run with -Z external-macro-backtrace for more info)
error: aborting due to 2 previous errors

View file

@ -9,6 +9,11 @@ note: lint level defined here
|
LL | #![deny(unreachable_code)]
| ^^^^^^^^^^^^^^^^
note: any code following this expression is unreachable
--> $DIR/expr_box.rs:6:17
|
LL | let x = box return;
| ^^^^^^
error: aborting due to previous error

View file

@ -9,12 +9,23 @@ note: lint level defined here
|
LL | #![deny(unreachable_code)]
| ^^^^^^^^^^^^^^^^
note: any code following this expression is unreachable
--> $DIR/expr_call.rs:13:9
|
LL | foo(return, 22);
| ^^^^^^
error: unreachable call
--> $DIR/expr_call.rs:18:5
|
LL | bar(return);
| ^^^
|
note: any code following this expression is unreachable
--> $DIR/expr_call.rs:18:9
|
LL | bar(return);
| ^^^^^^
error: aborting due to 2 previous errors

View file

@ -9,6 +9,11 @@ note: lint level defined here
|
LL | #![deny(unreachable_code)]
| ^^^^^^^^^^^^^^^^
note: any code following this expression is unreachable
--> $DIR/expr_cast.rs:9:14
|
LL | let x = {return} as !;
| ^^^^^^
error: aborting due to previous error

View file

@ -12,6 +12,11 @@ note: lint level defined here
|
LL | #![deny(unreachable_code)]
| ^^^^^^^^^^^^^^^^
note: any code following this expression is unreachable
--> $DIR/expr_if.rs:7:9
|
LL | if {return} {
| ^^^^^^
error: unreachable statement
--> $DIR/expr_if.rs:27:5
@ -19,6 +24,11 @@ error: unreachable statement
LL | println!("But I am.");
| ^^^^^^^^^^^^^^^^^^^^^^
|
note: any code following this expression is unreachable
--> $DIR/expr_if.rs:21:9
|
LL | return;
| ^^^^^^
= note: this error originates in a macro outside of the current crate (in Nightly builds, run with -Z external-macro-backtrace for more info)
error: aborting due to 2 previous errors

View file

@ -9,6 +9,11 @@ note: lint level defined here
|
LL | #![deny(unreachable_code)]
| ^^^^^^^^^^^^^^^^
note: any code following this expression is unreachable
--> $DIR/expr_loop.rs:7:12
|
LL | loop { return; }
| ^^^^^^
= note: this error originates in a macro outside of the current crate (in Nightly builds, run with -Z external-macro-backtrace for more info)
error: unreachable statement
@ -17,6 +22,11 @@ error: unreachable statement
LL | println!("I am dead.");
| ^^^^^^^^^^^^^^^^^^^^^^^
|
note: any code following this expression is unreachable
--> $DIR/expr_loop.rs:20:12
|
LL | loop { return; }
| ^^^^^^
= note: this error originates in a macro outside of the current crate (in Nightly builds, run with -Z external-macro-backtrace for more info)
error: unreachable statement
@ -25,6 +35,11 @@ error: unreachable statement
LL | println!("I am dead.");
| ^^^^^^^^^^^^^^^^^^^^^^^
|
note: any code following this expression is unreachable
--> $DIR/expr_loop.rs:31:5
|
LL | loop { 'middle: loop { loop { break 'middle; } } }
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
= note: this error originates in a macro outside of the current crate (in Nightly builds, run with -Z external-macro-backtrace for more info)
error: aborting due to 3 previous errors

View file

@ -9,6 +9,11 @@ note: lint level defined here
|
LL | #![deny(unreachable_code)]
| ^^^^^^^^^^^^^^^^
note: any code following this `match` expression is unreachable, as all arms diverge
--> $DIR/expr_match.rs:7:5
|
LL | match () { () => return }
| ^^^^^^^^^^^^^^^^^^^^^^^^^
= note: this error originates in a macro outside of the current crate (in Nightly builds, run with -Z external-macro-backtrace for more info)
error: unreachable statement
@ -17,6 +22,11 @@ error: unreachable statement
LL | println!("I am dead");
| ^^^^^^^^^^^^^^^^^^^^^^
|
note: any code following this `match` expression is unreachable, as all arms diverge
--> $DIR/expr_match.rs:18:5
|
LL | match () { () if false => return, () => return }
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
= note: this error originates in a macro outside of the current crate (in Nightly builds, run with -Z external-macro-backtrace for more info)
error: aborting due to 2 previous errors

View file

@ -9,12 +9,23 @@ note: lint level defined here
|
LL | #![deny(unreachable_code)]
| ^^^^^^^^^^^^^^^^
note: any code following this expression is unreachable
--> $DIR/expr_method.rs:16:13
|
LL | Foo.foo(return, 22);
| ^^^^^^
error: unreachable call
--> $DIR/expr_method.rs:21:9
|
LL | Foo.bar(return);
| ^^^
|
note: any code following this expression is unreachable
--> $DIR/expr_method.rs:21:13
|
LL | Foo.bar(return);
| ^^^^^^
error: aborting due to 2 previous errors

View file

@ -9,6 +9,11 @@ note: lint level defined here
|
LL | #![deny(unreachable_code)]
| ^^^^^^^^^^^^^^^^
note: any code following this expression is unreachable
--> $DIR/expr_repeat.rs:9:26
|
LL | let x: [usize; 2] = [return; 2];
| ^^^^^^
error: aborting due to previous error

View file

@ -9,6 +9,11 @@ note: lint level defined here
|
LL | #![deny(unreachable_code)]
| ^^^^^^^^^^^^^^^^
note: any code following this expression is unreachable
--> $DIR/expr_return.rs:10:30
|
LL | let x = {return {return {return;}}};
| ^^^^^^
error: aborting due to previous error

View file

@ -0,0 +1,15 @@
// Tests that we generate nice error messages
// when an expression is unreachble due to control
// flow inside of a macro expansion.
#![deny(unreachable_code)]
macro_rules! early_return {
() => {
return ()
}
}
fn main() {
return early_return!();
//~^ ERROR unreachable expression
}

View file

@ -0,0 +1,22 @@
error: unreachable expression
--> $DIR/expr_return_in_macro.rs:13:5
|
LL | return early_return!();
| ^^^^^^^^^^^^^^^^^^^^^^
|
note: lint level defined here
--> $DIR/expr_return_in_macro.rs:4:9
|
LL | #![deny(unreachable_code)]
| ^^^^^^^^^^^^^^^^
note: any code following this expression is unreachable
--> $DIR/expr_return_in_macro.rs:8:9
|
LL | return ()
| ^^^^^^^^^
...
LL | return early_return!();
| --------------- in this macro invocation
error: aborting due to previous error

View file

@ -9,24 +9,47 @@ note: lint level defined here
|
LL | #![deny(unreachable_code)]
| ^^^^^^^^^^^^^^^^
note: any code following this expression is unreachable
--> $DIR/expr_struct.rs:14:35
|
LL | let x = Foo { a: 22, b: 33, ..return };
| ^^^^^^
error: unreachable expression
--> $DIR/expr_struct.rs:19:33
|
LL | let x = Foo { a: return, b: 33, ..return };
| ^^
|
note: any code following this expression is unreachable
--> $DIR/expr_struct.rs:19:22
|
LL | let x = Foo { a: return, b: 33, ..return };
| ^^^^^^
error: unreachable expression
--> $DIR/expr_struct.rs:24:39
|
LL | let x = Foo { a: 22, b: return, ..return };
| ^^^^^^
|
note: any code following this expression is unreachable
--> $DIR/expr_struct.rs:24:29
|
LL | let x = Foo { a: 22, b: return, ..return };
| ^^^^^^
error: unreachable expression
--> $DIR/expr_struct.rs:29:13
|
LL | let x = Foo { a: 22, b: return };
| ^^^^^^^^^^^^^^^^^^^^^^^^
|
note: any code following this expression is unreachable
--> $DIR/expr_struct.rs:29:29
|
LL | let x = Foo { a: 22, b: return };
| ^^^^^^
error: aborting due to 4 previous errors

View file

@ -9,12 +9,23 @@ note: lint level defined here
|
LL | #![deny(unreachable_code)]
| ^^^^^^^^^^^^^^^^
note: any code following this expression is unreachable
--> $DIR/expr_tup.rs:9:30
|
LL | let x: (usize, usize) = (return, 2);
| ^^^^^^
error: unreachable expression
--> $DIR/expr_tup.rs:14:29
|
LL | let x: (usize, usize) = (2, return);
| ^^^^^^^^^^^
|
note: any code following this expression is unreachable
--> $DIR/expr_tup.rs:14:33
|
LL | let x: (usize, usize) = (2, return);
| ^^^^^^
error: aborting due to 2 previous errors

View file

@ -9,6 +9,11 @@ note: lint level defined here
|
LL | #![deny(unreachable_code)]
| ^^^^^^^^^^^^^^^^
note: any code following this expression is unreachable
--> $DIR/expr_type.rs:9:14
|
LL | let x = {return}: !;
| ^^^^^^
error: aborting due to previous error

View file

@ -15,6 +15,11 @@ note: lint level defined here
|
LL | #![deny(unreachable_code)]
| ^^^^^^^^^^^^^^^^
note: any code following this expression is unreachable
--> $DIR/expr_unary.rs:8:20
|
LL | let x: ! = ! { return; };
| ^^^^^^
error: aborting due to 2 previous errors

View file

@ -13,6 +13,11 @@ note: lint level defined here
|
LL | #![deny(unreachable_code)]
| ^^^^^^^^^^^^^^^^
note: any code following this expression is unreachable
--> $DIR/expr_while.rs:7:12
|
LL | while {return} {
| ^^^^^^
error: unreachable block in `while` expression
--> $DIR/expr_while.rs:22:20
@ -23,6 +28,12 @@ LL | |
LL | | println!("I am dead.");
LL | | }
| |_____^
|
note: any code following this expression is unreachable
--> $DIR/expr_while.rs:22:12
|
LL | while {return} {
| ^^^^^^
error: aborting due to 2 previous errors

View file

@ -5,4 +5,9 @@ LL | if let _ = return true && false {};
| ^^
|
= note: `#[warn(unreachable_code)]` on by default
note: any code following this expression is unreachable
--> $DIR/protect-precedences.rs:13:20
|
LL | if let _ = return true && false {};
| ^^^^^^^^^^^^^^^^^^^^

View file

@ -9,6 +9,11 @@ note: lint level defined here
|
LL | #![deny(unreachable_code)]
| ^^^^^^^^^^^^^^^^
note: any code following this expression is unreachable
--> $DIR/unreachable-code.rs:5:3
|
LL | loop{}
| ^^^^^^
error: aborting due to previous error

View file

@ -9,12 +9,23 @@ note: lint level defined here
|
LL | #![deny(unreachable_code)]
| ^^^^^^^^^^^^^^^^
note: any code following this expression is unreachable
--> $DIR/unreachable-in-call.rs:13:10
|
LL | call(diverge(),
| ^^^^^^^^^
error: unreachable call
--> $DIR/unreachable-in-call.rs:17:5
|
LL | call(
| ^^^^
|
note: any code following this expression is unreachable
--> $DIR/unreachable-in-call.rs:19:9
|
LL | diverge());
| ^^^^^^^^^
error: aborting due to 2 previous errors

View file

@ -9,6 +9,11 @@ note: lint level defined here
|
LL | #![warn(unreachable_code)]
| ^^^^^^^^^^^^^^^^
note: any code following this expression is unreachable
--> $DIR/unreachable-try-pattern.rs:19:36
|
LL | let y = (match x { Ok(n) => Ok(n as u32), Err(e) => Err(e) })?;
| ^
warning: unreachable pattern
--> $DIR/unreachable-try-pattern.rs:19:24

View file

@ -9,12 +9,23 @@ note: lint level defined here
|
LL | #![deny(unreachable_code)]
| ^^^^^^^^^^^^^^^^
note: any code following this expression is unreachable
--> $DIR/unwarned-match-on-never.rs:8:11
|
LL | match x {}
| ^
error: unreachable arm
--> $DIR/unwarned-match-on-never.rs:15:15
|
LL | () => ()
| ^^
|
note: any code following this expression is unreachable
--> $DIR/unwarned-match-on-never.rs:14:11
|
LL | match (return) {
| ^^^^^^^^
error: unreachable expression
--> $DIR/unwarned-match-on-never.rs:21:5
@ -23,6 +34,12 @@ LL | / match () {
LL | | () => (),
LL | | }
| |_____^
|
note: any code following this expression is unreachable
--> $DIR/unwarned-match-on-never.rs:20:5
|
LL | return;
| ^^^^^^
error: aborting due to 3 previous errors