Skip to content

Compiler panics in ambiguous arrayvec type situation #65611

Closed

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

Activity

  1. added
    C-bugCategory: This is a bug.
    I-ICEIssue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️
    T-compilerRelevant to the compiler team, which will review and decide on the PR/issue.
    on Oct 19, 2019
  2. jonas-schievink commented on Oct 19, 2019

    @jonas-schievink
    Contributor

    Also reproduces on nightly. Panic happens here:

      16: rustc_typeck::check::method::confirm::ConfirmContext::confirm
      17: rustc_typeck::check::method::<impl rustc_typeck::check::FnCtxt>::lookup_method
      18: rustc_typeck::check::expr::<impl rustc_typeck::check::FnCtxt>::check_expr_kind
      19: rustc_typeck::check::expr::<impl rustc_typeck::check::FnCtxt>::check_expr_with_expectation_and_needs
      20: rustc_typeck::check::FnCtxt::check_stmt
      21: rustc_typeck::check::FnCtxt::check_block_with_expected
      22: rustc_typeck::check::expr::<impl rustc_typeck::check::FnCtxt>::check_expr_kind
      23: rustc_typeck::check::expr::<impl rustc_typeck::check::FnCtxt>::check_expr_with_expectation_and_needs
      24: rustc_typeck::check::expr::<impl rustc_typeck::check::FnCtxt>::check_return_expr
    
  3. pnkfelix commented on Oct 24, 2019

    @pnkfelix
    Contributor

    triage: P-medium. removing nomination label.

    reasoning: has a PR. tagging as P-medium (since it does produce useful error message before ICE'ing), and removing nomination label.

  4. added 2 commits that reference this issue on Oct 24, 2019
    3312147
    7b3896f
  5. added a commit that references this issue on Mar 21, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

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