--- /dev/null
+// run-pass
+
+pub fn main() {
+ let i: isize = if false { panic!() } else { 5 };
+ println!("{}", i);
+}
--- /dev/null
+// run-pass
+
+fn even(x: usize) -> bool {
+ if x < 2 {
+ return false;
+ } else if x == 2 { return true; } else { return even(x - 2); }
+}
+
+fn foo(x: usize) {
+ if even(x) {
+ println!("{}", x);
+ } else {
+ panic!();
+ }
+}
+
+pub fn main() { foo(2); }
--- /dev/null
+fn main() {
+ let _ = if true {
+ 1i32
+ } else {
+ 2u32
+ };
+ //~^^ ERROR `if` and `else` have incompatible types
+ let _ = if true { 42i32 } else { 42u32 };
+ //~^ ERROR `if` and `else` have incompatible types
+ let _ = if true {
+ 3u32;
+ } else {
+ 4u32
+ };
+ //~^^ ERROR `if` and `else` have incompatible types
+ let _ = if true {
+ 5u32
+ } else {
+ 6u32;
+ };
+ //~^^ ERROR `if` and `else` have incompatible types
+ let _ = if true {
+ 7i32;
+ } else {
+ 8u32
+ };
+ //~^^ ERROR `if` and `else` have incompatible types
+ let _ = if true {
+ 9i32
+ } else {
+ 10u32;
+ };
+ //~^^ ERROR `if` and `else` have incompatible types
+ let _ = if true {
+
+ } else {
+ 11u32
+ };
+ //~^^ ERROR `if` and `else` have incompatible types
+ let _ = if true {
+ 12i32
+ } else {
+
+ };
+ //~^^^ ERROR `if` and `else` have incompatible types
+}
--- /dev/null
+error[E0308]: `if` and `else` have incompatible types
+ --> $DIR/if-else-type-mismatch.rs:5:9
+ |
+LL | let _ = if true {
+ | _____________-
+LL | | 1i32
+ | | ---- expected because of this
+LL | | } else {
+LL | | 2u32
+ | | ^^^^ expected `i32`, found `u32`
+LL | | };
+ | |_____- `if` and `else` have incompatible types
+
+error[E0308]: `if` and `else` have incompatible types
+ --> $DIR/if-else-type-mismatch.rs:8:38
+ |
+LL | let _ = if true { 42i32 } else { 42u32 };
+ | ----- ^^^^^ expected `i32`, found `u32`
+ | |
+ | expected because of this
+
+error[E0308]: `if` and `else` have incompatible types
+ --> $DIR/if-else-type-mismatch.rs:13:9
+ |
+LL | let _ = if true {
+ | _____________-
+LL | | 3u32;
+ | | -----
+ | | | |
+ | | | help: consider removing this semicolon
+ | | expected because of this
+LL | | } else {
+LL | | 4u32
+ | | ^^^^ expected `()`, found `u32`
+LL | | };
+ | |_____- `if` and `else` have incompatible types
+
+error[E0308]: `if` and `else` have incompatible types
+ --> $DIR/if-else-type-mismatch.rs:19:9
+ |
+LL | let _ = if true {
+ | _____________-
+LL | | 5u32
+ | | ---- expected because of this
+LL | | } else {
+LL | | 6u32;
+ | | ^^^^-
+ | | | |
+ | | | help: consider removing this semicolon
+ | | expected `u32`, found `()`
+LL | | };
+ | |_____- `if` and `else` have incompatible types
+
+error[E0308]: `if` and `else` have incompatible types
+ --> $DIR/if-else-type-mismatch.rs:25:9
+ |
+LL | let _ = if true {
+ | _____________-
+LL | | 7i32;
+ | | ----- expected because of this
+LL | | } else {
+LL | | 8u32
+ | | ^^^^ expected `()`, found `u32`
+LL | | };
+ | |_____- `if` and `else` have incompatible types
+
+error[E0308]: `if` and `else` have incompatible types
+ --> $DIR/if-else-type-mismatch.rs:31:9
+ |
+LL | let _ = if true {
+ | _____________-
+LL | | 9i32
+ | | ---- expected because of this
+LL | | } else {
+LL | | 10u32;
+ | | ^^^^^^ expected `i32`, found `()`
+LL | | };
+ | |_____- `if` and `else` have incompatible types
+
+error[E0308]: `if` and `else` have incompatible types
+ --> $DIR/if-else-type-mismatch.rs:37:9
+ |
+LL | let _ = if true {
+ | _____________________-
+LL | |
+LL | | } else {
+ | |_____- expected because of this
+LL | 11u32
+ | ^^^^^ expected `()`, found `u32`
+
+error[E0308]: `if` and `else` have incompatible types
+ --> $DIR/if-else-type-mismatch.rs:42:12
+ |
+LL | let _ = if true {
+ | ------- `if` and `else` have incompatible types
+LL | 12i32
+ | ----- expected because of this
+LL | } else {
+ | ____________^
+LL | |
+LL | | };
+ | |_____^ expected `i32`, found `()`
+
+error: aborting due to 8 previous errors
+
+For more information about this error, try `rustc --explain E0308`.
--- /dev/null
+// run-pass
+
+#![allow(unused_parens)]
+// pretty-expanded FIXME #23616
+
+fn foo() { if (return) { } } //~ WARNING unreachable block in `if` expression
+
+pub fn main() { foo(); }
--- /dev/null
+warning: unreachable block in `if` expression
+ --> $DIR/if-ret.rs:6:24
+ |
+LL | fn foo() { if (return) { } }
+ | -------- ^^^ unreachable block in `if` expression
+ | |
+ | any code following this expression is unreachable
+ |
+ = note: `#[warn(unreachable_code)]` on by default
+
+warning: 1 warning emitted
+
+++ /dev/null
-// run-pass
-
-pub fn main() {
- let i: isize = if false { panic!() } else { 5 };
- println!("{}", i);
-}
+++ /dev/null
-// run-pass
-
-fn even(x: usize) -> bool {
- if x < 2 {
- return false;
- } else if x == 2 { return true; } else { return even(x - 2); }
-}
-
-fn foo(x: usize) {
- if even(x) {
- println!("{}", x);
- } else {
- panic!();
- }
-}
-
-pub fn main() { foo(2); }
+++ /dev/null
-fn main() {
- let _ = if true {
- 1i32
- } else {
- 2u32
- };
- //~^^ ERROR `if` and `else` have incompatible types
- let _ = if true { 42i32 } else { 42u32 };
- //~^ ERROR `if` and `else` have incompatible types
- let _ = if true {
- 3u32;
- } else {
- 4u32
- };
- //~^^ ERROR `if` and `else` have incompatible types
- let _ = if true {
- 5u32
- } else {
- 6u32;
- };
- //~^^ ERROR `if` and `else` have incompatible types
- let _ = if true {
- 7i32;
- } else {
- 8u32
- };
- //~^^ ERROR `if` and `else` have incompatible types
- let _ = if true {
- 9i32
- } else {
- 10u32;
- };
- //~^^ ERROR `if` and `else` have incompatible types
- let _ = if true {
-
- } else {
- 11u32
- };
- //~^^ ERROR `if` and `else` have incompatible types
- let _ = if true {
- 12i32
- } else {
-
- };
- //~^^^ ERROR `if` and `else` have incompatible types
-}
+++ /dev/null
-error[E0308]: `if` and `else` have incompatible types
- --> $DIR/if-else-type-mismatch.rs:5:9
- |
-LL | let _ = if true {
- | _____________-
-LL | | 1i32
- | | ---- expected because of this
-LL | | } else {
-LL | | 2u32
- | | ^^^^ expected `i32`, found `u32`
-LL | | };
- | |_____- `if` and `else` have incompatible types
-
-error[E0308]: `if` and `else` have incompatible types
- --> $DIR/if-else-type-mismatch.rs:8:38
- |
-LL | let _ = if true { 42i32 } else { 42u32 };
- | ----- ^^^^^ expected `i32`, found `u32`
- | |
- | expected because of this
-
-error[E0308]: `if` and `else` have incompatible types
- --> $DIR/if-else-type-mismatch.rs:13:9
- |
-LL | let _ = if true {
- | _____________-
-LL | | 3u32;
- | | -----
- | | | |
- | | | help: consider removing this semicolon
- | | expected because of this
-LL | | } else {
-LL | | 4u32
- | | ^^^^ expected `()`, found `u32`
-LL | | };
- | |_____- `if` and `else` have incompatible types
-
-error[E0308]: `if` and `else` have incompatible types
- --> $DIR/if-else-type-mismatch.rs:19:9
- |
-LL | let _ = if true {
- | _____________-
-LL | | 5u32
- | | ---- expected because of this
-LL | | } else {
-LL | | 6u32;
- | | ^^^^-
- | | | |
- | | | help: consider removing this semicolon
- | | expected `u32`, found `()`
-LL | | };
- | |_____- `if` and `else` have incompatible types
-
-error[E0308]: `if` and `else` have incompatible types
- --> $DIR/if-else-type-mismatch.rs:25:9
- |
-LL | let _ = if true {
- | _____________-
-LL | | 7i32;
- | | ----- expected because of this
-LL | | } else {
-LL | | 8u32
- | | ^^^^ expected `()`, found `u32`
-LL | | };
- | |_____- `if` and `else` have incompatible types
-
-error[E0308]: `if` and `else` have incompatible types
- --> $DIR/if-else-type-mismatch.rs:31:9
- |
-LL | let _ = if true {
- | _____________-
-LL | | 9i32
- | | ---- expected because of this
-LL | | } else {
-LL | | 10u32;
- | | ^^^^^^ expected `i32`, found `()`
-LL | | };
- | |_____- `if` and `else` have incompatible types
-
-error[E0308]: `if` and `else` have incompatible types
- --> $DIR/if-else-type-mismatch.rs:37:9
- |
-LL | let _ = if true {
- | _____________________-
-LL | |
-LL | | } else {
- | |_____- expected because of this
-LL | 11u32
- | ^^^^^ expected `()`, found `u32`
-
-error[E0308]: `if` and `else` have incompatible types
- --> $DIR/if-else-type-mismatch.rs:42:12
- |
-LL | let _ = if true {
- | ------- `if` and `else` have incompatible types
-LL | 12i32
- | ----- expected because of this
-LL | } else {
- | ____________^
-LL | |
-LL | | };
- | |_____^ expected `i32`, found `()`
-
-error: aborting due to 8 previous errors
-
-For more information about this error, try `rustc --explain E0308`.
+++ /dev/null
-// run-pass
-
-#![allow(unused_parens)]
-// pretty-expanded FIXME #23616
-
-fn foo() { if (return) { } } //~ WARNING unreachable block in `if` expression
-
-pub fn main() { foo(); }
+++ /dev/null
-warning: unreachable block in `if` expression
- --> $DIR/if-ret.rs:6:24
- |
-LL | fn foo() { if (return) { } }
- | -------- ^^^ unreachable block in `if` expression
- | |
- | any code following this expression is unreachable
- |
- = note: `#[warn(unreachable_code)]` on by default
-
-warning: 1 warning emitted
-