trait Foo {}
impl Foo for () {}
#[cfg(not(good))]
fn foo(x: bool) -> Box<Foo+'static> {
match x {
true => box() (),
false => box() ()
}
}
#[cfg(good)]
fn foo(x: bool) -> Box<Foo+'static> {
match x {
true => box() () as Box<Foo>,
false => box() () as Box<Foo>
}
}
fn main() {
foo(true);
foo(false);
}
Compiling with --cfg good (i.e. explicit casts) runs 100% fine, compiling without it (i.e. implicit coercions) segfaults/crashes. This also runs fine on 0.12 on the playpen, and with if x { instead of match .
cc @nick29581 (maybe?)