Skip to content

Commit fa341d8

Browse files
committed
Update tests for new closure migration lint wording.
1 parent 50e7510 commit fa341d8

24 files changed

+276
-276
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

@@ -57,19 +57,19 @@ fn test_clone_trait() {
5757
let f = U(S(String::from("Hello World")), T(0));
5858
let c = || { let _ = &f;
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.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
@@ -18,18 +18,18 @@ fn test1_all_need_migration() {
1818
//~| HELP: add a dummy let to cause `t`, `t1`, `t2` to be fully captured
1919

2020
let _t = t.0;
21-
//~^ NOTE: in Rust 2018, closure captures all of `t`, but in Rust 2021, it only captures `t.0`
21+
//~^ NOTE: in Rust 2018, this closure captures all of `t`, but in Rust 2021, it will only capture `t.0`
2222
let _t1 = t1.0;
23-
//~^ NOTE: in Rust 2018, closure captures all of `t1`, but in Rust 2021, it only captures `t1.0`
23+
//~^ NOTE: in Rust 2018, this closure captures all of `t1`, but in Rust 2021, it will only capture `t1.0`
2424
let _t2 = t2.0;
25-
//~^ NOTE: in Rust 2018, closure captures all of `t2`, but in Rust 2021, it only captures `t2.0`
25+
//~^ NOTE: in Rust 2018, this closure captures all of `t2`, but in Rust 2021, it will only capture `t2.0`
2626
};
2727

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

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

5252
c();
5353
}
54-
//~^ in Rust 2018, `t` would be dropped here, but in Rust 2021, only `t.0` would be dropped here alongside the closure
55-
//~| in Rust 2018, `t1` would be dropped here, but in Rust 2021, only `t1.0` would be dropped here alongside the closure
54+
//~^ in Rust 2018, `t` is dropped here, but in Rust 2021, only `t.0` will be dropped here as part of the closure
55+
//~| in Rust 2018, `t1` is dropped here, but in Rust 2021, only `t1.0` will be dropped here as part of the closure
5656

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

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

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

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

9696
fn test5_only_drop_types_need_migration() {
9797
struct S(i32, i32);
@@ -106,13 +106,13 @@ fn test5_only_drop_types_need_migration() {
106106
//~| NOTE: for more information, see
107107
//~| HELP: add a dummy let to cause `t` to be fully captured
108108
let _t = t.0;
109-
//~^ NOTE: in Rust 2018, closure captures all of `t`, but in Rust 2021, it only captures `t.0`
109+
//~^ NOTE: in Rust 2018, this closure captures all of `t`, but in Rust 2021, it will only capture `t.0`
110110
let _s = s.0;
111111
};
112112

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

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

131131
c();
132132
}
133-
//~^ in Rust 2018, `t` would be dropped here, but in Rust 2021, only `t.1` would be dropped here alongside the closure
134-
//~| in Rust 2018, `t1` would be dropped here, but in Rust 2021, only `t1.1` would be dropped here alongside the closure
133+
//~^ in Rust 2018, `t` is dropped here, but in Rust 2021, only `t.1` will be dropped here as part of the closure
134+
//~| in Rust 2018, `t1` is dropped here, but in Rust 2021, only `t1.1` will be dropped here as part of the closure
135135

136136
// Test migration analysis in case of Drop + Non Drop aggregates.
137137
// Note we need migration here only because the non-copy (because Drop type) is captured,
@@ -144,12 +144,12 @@ fn test7_drop_non_drop_aggregate_need_migration() {
144144
//~| NOTE: for more information, see
145145
//~| HELP: add a dummy let to cause `t` to be fully captured
146146
let _t = t.0;
147-
//~^ NOTE: in Rust 2018, closure captures all of `t`, but in Rust 2021, it only captures `t.0`
147+
//~^ NOTE: in Rust 2018, this closure captures all of `t`, but in Rust 2021, it will only capture `t.0`
148148
};
149149

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

154154
fn main() {
155155
test1_all_need_migration();

0 commit comments

Comments
 (0)