Skip to content
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

Reordering type parameters bounds in trait vs impl causes ICE during trans #6334

Closed
nikomatsakis opened this issue May 8, 2013 · 2 comments
Labels
A-codegen Area: Code generation A-traits Area: Trait system I-ICE Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️

Comments

@nikomatsakis
Copy link
Contributor

The following test causes an ICE in trans:

// Copyright 2012 The Rust Project Developers. See the COPYRIGHT
// file at the top-level directory of this distribution and at
// http://rust-lang.org/COPYRIGHT.
//
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
// option. This file may not be copied, modified, or distributed
// except according to those terms.

// Tests that everything still compiles and runs fine even when
// we reorder the bounds.

trait A {
    fn a(&self) -> uint;
}

trait B {
    fn b(&self) -> uint;
}

trait C {
    fn combine<T:A+B>(&self, t: &T) -> uint;
}

struct Foo;

impl A for Foo {
    fn a(&self) -> uint { 1 }
}

impl B for Foo {
    fn b(&self) -> uint { 2 }
}

struct Bar;

impl C for Bar {
    // Note below: bounds in impl decl are in reverse order.
    fn combine<T:B+A>(&self, t: &T) -> uint {
        (t.a() * 100) + t.b()
    }
}

fn use_c<S:C, T:B+A>(s: &S, t: &T) -> uint {
    s.combine(t)
}

fn main() {
    let foo = Foo;
    let bar = Bar;
    let r = use_c(&bar, &foo);
    assert_eq!(r, 102);
}
@emberian
Copy link
Member

What a silly bug! Backtrace:

