Skip to content

Type inference suggests correction to non-existent variable __next #51116

Description

@sunjay

This code: (Playground link)

fn main() {
    let tiles = Default::default();
    for row in &mut tiles {
        for tile in row {
            *tile = 0;
        }
    }
    
    let tiles: [[usize; 3]; 3] = tiles;
}

Fails with this error:

error[E0282]: type annotations needed
 --> src/main.rs:5:13
  |
4 |         for tile in row {
  |             ---- consider giving `__next` a type
5 |             *tile = 0;
  |             ^^^^^ cannot infer type for `_`

Type inference (rightfully) fails on this code. However, the variable that it suggests fixing is called __next and does not actually exist in my code. It is probably some internal variable generated by the compiler.

Activity

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-diagnosticsArea: Messages for errors, warnings, and lintsC-bugCategory: This is a bug.

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions