You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: src/test/ui/closures/2229_closure_analysis/migrations/auto_traits.fixed
+7-6
Original file line number
Diff line number
Diff line change
@@ -20,8 +20,8 @@ fn test_send_trait() {
20
20
let mut f = 10;
21
21
let fptr = SendPointer(&mut f as *mut i32);
22
22
thread::spawn(move || { let _ = &fptr; unsafe {
23
-
//~^ ERROR: `Send` trait implementation for closure
24
-
//~| 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`
23
+
//~^ ERROR: changes to closure capture
24
+
//~| NOTE: in Rust 2018, this closure implements `Send`
25
25
//~| NOTE: for more information, see
26
26
//~| HELP: add a dummy let to cause `fptr` to be fully captured
27
27
*fptr.0 = 20;
@@ -40,8 +40,9 @@ fn test_sync_trait() {
40
40
let f = CustomInt(&mut f as *mut i32);
41
41
let fptr = SyncPointer(f);
42
42
thread::spawn(move || { let _ = &fptr; unsafe {
43
-
//~^ ERROR: `Sync`, `Send` trait implementation for closure
44
-
//~| 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`
43
+
//~^ ERROR: changes to closure capture
44
+
//~| NOTE: in Rust 2018, this closure implements `Sync`
45
+
//~| NOTE: in Rust 2018, this closure implements `Send`
45
46
//~| NOTE: for more information, see
46
47
//~| HELP: add a dummy let to cause `fptr` to be fully captured
47
48
*fptr.0.0 = 20;
@@ -65,8 +66,8 @@ fn test_clone_trait() {
65
66
let f = U(S(Foo(0)), T(0));
66
67
let c = || {
67
68
let _ = &f;
68
-
//~^ ERROR: `Clone` trait implementation for closure and drop order
69
-
//~| 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`
69
+
//~^ ERROR: changes to closure capture in Rust 2021 will affect drop order and which traits the closure implements
70
+
//~| NOTE: in Rust 2018, this closure implements `Clone`
70
71
//~| NOTE: for more information, see
71
72
//~| HELP: add a dummy let to cause `f` to be fully captured
Copy file name to clipboardExpand all lines: src/test/ui/closures/2229_closure_analysis/migrations/auto_traits.rs
+7-6
Original file line number
Diff line number
Diff line change
@@ -20,8 +20,8 @@ fn test_send_trait() {
20
20
letmut f = 10;
21
21
let fptr = SendPointer(&mut f as*muti32);
22
22
thread::spawn(move || unsafe{
23
-
//~^ ERROR: `Send` trait implementation for closure
24
-
//~| 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`
23
+
//~^ ERROR: changes to closure capture
24
+
//~| NOTE: in Rust 2018, this closure implements `Send`
25
25
//~| NOTE: for more information, see
26
26
//~| HELP: add a dummy let to cause `fptr` to be fully captured
27
27
*fptr.0 = 20;
@@ -40,8 +40,9 @@ fn test_sync_trait() {
40
40
let f = CustomInt(&mut f as*muti32);
41
41
let fptr = SyncPointer(f);
42
42
thread::spawn(move || unsafe{
43
-
//~^ ERROR: `Sync`, `Send` trait implementation for closure
44
-
//~| 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`
43
+
//~^ ERROR: changes to closure capture
44
+
//~| NOTE: in Rust 2018, this closure implements `Sync`
45
+
//~| NOTE: in Rust 2018, this closure implements `Send`
45
46
//~| NOTE: for more information, see
46
47
//~| HELP: add a dummy let to cause `fptr` to be fully captured
47
48
*fptr.0.0 = 20;
@@ -64,8 +65,8 @@ impl Clone for U {
64
65
fntest_clone_trait(){
65
66
let f = U(S(Foo(0)),T(0));
66
67
let c = || {
67
-
//~^ ERROR: `Clone` trait implementation for closure and drop order
68
-
//~| 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`
68
+
//~^ ERROR: changes to closure capture in Rust 2021 will affect drop order and which traits the closure implements
69
+
//~| NOTE: in Rust 2018, this closure implements `Clone`
69
70
//~| NOTE: for more information, see
70
71
//~| HELP: add a dummy let to cause `f` to be fully captured
Copy file name to clipboardExpand all lines: src/test/ui/closures/2229_closure_analysis/migrations/auto_traits.stderr
+11-8
Original file line number
Diff line number
Diff line change
@@ -1,8 +1,8 @@
1
-
error: changes to closure capture in Rust 2021 will affect `Send` trait implementation for closure
1
+
error: changes to closure capture in Rust 2021 will affect which traits the closure implements
2
2
--> $DIR/auto_traits.rs:22:19
3
3
|
4
4
LL | thread::spawn(move || unsafe {
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`
5
+
| ^^^^^^^^^^^^^^ in Rust 2018, this closure implements `Send` as `fptr` implements `Send`, but in Rust 2021, this closure will no longer implement `Send` because `fptr` is not fully captured and `fptr.0` does not implement `Send`
6
6
...
7
7
LL | *fptr.0 = 20;
8
8
| ------- in Rust 2018, this closure captures all of `fptr`, but in Rust 2021, it will only capture `fptr.0`
@@ -23,11 +23,14 @@ LL |
23
23
LL | *fptr.0 = 20;
24
24
...
25
25
26
-
error: changes to closure capture in Rust 2021 will affect `Sync`, `Send` trait implementation for closure
26
+
error: changes to closure capture in Rust 2021 will affect which traits the closure implements
27
27
--> $DIR/auto_traits.rs:42:19
28
28
|
29
29
LL | thread::spawn(move || unsafe {
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`
30
+
| ^^^^^^^^^^^^^^
31
+
| |
32
+
| in Rust 2018, this closure implements `Sync` as `fptr` implements `Sync`, but in Rust 2021, this closure will no longer implement `Sync` because `fptr` is not fully captured and `fptr.0.0` does not implement `Sync`
33
+
| in Rust 2018, this closure implements `Send` as `fptr` implements `Send`, but in Rust 2021, this closure will no longer implement `Send` because `fptr` is not fully captured and `fptr.0.0` does not implement `Send`
31
34
...
32
35
LL | *fptr.0.0 = 20;
33
36
| --------- in Rust 2018, this closure captures all of `fptr`, but in Rust 2021, it will only capture `fptr.0.0`
@@ -40,14 +43,14 @@ LL |
40
43
LL |
41
44
LL |
42
45
LL |
43
-
LL | *fptr.0.0 = 20;
46
+
LL |
44
47
...
45
48
46
-
error: changes to closure capture in Rust 2021 will affect `Clone` trait implementation for closure and drop order
47
-
--> $DIR/auto_traits.rs:66:13
49
+
error: changes to closure capture in Rust 2021 will affect drop order and which traits the closure implements
50
+
--> $DIR/auto_traits.rs:67:13
48
51
|
49
52
LL | let c = || {
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`
53
+
| ^^ in Rust 2018, this closure implements `Clone` as `f` implements `Clone`, but in Rust 2021, this closure will no longer implement `Clone` because `f` is not fully captured and `f.1` does not implement `Clone`
51
54
...
52
55
LL | let f_1 = f.1;
53
56
| --- in Rust 2018, this closure captures all of `f`, but in Rust 2021, it will only capture `f.1`
Copy file name to clipboardExpand all lines: src/test/ui/closures/2229_closure_analysis/migrations/mir_calls_to_shims.fixed
+3-2
Original file line number
Diff line number
Diff line change
@@ -19,8 +19,9 @@ where
19
19
let f = panic::AssertUnwindSafe(f);
20
20
let result = panic::catch_unwind(move || {
21
21
let _ = &f;
22
-
//~^ ERROR: `UnwindSafe`, `RefUnwindSafe` trait implementation for closure
23
-
//~| NOTE: in Rust 2018, this closure implements `UnwindSafe`, `RefUnwindSafe` as `f` implements `UnwindSafe`, `RefUnwindSafe`, but in Rust 2021, this closure will no longer implement `UnwindSafe`, `RefUnwindSafe` as `f.0` does not implement `UnwindSafe`, `RefUnwindSafe`
22
+
//~^ ERROR: changes to closure capture in Rust 2021 will affect which traits the closure implements [rust_2021_incompatible_closure_captures]
23
+
//~| NOTE: in Rust 2018, this closure implements `UnwindSafe`
24
+
//~| NOTE: in Rust 2018, this closure implements `RefUnwindSafe`
24
25
//~| NOTE: for more information, see
25
26
//~| HELP: add a dummy let to cause `f` to be fully captured
Copy file name to clipboardExpand all lines: src/test/ui/closures/2229_closure_analysis/migrations/mir_calls_to_shims.rs
+3-2
Original file line number
Diff line number
Diff line change
@@ -18,8 +18,9 @@ where
18
18
{
19
19
let f = panic::AssertUnwindSafe(f);
20
20
let result = panic::catch_unwind(move || {
21
-
//~^ ERROR: `UnwindSafe`, `RefUnwindSafe` trait implementation for closure
22
-
//~| NOTE: in Rust 2018, this closure implements `UnwindSafe`, `RefUnwindSafe` as `f` implements `UnwindSafe`, `RefUnwindSafe`, but in Rust 2021, this closure will no longer implement `UnwindSafe`, `RefUnwindSafe` as `f.0` does not implement `UnwindSafe`, `RefUnwindSafe`
21
+
//~^ ERROR: changes to closure capture in Rust 2021 will affect which traits the closure implements [rust_2021_incompatible_closure_captures]
22
+
//~| NOTE: in Rust 2018, this closure implements `UnwindSafe`
23
+
//~| NOTE: in Rust 2018, this closure implements `RefUnwindSafe`
23
24
//~| NOTE: for more information, see
24
25
//~| HELP: add a dummy let to cause `f` to be fully captured
Copy file name to clipboardExpand all lines: src/test/ui/closures/2229_closure_analysis/migrations/mir_calls_to_shims.stderr
+5-2
Original file line number
Diff line number
Diff line change
@@ -1,8 +1,11 @@
1
-
error: changes to closure capture in Rust 2021 will affect `UnwindSafe`, `RefUnwindSafe` trait implementation for closure
1
+
error: changes to closure capture in Rust 2021 will affect which traits the closure implements
2
2
--> $DIR/mir_calls_to_shims.rs:20:38
3
3
|
4
4
LL | let result = panic::catch_unwind(move || {
5
-
| ^^^^^^^ in Rust 2018, this closure implements `UnwindSafe`, `RefUnwindSafe` as `f` implements `UnwindSafe`, `RefUnwindSafe`, but in Rust 2021, this closure will no longer implement `UnwindSafe`, `RefUnwindSafe` as `f.0` does not implement `UnwindSafe`, `RefUnwindSafe`
5
+
| ^^^^^^^
6
+
| |
7
+
| in Rust 2018, this closure implements `UnwindSafe` as `f` implements `UnwindSafe`, but in Rust 2021, this closure will no longer implement `UnwindSafe` because `f` is not fully captured and `f.0` does not implement `UnwindSafe`
8
+
| in Rust 2018, this closure implements `RefUnwindSafe` as `f` implements `RefUnwindSafe`, but in Rust 2021, this closure will no longer implement `RefUnwindSafe` because `f` is not fully captured and `f.0` does not implement `RefUnwindSafe`
6
9
...
7
10
LL | f.0()
8
11
| --- in Rust 2018, this closure captures all of `f`, but in Rust 2021, it will only capture `f.0`
Copy file name to clipboardExpand all lines: src/test/ui/closures/2229_closure_analysis/migrations/multi_diagnostics.fixed
+13-13
Original file line number
Diff line number
Diff line change
@@ -18,7 +18,6 @@ impl Foo {
18
18
}
19
19
}
20
20
21
-
22
21
struct S(Foo);
23
22
24
23
#[derive(Clone)]
@@ -37,8 +36,8 @@ fn test_multi_issues() {
37
36
let f2 = U(S(Foo::from("bar")), T(0));
38
37
let c = || {
39
38
let _ = (&f1, &f2);
40
-
//~^ ERROR: `Clone` trait implementation for closure and drop order
41
-
//~| NOTE: in Rust 2018, this closure implements `Clone` as `f1` implements `Clone`, but in Rust 2021, this closure will no longer implement `Clone` as `f1.0` does not implement `Clone`
39
+
//~^ ERROR: changes to closure capture in Rust 2021
40
+
//~| NOTE: in Rust 2018, this closure implements `Clone` as `f1` implements `Clone`
42
41
//~| NOTE: for more information, see
43
42
//~| HELP: add a dummy let to cause `f1`, `f2` to be fully captured
//~^ ERROR: `Clone` trait implementation for closure
61
-
//~| NOTE: in Rust 2018, this closure implements `Clone` as `f1` implements `Clone`, but in Rust 2021, this closure will no longer implement `Clone` as `f1.0` does not implement `Clone`
59
+
//~^ ERROR: changes to closure capture in Rust 2021 will affect which traits the closure implements [rust_2021_incompatible_closure_captures]
60
+
//~| NOTE: in Rust 2018, this closure implements `Clone` as `f1` implements `Clone`
62
61
//~| NOTE: for more information, see
63
62
//~| HELP: add a dummy let to cause `f1` to be fully captured
let f1 = U1(S(Foo::from("foo")), T(0), S(Foo::from("bar")));
84
83
let c = || {
85
84
let _ = &f1;
86
-
//~^ ERROR: `Clone` trait implementation for closure
87
-
//~| NOTE: in Rust 2018, this closure implements `Clone` as `f1` implements `Clone`, but in Rust 2021, this closure will no longer implement `Clone` as `f1.0` does not implement `Clone`
88
-
//~| NOTE: in Rust 2018, this closure implements `Clone` as `f1` implements `Clone`, but in Rust 2021, this closure will no longer implement `Clone` as `f1.2` does not implement `Clone`
85
+
//~^ ERROR: changes to closure capture in Rust 2021 will affect which traits the closure implements [rust_2021_incompatible_closure_captures]
86
+
//~| NOTE: in Rust 2018, this closure implements `Clone` as `f1` implements `Clone`
87
+
//~| NOTE: in Rust 2018, this closure implements `Clone` as `f1` implements `Clone`
89
88
//~| NOTE: for more information, see
90
89
//~| HELP: add a dummy let to cause `f1` to be fully captured
let f1 = U1(S(Foo::from("foo")), T(0), S(Foo::from("bar")));
104
103
let c = || {
105
104
let _ = &f1;
106
-
//~^ ERROR: `Clone` trait implementation for closure and drop order
107
-
//~| NOTE: in Rust 2018, this closure implements `Clone` as `f1` implements `Clone`, but in Rust 2021, this closure will no longer implement `Clone` as `f1.0` does not implement `Clone`
105
+
//~^ ERROR: changes to closure capture in Rust 2021 will affect drop order and which traits the closure implements
106
+
//~| NOTE: in Rust 2018, this closure implements `Clone` as `f1` implements `Clone`
108
107
//~| NOTE: for more information, see
109
108
//~| HELP: add a dummy let to cause `f1` to be fully captured
thread::spawn(move || { let _ = (&fptr1, &fptr2); unsafe {
139
-
//~^ ERROR: `Sync`, `Send` trait implementation for closure
140
-
//~| NOTE: in Rust 2018, this closure implements `Sync`, `Send` as `fptr1` implements `Sync`, `Send`, but in Rust 2021, this closure will no longer implement `Sync`, `Send` as `fptr1.0.0` does not implement `Sync`, `Send`
141
-
//~| NOTE: in Rust 2018, this closure implements `Send` as `fptr2` implements `Send`, but in Rust 2021, this closure will no longer implement `Send` as `fptr2.0` does not implement `Send`
138
+
//~^ ERROR: changes to closure capture in Rust 2021
139
+
//~| NOTE: in Rust 2018, this closure implements `Sync` as `fptr1` implements `Sync`
140
+
//~| NOTE: in Rust 2018, this closure implements `Send` as `fptr1` implements `Send`
141
+
//~| NOTE: in Rust 2018, this closure implements `Send` as `fptr2` implements `Send`
142
142
//~| NOTE: for more information, see
143
143
//~| HELP: add a dummy let to cause `fptr1`, `fptr2` to be fully captured
0 commit comments