Skip to content

Commit 8cbeaf7

Browse files
committed
Address comments
1 parent ca44372 commit 8cbeaf7

File tree

7 files changed

+15
-15
lines changed

7 files changed

+15
-15
lines changed

compiler/rustc_typeck/src/check/upvar.rs

+5-5
Original file line numberDiff line numberDiff line change
@@ -619,7 +619,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
619619
}
620620

621621
if auto_trait_reasons.len() > 0 && drop_reason {
622-
reasons = format!("{}, and ", reasons);
622+
reasons = format!("{} and ", reasons);
623623
}
624624

625625
if drop_reason {
@@ -886,12 +886,12 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
886886
};
887887

888888
// Combine all the captures responsible for needing migrations into one HashSet
889-
let mut capture_disagnostic = drop_reorder_diagnostic.clone();
889+
let mut capture_diagnostic = drop_reorder_diagnostic.clone();
890890
for key in auto_trait_diagnostic.keys() {
891-
capture_disagnostic.insert(key.clone());
891+
capture_diagnostic.insert(key.clone());
892892
}
893893

894-
for captured_info in capture_disagnostic.iter() {
894+
for captured_info in capture_diagnostic.iter() {
895895
// Get the auto trait reasons of why migration is needed because of that capture, if there are any
896896
let capture_trait_reasons =
897897
if let Some(reasons) = auto_trait_diagnostic.get(captured_info) {
@@ -917,7 +917,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
917917
));
918918
}
919919

920-
if capture_disagnostic.len() > 0 {
920+
if capture_diagnostic.len() > 0 {
921921
need_migrations.push((var_hir_id, responsible_captured_hir_ids));
922922
}
923923
}

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

+1-1
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ impl Clone for U {
5656
fn test_clone_trait() {
5757
let f = U(S(String::from("Hello World")), T(0));
5858
let c = || { let _ = &f;
59-
//~^ ERROR: `Clone` trait implementation for closure, and drop order
59+
//~^ ERROR: `Clone` trait implementation for closure and drop order
6060
//~| 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`
6161
//~| NOTE: for more information, see
6262
//~| HELP: add a dummy let to cause `f` to be fully captured

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

+1-1
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ impl Clone for U {
5656
fn test_clone_trait() {
5757
let f = U(S(String::from("Hello World")), T(0));
5858
let c = || {
59-
//~^ ERROR: `Clone` trait implementation for closure, and drop order
59+
//~^ ERROR: `Clone` trait implementation for closure and drop order
6060
//~| 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`
6161
//~| NOTE: for more information, see
6262
//~| HELP: add a dummy let to cause `f` to be fully captured

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

+1-1
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ LL |
4343
LL | *fptr.0.0 = 20;
4444
...
4545

46-
error: changes to closure capture in Rust 2021 will affect `Clone` trait implementation for closure, and drop order
46+
error: changes to closure capture in Rust 2021 will affect `Clone` trait implementation for closure and drop order
4747
--> $DIR/auto_traits.rs:58:13
4848
|
4949
LL | let c = || {

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

+2-2
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ fn test_multi_issues() {
2121
let f1 = U(S(String::from("foo")), T(0));
2222
let f2 = U(S(String::from("bar")), T(0));
2323
let c = || { let _ = (&f1, &f2);
24-
//~^ ERROR: `Clone` trait implementation for closure, and drop order
24+
//~^ ERROR: `Clone` trait implementation for closure and drop order
2525
//~| 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`
2626
//~| NOTE: for more information, see
2727
//~| 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() {
8484
fn test_capturing_several_disjoint_fields_individually_2() {
8585
let f1 = U1(S(String::from("foo")), T(0), S(String::from("bar")));
8686
let c = || { let _ = &f1;
87-
//~^ ERROR: `Clone` trait implementation for closure, and drop order
87+
//~^ ERROR: `Clone` trait implementation for closure and drop order
8888
//~| 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`
8989
//~| NOTE: for more information, see
9090
//~| HELP: add a dummy let to cause `f1` to be fully captured

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

+2-2
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ fn test_multi_issues() {
2121
let f1 = U(S(String::from("foo")), T(0));
2222
let f2 = U(S(String::from("bar")), T(0));
2323
let c = || {
24-
//~^ ERROR: `Clone` trait implementation for closure, and drop order
24+
//~^ ERROR: `Clone` trait implementation for closure and drop order
2525
//~| 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`
2626
//~| NOTE: for more information, see
2727
//~| 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() {
8484
fn test_capturing_several_disjoint_fields_individually_2() {
8585
let f1 = U1(S(String::from("foo")), T(0), S(String::from("bar")));
8686
let c = || {
87-
//~^ ERROR: `Clone` trait implementation for closure, and drop order
87+
//~^ ERROR: `Clone` trait implementation for closure and drop order
8888
//~| 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`
8989
//~| NOTE: for more information, see
9090
//~| HELP: add a dummy let to cause `f1` to be fully captured

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

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
error: changes to closure capture in Rust 2021 will affect `Clone` trait implementation for closure, and drop order
1+
error: changes to closure capture in Rust 2021 will affect `Clone` trait implementation for closure and drop order
22
--> $DIR/multi_diagnostics.rs:23:13
33
|
44
LL | let c = || {
@@ -75,7 +75,7 @@ LL |
7575
LL |
7676
...
7777

78-
error: changes to closure capture in Rust 2021 will affect `Clone` trait implementation for closure, and drop order
78+
error: changes to closure capture in Rust 2021 will affect `Clone` trait implementation for closure and drop order
7979
--> $DIR/multi_diagnostics.rs:86:13
8080
|
8181
LL | let c = || {
@@ -90,8 +90,8 @@ LL | let _f_1 = f1.1;
9090
LL | }
9191
| -
9292
| |
93-
| in Rust 2018, `f1` would be dropped here, but in Rust 2021, only `f1.0` would be dropped here alongside the closure
9493
| in Rust 2018, `f1` would be dropped here, but in Rust 2021, only `f1.1` would be dropped here alongside the closure
94+
| in Rust 2018, `f1` would be dropped here, but in Rust 2021, only `f1.0` would be dropped here alongside the closure
9595
|
9696
= note: for more information, see <https://doc.rust-lang.org/nightly/edition-guide/rust-2021/disjoint-capture-in-closures.html>
9797
help: add a dummy let to cause `f1` to be fully captured

0 commit comments

Comments
 (0)