mirror of
https://github.com/rust-lang/rust
synced 2024-09-05 16:57:03 +00:00
29 lines
446 B
Rust
29 lines
446 B
Rust
//@ run-rustfix
|
|
|
|
#![allow(dead_code)]
|
|
|
|
struct S;
|
|
struct Y;
|
|
|
|
trait Trait {}
|
|
|
|
impl Trait for S {}
|
|
impl Trait for Y {}
|
|
|
|
fn foo() -> Box<dyn Trait> {
|
|
if true {
|
|
Box::new(S)
|
|
} else {
|
|
Box::new(Y) //~ ERROR `if` and `else` have incompatible types
|
|
}
|
|
}
|
|
|
|
fn bar() -> Box<dyn Trait> {
|
|
match true {
|
|
true => Box::new(S),
|
|
false => Box::new(Y), //~ ERROR `match` arms have incompatible types
|
|
}
|
|
}
|
|
|
|
fn main() {}
|