[16:36:30]/tmp> RUST_LOG=rustc=1,::rt::backtrace rustc foo.rs 
rust: task failed at 'could not find method while translating', /home/cmr/hacking/rust/src/libstd/option.rs:307
/home/cmr/.local/bin/../lib/librustrt.so(+0x1aacd)[0x7f47e3776acd]
/home/cmr/.local/bin/../lib/librustrt.so(+0x1b7c9)[0x7f47e37777c9]
/home/cmr/.local/bin/../lib/librustrt.so(+0x2bb45)[0x7f47e3787b45]
/home/cmr/.local/bin/../lib/librustrt.so(_ZN9rust_task15call_on_c_stackEPvS0_+0xc3)[0x7f47e3778573]
/home/cmr/.local/bin/../lib/librustrt.so(upcall_fail+0xa8)[0x7f47e3778fd8]
/home/cmr/.local/bin/../lib/libstd-6c65cf4b443341b1-0.7.so(_ZN3sys13begin_unwind_16_89e154cd09156713_07E+0x3cc)[0x7f47e51e3eac]
/home/cmr/.local/bin/../lib/libstd-6c65cf4b443341b1-0.7.so(+0xfaad2)[0x7f47e51e3ad2]
/home/cmr/.local/bin/../lib/libstd-6c65cf4b443341b1-0.7.so(+0xfaa01)[0x7f47e51e3a01]
/home/cmr/.local/bin/../lib/libstd-6c65cf4b443341b1-0.7.so(+0xfaa8c)[0x7f47e51e3a8c]
/home/cmr/.local/bin/../lib/libstd-6c65cf4b443341b1-0.7.so(+0xfaa01)[0x7f47e51e3a01]
/home/cmr/.local/bin/../lib/libstd-6c65cf4b443341b1-0.7.so(_ZN3sys14__extensions__10meth_100689fail_with17_d96679812a86c3673_07E+0x7b)[0x7f47e514df1b]
/home/cmr/.local/bin/../lib/librustc-d3cb8c2ccd84a7a7-0.7.so(_ZN6middle5trans4meth27method_with_name_or_default17_586b8c59672e62f03_07E+0x1171)[0x7f47e3c4b661]
/home/cmr/.local/bin/../lib/librustc-d3cb8c2ccd84a7a7-0.7.so(_ZN6middle5trans4meth26trans_monomorphized_callee17_284f2277bb6b9a303_07E+0x2e5)[0x7f47e3c4bdc5]
/home/cmr/.local/bin/../lib/librustc-d3cb8c2ccd84a7a7-0.7.so(_ZN6middle5trans4meth19trans_method_callee16_f3a28ef97c4b0fd3_07E+0x1382)[0x7f47e3b547b2]
/home/cmr/.local/bin/../lib/librustc-d3cb8c2ccd84a7a7-0.7.so(+0x1a98d8)[0x7f47e3b528d8]
/home/cmr/.local/bin/../lib/librustc-d3cb8c2ccd84a7a7-0.7.so(+0x1bc271)[0x7f47e3b65271]
/home/cmr/.local/bin/../lib/librustc-d3cb8c2ccd84a7a7-0.7.so(_ZN6middle5trans4base10with_scope16_d9e61de1d578ab63_07E+0x426)[0x7f47e3b18176]
/home/cmr/.local/bin/../lib/librustc-d3cb8c2ccd84a7a7-0.7.so(_ZN6middle5trans6callee16trans_call_inner17_9a834a73d699b4b03_07E+0x119)[0x7f47e3b51639]
/home/cmr/.local/bin/../lib/librustc-d3cb8c2ccd84a7a7-0.7.so(_ZN6middle5trans6callee17trans_method_call16_2b4bb88edf82b763_07E+0x69c)[0x7f47e3b51dec]
/home/cmr/.local/bin/../lib/librustc-d3cb8c2ccd84a7a7-0.7.so(_ZN6middle5trans4expr27trans_rvalue_dps_unadjusted17_6aa5384cec43b96a3_07E+0x694)[0x7f47e3b74e24]
/home/cmr/.local/bin/../lib/librustc-d3cb8c2ccd84a7a7-0.7.so(_ZN6middle5trans4expr25trans_to_datum_unadjusted16_637a329f6de24423_07E+0x72e)[0x7f47e3b6c47e]
/home/cmr/.local/bin/../lib/librustc-d3cb8c2ccd84a7a7-0.7.so(_ZN6middle5trans4expr14trans_to_datum16_637a329f6de24423_07E+0x1d1)[0x7f47e3b0fee1]
/home/cmr/.local/bin/../lib/librustc-d3cb8c2ccd84a7a7-0.7.so(_ZN6middle5trans4expr12trans_binary16_cb549c773a7ffc23_07E+0x12a)[0x7f47e3b7b78a]
/home/cmr/.local/bin/../lib/librustc-d3cb8c2ccd84a7a7-0.7.so(_ZN6middle5trans4expr29trans_rvalue_datum_unadjusted16_637a329f6de24423_07E+0xa24)[0x7f47e3b73d44]
/home/cmr/.local/bin/../lib/librustc-d3cb8c2ccd84a7a7-0.7.so(_ZN6middle5trans4expr29trans_rvalue_datum_unadjusted16_637a329f6de24423_07E+0x3a7)[0x7f47e3b736c7]
/home/cmr/.local/bin/../lib/librustc-d3cb8c2ccd84a7a7-0.7.so(_ZN6middle5trans4expr25trans_to_datum_unadjusted16_637a329f6de24423_07E+0x407)[0x7f47e3b6c157]
/home/cmr/.local/bin/../lib/librustc-d3cb8c2ccd84a7a7-0.7.so(_ZN6middle5trans4expr14trans_to_datum16_637a329f6de24423_07E+0x1d1)[0x7f47e3b0fee1]
/home/cmr/.local/bin/../lib/librustc-d3cb8c2ccd84a7a7-0.7.so(_ZN6middle5trans4expr12trans_binary16_cb549c773a7ffc23_07E+0x12a)[0x7f47e3b7b78a]
/home/cmr/.local/bin/../lib/librustc-d3cb8c2ccd84a7a7-0.7.so(_ZN6middle5trans4expr29trans_rvalue_datum_unadjusted16_637a329f6de24423_07E+0xa24)[0x7f47e3b73d44]
/home/cmr/.local/bin/../lib/librustc-d3cb8c2ccd84a7a7-0.7.so(_ZN6middle5trans4expr10trans_into17_6aa5384cec43b96a3_07E+0x8f9)[0x7f47e3b0d209]
/home/cmr/.local/bin/../lib/librustc-d3cb8c2ccd84a7a7-0.7.so(_ZN6middle5trans11controlflow11trans_block16_a1a3d8a7623fa0c3_07E+0x265)[0x7f47e3b09d45]
/home/cmr/.local/bin/../lib/librustc-d3cb8c2ccd84a7a7-0.7.so(_ZN6middle5trans4base13trans_closure17_b8db6d925d34efc33_07E+0x90c)[0x7f47e3c0af7c]
/home/cmr/.local/bin/../lib/librustc-d3cb8c2ccd84a7a7-0.7.so(_ZN6middle5trans4base8trans_fn17_c81fea88312b9e293_07E+0x452)[0x7f47e3acdde2]
/home/cmr/.local/bin/../lib/librustc-d3cb8c2ccd84a7a7-0.7.so(_ZN6middle5trans4meth12trans_method17_4928db1bbbbde6fa3_07E+0x234)[0x7f47e3b02aa4]
/home/cmr/.local/bin/../lib/librustc-d3cb8c2ccd84a7a7-0.7.so(_ZN6middle5trans12monomorphize14monomorphic_fn17_1e195717afcc97653_07E+0x3724)[0x7f47e3ad1b64]
/home/cmr/.local/bin/../lib/librustc-d3cb8c2ccd84a7a7-0.7.so(_ZN6middle5trans6callee25trans_fn_ref_with_vtables16_bbb222c1e45d8583_07E+0x1e95)[0x7f47e3b4c0a5]
/home/cmr/.local/bin/../lib/librustc-d3cb8c2ccd84a7a7-0.7.so(_ZN6middle5trans4meth26trans_monomorphized_callee17_284f2277bb6b9a303_07E+0x582)[0x7f47e3c4c062]
/home/cmr/.local/bin/../lib/librustc-d3cb8c2ccd84a7a7-0.7.so(_ZN6middle5trans4meth19trans_method_callee16_f3a28ef97c4b0fd3_07E+0x1382)[0x7f47e3b547b2]
/home/cmr/.local/bin/../lib/librustc-d3cb8c2ccd84a7a7-0.7.so(+0x1a98d8)[0x7f47e3b528d8]
/home/cmr/.local/bin/../lib/librustc-d3cb8c2ccd84a7a7-0.7.so(+0x1bc271)[0x7f47e3b65271]
/home/cmr/.local/bin/../lib/librustc-d3cb8c2ccd84a7a7-0.7.so(_ZN6middle5trans4base10with_scope16_d9e61de1d578ab63_07E+0x426)[0x7f47e3b18176]
/home/cmr/.local/bin/../lib/librustc-d3cb8c2ccd84a7a7-0.7.so(_ZN6middle5trans6callee16trans_call_inner17_9a834a73d699b4b03_07E+0x119)[0x7f47e3b51639]
/home/cmr/.local/bin/../lib/librustc-d3cb8c2ccd84a7a7-0.7.so(_ZN6middle5trans6callee17trans_method_call16_2b4bb88edf82b763_07E+0x69c)[0x7f47e3b51dec]
/home/cmr/.local/bin/../lib/librustc-d3cb8c2ccd84a7a7-0.7.so(_ZN6middle5trans4expr27trans_rvalue_dps_unadjusted17_6aa5384cec43b96a3_07E+0x694)[0x7f47e3b74e24]
/home/cmr/.local/bin/../lib/librustc-d3cb8c2ccd84a7a7-0.7.so(_ZN6middle5trans4expr10trans_into17_6aa5384cec43b96a3_07E+0x864)[0x7f47e3b0d174]
/home/cmr/.local/bin/../lib/librustc-d3cb8c2ccd84a7a7-0.7.so(_ZN6middle5trans11controlflow11trans_block16_a1a3d8a7623fa0c3_07E+0x265)[0x7f47e3b09d45]
/home/cmr/.local/bin/../lib/librustc-d3cb8c2ccd84a7a7-0.7.so(_ZN6middle5trans4base13trans_closure17_b8db6d925d34efc33_07E+0x90c)[0x7f47e3c0af7c]
/home/cmr/.local/bin/../lib/librustc-d3cb8c2ccd84a7a7-0.7.so(_ZN6middle5trans4base8trans_fn17_c81fea88312b9e293_07E+0x452)[0x7f47e3acdde2]
/home/cmr/.local/bin/../lib/librustc-d3cb8c2ccd84a7a7-0.7.so(_ZN6middle5trans12monomorphize14monomorphic_fn17_1e195717afcc97653_07E+0x2178)[0x7f47e3ad05b8]
/home/cmr/.local/bin/../lib/librustc-d3cb8c2ccd84a7a7-0.7.so(_ZN6middle5trans6callee25trans_fn_ref_with_vtables16_bbb222c1e45d8583_07E+0x1e95)[0x7f47e3b4c0a5]
/home/cmr/.local/bin/../lib/librustc-d3cb8c2ccd84a7a7-0.7.so(_ZN6middle5trans6callee12trans_fn_ref16_8aacd8dad6533683_07E+0x638)[0x7f47e3b45cc8]
/home/cmr/.local/bin/../lib/librustc-d3cb8c2ccd84a7a7-0.7.so(_ZN6middle5trans6callee5trans9trans_def17_1564f81c20c381583_07E+0x15f)[0x7f47e3b4444f]
/home/cmr/.local/bin/../lib/librustc-d3cb8c2ccd84a7a7-0.7.so(_ZN6middle5trans6callee5trans16_b2108e8dda6cee33_07E+0x34e)[0x7f47e3b43dfe]
/home/cmr/.local/bin/../lib/librustc-d3cb8c2ccd84a7a7-0.7.so(+0x1a8701)[0x7f47e3b51701]
/home/cmr/.local/bin/../lib/librustc-d3cb8c2ccd84a7a7-0.7.so(+0x1bc271)[0x7f47e3b65271]
/home/cmr/.local/bin/../lib/librustc-d3cb8c2ccd84a7a7-0.7.so(_ZN6middle5trans4base10with_scope16_d9e61de1d578ab63_07E+0x426)[0x7f47e3b18176]
/home/cmr/.local/bin/../lib/librustc-d3cb8c2ccd84a7a7-0.7.so(_ZN6middle5trans6callee16trans_call_inner17_9a834a73d699b4b03_07E+0x119)[0x7f47e3b51639]
/home/cmr/.local/bin/../lib/librustc-d3cb8c2ccd84a7a7-0.7.so(_ZN6middle5trans6callee10trans_call17_5ece37fa7d438db63_07E+0x32b)[0x7f47e3b512db]
/home/cmr/.local/bin/../lib/librustc-d3cb8c2ccd84a7a7-0.7.so(_ZN6middle5trans4expr27trans_rvalue_dps_unadjusted17_6aa5384cec43b96a3_07E+0x615)[0x7f47e3b74da5]
/home/cmr/.local/bin/../lib/librustc-d3cb8c2ccd84a7a7-0.7.so(_ZN6middle5trans4expr10trans_into17_6aa5384cec43b96a3_07E+0x864)[0x7f47e3b0d174]
/home/cmr/.local/bin/../lib/librustc-d3cb8c2ccd84a7a7-0.7.so(_ZN6middle5trans4base10init_local16_daf992f2bcbfbc43_07E+0x5ad)[0x7f47e3c02bbd]
/home/cmr/.local/bin/../lib/librustc-d3cb8c2ccd84a7a7-0.7.so(_ZN6middle5trans4base10trans_stmt17_3ab12d54e9382a393_07E+0x608)[0x7f47e3b0c258]
/home/cmr/.local/bin/../lib/librustc-d3cb8c2ccd84a7a7-0.7.so(_ZN6middle5trans11controlflow11trans_block16_a1a3d8a7623fa0c3_07E+0x156)[0x7f47e3b09c36]
/home/cmr/.local/bin/../lib/librustc-d3cb8c2ccd84a7a7-0.7.so(_ZN6middle5trans4base13trans_closure17_b8db6d925d34efc33_07E+0x6f2)[0x7f47e3c0ad62]
/home/cmr/.local/bin/../lib/librustc-d3cb8c2ccd84a7a7-0.7.so(_ZN6middle5trans4base8trans_fn17_c81fea88312b9e293_07E+0x452)[0x7f47e3acdde2]
/home/cmr/.local/bin/../lib/librustc-d3cb8c2ccd84a7a7-0.7.so(_ZN6middle5trans4base10trans_item17_abfeb2c733807abd3_07E+0xa78)[0x7f47e3ac6df8]
/home/cmr/.local/bin/../lib/librustc-d3cb8c2ccd84a7a7-0.7.so(_ZN6middle5trans4base9trans_mod16_d54da25032113143_07E+0x8d)[0x7f47e3c0eb2d]
/home/cmr/.local/bin/../lib/librustc-d3cb8c2ccd84a7a7-0.7.so(_ZN6middle5trans4base11trans_crate15_56f0fc14e447483_07E+0x469)[0x7f47e3c1d669]
/home/cmr/.local/bin/../lib/librustc-d3cb8c2ccd84a7a7-0.7.so(+0x7a91ad)[0x7f47e41521ad]
/home/cmr/.local/bin/../lib/librustc-d3cb8c2ccd84a7a7-0.7.so(_ZN6driver6driver12compile_rest16_a7e075f89b93d633_07E+0x24d5)[0x7f47e414fed5]
/home/cmr/.local/bin/../lib/librustc-d3cb8c2ccd84a7a7-0.7.so(+0x7dad74)[0x7f47e4183d74]
/home/cmr/.local/bin/../lib/librustc-d3cb8c2ccd84a7a7-0.7.so(_ZN6driver6driver12compile_upto17_c68c1e2085f3205e3_07E+0x13c)[0x7f47e41524dc]
/home/cmr/.local/bin/../lib/librustc-d3cb8c2ccd84a7a7-0.7.so(_ZN6driver6driver13compile_input17_8fb49a3d65db4a823_07E+0xd5)[0x7f47e4152875]
/home/cmr/.local/bin/../lib/librustc-d3cb8c2ccd84a7a7-0.7.so(_ZN12run_compiler17_7449a6c8ce5854633_07E+0x1b13)[0x7f47e4171cb3]
/home/cmr/.local/bin/../lib/librustc-d3cb8c2ccd84a7a7-0.7.so(+0x7daa9e)[0x7f47e4183a9e]
/home/cmr/.local/bin/../lib/librustc-d3cb8c2ccd84a7a7-0.7.so(+0x7d8547)[0x7f47e4181547]
/home/cmr/.local/bin/../lib/librustc-d3cb8c2ccd84a7a7-0.7.so(+0x7cfe5b)[0x7f47e4178e5b]
/home/cmr/.local/bin/../lib/librustc-d3cb8c2ccd84a7a7-0.7.so(+0x7dad74)[0x7f47e4183d74]
/home/cmr/.local/bin/../lib/libstd-6c65cf4b443341b1-0.7.so(+0xcd961)[0x7f47e51b6961]
/home/cmr/.local/bin/../lib/libstd-6c65cf4b443341b1-0.7.so(+0x143d6c)[0x7f47e522cd6c]
/home/cmr/.local/bin/../lib/librustrt.so(_Z18task_start_wrapperP10spawn_args+0x23)[0x7f47e3776e43]
error: internal compiler error: unexpected failure
note: the compiler hit an unexpected failure path. this is a bug
note: try running with RUST_LOG=rustc=1,::rt::backtrace to get further details and report the results to github.com/mozilla/rust/issues
rust: task failed at 'explicit failure', /home/cmr/hacking/rust/src/librustc/rustc.rs:354
/home/cmr/.local/bin/../lib/librustrt.so(+0x1aacd)[0x7f47e3776acd]
/home/cmr/.local/bin/../lib/librustrt.so(+0x1b7c9)[0x7f47e37777c9]
/home/cmr/.local/bin/../lib/librustrt.so(+0x2bb45)[0x7f47e3787b45]
/home/cmr/.local/bin/../lib/librustrt.so(_ZN9rust_task15call_on_c_stackEPvS0_+0xc3)[0x7f47e3778573]
/home/cmr/.local/bin/../lib/librustrt.so(upcall_fail+0xa8)[0x7f47e3778fd8]
/home/cmr/.local/bin/../lib/libstd-6c65cf4b443341b1-0.7.so(_ZN3sys13begin_unwind_16_89e154cd09156713_07E+0x3cc)[0x7f47e51e3eac]
/home/cmr/.local/bin/../lib/libstd-6c65cf4b443341b1-0.7.so(+0xfb032)[0x7f47e51e4032]
/home/cmr/.local/bin/../lib/libstd-6c65cf4b443341b1-0.7.so(+0xfaa01)[0x7f47e51e3a01]
/home/cmr/.local/bin/../lib/libstd-6c65cf4b443341b1-0.7.so(+0xfafec)[0x7f47e51e3fec]
/home/cmr/.local/bin/../lib/libstd-6c65cf4b443341b1-0.7.so(+0xfaa01)[0x7f47e51e3a01]
/home/cmr/.local/bin/../lib/libstd-6c65cf4b443341b1-0.7.so(+0x79d64)[0x7f47e5162d64]
/home/cmr/.local/bin/../lib/libstd-6c65cf4b443341b1-0.7.so(+0x143d6c)[0x7f47e522cd6c]
/home/cmr/.local/bin/../lib/librustc-d3cb8c2ccd84a7a7-0.7.so(_ZN7monitor17_bd33c0a4efdb3aac3_07E+0x2295)[0x7f47e4174b95]
/home/cmr/.local/bin/../lib/librustc-d3cb8c2ccd84a7a7-0.7.so(+0x7dad74)[0x7f47e4183d74]
/home/cmr/.local/bin/../lib/librustc-d3cb8c2ccd84a7a7-0.7.so(_ZN4main15_f3d16eaf7d57383_07E+0x87)[0x7f47e41839c7]
/home/cmr/.local/bin/../lib/librustrt.so(_Z18task_start_wrapperP10spawn_args+0x23)[0x7f47e3776e43]
rust: domain main @0x1d19030 root task failed
leaked memory in rust main loop (1 objects)
rustc: ../src/rt/memory_region.cpp:192: memory_region::~memory_region(): Assertion `false' failed.
zsh: abort (core dumped)  RUST_LOG=rustc=1,::rt::backtrace rustc foo.rs

@catamorphism
Copy link
Contributor

Still fails with the same ICE as of b477f7a . Doesn't seem like a release blocker, though.

bors added a commit that referenced this issue Aug 6, 2014
@bors bors closed this as completed in 08f033b Aug 6, 2014
flip1995 pushed a commit to flip1995/rust that referenced this issue Nov 20, 2020
Rustup

r? `@ghost`

changelog: none
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-codegen Area: Code generation A-traits Area: Trait system I-ICE Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants