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

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

Closed
burg opened this issue Nov 14, 2012 · 3 comments
Closed

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

burg opened this issue Nov 14, 2012 · 3 comments
Labels
A-trait-system Area: Trait system A-type-system Area: Type system I-ICE Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️
Milestone

Comments

@burg
Copy link

burg commented Nov 14, 2012

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();
}
@catamorphism
Copy link
Contributor

There seem to be two separate issues: first, there's a very misleading error message (the real problem is that the impl method woops is static, and the trait method isn't). Second, the ICE, which still happens even after I make both methods static. Investigating...

catamorphism added a commit to catamorphism/rust that referenced this issue Nov 16, 2012
Exit with a fatal error, instead of recording a non-fatal error,
when we encounter an impl method that's static when its corresponding
trait method isn't (or vice versa). This is because code later on in
the typechecker will expect the staticness of the two methods to be
consistent and ICE otherwise.

As per rust-lang#3969
@catamorphism
Copy link
Contributor

Fixed, pending review.

@ghost ghost assigned catamorphism Nov 16, 2012
@burg
Copy link
Author

burg commented Nov 16, 2012

😸

tesuji pushed a commit to tesuji/rustc that referenced this issue Jun 4, 2020
tesuji pushed a commit to tesuji/rustc that referenced this issue Jun 4, 2020
…shearth

add testcase that no longer ICEs

Fixes rust-lang#3969

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

No branches or pull requests

2 participants