Skip to content

Commit

Permalink
Make the diagnostic message more readable
Browse files Browse the repository at this point in the history
  • Loading branch information
arora-aman committed Apr 2, 2021
1 parent a721957 commit 1b9620d
Show file tree
Hide file tree
Showing 13 changed files with 56 additions and 56 deletions.
4 changes: 2 additions & 2 deletions compiler/rustc_typeck/src/check/upvar.rs
Original file line number Diff line number Diff line change
Expand Up @@ -511,8 +511,8 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
};

let diagnostic_msg = format!(
"`{}` causes {} to be fully captured",
migration_string, migrated_variables_concat
"add a dummy let to cause {} to be fully captured",
migrated_variables_concat
);

diagnostics_builder.span_suggestion(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ fn test1_all_need_migration() {

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

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

let c = || { let _ = (&t, &t1);
//~^ ERROR: drop order affected for closure because of `capture_disjoint_fields`
//~| HELP:` let _ = (&t, &t1)` causes `t`, `t1` to be fully captured
//~| HELP: add a dummy let to cause `t`, `t1` to be fully captured
let _t = t.0;
let _t1 = t1.0;
let _t2 = t2;
Expand All @@ -49,7 +49,7 @@ fn test3_only_by_value_need_migration() {
let t1 = (String::new(), String::new());
let c = || { let _ = &t;
//~^ ERROR: drop order affected for closure because of `capture_disjoint_fields`
//~| HELP: `let _ = &t` causes `t` to be fully captured
//~| HELP: add a dummy let to cause `t` to be fully captured
let _t = t.0;
println!("{}", t1.1);
};
Expand All @@ -67,7 +67,7 @@ fn test4_only_non_copy_types_need_migration() {

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

let c = || { let _ = &t;
//~^ ERROR: drop order affected for closure because of `capture_disjoint_fields`
//~| HELP: `let _ = &t` causes `t` to be fully captured
//~| HELP: add a dummy let to cause `t` to be fully captured
let _t = t.0;
let _s = s.0;
};
Expand All @@ -100,7 +100,7 @@ fn test6_move_closures_non_copy_types_might_need_migration() {
let t1 = (String::new(), String::new());
let c = move || { let _ = (&t1, &t);
//~^ ERROR: drop order affected for closure because of `capture_disjoint_fields`
//~| HELP: `let _ = (&t1, &t)` causes `t1`, `t` to be fully captured
//~| HELP: add a dummy let to cause `t1`, `t` to be fully captured
println!("{} {}", t1.1, t.1);
};

Expand All @@ -115,7 +115,7 @@ fn test7_drop_non_drop_aggregate_need_migration() {

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

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ fn test1_all_need_migration() {

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

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

let c = || {
//~^ ERROR: drop order affected for closure because of `capture_disjoint_fields`
//~| HELP:` let _ = (&t, &t1)` causes `t`, `t1` to be fully captured
//~| HELP: add a dummy let to cause `t`, `t1` to be fully captured
let _t = t.0;
let _t1 = t1.0;
let _t2 = t2;
Expand All @@ -49,7 +49,7 @@ fn test3_only_by_value_need_migration() {
let t1 = (String::new(), String::new());
let c = || {
//~^ ERROR: drop order affected for closure because of `capture_disjoint_fields`
//~| HELP: `let _ = &t` causes `t` to be fully captured
//~| HELP: add a dummy let to cause `t` to be fully captured
let _t = t.0;
println!("{}", t1.1);
};
Expand All @@ -67,7 +67,7 @@ fn test4_only_non_copy_types_need_migration() {

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

let c = || {
//~^ ERROR: drop order affected for closure because of `capture_disjoint_fields`
//~| HELP: `let _ = &t` causes `t` to be fully captured
//~| HELP: add a dummy let to cause `t` to be fully captured
let _t = t.0;
let _s = s.0;
};
Expand All @@ -100,7 +100,7 @@ fn test6_move_closures_non_copy_types_might_need_migration() {
let t1 = (String::new(), String::new());
let c = move || {
//~^ ERROR: drop order affected for closure because of `capture_disjoint_fields`
//~| HELP: `let _ = (&t1, &t)` causes `t1`, `t` to be fully captured
//~| HELP: add a dummy let to cause `t1`, `t` to be fully captured
println!("{} {}", t1.1, t.1);
};

Expand All @@ -115,7 +115,7 @@ fn test7_drop_non_drop_aggregate_need_migration() {

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

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ note: the lint level is defined here
|
LL | #![deny(disjoint_capture_drop_reorder)]
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
help: `let _ = (&t, &t1, &t2)` causes `t`, `t1`, `t2` to be fully captured
help: add a dummy let to cause `t`, `t1`, `t2` to be fully captured
|
LL | let c = || { let _ = (&t, &t1, &t2);
LL |
Expand All @@ -39,7 +39,7 @@ LL | | let _t2 = t2;
LL | | };
| |_____^
|
help: `let _ = (&t, &t1)` causes `t`, `t1` to be fully captured
help: add a dummy let to cause `t`, `t1` to be fully captured
|
LL | let c = || { let _ = (&t, &t1);
LL |
Expand All @@ -61,7 +61,7 @@ LL | | println!("{}", t1.1);
LL | | };
| |_____^
|
help: `let _ = &t` causes `t` to be fully captured
help: add a dummy let to cause `t` to be fully captured
|
LL | let c = || { let _ = &t;
LL |
Expand All @@ -83,7 +83,7 @@ LL | | let _t1 = t1.0;
LL | | };
| |_____^
|
help: `let _ = &t` causes `t` to be fully captured
help: add a dummy let to cause `t` to be fully captured
|
LL | let c = || { let _ = &t;
LL |
Expand All @@ -105,7 +105,7 @@ LL | | let _s = s.0;
LL | | };
| |_____^
|
help: `let _ = &t` causes `t` to be fully captured
help: add a dummy let to cause `t` to be fully captured
|
LL | let c = || { let _ = &t;
LL |
Expand All @@ -126,7 +126,7 @@ LL | | println!("{} {}", t1.1, t.1);
LL | | };
| |_____^
|
help: `let _ = (&t1, &t)` causes `t1`, `t` to be fully captured
help: add a dummy let to cause `t1`, `t` to be fully captured
|
LL | let c = move || { let _ = (&t1, &t);
LL |
Expand All @@ -146,7 +146,7 @@ LL | | let _t = t.0;
LL | | };
| |_____^
|
help: `let _ = &t` causes `t` to be fully captured
help: add a dummy let to cause `t` to be fully captured
|
LL | let c = || { let _ = &t;
LL |
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ fn closure_contains_block() {
let t = (Foo(0), Foo(0));
let c = || { let _ = &t;
//~^ ERROR: drop order affected for closure because of `capture_disjoint_fields`
//~| HELP: `let _ = &t` causes `t` to be fully captured
//~| HELP: add a dummy let to cause `t` to be fully captured
let _t = t.0;
};

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

c();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ fn closure_contains_block() {
let t = (Foo(0), Foo(0));
let c = || {
//~^ ERROR: drop order affected for closure because of `capture_disjoint_fields`
//~| HELP: `let _ = &t` causes `t` to be fully captured
//~| HELP: add a dummy let to cause `t` to be fully captured
let _t = t.0;
};

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

c();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ note: the lint level is defined here
|
LL | #![deny(disjoint_capture_drop_reorder)]
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
help: `let _ = &t` causes `t` to be fully captured
help: add a dummy let to cause `t` to be fully captured
|
LL | let c = || { let _ = &t;
LL |
Expand All @@ -29,7 +29,7 @@ error: drop order affected for closure because of `capture_disjoint_fields`
LL | let c = || t.0;
| ^^^^^^
|
help: `let _ = &t` causes `t` to be fully captured
help: add a dummy let to cause `t` to be fully captured
|
LL | let c = || { let _ = &t; t.0 };
| ^^^^^^^^^^^^^^^^^^^
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ fn test_precise_analysis_drop_paths_not_captured_by_move() {

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

let c = || { let _ = &u;
//~^ ERROR: drop order affected for closure because of `capture_disjoint_fields`
//~| HELP: `let _ = &u` causes `u` to be fully captured
//~| HELP: add a dummy let to cause `u` to be fully captured
let _x = u.0.0;
let _x = u.0.1;
let _x = u.1.0;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ fn test_precise_analysis_drop_paths_not_captured_by_move() {

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

let c = || {
//~^ ERROR: drop order affected for closure because of `capture_disjoint_fields`
//~| HELP: `let _ = &u` causes `u` to be fully captured
//~| HELP: add a dummy let to cause `u` to be fully captured
let _x = u.0.0;
let _x = u.0.1;
let _x = u.1.0;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ note: the lint level is defined here
|
LL | #![deny(disjoint_capture_drop_reorder)]
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
help: `let _ = &t` causes `t` to be fully captured
help: add a dummy let to cause `t` to be fully captured
|
LL | let c = || { let _ = &t;
LL |
Expand All @@ -38,7 +38,7 @@ LL | | let _x = u.1.0;
LL | | };
| |_____^
|
help: `let _ = &u` causes `u` to be fully captured
help: add a dummy let to cause `u` to be fully captured
|
LL | let c = || { let _ = &u;
LL |
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ fn test1_all_need_migration() {

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

let c = || { let _ = (&t, &t1);
//~^ ERROR: drop order affected for closure because of `capture_disjoint_fields`
//~| HELP:` let _ = (&t, &t1)` causes `t`, `t1` to be fully captured
//~| HELP: add a dummy let to cause `t`, `t1` to be fully captured
let _t = t.0;
let _t1 = t1.0;
let _t2 = t2;
Expand All @@ -58,7 +58,7 @@ fn test3_only_by_value_need_migration() {
let t1 = (Foo(0), Foo(0));
let c = || { let _ = &t;
//~^ ERROR: drop order affected for closure because of `capture_disjoint_fields`
//~| HELP: `let _ = &t` causes `t` to be fully captured
//~| HELP: add a dummy let to cause `t` to be fully captured
let _t = t.0;
println!("{:?}", t1.1);
};
Expand All @@ -75,7 +75,7 @@ fn test4_type_contains_drop_need_migration() {

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

Expand All @@ -90,7 +90,7 @@ fn test5_drop_non_drop_aggregate_need_migration() {

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

Expand All @@ -103,7 +103,7 @@ fn test6_significant_insignificant_drop_aggregate_need_migration() {

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

Expand All @@ -118,7 +118,7 @@ fn test7_move_closures_non_copy_types_might_need_migration() {

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

Expand Down
Loading

0 comments on commit 1b9620d

Please sign in to comment.