diff --git a/compiler/rustc_typeck/src/check/upvar.rs b/compiler/rustc_typeck/src/check/upvar.rs index 542d9a58e8aed..04a9e65e6647d 100644 --- a/compiler/rustc_typeck/src/check/upvar.rs +++ b/compiler/rustc_typeck/src/check/upvar.rs @@ -1270,7 +1270,7 @@ fn migration_suggestion_for_2229(tcx: TyCtxt<'_>, need_migrations: &Vec>(); let migrations_list_concat = need_migrations_strings.join(", "); - format!("let ({}) = ({});", migrations_list_concat, migrations_list_concat) + format!("drop(&({}));", migrations_list_concat) } /// Helper function to determine if we need to escalate CaptureKind from diff --git a/src/test/ui/closures/2229_closure_analysis/migrations/insignificant_drop.rs b/src/test/ui/closures/2229_closure_analysis/migrations/insignificant_drop.rs index 5b5092e9db9a4..02b373620966e 100644 --- a/src/test/ui/closures/2229_closure_analysis/migrations/insignificant_drop.rs +++ b/src/test/ui/closures/2229_closure_analysis/migrations/insignificant_drop.rs @@ -12,7 +12,7 @@ fn test1_all_need_migration() { let c = || { //~^ERROR: drop order affected for closure because of `capture_disjoint_fields` - //~| NOTE: let (t, t1, t2) = (t, t1, t2); + //~| NOTE: drop(&(t, t1, t2)); let _t = t.0; let _t1 = t1.0; let _t2 = t2.0; @@ -30,7 +30,7 @@ fn test2_only_precise_paths_need_migration() { let c = || { //~^ERROR: drop order affected for closure because of `capture_disjoint_fields` - //~| NOTE: let (t, t1) = (t, t1); + //~| NOTE: drop(&(t, t1)); let _t = t.0; let _t1 = t1.0; let _t2 = t2; @@ -46,7 +46,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` - //~| NOTE: let (t) = (t); + //~| NOTE: drop(&(t)); let _t = t.0; println!("{}", t1.1); }; @@ -64,7 +64,7 @@ fn test4_only_non_copy_types_need_migration() { let c = || { //~^ERROR: drop order affected for closure because of `capture_disjoint_fields` - //~| NOTE: let (t) = (t); + //~| NOTE: drop(&(t)); let _t = t.0; let _t1 = t1.0; }; @@ -82,7 +82,7 @@ fn test5_only_drop_types_need_migration() { let c = || { //~^ERROR: drop order affected for closure because of `capture_disjoint_fields` - //~| NOTE: let (t) = (t); + //~| NOTE: drop(&(t)); let _t = t.0; let _s = s.0; }; @@ -97,7 +97,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` - //~| NOTE: let (t1, t) = (t1, t); + //~| NOTE: drop(&(t1, t)); println!("{} {}", t1.1, t.1); }; @@ -112,7 +112,7 @@ fn test7_drop_non_drop_aggregate_need_migration() { let c = || { //~^ERROR: drop order affected for closure because of `capture_disjoint_fields` - //~| NOTE: let (t) = (t); + //~| NOTE: drop(&(t)); let _t = t.0; }; diff --git a/src/test/ui/closures/2229_closure_analysis/migrations/insignificant_drop.stderr b/src/test/ui/closures/2229_closure_analysis/migrations/insignificant_drop.stderr index 8b35105cf8258..656c132c12dee 100644 --- a/src/test/ui/closures/2229_closure_analysis/migrations/insignificant_drop.stderr +++ b/src/test/ui/closures/2229_closure_analysis/migrations/insignificant_drop.stderr @@ -16,7 +16,7 @@ note: the lint level is defined here | LL | #![deny(disjoint_capture_drop_reorder)] | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - = note: let (t, t1, t2) = (t, t1, t2); + = note: drop(&(t, t1, t2)); error: drop order affected for closure because of `capture_disjoint_fields` --> $DIR/insignificant_drop.rs:31:13 @@ -31,7 +31,7 @@ LL | | let _t2 = t2; LL | | }; | |_____^ | - = note: let (t, t1) = (t, t1); + = note: drop(&(t, t1)); error: drop order affected for closure because of `capture_disjoint_fields` --> $DIR/insignificant_drop.rs:47:13 @@ -45,7 +45,7 @@ LL | | println!("{}", t1.1); LL | | }; | |_____^ | - = note: let (t) = (t); + = note: drop(&(t)); error: drop order affected for closure because of `capture_disjoint_fields` --> $DIR/insignificant_drop.rs:65:13 @@ -59,7 +59,7 @@ LL | | let _t1 = t1.0; LL | | }; | |_____^ | - = note: let (t) = (t); + = note: drop(&(t)); error: drop order affected for closure because of `capture_disjoint_fields` --> $DIR/insignificant_drop.rs:83:13 @@ -73,7 +73,7 @@ LL | | let _s = s.0; LL | | }; | |_____^ | - = note: let (t) = (t); + = note: drop(&(t)); error: drop order affected for closure because of `capture_disjoint_fields` --> $DIR/insignificant_drop.rs:98:13 @@ -86,7 +86,7 @@ LL | | println!("{} {}", t1.1, t.1); LL | | }; | |_____^ | - = note: let (t1, t) = (t1, t); + = note: drop(&(t1, t)); error: drop order affected for closure because of `capture_disjoint_fields` --> $DIR/insignificant_drop.rs:113:13 @@ -99,7 +99,7 @@ LL | | let _t = t.0; LL | | }; | |_____^ | - = note: let (t) = (t); + = note: drop(&(t)); error: aborting due to 7 previous errors diff --git a/src/test/ui/closures/2229_closure_analysis/migrations/significant_drop.rs b/src/test/ui/closures/2229_closure_analysis/migrations/significant_drop.rs index 25b5539b86289..ed5e4ea8be011 100644 --- a/src/test/ui/closures/2229_closure_analysis/migrations/significant_drop.rs +++ b/src/test/ui/closures/2229_closure_analysis/migrations/significant_drop.rs @@ -23,7 +23,7 @@ fn test1_all_need_migration() { let c = || { //~^ERROR: drop order affected for closure because of `capture_disjoint_fields` - //~| NOTE: let (t, t1, t2) = (t, t1, t2); + //~| NOTE: drop(&(t, t1, t2)); let _t = t.0; let _t1 = t1.0; let _t2 = t2.0; @@ -41,7 +41,7 @@ fn test2_only_precise_paths_need_migration() { let c = || { //~^ERROR: drop order affected for closure because of `capture_disjoint_fields` - //~| NOTE: let (t, t1) = (t, t1); + //~| NOTE: drop(&(t, t1)); let _t = t.0; let _t1 = t1.0; let _t2 = t2; @@ -57,7 +57,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` - //~| NOTE: let (t) = (t); + //~| NOTE: drop(&(t)); let _t = t.0; println!("{:?}", t1.1); }; @@ -74,7 +74,7 @@ fn test4_type_contains_drop_need_migration() { let c = || { //~^ERROR: drop order affected for closure because of `capture_disjoint_fields` - //~| NOTE: let (t) = (t); + //~| NOTE: drop(&(t)); let _t = t.0; }; @@ -89,7 +89,7 @@ fn test5_drop_non_drop_aggregate_need_migration() { let c = || { //~^ERROR: drop order affected for closure because of `capture_disjoint_fields` - //~| NOTE: let (t) = (t); + //~| NOTE: drop(&(t)); let _t = t.0; }; @@ -104,7 +104,7 @@ fn test6_significant_insignificant_drop_aggregate_need_migration() { let c = || { //~^ERROR: drop order affected for closure because of `capture_disjoint_fields` - //~| NOTE: let (t) = (t); + //~| NOTE: drop(&(t)); let _t = t.1; }; @@ -119,7 +119,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` - //~| NOTE: let (t1, t) = (t1, t); + //~| NOTE: drop(&(t1, t)); println!("{:?} {:?}", t1.1, t.1); }; diff --git a/src/test/ui/closures/2229_closure_analysis/migrations/significant_drop.stderr b/src/test/ui/closures/2229_closure_analysis/migrations/significant_drop.stderr index 52b6a628cc0ba..6c21b27b493ba 100644 --- a/src/test/ui/closures/2229_closure_analysis/migrations/significant_drop.stderr +++ b/src/test/ui/closures/2229_closure_analysis/migrations/significant_drop.stderr @@ -16,7 +16,7 @@ note: the lint level is defined here | LL | #![deny(disjoint_capture_drop_reorder)] | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - = note: let (t, t1, t2) = (t, t1, t2); + = note: drop(&(t, t1, t2)); error: drop order affected for closure because of `capture_disjoint_fields` --> $DIR/significant_drop.rs:42:13 @@ -31,7 +31,7 @@ LL | | let _t2 = t2; LL | | }; | |_____^ | - = note: let (t, t1) = (t, t1); + = note: drop(&(t, t1)); error: drop order affected for closure because of `capture_disjoint_fields` --> $DIR/significant_drop.rs:58:13 @@ -45,7 +45,7 @@ LL | | println!("{:?}", t1.1); LL | | }; | |_____^ | - = note: let (t) = (t); + = note: drop(&(t)); error: drop order affected for closure because of `capture_disjoint_fields` --> $DIR/significant_drop.rs:75:13 @@ -58,7 +58,7 @@ LL | | let _t = t.0; LL | | }; | |_____^ | - = note: let (t) = (t); + = note: drop(&(t)); error: drop order affected for closure because of `capture_disjoint_fields` --> $DIR/significant_drop.rs:90:13 @@ -71,7 +71,7 @@ LL | | let _t = t.0; LL | | }; | |_____^ | - = note: let (t) = (t); + = note: drop(&(t)); error: drop order affected for closure because of `capture_disjoint_fields` --> $DIR/significant_drop.rs:105:13 @@ -84,7 +84,7 @@ LL | | let _t = t.1; LL | | }; | |_____^ | - = note: let (t) = (t); + = note: drop(&(t)); error: drop order affected for closure because of `capture_disjoint_fields` --> $DIR/significant_drop.rs:120:13 @@ -97,7 +97,7 @@ LL | | println!("{:?} {:?}", t1.1, t.1); LL | | }; | |_____^ | - = note: let (t1, t) = (t1, t); + = note: drop(&(t1, t)); error: aborting due to 7 previous errors