You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Rollup merge of #87953 - m-ou-se:closure-migration-multiline-formatting, r=petrochenkov
Improve formatting of closure capture migration suggestion for multi-line closures.
Fixes#87952
Before:
```
help: add a dummy let to cause `a` to be fully captured
|
5 ~ let _ = || { let _ = &a;
6 + dbg!(a.0);
7 ~ };
|
```
After:
```
help: add a dummy let to cause `a` to be fully captured
|
5 ~ let _ = || {
6 + let _ = &a;
7 + dbg!(a.0);
8 ~ };
|
```
Copy file name to clipboardExpand all lines: src/test/ui/closures/2229_closure_analysis/migrations/auto_traits.fixed
+2-1
Original file line number
Diff line number
Diff line change
@@ -55,7 +55,8 @@ impl Clone for U {
55
55
56
56
fn test_clone_trait() {
57
57
let f = U(S(String::from("Hello World")), T(0));
58
-
let c = || { let _ = &f;
58
+
let c = || {
59
+
let _ = &f;
59
60
//~^ ERROR: `Clone` trait implementation for closure and drop order
60
61
//~| NOTE: in Rust 2018, this closure would implement `Clone` as `f` implements `Clone`, but in Rust 2021, this closure would no longer implement `Clone` as `f.1` does not implement `Clone`
Copy file name to clipboardExpand all lines: src/test/ui/closures/2229_closure_analysis/migrations/mir_calls_to_shims.fixed
+2-1
Original file line number
Diff line number
Diff line change
@@ -17,7 +17,8 @@ where
17
17
F: FnOnce(),
18
18
{
19
19
let f = panic::AssertUnwindSafe(f);
20
-
let result = panic::catch_unwind(move || { let _ = &f;
20
+
let result = panic::catch_unwind(move || {
21
+
let _ = &f;
21
22
//~^ ERROR: `UnwindSafe`, `RefUnwindSafe` trait implementation for closure
22
23
//~| NOTE: in Rust 2018, this closure would implement `UnwindSafe`, `RefUnwindSafe` as `f` implements `UnwindSafe`, `RefUnwindSafe`, but in Rust 2021, this closure would no longer implement `UnwindSafe`, `RefUnwindSafe` as `f.0` does not implement `UnwindSafe`, `RefUnwindSafe`
Copy file name to clipboardExpand all lines: src/test/ui/closures/2229_closure_analysis/migrations/multi_diagnostics.fixed
+8-4
Original file line number
Diff line number
Diff line change
@@ -20,7 +20,8 @@ impl Clone for U {
20
20
fn test_multi_issues() {
21
21
let f1 = U(S(String::from("foo")), T(0));
22
22
let f2 = U(S(String::from("bar")), T(0));
23
-
let c = || { let _ = (&f1, &f2);
23
+
let c = || {
24
+
let _ = (&f1, &f2);
24
25
//~^ ERROR: `Clone` trait implementation for closure and drop order
25
26
//~| NOTE: in Rust 2018, this closure would implement `Clone` as `f1` implements `Clone`, but in Rust 2021, this closure would no longer implement `Clone` as `f1.0` does not implement `Clone`
//~^ ERROR: `Clone` trait implementation for closure
44
46
//~| NOTE: in Rust 2018, this closure would implement `Clone` as `f1` implements `Clone`, but in Rust 2021, this closure would no longer implement `Clone` as `f1.0` does not implement `Clone`
let f1 = U1(S(String::from("foo")), T(0), S(String::from("bar")));
67
-
let c = || { let _ = &f1;
69
+
let c = || {
70
+
let _ = &f1;
68
71
//~^ ERROR: `Clone` trait implementation for closure
69
72
//~| NOTE: in Rust 2018, this closure would implement `Clone` as `f1` implements `Clone`, but in Rust 2021, this closure would no longer implement `Clone` as `f1.0` does not implement `Clone`
70
73
//~| NOTE: in Rust 2018, this closure would implement `Clone` as `f1` implements `Clone`, but in Rust 2021, this closure would no longer implement `Clone` as `f1.2` does not implement `Clone`
let f1 = U1(S(String::from("foo")), T(0), S(String::from("bar")));
86
-
let c = || { let _ = &f1;
89
+
let c = || {
90
+
let _ = &f1;
87
91
//~^ ERROR: `Clone` trait implementation for closure and drop order
88
92
//~| NOTE: in Rust 2018, this closure would implement `Clone` as `f1` implements `Clone`, but in Rust 2021, this closure would no longer implement `Clone` as `f1.0` does not implement `Clone`
0 commit comments