Skip to content

Commit 1b9620d

Browse files
committed
Make the diagnostic message more readable
1 parent a721957 commit 1b9620d

13 files changed

+56
-56
lines changed

compiler/rustc_typeck/src/check/upvar.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -511,8 +511,8 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
511511
};
512512

513513
let diagnostic_msg = format!(
514-
"`{}` causes {} to be fully captured",
515-
migration_string, migrated_variables_concat
514+
"add a dummy let to cause {} to be fully captured",
515+
migrated_variables_concat
516516
);
517517

518518
diagnostics_builder.span_suggestion(

src/test/ui/closures/2229_closure_analysis/migrations/insignificant_drop.fixed

+7-7
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ fn test1_all_need_migration() {
1414

1515
let c = || { let _ = (&t, &t1, &t2);
1616
//~^ ERROR: drop order affected for closure because of `capture_disjoint_fields`
17-
//~| HELP:` let _ = (&t, &t1, &t2)` causes `t`, `t1`, `t2` to be fully captured
17+
//~| HELP: add a dummy let to cause `t`, `t1`, `t2` to be fully captured
1818

1919
let _t = t.0;
2020
let _t1 = t1.0;
@@ -33,7 +33,7 @@ fn test2_only_precise_paths_need_migration() {
3333

3434
let c = || { let _ = (&t, &t1);
3535
//~^ ERROR: drop order affected for closure because of `capture_disjoint_fields`
36-
//~| HELP:` let _ = (&t, &t1)` causes `t`, `t1` to be fully captured
36+
//~| HELP: add a dummy let to cause `t`, `t1` to be fully captured
3737
let _t = t.0;
3838
let _t1 = t1.0;
3939
let _t2 = t2;
@@ -49,7 +49,7 @@ fn test3_only_by_value_need_migration() {
4949
let t1 = (String::new(), String::new());
5050
let c = || { let _ = &t;
5151
//~^ ERROR: drop order affected for closure because of `capture_disjoint_fields`
52-
//~| HELP: `let _ = &t` causes `t` to be fully captured
52+
//~| HELP: add a dummy let to cause `t` to be fully captured
5353
let _t = t.0;
5454
println!("{}", t1.1);
5555
};
@@ -67,7 +67,7 @@ fn test4_only_non_copy_types_need_migration() {
6767

6868
let c = || { let _ = &t;
6969
//~^ ERROR: drop order affected for closure because of `capture_disjoint_fields`
70-
//~| HELP: `let _ = &t` causes `t` to be fully captured
70+
//~| HELP: add a dummy let to cause `t` to be fully captured
7171
let _t = t.0;
7272
let _t1 = t1.0;
7373
};
@@ -85,7 +85,7 @@ fn test5_only_drop_types_need_migration() {
8585

8686
let c = || { let _ = &t;
8787
//~^ ERROR: drop order affected for closure because of `capture_disjoint_fields`
88-
//~| HELP: `let _ = &t` causes `t` to be fully captured
88+
//~| HELP: add a dummy let to cause `t` to be fully captured
8989
let _t = t.0;
9090
let _s = s.0;
9191
};
@@ -100,7 +100,7 @@ fn test6_move_closures_non_copy_types_might_need_migration() {
100100
let t1 = (String::new(), String::new());
101101
let c = move || { let _ = (&t1, &t);
102102
//~^ ERROR: drop order affected for closure because of `capture_disjoint_fields`
103-
//~| HELP: `let _ = (&t1, &t)` causes `t1`, `t` to be fully captured
103+
//~| HELP: add a dummy let to cause `t1`, `t` to be fully captured
104104
println!("{} {}", t1.1, t.1);
105105
};
106106

@@ -115,7 +115,7 @@ fn test7_drop_non_drop_aggregate_need_migration() {
115115

116116
let c = || { let _ = &t;
117117
//~^ ERROR: drop order affected for closure because of `capture_disjoint_fields`
118-
//~| HELP: `let _ = &t` causes `t` to be fully captured
118+
//~| HELP: add a dummy let to cause `t` to be fully captured
119119
let _t = t.0;
120120
};
121121

src/test/ui/closures/2229_closure_analysis/migrations/insignificant_drop.rs

+7-7
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ fn test1_all_need_migration() {
1414

1515
let c = || {
1616
//~^ ERROR: drop order affected for closure because of `capture_disjoint_fields`
17-
//~| HELP:` let _ = (&t, &t1, &t2)` causes `t`, `t1`, `t2` to be fully captured
17+
//~| HELP: add a dummy let to cause `t`, `t1`, `t2` to be fully captured
1818

1919
let _t = t.0;
2020
let _t1 = t1.0;
@@ -33,7 +33,7 @@ fn test2_only_precise_paths_need_migration() {
3333

3434
let c = || {
3535
//~^ ERROR: drop order affected for closure because of `capture_disjoint_fields`
36-
//~| HELP:` let _ = (&t, &t1)` causes `t`, `t1` to be fully captured
36+
//~| HELP: add a dummy let to cause `t`, `t1` to be fully captured
3737
let _t = t.0;
3838
let _t1 = t1.0;
3939
let _t2 = t2;
@@ -49,7 +49,7 @@ fn test3_only_by_value_need_migration() {
4949
let t1 = (String::new(), String::new());
5050
let c = || {
5151
//~^ ERROR: drop order affected for closure because of `capture_disjoint_fields`
52-
//~| HELP: `let _ = &t` causes `t` to be fully captured
52+
//~| HELP: add a dummy let to cause `t` to be fully captured
5353
let _t = t.0;
5454
println!("{}", t1.1);
5555
};
@@ -67,7 +67,7 @@ fn test4_only_non_copy_types_need_migration() {
6767

6868
let c = || {
6969
//~^ ERROR: drop order affected for closure because of `capture_disjoint_fields`
70-
//~| HELP: `let _ = &t` causes `t` to be fully captured
70+
//~| HELP: add a dummy let to cause `t` to be fully captured
7171
let _t = t.0;
7272
let _t1 = t1.0;
7373
};
@@ -85,7 +85,7 @@ fn test5_only_drop_types_need_migration() {
8585

8686
let c = || {
8787
//~^ ERROR: drop order affected for closure because of `capture_disjoint_fields`
88-
//~| HELP: `let _ = &t` causes `t` to be fully captured
88+
//~| HELP: add a dummy let to cause `t` to be fully captured
8989
let _t = t.0;
9090
let _s = s.0;
9191
};
@@ -100,7 +100,7 @@ fn test6_move_closures_non_copy_types_might_need_migration() {
100100
let t1 = (String::new(), String::new());
101101
let c = move || {
102102
//~^ ERROR: drop order affected for closure because of `capture_disjoint_fields`
103-
//~| HELP: `let _ = (&t1, &t)` causes `t1`, `t` to be fully captured
103+
//~| HELP: add a dummy let to cause `t1`, `t` to be fully captured
104104
println!("{} {}", t1.1, t.1);
105105
};
106106

@@ -115,7 +115,7 @@ fn test7_drop_non_drop_aggregate_need_migration() {
115115

116116
let c = || {
117117
//~^ ERROR: drop order affected for closure because of `capture_disjoint_fields`
118-
//~| HELP: `let _ = &t` causes `t` to be fully captured
118+
//~| HELP: add a dummy let to cause `t` to be fully captured
119119
let _t = t.0;
120120
};
121121

src/test/ui/closures/2229_closure_analysis/migrations/insignificant_drop.stderr

+7-7
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ note: the lint level is defined here
1616
|
1717
LL | #![deny(disjoint_capture_drop_reorder)]
1818
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
19-
help: `let _ = (&t, &t1, &t2)` causes `t`, `t1`, `t2` to be fully captured
19+
help: add a dummy let to cause `t`, `t1`, `t2` to be fully captured
2020
|
2121
LL | let c = || { let _ = (&t, &t1, &t2);
2222
LL |
@@ -39,7 +39,7 @@ LL | | let _t2 = t2;
3939
LL | | };
4040
| |_____^
4141
|
42-
help: `let _ = (&t, &t1)` causes `t`, `t1` to be fully captured
42+
help: add a dummy let to cause `t`, `t1` to be fully captured
4343
|
4444
LL | let c = || { let _ = (&t, &t1);
4545
LL |
@@ -61,7 +61,7 @@ LL | | println!("{}", t1.1);
6161
LL | | };
6262
| |_____^
6363
|
64-
help: `let _ = &t` causes `t` to be fully captured
64+
help: add a dummy let to cause `t` to be fully captured
6565
|
6666
LL | let c = || { let _ = &t;
6767
LL |
@@ -83,7 +83,7 @@ LL | | let _t1 = t1.0;
8383
LL | | };
8484
| |_____^
8585
|
86-
help: `let _ = &t` causes `t` to be fully captured
86+
help: add a dummy let to cause `t` to be fully captured
8787
|
8888
LL | let c = || { let _ = &t;
8989
LL |
@@ -105,7 +105,7 @@ LL | | let _s = s.0;
105105
LL | | };
106106
| |_____^
107107
|
108-
help: `let _ = &t` causes `t` to be fully captured
108+
help: add a dummy let to cause `t` to be fully captured
109109
|
110110
LL | let c = || { let _ = &t;
111111
LL |
@@ -126,7 +126,7 @@ LL | | println!("{} {}", t1.1, t.1);
126126
LL | | };
127127
| |_____^
128128
|
129-
help: `let _ = (&t1, &t)` causes `t1`, `t` to be fully captured
129+
help: add a dummy let to cause `t1`, `t` to be fully captured
130130
|
131131
LL | let c = move || { let _ = (&t1, &t);
132132
LL |
@@ -146,7 +146,7 @@ LL | | let _t = t.0;
146146
LL | | };
147147
| |_____^
148148
|
149-
help: `let _ = &t` causes `t` to be fully captured
149+
help: add a dummy let to cause `t` to be fully captured
150150
|
151151
LL | let c = || { let _ = &t;
152152
LL |

src/test/ui/closures/2229_closure_analysis/migrations/migrations_rustfix.fixed

+2-2
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ fn closure_contains_block() {
1818
let t = (Foo(0), Foo(0));
1919
let c = || { let _ = &t;
2020
//~^ ERROR: drop order affected for closure because of `capture_disjoint_fields`
21-
//~| HELP: `let _ = &t` causes `t` to be fully captured
21+
//~| HELP: add a dummy let to cause `t` to be fully captured
2222
let _t = t.0;
2323
};
2424

@@ -29,7 +29,7 @@ fn closure_doesnt_contain_block() {
2929
let t = (Foo(0), Foo(0));
3030
let c = || { let _ = &t; t.0 };
3131
//~^ ERROR: drop order affected for closure because of `capture_disjoint_fields`
32-
//~| HELP: `let _ = &t` causes `t` to be fully captured
32+
//~| HELP: add a dummy let to cause `t` to be fully captured
3333

3434
c();
3535
}

src/test/ui/closures/2229_closure_analysis/migrations/migrations_rustfix.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ fn closure_contains_block() {
1818
let t = (Foo(0), Foo(0));
1919
let c = || {
2020
//~^ ERROR: drop order affected for closure because of `capture_disjoint_fields`
21-
//~| HELP: `let _ = &t` causes `t` to be fully captured
21+
//~| HELP: add a dummy let to cause `t` to be fully captured
2222
let _t = t.0;
2323
};
2424

@@ -29,7 +29,7 @@ fn closure_doesnt_contain_block() {
2929
let t = (Foo(0), Foo(0));
3030
let c = || t.0;
3131
//~^ ERROR: drop order affected for closure because of `capture_disjoint_fields`
32-
//~| HELP: `let _ = &t` causes `t` to be fully captured
32+
//~| HELP: add a dummy let to cause `t` to be fully captured
3333

3434
c();
3535
}

src/test/ui/closures/2229_closure_analysis/migrations/migrations_rustfix.stderr

+2-2
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ note: the lint level is defined here
1414
|
1515
LL | #![deny(disjoint_capture_drop_reorder)]
1616
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
17-
help: `let _ = &t` causes `t` to be fully captured
17+
help: add a dummy let to cause `t` to be fully captured
1818
|
1919
LL | let c = || { let _ = &t;
2020
LL |
@@ -29,7 +29,7 @@ error: drop order affected for closure because of `capture_disjoint_fields`
2929
LL | let c = || t.0;
3030
| ^^^^^^
3131
|
32-
help: `let _ = &t` causes `t` to be fully captured
32+
help: add a dummy let to cause `t` to be fully captured
3333
|
3434
LL | let c = || { let _ = &t; t.0 };
3535
| ^^^^^^^^^^^^^^^^^^^

src/test/ui/closures/2229_closure_analysis/migrations/precise.fixed

+2-2
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ fn test_precise_analysis_drop_paths_not_captured_by_move() {
1818

1919
let c = || { let _ = &t;
2020
//~^ ERROR: drop order affected for closure because of `capture_disjoint_fields`
21-
//~| HELP: `let _ = &t` causes `t` to be fully captured
21+
//~| HELP: add a dummy let to cause `t` to be fully captured
2222
let _t = t.0;
2323
let _t = &t.1;
2424
};
@@ -41,7 +41,7 @@ fn test_precise_analysis_long_path_missing() {
4141

4242
let c = || { let _ = &u;
4343
//~^ ERROR: drop order affected for closure because of `capture_disjoint_fields`
44-
//~| HELP: `let _ = &u` causes `u` to be fully captured
44+
//~| HELP: add a dummy let to cause `u` to be fully captured
4545
let _x = u.0.0;
4646
let _x = u.0.1;
4747
let _x = u.1.0;

src/test/ui/closures/2229_closure_analysis/migrations/precise.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ fn test_precise_analysis_drop_paths_not_captured_by_move() {
1818

1919
let c = || {
2020
//~^ ERROR: drop order affected for closure because of `capture_disjoint_fields`
21-
//~| HELP: `let _ = &t` causes `t` to be fully captured
21+
//~| HELP: add a dummy let to cause `t` to be fully captured
2222
let _t = t.0;
2323
let _t = &t.1;
2424
};
@@ -41,7 +41,7 @@ fn test_precise_analysis_long_path_missing() {
4141

4242
let c = || {
4343
//~^ ERROR: drop order affected for closure because of `capture_disjoint_fields`
44-
//~| HELP: `let _ = &u` causes `u` to be fully captured
44+
//~| HELP: add a dummy let to cause `u` to be fully captured
4545
let _x = u.0.0;
4646
let _x = u.0.1;
4747
let _x = u.1.0;

src/test/ui/closures/2229_closure_analysis/migrations/precise.stderr

+2-2
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ note: the lint level is defined here
1515
|
1616
LL | #![deny(disjoint_capture_drop_reorder)]
1717
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
18-
help: `let _ = &t` causes `t` to be fully captured
18+
help: add a dummy let to cause `t` to be fully captured
1919
|
2020
LL | let c = || { let _ = &t;
2121
LL |
@@ -38,7 +38,7 @@ LL | | let _x = u.1.0;
3838
LL | | };
3939
| |_____^
4040
|
41-
help: `let _ = &u` causes `u` to be fully captured
41+
help: add a dummy let to cause `u` to be fully captured
4242
|
4343
LL | let c = || { let _ = &u;
4444
LL |

src/test/ui/closures/2229_closure_analysis/migrations/significant_drop.fixed

+7-7
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ fn test1_all_need_migration() {
2424

2525
let c = || { let _ = (&t, &t1, &t2);
2626
//~^ ERROR: drop order affected for closure because of `capture_disjoint_fields`
27-
//~| HELP:` let _ = (&t, &t1, &t2)` causes `t`, `t1`, `t2` to be fully captured
27+
//~| HELP: add a dummy let to cause `t`, `t1`, `t2` to be fully captured
2828
let _t = t.0;
2929
let _t1 = t1.0;
3030
let _t2 = t2.0;
@@ -42,7 +42,7 @@ fn test2_only_precise_paths_need_migration() {
4242

4343
let c = || { let _ = (&t, &t1);
4444
//~^ ERROR: drop order affected for closure because of `capture_disjoint_fields`
45-
//~| HELP:` let _ = (&t, &t1)` causes `t`, `t1` to be fully captured
45+
//~| HELP: add a dummy let to cause `t`, `t1` to be fully captured
4646
let _t = t.0;
4747
let _t1 = t1.0;
4848
let _t2 = t2;
@@ -58,7 +58,7 @@ fn test3_only_by_value_need_migration() {
5858
let t1 = (Foo(0), Foo(0));
5959
let c = || { let _ = &t;
6060
//~^ ERROR: drop order affected for closure because of `capture_disjoint_fields`
61-
//~| HELP: `let _ = &t` causes `t` to be fully captured
61+
//~| HELP: add a dummy let to cause `t` to be fully captured
6262
let _t = t.0;
6363
println!("{:?}", t1.1);
6464
};
@@ -75,7 +75,7 @@ fn test4_type_contains_drop_need_migration() {
7575

7676
let c = || { let _ = &t;
7777
//~^ ERROR: drop order affected for closure because of `capture_disjoint_fields`
78-
//~| HELP: `let _ = &t` causes `t` to be fully captured
78+
//~| HELP: add a dummy let to cause `t` to be fully captured
7979
let _t = t.0;
8080
};
8181

@@ -90,7 +90,7 @@ fn test5_drop_non_drop_aggregate_need_migration() {
9090

9191
let c = || { let _ = &t;
9292
//~^ ERROR: drop order affected for closure because of `capture_disjoint_fields`
93-
//~| HELP: `let _ = &t` causes `t` to be fully captured
93+
//~| HELP: add a dummy let to cause `t` to be fully captured
9494
let _t = t.0;
9595
};
9696

@@ -103,7 +103,7 @@ fn test6_significant_insignificant_drop_aggregate_need_migration() {
103103

104104
let c = || { let _ = &t;
105105
//~^ ERROR: drop order affected for closure because of `capture_disjoint_fields`
106-
//~| HELP: `let _ = &t` causes `t` to be fully captured
106+
//~| HELP: add a dummy let to cause `t` to be fully captured
107107
let _t = t.1;
108108
};
109109

@@ -118,7 +118,7 @@ fn test7_move_closures_non_copy_types_might_need_migration() {
118118

119119
let c = move || { let _ = (&t1, &t);
120120
//~^ ERROR: drop order affected for closure because of `capture_disjoint_fields`
121-
//~| HELP: `let _ = (&t1, &t)` causes `t1`, `t` to be fully captured
121+
//~| HELP: add a dummy let to cause `t1`, `t` to be fully captured
122122
println!("{:?} {:?}", t1.1, t.1);
123123
};
124124

0 commit comments

Comments
 (0)