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

rustc panic #39970

Closed
apt1002 opened this issue Feb 20, 2017 · 9 comments
Closed

rustc panic #39970

apt1002 opened this issue Feb 20, 2017 · 9 comments
Assignees
Labels
I-ICE Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️

Comments

@apt1002
Copy link

apt1002 commented Feb 20, 2017

rustc asked me to file a bug report:

error: internal compiler error: /buildslave/rust-buildbot/slave/stable-dist-rustc-linux/build/src/librustc/infer/mod.rs:626: Encountered errors [FulfillmentError(Obligation(predicate=Binder(ProjectionPredicate(ProjectionTy { trait_ref: <std::vec::Vec<f32> as array::Array<'a, usize>>, item_name: Element(610) }, _)),depth=1),MismatchedProjectionTypes(RegionsInsufficientlyPolymorphic(BrNamed(CrateNum(0):DefIndex(1030), 'a(180), WontChange), '_#0r)))] resolving bounds after type-checking

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

thread 'rustc' panicked at 'Box', /buildslave/rust-buildbot/slave/stable-dist-rustc-linux/build/src/librustc_errors/lib.rs:382
note: Run with RUST_BACKTRACE=1 for a backtrace.

Here's a fragment of code sufficient to trigger the bug. It's not minimal yet, sorry. The code might not be correct; I was kinda relying on the compiler to tell me. ;-)

$ rustc --version --verbose
rustc 1.15.1 (021bd29 2017-02-08)
binary: rustc
commit-hash: 021bd29
commit-date: 2017-02-08
host: x86_64-unknown-linux-gnu
release: 1.15.1
LLVM version: 3.9

I hope you can make something of this.

@est31
Copy link
Member

est31 commented Feb 20, 2017

@est31
Copy link
Member

est31 commented Feb 20, 2017

@apt1002
Copy link
Author

apt1002 commented Feb 20, 2017

@apt1002
Copy link
Author

apt1002 commented Feb 20, 2017

The following features seem to be essential:

  • Type Element must be a reference.
  • The bound "Element=V" must be present.

@est31
Copy link
Member

est31 commented Feb 20, 2017

I think I found it:

trait Array<'a> {
    type Element: 'a;
}

trait Visit {
    fn visit() {}
}

impl<'a> Array<'a> for () {
    type Element = &'a ();
}

impl Visit for () where
    //(): for<'a> Array<'a, Element=&'a ()>, // No ICE
    (): for<'a> Array<'a, Element=()>, // ICE
{}

fn main() {
    <() as Visit>::visit();
}

This gives an error message like:

error: internal compiler error: /buildslave/rust-buildbot/slave/stable-dist-rustc-linux/build/src/librustc/infer/mod.rs:626: Encountered errors `[FulfillmentError(Obligation(predicate=Binder(ProjectionPredicate(ProjectionTy { trait_ref: <() as Array<'a>>, item_name: Element(83) }, ())),depth=1),MismatchedProjectionTypes(Sorts(ExpectedFound { expected: &(), found: () })))]` resolving bounds after type-checking

Note the expected: &(), found: () here

@apt1002
Copy link
Author

apt1002 commented Feb 20, 2017

Good spot. Can also interchange () with &() to get an even simpler version.

@apt1002
Copy link
Author

apt1002 commented Feb 20, 2017

The <() as Visit> part seems to be essential. No ICE.

@apt1002
Copy link
Author

apt1002 commented Feb 20, 2017

Another slight simplification.

@apt1002
Copy link
Author

apt1002 commented Feb 22, 2017

I have some more evidence that I think is worth recording here. Our minimised version above crashes the compiler in a case where it should be reporting an error. I now have a version that crashes the compiler when it should be accepting the program.

I returned to my original program and specialized it to the case I care about, i.e. I instantiated all the generics. After minor fixes, it works. However, replacing &'a mut f32 with the equivalent <Vec<f32> as Array<'a, usize>>::Element crashes the compiler.

Parially minmized. Fully minimized.

@arielb1 arielb1 self-assigned this Feb 27, 2017
@Mark-Simulacrum Mark-Simulacrum added the I-ICE Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️ label May 24, 2017
nikomatsakis pushed a commit to arielb1/rust that referenced this issue Jul 7, 2017
The evaluation cache already exists, and it can handle differing
parameter environments natively.

Fixes rust-lang#39970.
Fixes rust-lang#42796.
bors added a commit that referenced this issue Jul 7, 2017
Replace the global fulfillment cache with the evaluation cache

This uses the new "Chalk" ParamEnv refactoring to check "global" predicates in an empty environment, which should be correct because global predicates aren't affected by a consistent environment.

Fixes #39970.
Fixes #42796.

r? @nikomatsakis
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

4 participants