Skip to content

[NLL] rejects-valid vec of array usage #46994

Closed
@leonardo-m

Description

@leonardo-m

This code compiles without feature(nll):

#![feature(nll)]
fn main() {
    let mut m = vec![[0; 1]; 1];
    m[0][0] = 1;
}

With feature(nll) it gives:

error[E0597]: `m` does not live long enough
 --> ...\test.rs:4:5
  |
4 |     m[0][0] = 1;
  |     ^ borrowed value does not live long enough
5 | }
  |  - borrowed value only lives until here
  |
  = note: borrowed value must be valid for lifetime '_#2r...

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-NLLArea: Non-lexical lifetimes (NLL)

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions