Skip to content

Commit ecebb66

Browse files
committed
Add test for removing &mut for &mut format!().
1 parent b4524f8 commit ecebb66

File tree

2 files changed

+25
-1
lines changed

2 files changed

+25
-1
lines changed

src/test/ui/suggestions/format-borrow.rs

+4
Original file line numberDiff line numberDiff line change
@@ -3,4 +3,8 @@ fn main() {
33
//~^ ERROR mismatched types
44
let b: String = &format!("b");
55
//~^ ERROR mismatched types
6+
let c: String = &mut format!("c");
7+
//~^ ERROR mismatched types
8+
let d: String = &mut (format!("d"));
9+
//~^ ERROR mismatched types
610
}

src/test/ui/suggestions/format-borrow.stderr

+21-1
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,26 @@ LL | let b: String = &format!("b");
1818
| | help: consider removing the borrow: `format!("b")`
1919
| expected due to this
2020

21-
error: aborting due to 2 previous errors
21+
error[E0308]: mismatched types
22+
--> $DIR/format-borrow.rs:6:21
23+
|
24+
LL | let c: String = &mut format!("c");
25+
| ------ ^^^^^^^^^^^^^^^^^
26+
| | |
27+
| | expected struct `String`, found `&mut String`
28+
| | help: consider removing the borrow: `format!("c")`
29+
| expected due to this
30+
31+
error[E0308]: mismatched types
32+
--> $DIR/format-borrow.rs:8:21
33+
|
34+
LL | let d: String = &mut (format!("d"));
35+
| ------ ^^^^^^^^^^^^^^^^^^^
36+
| | |
37+
| | expected struct `String`, found `&mut String`
38+
| | help: consider removing the borrow: `format!("d")`
39+
| expected due to this
40+
41+
error: aborting due to 4 previous errors
2242

2343
For more information about this error, try `rustc --explain E0308`.

0 commit comments

Comments
 (0)