From 8cbeaf738267c8ddb5ab205dae4404e2f25eeeeb Mon Sep 17 00:00:00 2001 From: Roxane Date: Fri, 9 Jul 2021 10:18:55 -0400 Subject: [PATCH] Address comments --- compiler/rustc_typeck/src/check/upvar.rs | 10 +++++----- .../2229_closure_analysis/migrations/auto_traits.fixed | 2 +- .../2229_closure_analysis/migrations/auto_traits.rs | 2 +- .../migrations/auto_traits.stderr | 2 +- .../migrations/multi_diagnostics.fixed | 4 ++-- .../migrations/multi_diagnostics.rs | 4 ++-- .../migrations/multi_diagnostics.stderr | 6 +++--- 7 files changed, 15 insertions(+), 15 deletions(-) diff --git a/compiler/rustc_typeck/src/check/upvar.rs b/compiler/rustc_typeck/src/check/upvar.rs index 2b82b4dff2e5..b6d1468b7a61 100644 --- a/compiler/rustc_typeck/src/check/upvar.rs +++ b/compiler/rustc_typeck/src/check/upvar.rs @@ -619,7 +619,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { } if auto_trait_reasons.len() > 0 && drop_reason { - reasons = format!("{}, and ", reasons); + reasons = format!("{} and ", reasons); } if drop_reason { @@ -886,12 +886,12 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { }; // Combine all the captures responsible for needing migrations into one HashSet - let mut capture_disagnostic = drop_reorder_diagnostic.clone(); + let mut capture_diagnostic = drop_reorder_diagnostic.clone(); for key in auto_trait_diagnostic.keys() { - capture_disagnostic.insert(key.clone()); + capture_diagnostic.insert(key.clone()); } - for captured_info in capture_disagnostic.iter() { + for captured_info in capture_diagnostic.iter() { // Get the auto trait reasons of why migration is needed because of that capture, if there are any let capture_trait_reasons = if let Some(reasons) = auto_trait_diagnostic.get(captured_info) { @@ -917,7 +917,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { )); } - if capture_disagnostic.len() > 0 { + if capture_diagnostic.len() > 0 { need_migrations.push((var_hir_id, responsible_captured_hir_ids)); } } diff --git a/src/test/ui/closures/2229_closure_analysis/migrations/auto_traits.fixed b/src/test/ui/closures/2229_closure_analysis/migrations/auto_traits.fixed index 42863b440fc1..e2b7b8f02752 100644 --- a/src/test/ui/closures/2229_closure_analysis/migrations/auto_traits.fixed +++ b/src/test/ui/closures/2229_closure_analysis/migrations/auto_traits.fixed @@ -56,7 +56,7 @@ impl Clone for U { fn test_clone_trait() { let f = U(S(String::from("Hello World")), T(0)); let c = || { let _ = &f; - //~^ ERROR: `Clone` trait implementation for closure, and drop order + //~^ ERROR: `Clone` trait implementation for closure and drop order //~| 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` //~| NOTE: for more information, see //~| HELP: add a dummy let to cause `f` to be fully captured diff --git a/src/test/ui/closures/2229_closure_analysis/migrations/auto_traits.rs b/src/test/ui/closures/2229_closure_analysis/migrations/auto_traits.rs index ae987f526d04..6c56ca27475a 100644 --- a/src/test/ui/closures/2229_closure_analysis/migrations/auto_traits.rs +++ b/src/test/ui/closures/2229_closure_analysis/migrations/auto_traits.rs @@ -56,7 +56,7 @@ impl Clone for U { fn test_clone_trait() { let f = U(S(String::from("Hello World")), T(0)); let c = || { - //~^ ERROR: `Clone` trait implementation for closure, and drop order + //~^ ERROR: `Clone` trait implementation for closure and drop order //~| 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` //~| NOTE: for more information, see //~| HELP: add a dummy let to cause `f` to be fully captured diff --git a/src/test/ui/closures/2229_closure_analysis/migrations/auto_traits.stderr b/src/test/ui/closures/2229_closure_analysis/migrations/auto_traits.stderr index 2af85852c01a..9c954b1465d8 100644 --- a/src/test/ui/closures/2229_closure_analysis/migrations/auto_traits.stderr +++ b/src/test/ui/closures/2229_closure_analysis/migrations/auto_traits.stderr @@ -43,7 +43,7 @@ LL | LL | *fptr.0.0 = 20; ... -error: changes to closure capture in Rust 2021 will affect `Clone` trait implementation for closure, and drop order +error: changes to closure capture in Rust 2021 will affect `Clone` trait implementation for closure and drop order --> $DIR/auto_traits.rs:58:13 | LL | let c = || { diff --git a/src/test/ui/closures/2229_closure_analysis/migrations/multi_diagnostics.fixed b/src/test/ui/closures/2229_closure_analysis/migrations/multi_diagnostics.fixed index e5102fee5887..98f578abc44d 100644 --- a/src/test/ui/closures/2229_closure_analysis/migrations/multi_diagnostics.fixed +++ b/src/test/ui/closures/2229_closure_analysis/migrations/multi_diagnostics.fixed @@ -21,7 +21,7 @@ fn test_multi_issues() { let f1 = U(S(String::from("foo")), T(0)); let f2 = U(S(String::from("bar")), T(0)); let c = || { let _ = (&f1, &f2); - //~^ ERROR: `Clone` trait implementation for closure, and drop order + //~^ ERROR: `Clone` trait implementation for closure and drop order //~| 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` //~| NOTE: for more information, see //~| HELP: add a dummy let to cause `f1`, `f2` to be fully captured @@ -84,7 +84,7 @@ fn test_capturing_several_disjoint_fields_individually_1() { fn test_capturing_several_disjoint_fields_individually_2() { let f1 = U1(S(String::from("foo")), T(0), S(String::from("bar"))); let c = || { let _ = &f1; - //~^ ERROR: `Clone` trait implementation for closure, and drop order + //~^ ERROR: `Clone` trait implementation for closure and drop order //~| 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` //~| NOTE: for more information, see //~| HELP: add a dummy let to cause `f1` to be fully captured diff --git a/src/test/ui/closures/2229_closure_analysis/migrations/multi_diagnostics.rs b/src/test/ui/closures/2229_closure_analysis/migrations/multi_diagnostics.rs index d05c0bc1bbce..1577b91c9601 100644 --- a/src/test/ui/closures/2229_closure_analysis/migrations/multi_diagnostics.rs +++ b/src/test/ui/closures/2229_closure_analysis/migrations/multi_diagnostics.rs @@ -21,7 +21,7 @@ fn test_multi_issues() { let f1 = U(S(String::from("foo")), T(0)); let f2 = U(S(String::from("bar")), T(0)); let c = || { - //~^ ERROR: `Clone` trait implementation for closure, and drop order + //~^ ERROR: `Clone` trait implementation for closure and drop order //~| 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` //~| NOTE: for more information, see //~| HELP: add a dummy let to cause `f1`, `f2` to be fully captured @@ -84,7 +84,7 @@ fn test_capturing_several_disjoint_fields_individually_1() { fn test_capturing_several_disjoint_fields_individually_2() { let f1 = U1(S(String::from("foo")), T(0), S(String::from("bar"))); let c = || { - //~^ ERROR: `Clone` trait implementation for closure, and drop order + //~^ ERROR: `Clone` trait implementation for closure and drop order //~| 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` //~| NOTE: for more information, see //~| HELP: add a dummy let to cause `f1` to be fully captured diff --git a/src/test/ui/closures/2229_closure_analysis/migrations/multi_diagnostics.stderr b/src/test/ui/closures/2229_closure_analysis/migrations/multi_diagnostics.stderr index 5f09230d45ca..856fbdf5f9fd 100644 --- a/src/test/ui/closures/2229_closure_analysis/migrations/multi_diagnostics.stderr +++ b/src/test/ui/closures/2229_closure_analysis/migrations/multi_diagnostics.stderr @@ -1,4 +1,4 @@ -error: changes to closure capture in Rust 2021 will affect `Clone` trait implementation for closure, and drop order +error: changes to closure capture in Rust 2021 will affect `Clone` trait implementation for closure and drop order --> $DIR/multi_diagnostics.rs:23:13 | LL | let c = || { @@ -75,7 +75,7 @@ LL | LL | ... -error: changes to closure capture in Rust 2021 will affect `Clone` trait implementation for closure, and drop order +error: changes to closure capture in Rust 2021 will affect `Clone` trait implementation for closure and drop order --> $DIR/multi_diagnostics.rs:86:13 | LL | let c = || { @@ -90,8 +90,8 @@ LL | let _f_1 = f1.1; LL | } | - | | - | in Rust 2018, `f1` would be dropped here, but in Rust 2021, only `f1.0` would be dropped here alongside the closure | in Rust 2018, `f1` would be dropped here, but in Rust 2021, only `f1.1` would be dropped here alongside the closure + | in Rust 2018, `f1` would be dropped here, but in Rust 2021, only `f1.0` would be dropped here alongside the closure | = note: for more information, see help: add a dummy let to cause `f1` to be fully captured