From 64d98f8ee037282c35007b64c2649055c56af1db Mon Sep 17 00:00:00 2001 From: Daniel Baumann Date: Wed, 17 Apr 2024 14:19:03 +0200 Subject: Merging upstream version 1.68.2+dfsg1. Signed-off-by: Daniel Baumann --- tests/ui/reachable/expr_if.rs | 31 +++++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) create mode 100644 tests/ui/reachable/expr_if.rs (limited to 'tests/ui/reachable/expr_if.rs') diff --git a/tests/ui/reachable/expr_if.rs b/tests/ui/reachable/expr_if.rs new file mode 100644 index 000000000..3c04eaf48 --- /dev/null +++ b/tests/ui/reachable/expr_if.rs @@ -0,0 +1,31 @@ +#![allow(unused_variables)] +#![allow(unused_assignments)] +#![allow(dead_code)] +#![deny(unreachable_code)] + +fn foo() { + if {return} { //~ ERROR unreachable block in `if` + println!("Hello, world!"); + } +} + +fn bar() { + if {true} { + return; + } + println!("I am not dead."); +} + +fn baz() { + if {true} { + return; + } else { + return; + } + // As the next action to be taken after the if arms, we should + // report the `println!` as unreachable: + println!("But I am."); + //~^ ERROR unreachable statement +} + +fn main() { } -- cgit v1.2.3