Skip to content

Commit 2db4533

Browse files
committed
Update tests for new closure migration lint wording.
1 parent fa7bf88 commit 2db4533

27 files changed

+280
-280
lines changed

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

+7-7
Original file line numberDiff line numberDiff line change
@@ -13,11 +13,11 @@ fn test_send_trait() {
1313
let fptr = SendPointer(&mut f as *mut i32);
1414
thread::spawn(move || { let _ = &fptr; unsafe {
1515
//~^ ERROR: `Send` trait implementation for closure
16-
//~| NOTE: in Rust 2018, this closure would implement `Send` as `fptr` implements `Send`, but in Rust 2021, this closure would no longer implement `Send` as `fptr.0` does not implement `Send`
16+
//~| NOTE: in Rust 2018, this closure implements `Send` as `fptr` implements `Send`, but in Rust 2021, this closure will no longer implement `Send` as `fptr.0` does not implement `Send`
1717
//~| NOTE: for more information, see
1818
//~| HELP: add a dummy let to cause `fptr` to be fully captured
1919
*fptr.0 = 20;
20-
//~^ NOTE: in Rust 2018, closure captures all of `fptr`, but in Rust 2021, it only captures `fptr.0`
20+
//~^ NOTE: in Rust 2018, this closure captures all of `fptr`, but in Rust 2021, it will only capture `fptr.0`
2121
} });
2222
}
2323

@@ -33,11 +33,11 @@ fn test_sync_trait() {
3333
let fptr = SyncPointer(f);
3434
thread::spawn(move || { let _ = &fptr; unsafe {
3535
//~^ ERROR: `Sync`, `Send` trait implementation for closure
36-
//~| NOTE: in Rust 2018, this closure would implement `Sync`, `Send` as `fptr` implements `Sync`, `Send`, but in Rust 2021, this closure would no longer implement `Sync`, `Send` as `fptr.0.0` does not implement `Sync`, `Send`
36+
//~| NOTE: in Rust 2018, this closure implements `Sync`, `Send` as `fptr` implements `Sync`, `Send`, but in Rust 2021, this closure will no longer implement `Sync`, `Send` as `fptr.0.0` does not implement `Sync`, `Send`
3737
//~| NOTE: for more information, see
3838
//~| HELP: add a dummy let to cause `fptr` to be fully captured
3939
*fptr.0.0 = 20;
40-
//~^ NOTE: in Rust 2018, closure captures all of `fptr`, but in Rust 2021, it only captures `fptr.0.0`
40+
//~^ NOTE: in Rust 2018, this closure captures all of `fptr`, but in Rust 2021, it will only capture `fptr.0.0`
4141
} });
4242
}
4343

@@ -58,19 +58,19 @@ fn test_clone_trait() {
5858
let c = || {
5959
let _ = &f;
6060
//~^ ERROR: `Clone` trait implementation for closure and drop order
61-
//~| 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`
61+
//~| NOTE: in Rust 2018, this closure implements `Clone` as `f` implements `Clone`, but in Rust 2021, this closure will no longer implement `Clone` as `f.1` does not implement `Clone`
6262
//~| NOTE: for more information, see
6363
//~| HELP: add a dummy let to cause `f` to be fully captured
6464
let f_1 = f.1;
65-
//~^ NOTE: in Rust 2018, closure captures all of `f`, but in Rust 2021, it only captures `f.1`
65+
//~^ NOTE: in Rust 2018, this closure captures all of `f`, but in Rust 2021, it will only capture `f.1`
6666
println!("{:?}", f_1.0);
6767
};
6868

6969
let c_clone = c.clone();
7070

7171
c_clone();
7272
}
73-
//~^ NOTE: in Rust 2018, `f` would be dropped here, but in Rust 2021, only `f.1` would be dropped here alongside the closure
73+
//~^ NOTE: in Rust 2018, `f` is dropped here, but in Rust 2021, only `f.1` will be dropped here as part of the closure
7474

