Skip to content

ICE with trait object + associated type #26866

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

Closed
BurntSushi opened this issue Jul 7, 2015 · 7 comments
Closed

ICE with trait object + associated type #26866

BurntSushi opened this issue Jul 7, 2015 · 7 comments
Labels
I-ICE Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️

Comments

@BurntSushi
Copy link
Member

Probably not minimal example:

#[derive(Clone, Debug)]
struct Foo;

pub trait Bar {
    fn shrink(&self) -> Box<Iterator<Item=Self>>;
}

impl Bar for Foo {
    fn shrink(&self) -> Box<Iterator<Item=Foo>> {
        Box::new(None.into_iter())
    }
}

fn main() {
}

Version: rustc 1.3.0-nightly (6d71ce536 2015-07-06)

This code was working on the previous nightly---I think the 2015-07-06 nightly introduced this regression. In particular, this very badly breaks any non-trivial use of QuickCheck (which has the same signature as shrink above).

@BurntSushi BurntSushi added the I-ICE Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️ label Jul 7, 2015
@BurntSushi
Copy link
Member Author

I forgot to show the output of compilation:

[andrew@Liger qc] cargo run --verbose
   Compiling qc v0.1.0 (file:///tmp/qc)
     Running `rustc src/main.rs --crate-name qc --crate-type bin -g --out-dir /tmp/qc/target/debug --emit=dep-info,link -L dependency=/tmp/qc/target/debug -L dependency=/tmp/qc/target/debug/deps`
../src/libcore/iter.rs:804:35: 804:42 error: internal compiler error: Encountered error `Unimplemented` selecting `Binder(<Foo as core::cmp::PartialOrd>)` during trans
note: the compiler unexpectedly panicked. this is a bug.
note: we would appreciate a bug report: https://github.com/rust-lang/rust/blob/master/CONTRIBUTING.md#bug-reports
note: run with `RUST_BACKTRACE=1` for a backtrace
thread 'rustc' panicked at 'Box<Any>', ../src/libsyntax/diagnostic.rs:176


Could not compile `qc`.

Caused by:                                                                                                        
  Process didn't exit successfully: `rustc src/main.rs --crate-name qc --crate-type bin -g --out-dir /tmp/qc/target/debug --emit=dep-info,link -L dependency=/tmp/qc/target/debug -L dependency=/tmp/qc/target/debug/deps` (exit code: 101)

@tomjakubowski
Copy link
Contributor

Smaller example:

pub struct Foo;

impl Foo {
    pub fn shrink(&self) -> Box<Iterator<Item=Foo>> {
        Box::new(None.into_iter())
    }
}

fn main() {
}

@tomjakubowski
Copy link
Contributor

This also seems to only happen if the associated type binding is the Self type in an impl. This works for example:

pub struct Foo;

impl Foo {
    pub fn shrink(&self) -> Box<Iterator<Item=String>> {
        Box::new(None.into_iter())
    }
}

fn main() {
}

@jroesch
Copy link
Member

jroesch commented Jul 8, 2015

99% sure this is maybe due to the fulfillment context bug I committed that @eddyb fixed yesterday. The PR should be in tonights nightly. Here is the PR: #26807. I'll try it out on a build of master and report back.

@eddyb
Copy link
Member

eddyb commented Jul 8, 2015

Incidentally, those examples are very close to the test case added in #26807.

@apasel422
Copy link
Contributor

All three examples in this issue compile now.

@alexcrichton
Copy link
Member

Yay!

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

No branches or pull requests

6 participants