summaryrefslogtreecommitdiffstats
path: root/tests/ui/pattern/issue-52240.rs
blob: 5def557789f0fcd8babaec56ed95a92402f1be74 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
// issue-52240: Can turn immutable into mut with `ref mut`

enum Foo {
    Bar(i32),
}

fn main() {
    let arr = vec!(Foo::Bar(0));
    if let (Some(Foo::Bar(ref mut val)), _) = (&arr.get(0), 0) {
        //~^ ERROR cannot borrow data in a `&` reference as mutable
        *val = 9001;
    }
    match arr[0] {
        Foo::Bar(ref s) => println!("{}", s)
    }
}