Skip to content

Commit

Permalink
Unignore closure-bang.
Browse files Browse the repository at this point in the history
This test was ignored long ago in
#20578 when the syntax for
closures was changed.

The current status is that a closure with an explicit `!` return type
will trigger the `unreachable_code` lint which appears to be the
original intent of the test
(#16836). A closure without a
return type won't trigger the lint since the `!` type isn't inferred
(AFAIK). This restores the test to its original form.
  • Loading branch information
ehuss committed Apr 15, 2023
1 parent fd57c6b commit d7ed5a5
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 3 deletions.
4 changes: 1 addition & 3 deletions tests/ui/lint/dead-code/closure-bang.rs
Original file line number Diff line number Diff line change
@@ -1,9 +1,7 @@
// ignore-test FIXME(#20574)

#![deny(unreachable_code)]

fn main() {
let x = || panic!();
let x = || -> ! { panic!() };
x();
println!("Foo bar"); //~ ERROR: unreachable statement
}
17 changes: 17 additions & 0 deletions tests/ui/lint/dead-code/closure-bang.stderr
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
error: unreachable statement
--> $DIR/closure-bang.rs:6:5
|
LL | x();
| --- any code following this expression is unreachable
LL | println!("Foo bar");
| ^^^^^^^^^^^^^^^^^^^ unreachable statement
|
note: the lint level is defined here
--> $DIR/closure-bang.rs:1:9
|
LL | #![deny(unreachable_code)]
| ^^^^^^^^^^^^^^^^
= note: this error originates in the macro `println` (in Nightly builds, run with -Z macro-backtrace for more info)

error: aborting due to previous error

0 comments on commit d7ed5a5

Please sign in to comment.