Skip to content

Compiler panics in ambiguous arrayvec type situation #65611

Closed
@grantslatton

Description

@grantslatton

The compiler correctly errors about the ambiguous types, but also panics on this code:

use arrayvec::ArrayVec;

fn main() {
    let mut buffer = ArrayVec::new();
    let x = buffer.last().unwrap().0.clone();
    buffer.reverse(); 
}
error[E0282]: type annotations needed
 --> src/main.rs:5:13
  |
5 |     let x = buffer.last().unwrap().0.clone();
  |             ^^^^^^^^^^^^^^^^^^^^^^^^ cannot infer type for `T`
  |
  = note: type must be known at this point

error[E0609]: no field `0` on type `&_`
 --> src/main.rs:5:36
  |
5 |     let x = buffer.last().unwrap().0.clone();
  |                                    ^

thread 'rustc' panicked at 'called `Option::unwrap()` on a `None` value', src/libcore/option.rs:378:21

https://play.rust-lang.org/?version=stable&mode=debug&edition=2018&gist=d6120e5e2819deb7a546f61bae891657

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-type-systemArea: Type systemC-bugCategory: This is a bug.I-ICEIssue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️P-mediumMedium priorityT-compilerRelevant to the compiler team, which will review and decide on the PR/issue.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions