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

Internal compiler error when using a trait with default implementations as a field in a struct #3694

Closed
andymatuschak opened this issue Oct 8, 2012 · 4 comments
Labels
A-traits Area: Trait system I-ICE Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️

Comments

@andymatuschak
Copy link

I get this internal compiler error:

rust: task failed at 'option::get none', /Users/andym/Downloads/rust/src/rustc/rustc.rc:1
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=0,::rt::backtrace to get further details and report the results to github.com/mozilla/rust/issues
rust: task failed at 'explicit failure', /Users/andym/Downloads/rust/src/rustc/driver/rustc.rs:275
rust: domain main @0x7fd1e980c210 root task failed
rust: task failed at 'killed', /Users/andym/Downloads/rust/src/libcore/task.rs:663

When I compile this file:

pub trait Something {
    pure fn thing() -> int;
    pure fn what() -> int { 3 }
}

impl int: Something {
    pure fn thing() -> int { 4 }
}

struct AnotherThing {
    something: Something
}

fn main() {
    let at = AnotherThing {something: 4 as Something};
    at.something.what();
}

If Something has only required methods—no provided methods—then the error is not exhibited.

This is manifesting in rustc built from f96a2a2 on Mac OS 10.8.2.

@catamorphism
Copy link
Contributor

Reproduced as of eed2ca6

@ghost ghost assigned catamorphism Feb 21, 2013
@catamorphism
Copy link
Contributor

The result is now a type error saying the object doesn't have a what method, rather than an ICE. Nominating for milestone 3, feature-complete (this is part of making default methods work).

@msullivan
Copy link
Contributor

The type error is because we got rid of implicit self, so the test needed to be updated to expose the bug.

Fixed the bug earlier this week, though, but didn't realize that this was the bug for it.

@msullivan
Copy link
Contributor

Marking that this was part of #2794 for tracking purposes.

bors pushed a commit to rust-lang-ci/rust that referenced this issue May 15, 2021
RalfJung pushed a commit to RalfJung/rust that referenced this issue Jun 29, 2024
…f_checked_ops, r=RalfJung

Use strict ops instead of checked ops

## What

Replace `checked_add(...).unwrap()` with `strict_add(...)`, etc.

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

No branches or pull requests

3 participants