Skip to content

Unparseable type suggested in error message #40859

@mulkieran

Description

@mulkieran
fn m(var: &[&mut u8]) {
    for i in var.iter_mut() {
        **i = 4;
    }
}

fn main() {
    let mut a = 1;
    let mut b = 2;
    let mut c = 3;
    let mut v = vec![&mut a, &mut b, &mut c];
    
    m(&mut v);
    println!("{:?}", v);
}

Gives error:

rustc 1.17.0-nightly (7846dbe0c 2017-03-26)
error: cannot borrow immutable borrowed content `*var` as mutable
 --> <anon>:2:14
  |
1 | fn m(var: &[&mut u8]) {
  |           ---------- use `&mut [&mut mut u8]` here to make mutable
2 |     for i in var.iter_mut() {
  |              ^^^ cannot borrow as mutable

error: aborting due to previous error

It suggests the type &mut [&mut mut u8] but that is not a valid Rust type. Happens in stable, beta, nightly.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions