Skip to content

Mismatch of static/instance fn between impl and trait causes ICE #3969

Closed
@burg

Description

@burg

Not sure what is going on here. Maybe the check for static-ness agreement should fail compilation first?

Error

[burg@burg-macchiato Desktop]# rustc test.rs
test.rs:10:4: 10:51 error: method `woops`'s self type does not match the trait method's self type
test.rs:10     static fn woops(&const self) -> ~str { ~"foo" }
               ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
error: internal compiler error: calling transform_self_type_for_method on static method

Test case

struct Bike {
    name: ~str,
}

trait BikeMethods {
    fn woops(&const self) -> ~str;
}

pub impl Bike : BikeMethods {
    static fn woops(&const self) -> ~str { ~"foo" }
}

pub fn main() {
    let b = Bike { name: ~"schwinn" };
    b.woops();
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-trait-systemArea: Trait systemA-type-systemArea: Type systemI-ICEIssue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions