mirror of
https://github.com/rust-lang/rust.git
synced 2025-10-03 10:47:16 +00:00

``` error[E0308]: mismatched types --> $DIR/expr-as-stmt-2.rs:15:15 | LL | if true { true } else { false } && true; | ----------^^^^----------------- | | | | | expected `()`, found `bool` | expected this to be `()` | help: parentheses are required to parse this as an expression | LL | (if true { true } else { false }) && true; | + + ```
32 lines
1.1 KiB
Rust
32 lines
1.1 KiB
Rust
// This is not autofixable because we give extra suggestions to end the first expression with `;`.
|
|
fn foo(a: Option<u32>, b: Option<u32>) -> bool {
|
|
if let Some(x) = a { true } else { false }
|
|
//~^ ERROR mismatched types
|
|
//~| ERROR mismatched types
|
|
&& //~ ERROR mismatched types
|
|
if let Some(y) = a { true } else { false }
|
|
}
|
|
|
|
fn bar() -> bool {
|
|
false
|
|
}
|
|
|
|
fn main() {
|
|
if true { true } else { false } && true;
|
|
//~^ ERROR mismatched types
|
|
//~| ERROR mismatched types
|
|
if true { true } else { false } && if true { true } else { false };
|
|
//~^ ERROR mismatched types
|
|
//~| ERROR mismatched types
|
|
if true { true } else { false } if true { true } else { false };
|
|
//~^ ERROR mismatched types
|
|
//~| ERROR mismatched types
|
|
if true { bar() } else { bar() } && if true { bar() } else { bar() };
|
|
//~^ ERROR mismatched types
|
|
//~| ERROR mismatched types
|
|
if true { bar() } else { bar() } if true { bar() } else { bar() };
|
|
//~^ ERROR mismatched types
|
|
//~| ERROR mismatched types
|
|
let _ = if true { true } else { false } && true; // ok
|
|
}
|