Skip to content

ICE with default methods of the same name on derived trait #8885

Closed
@Zolomon

Description

@Zolomon
fn main() {
    struct Example;

    trait BaseTrait { fn toString(&self) -> ~str { ~"BaseTrait" } }

    trait DerivedTrait : BaseTrait {
        fn new() -> Self;
        fn toString(&self) -> ~str { ~"DerivedTrait" }
    }

    impl BaseTrait for Example { }

    impl DerivedTrait for Example { fn new() -> Example { Example } }

    let bug: Example = DerivedTrait::new();
    println(fmt!("%s", bug.toString()));
}

klutzy@#rust was kind enough to give me debug output:

$ rustc.exe --version
d:\stone\rust\build-32\i686-pc-mingw32\stage2\bin\rustc.exe 0.8-pre
host: i686-pc-mingw32

$ RUST_LOG=rustc=1 rustc.exe x.rs
x.rs:32:20: 32:32 error: multiple applicable methods in scope
x.rs:32         println(fmt!("%s", bug.toString()));
                                   ^~~~~~~~~~~~
note: in expansion of fmt!
x.rs:32:9: 32:34 note: expansion site
task <unnamed> failed at 'report_static_candidate: bad item {crate: 0, node: 120}', D:\stone\rust\src\librustc\middle\typeck\check\method.rs:1306
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 to get further details and report the results to github.com/mozilla/rust/issues
task <unnamed> failed at 'explicit failure', d:\stone\rust\src\librustc\rustc.rs:376

We thought it was related to #8808, this might be a duplicate.

Metadata

Metadata

Assignees

No one assigned

    Labels

    I-ICEIssue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions