Skip to content

rustc panic #39970

Closed
Closed

Description

@apt1002

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.

Activity

  1. apt1002 commented on Feb 20, 2017

    @apt1002
    Author
  2. apt1002 commented on Feb 20, 2017

    @apt1002
    Author

    The following features seem to be essential:

    • Type Element must be a reference.
    • The bound "Element=V" must be present.
  3. est31 commented on Feb 20, 2017

    @est31
    Member

    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

  4. apt1002 commented on Feb 20, 2017

    @apt1002
    Author

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

  5. apt1002 commented on Feb 20, 2017

    @apt1002
    Author

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

  6. apt1002 commented on Feb 20, 2017

    @apt1002
    Author

    Another slight simplification.

  7. apt1002 commented on Feb 22, 2017

    @apt1002
    Author

    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.

  8. self-assigned this
    on Feb 27, 2017
  9. added
    I-ICEIssue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️
    on May 24, 2017
  10. added a commit that references this issue on Jul 7, 2017
    87a1181
  11. added a commit that references this issue on Jul 7, 2017
    9b85e1c
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

I-ICEIssue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions