Skip to content

Trait object implicit coercions through a match are incorrectly codegen'd #20419

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
huonw opened this issue Jan 2, 2015 · 2 comments
Closed
Labels
I-crash Issue: The compiler crashes (SIGSEGV, SIGABRT, etc). Use I-ICE instead when the compiler panics.

Comments

@huonw
Copy link
Member

huonw commented Jan 2, 2015

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?)

@huonw huonw added I-crash Issue: The compiler crashes (SIGSEGV, SIGABRT, etc). Use I-ICE instead when the compiler panics. I-nominated and removed I-nominated labels Jan 2, 2015
@huonw huonw changed the title Trait object coercions through a match are incorrectly codegen'd Trait object implicit coercions through a match are incorrectly codegen'd Jan 2, 2015
Nemo157 added a commit to RoaringBitmap/roaring-rs that referenced this issue Jan 2, 2015
@shepmaster
Copy link
Member

Perhaps duplicate of #20097?

@alexcrichton
Copy link
Member

Closing as a dupe of #20097

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
I-crash Issue: The compiler crashes (SIGSEGV, SIGABRT, etc). Use I-ICE instead when the compiler panics.
Projects
None yet
Development

No branches or pull requests

3 participants