Make the diagnostic message more readable

This commit is contained in:
Aman Arora 2021-04-01 21:33:11 -04:00
parent a721957a3d
commit 1b9620d75f
13 changed files with 56 additions and 56 deletions

View file

@ -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(

View file

@ -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;
@ -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;
@ -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);
};
@ -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;
};
@ -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;
};
@ -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);
};
@ -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;
};

View file

@ -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;
@ -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;
@ -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);
};
@ -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;
};
@ -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;
};
@ -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);
};
@ -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;
};

View file

@ -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 |
@ -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 |
@ -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 |
@ -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 |
@ -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 |
@ -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 |
@ -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 |

View file

@ -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;
};
@ -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();
}

View file

@ -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;
};
@ -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();
}

View file

@ -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 |
@ -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 };
| ^^^^^^^^^^^^^^^^^^^

View file

@ -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;
};
@ -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;

View file

@ -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;
};
@ -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;

View file

@ -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 |
@ -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 |

View file

@ -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;
@ -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;
@ -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);
};
@ -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;
};
@ -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;
};
@ -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;
};
@ -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);
};

View file

@ -24,7 +24,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;
let _t2 = t2.0;
@ -42,7 +42,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;
@ -58,7 +58,7 @@ fn test3_only_by_value_need_migration() {
let t1 = (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;
println!("{:?}", t1.1);
};
@ -75,7 +75,7 @@ fn test4_type_contains_drop_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;
};
@ -90,7 +90,7 @@ fn test5_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;
};
@ -103,7 +103,7 @@ fn test6_significant_insignificant_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.1;
};
@ -118,7 +118,7 @@ fn test7_move_closures_non_copy_types_might_need_migration() {
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);
};

View file

@ -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 |
@ -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 |
@ -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 |
@ -82,7 +82,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 |
@ -102,7 +102,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 |
@ -122,7 +122,7 @@ LL | | let _t = t.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 |
@ -142,7 +142,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 |