]> git.lizzy.rs Git - rust.git/blob - src/test/ui/issues/issue-45199.rs
Auto merge of #57108 - Mark-Simulacrum:license-remove, r=pietroalbini
[rust.git] / src / test / ui / issues / issue-45199.rs
1 // revisions: ast mir
2 //[mir]compile-flags: -Zborrowck=mir
3
4 fn test_drop_replace() {
5     let b: Box<isize>;
6     //[mir]~^ HELP make this binding mutable
7     //[mir]~| SUGGESTION mut b
8     b = Box::new(1);    //[ast]~ NOTE first assignment
9                         //[mir]~^ NOTE first assignment
10     b = Box::new(2);    //[ast]~ ERROR cannot assign twice to immutable variable
11                         //[mir]~^ ERROR cannot assign twice to immutable variable `b`
12                         //[ast]~| NOTE cannot assign twice to immutable
13                         //[mir]~| NOTE cannot assign twice to immutable
14 }
15
16 fn test_call() {
17     let b = Box::new(1);    //[ast]~ NOTE first assignment
18                             //[mir]~^ NOTE first assignment
19                             //[mir]~| HELP make this binding mutable
20                             //[mir]~| SUGGESTION mut b
21     b = Box::new(2);        //[ast]~ ERROR cannot assign twice to immutable variable
22                             //[mir]~^ ERROR cannot assign twice to immutable variable `b`
23                             //[ast]~| NOTE cannot assign twice to immutable
24                             //[mir]~| NOTE cannot assign twice to immutable
25 }
26
27 fn test_args(b: Box<i32>) {  //[ast]~ NOTE first assignment
28                                 //[mir]~^ HELP make this binding mutable
29                                 //[mir]~| SUGGESTION mut b
30     b = Box::new(2);            //[ast]~ ERROR cannot assign twice to immutable variable
31                                 //[mir]~^ ERROR cannot assign to immutable argument `b`
32                                 //[ast]~| NOTE cannot assign twice to immutable
33                                 //[mir]~| NOTE cannot assign to immutable argument
34 }
35
36 fn main() {}