7575
fn main() {
7676
test_send_trait();

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

+7-7
Original file line numberDiff line numberDiff line change
@@ -13,11 +13,11 @@ fn test_send_trait() {
1313
let fptr = SendPointer(&mut f as *mut i32);
1414
thread::spawn(move || unsafe {
1515
//~^ ERROR: `Send` trait implementation for closure
16-
//~| NOTE: in Rust 2018, this closure would implement `Send` as `fptr` implements `Send`, but in Rust 2021, this closure would no longer implement `Send` as `fptr.0` does not implement `Send`
16+
//~| NOTE: in Rust 2018, this closure implements `Send` as `fptr` implements `Send`, but in Rust 2021, this closure will no longer implement `Send` as `fptr.0` does not implement `Send`
1717
//~| NOTE: for more information, see
1818
//~| HELP: add a dummy let to cause `fptr` to be fully captured
1919
*fptr.0 = 20;
20-
//~^ NOTE: in Rust 2018, closure captures all of `fptr`, but in Rust 2021, it only captures `fptr.0`
20+
//~^ NOTE: in Rust 2018, this closure captures all of `fptr`, but in Rust 2021, it will only capture `fptr.0`
2121
});
2222
}
2323

@@ -33,11 +33,11 @@ fn test_sync_trait() {
3333
let fptr = SyncPointer(f);
3434
thread::spawn(move || unsafe {
3535
//~^ ERROR: `Sync`, `Send` trait implementation for closure
36-
//~| NOTE: in Rust 2018, this closure would implement `Sync`, `Send` as `fptr` implements `Sync`, `Send`, but in Rust 2021, this closure would no longer implement `Sync`, `Send` as `fptr.0.0` does not implement `Sync`, `Send`
36+
//~| NOTE: in Rust 2018, this closure implements `Sync`, `Send` as `fptr` implements `Sync`, `Send`, but in Rust 2021, this closure will no longer implement `Sync`, `Send` as `fptr.0.0` does not implement `Sync`, `Send`
3737
//~| NOTE: for more information, see
3838
//~| HELP: add a dummy let to cause `fptr` to be fully captured
3939
*fptr.0.0 = 20;
40-
//~^ NOTE: in Rust 2018, closure captures all of `fptr`, but in Rust 2021, it only captures `fptr.0.0`
40+
//~^ NOTE: in Rust 2018, this closure captures all of `fptr`, but in Rust 2021, it will only capture `fptr.0.0`
4141
});
4242
}
4343

@@ -57,19 +57,19 @@ fn test_clone_trait() {
5757
let f = U(S(String::from("Hello World")), T(0));
5858
let c = || {
5959
//~^ ERROR: `Clone` trait implementation for closure and drop order
60-
//~| 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`
60+
//~| NOTE: in Rust 2018, this closure implements `Clone` as `f` implements `Clone`, but in Rust 2021, this closure will 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
6363
let f_1 = f.1;
64-
//~^ NOTE: in Rust 2018, closure captures all of `f`, but in Rust 2021, it only captures `f.1`
64+
//~^ NOTE: in Rust 2018, this closure captures all of `f`, but in Rust 2021, it will only capture `f.1`
6565
println!("{:?}", f_1.0);
6666
};
6767

6868
let c_clone = c.clone();
6969

7070
c_clone();
7171
}
72-
//~^ NOTE: in Rust 2018, `f` would be dropped here, but in Rust 2021, only `f.1` would be dropped here alongside the closure
72+
//~^ NOTE: in Rust 2018, `f` is dropped here, but in Rust 2021, only `f.1` will be dropped here as part of the closure
7373

7474
fn main() {
7575
test_send_trait();

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

+7-7
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,10 @@ error: changes to closure capture in Rust 2021 will affect `Send` trait implemen
22
--> $DIR/auto_traits.rs:14:19
33
|
44
LL | thread::spawn(move || unsafe {
5-
| ^^^^^^^^^^^^^^ in Rust 2018, this closure would implement `Send` as `fptr` implements `Send`, but in Rust 2021, this closure would no longer implement `Send` as `fptr.0` does not implement `Send`
5+
| ^^^^^^^^^^^^^^ in Rust 2018, this closure implements `Send` as `fptr` implements `Send`, but in Rust 2021, this closure will no longer implement `Send` as `fptr.0` does not implement `Send`
66
...
77
LL | *fptr.0 = 20;
8-
| ------- in Rust 2018, closure captures all of `fptr`, but in Rust 2021, it only captures `fptr.0`
8+
| ------- in Rust 2018, this closure captures all of `fptr`, but in Rust 2021, it will only capture `fptr.0`
99
|
1010
note: the lint level is defined here
1111
--> $DIR/auto_traits.rs:2:9
@@ -27,10 +27,10 @@ error: changes to closure capture in Rust 2021 will affect `Sync`, `Send` trait
2727
--> $DIR/auto_traits.rs:34:19
2828
|
2929
LL | thread::spawn(move || unsafe {
30-
| ^^^^^^^^^^^^^^ in Rust 2018, this closure would implement `Sync`, `Send` as `fptr` implements `Sync`, `Send`, but in Rust 2021, this closure would no longer implement `Sync`, `Send` as `fptr.0.0` does not implement `Sync`, `Send`
30+
| ^^^^^^^^^^^^^^ in Rust 2018, this closure implements `Sync`, `Send` as `fptr` implements `Sync`, `Send`, but in Rust 2021, this closure will no longer implement `Sync`, `Send` as `fptr.0.0` does not implement `Sync`, `Send`
3131
...
3232
LL | *fptr.0.0 = 20;
33-
| --------- in Rust 2018, closure captures all of `fptr`, but in Rust 2021, it only captures `fptr.0.0`
33+
| --------- in Rust 2018, this closure captures all of `fptr`, but in Rust 2021, it will only capture `fptr.0.0`
3434
|
3535
= note: for more information, see <https://doc.rust-lang.org/nightly/edition-guide/rust-2021/disjoint-capture-in-closures.html>
3636
help: add a dummy let to cause `fptr` to be fully captured
@@ -47,13 +47,13 @@ error: changes to closure capture in Rust 2021 will affect `Clone` trait impleme
4747
--> $DIR/auto_traits.rs:58:13
4848
|
4949
LL | let c = || {
50-
| ^^ 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`
50+
| ^^ in Rust 2018, this closure implements `Clone` as `f` implements `Clone`, but in Rust 2021, this closure will no longer implement `Clone` as `f.1` does not implement `Clone`
5151
...
5252
LL | let f_1 = f.1;
53-
| --- in Rust 2018, closure captures all of `f`, but in Rust 2021, it only captures `f.1`
53+
| --- in Rust 2018, this closure captures all of `f`, but in Rust 2021, it will only capture `f.1`
5454
...
5555
LL | }
56-
| - in Rust 2018, `f` would be dropped here, but in Rust 2021, only `f.1` would be dropped here alongside the closure
56+
| - in Rust 2018, `f` is dropped here, but in Rust 2021, only `f.1` will be dropped here as part of the closure
5757
|
5858
= note: for more information, see <https://doc.rust-lang.org/nightly/edition-guide/rust-2021/disjoint-capture-in-closures.html>
5959
help: add a dummy let to cause `f` to be fully captured

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

+22-22
Original file line numberDiff line numberDiff line change
@@ -19,18 +19,18 @@ fn test1_all_need_migration() {
1919
//~| HELP: add a dummy let to cause `t`, `t1`, `t2` to be fully captured
2020

2121
let _t = t.0;
22-
//~^ NOTE: in Rust 2018, closure captures all of `t`, but in Rust 2021, it only captures `t.0`
22+
//~^ NOTE: in Rust 2018, this closure captures all of `t`, but in Rust 2021, it will only capture `t.0`
2323
let _t1 = t1.0;
24-
//~^ NOTE: in Rust 2018, closure captures all of `t1`, but in Rust 2021, it only captures `t1.0`
24+
//~^ NOTE: in Rust 2018, this closure captures all of `t1`, but in Rust 2021, it will only capture `t1.0`
2525
let _t2 = t2.0;
26-
//~^ NOTE: in Rust 2018, closure captures all of `t2`, but in Rust 2021, it only captures `t2.0`
26+
//~^ NOTE: in Rust 2018, this closure captures all of `t2`, but in Rust 2021, it will only capture `t2.0`
2727
};
2828

2929
c();
3030
}
31-
//~^ in Rust 2018, `t` would be dropped here, but in Rust 2021, only `t.0` would be dropped here alongside the closure
32-
//~| in Rust 2018, `t1` would be dropped here, but in Rust 2021, only `t1.0` would be dropped here alongside the closure
33-
//~| in Rust 2018, `t2` would be dropped here, but in Rust 2021, only `t2.0` would be dropped here alongside the closure
31+
//~^ in Rust 2018, `t` is dropped here, but in Rust 2021, only `t.0` will be dropped here as part of the closure
32+
//~| in Rust 2018, `t1` is dropped here, but in Rust 2021, only `t1.0` will be dropped here as part of the closure
33+
//~| in Rust 2018, `t2` is dropped here, but in Rust 2021, only `t2.0` will be dropped here as part of the closure
3434

3535
// String implements drop and therefore should be migrated.
3636
// But in this test cases, `t2` is completely captured and when it is dropped won't be affected
@@ -45,16 +45,16 @@ fn test2_only_precise_paths_need_migration() {
4545
//~| NOTE: for more information, see
4646
//~| HELP: add a dummy let to cause `t`, `t1` to be fully captured
4747
let _t = t.0;
48-
//~^ NOTE: in Rust 2018, closure captures all of `t`, but in Rust 2021, it only captures `t.0`
48+
//~^ NOTE: in Rust 2018, this closure captures all of `t`, but in Rust 2021, it will only capture `t.0`
4949
let _t1 = t1.0;
50-
//~^ NOTE: in Rust 2018, closure captures all of `t1`, but in Rust 2021, it only captures `t1.0`
50+
//~^ NOTE: in Rust 2018, this closure captures all of `t1`, but in Rust 2021, it will only capture `t1.0`
5151
let _t2 = t2;
5252
};
5353

5454
c();
5555
}
56-
//~^ in Rust 2018, `t` would be dropped here, but in Rust 2021, only `t.0` would be dropped here alongside the closure
57-
//~| in Rust 2018, `t1` would be dropped here, but in Rust 2021, only `t1.0` would be dropped here alongside the closure
56+
//~^ in Rust 2018, `t` is dropped here, but in Rust 2021, only `t.0` will be dropped here as part of the closure
57+
//~| in Rust 2018, `t1` is dropped here, but in Rust 2021, only `t1.0` will be dropped here as part of the closure
5858

5959
// If a variable would've not been captured by value then it would've not been
6060
// dropped with the closure and therefore doesn't need migration.
@@ -67,13 +67,13 @@ fn test3_only_by_value_need_migration() {
6767
//~| NOTE: for more information, see
6868
//~| HELP: add a dummy let to cause `t` to be fully captured
6969
let _t = t.0;
70-
//~^ NOTE: in Rust 2018, closure captures all of `t`, but in Rust 2021, it only captures `t.0`
70+
//~^ NOTE: in Rust 2018, this closure captures all of `t`, but in Rust 2021, it will only capture `t.0`
7171
println!("{}", t1.1);
7272
};
7373

7474
c();
7575
}
76-
//~^ in Rust 2018, `t` would be dropped here, but in Rust 2021, only `t.0` would be dropped here alongside the closure
76+
//~^ in Rust 2018, `t` is dropped here, but in Rust 2021, only `t.0` will be dropped here as part of the closure
7777

7878
// Copy types get copied into the closure instead of move. Therefore we don't need to
7979
// migrate then as their drop order isn't tied to the closure.
@@ -89,13 +89,13 @@ fn test4_only_non_copy_types_need_migration() {
8989
//~| NOTE: for more information, see
9090
//~| HELP: add a dummy let to cause `t` to be fully captured
9191
let _t = t.0;
92-
//~^ NOTE: in Rust 2018, closure captures all of `t`, but in Rust 2021, it only captures `t.0`
92+
//~^ NOTE: in Rust 2018, this closure captures all of `t`, but in Rust 2021, it will only capture `t.0`
9393
let _t1 = t1.0;
9494
};
9595

9696
c();
9797
}
98-
//~^ in Rust 2018, `t` would be dropped here, but in Rust 2021, only `t.0` would be dropped here alongside the closure
98+
//~^ in Rust 2018, `t` is dropped here, but in Rust 2021, only `t.0` will be dropped here as part of the closure
9999

100100
fn test5_only_drop_types_need_migration() {
101101
struct S(i32, i32);
@@ -111,13 +111,13 @@ fn test5_only_drop_types_need_migration() {
111111
//~| NOTE: for more information, see
112112
//~| HELP: add a dummy let to cause `t` to be fully captured
113113
let _t = t.0;
114-
//~^ NOTE: in Rust 2018, closure captures all of `t`, but in Rust 2021, it only captures `t.0`
114+
//~^ NOTE: in Rust 2018, this closure captures all of `t`, but in Rust 2021, it will only capture `t.0`
115115
let _s = s.0;
116116
};
117117

118118
c();
119119
}
120-
//~^ in Rust 2018, `t` would be dropped here, but in Rust 2021, only `t.0` would be dropped here alongside the closure
120+
//~^ in Rust 2018, `t` is dropped here, but in Rust 2021, only `t.0` will be dropped here as part of the closure
121121

122122
// Since we are using a move closure here, both `t` and `t1` get moved
123123
// even though they are being used by ref inside the closure.
@@ -130,14 +130,14 @@ fn test6_move_closures_non_copy_types_might_need_migration() {
130130
//~| NOTE: for more information, see
131131
//~| HELP: add a dummy let to cause `t1`, `t` to be fully captured
132132
println!("{} {}", t1.1, t.1);
133-
//~^ NOTE: in Rust 2018, closure captures all of `t`, but in Rust 2021, it only captures `t.1`
134-
//~| NOTE: in Rust 2018, closure captures all of `t1`, but in Rust 2021, it only captures `t1.1`
133+
//~^ NOTE: in Rust 2018, this closure captures all of `t`, but in Rust 2021, it will only capture `t.1`
134+
//~| NOTE: in Rust 2018, this closure captures all of `t1`, but in Rust 2021, it will only capture `t1.1`
135135
};
136136

137137
c();
138138
}
139-
//~^ in Rust 2018, `t` would be dropped here, but in Rust 2021, only `t.1` would be dropped here alongside the closure
140-
//~| in Rust 2018, `t1` would be dropped here, but in Rust 2021, only `t1.1` would be dropped here alongside the closure
139+
//~^ in Rust 2018, `t` is dropped here, but in Rust 2021, only `t.1` will be dropped here as part of the closure
140+
//~| in Rust 2018, `t1` is dropped here, but in Rust 2021, only `t1.1` will be dropped here as part of the closure
141141

142142
// Test migration analysis in case of Drop + Non Drop aggregates.
143143
// Note we need migration here only because the non-copy (because Drop type) is captured,
@@ -151,12 +151,12 @@ fn test7_drop_non_drop_aggregate_need_migration() {
151151
//~| NOTE: for more information, see
152152
//~| HELP: add a dummy let to cause `t` to be fully captured
153153
let _t = t.0;
154-
//~^ NOTE: in Rust 2018, closure captures all of `t`, but in Rust 2021, it only captures `t.0`
154+
//~^ NOTE: in Rust 2018, this closure captures all of `t`, but in Rust 2021, it will only capture `t.0`
155155
};
156156

157157
c();
158158
}
159-
//~^ in Rust 2018, `t` would be dropped here, but in Rust 2021, only `t.0` would be dropped here alongside the closure
159+
//~^ in Rust 2018, `t` is dropped here, but in Rust 2021, only `t.0` will be dropped here as part of the closure
160160

161161
fn main() {
162162
test1_all_need_migration();

0 commit comments

Comments
 (0)