]> git.lizzy.rs Git - rust.git/blob - src/test/ui/issues/issue-52240.rs
Rollup merge of #59825 - jsgf:from-ref-string, r=sfackler
[rust.git] / src / test / ui / issues / issue-52240.rs
1 // issue-52240: Can turn immutable into mut with `ref mut`
2
3 enum Foo {
4     Bar(i32),
5 }
6
7 fn main() {
8     let arr = vec!(Foo::Bar(0));
9     if let (Some(Foo::Bar(ref mut val)), _) = (&arr.get(0), 0) {
10         //~^ ERROR cannot borrow data in a `&` reference as mutable
11         *val = 9001;
12     }
13     match arr[0] {
14         Foo::Bar(ref s) => println!("{}", s)
15     }
16 }