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
let missing_trait = &reasons[..reasons.find("closure trait implementation").unwrap() - 1];
544
-
545
-
diagnostics_builder.span_label(closure_ending_span,format!("in Rust 2018, this closure would implement {} as `{}` implements {}, but in Rust 2021, this closure will no longer implement {} as {} does not implement {}",
547
+
diagnostics_builder.span_label(closure_head_span,format!("in Rust 2018, this closure would implement {} as `{}` implements {}, but in Rust 2021, this closure would no longer implement {} as {} does not implement {}",
Copy file name to clipboardExpand all lines: src/test/ui/closures/2229_closure_analysis/migrations/auto_traits.fixed
+6-6Lines changed: 6 additions & 6 deletions
Original file line number
Diff line number
Diff line change
@@ -12,8 +12,8 @@ fn test_send_trait() {
12
12
let mut f = 10;
13
13
let fptr = SendPointer(&mut f as *mut i32);
14
14
thread::spawn(move || { let _ = &fptr; unsafe {
15
-
//~^ ERROR: `Send` closure trait implementation
16
-
//~| NOTE: in Rust 2018, this closure would implement `Send` as `fptr` implements `Send`, but in Rust 2021, this closure will no longer implement `Send` as `fptr.0` does not implement `Send`
15
+
//~^ 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`
17
17
//~| NOTE: for more information, see
18
18
//~| HELP: add a dummy let to cause `fptr` to be fully captured
//~| NOTE: in Rust 2018, this closure would implement `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`
35
+
//~^ 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`
37
37
//~| NOTE: for more information, see
38
38
//~| HELP: add a dummy let to cause `fptr` to be fully captured
39
39
*fptr.0.0 = 20;
@@ -56,8 +56,8 @@ impl Clone for U {
56
56
fn test_clone_trait() {
57
57
let f = U(S(String::from("Hello World")), T(0));
58
58
let c = || { let _ = &f;
59
-
//~^ ERROR: `Clone` closure trait implementation, and drop order
60
-
//~| NOTE: in Rust 2018, this closure would implement `Clone` as `f` implements `Clone`, but in Rust 2021, this closure will no longer implement `Clone` as `f.1` does not implement `Clone`
59
+
//~^ 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`
61
61
//~| NOTE: for more information, see
62
62
//~| 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
+6-6Lines changed: 6 additions & 6 deletions
Original file line number
Diff line number
Diff line change
@@ -12,8 +12,8 @@ fn test_send_trait() {
12
12
letmut f = 10;
13
13
let fptr = SendPointer(&mut f as*muti32);
14
14
thread::spawn(move || unsafe{
15
-
//~^ ERROR: `Send` closure trait implementation
16
-
//~| NOTE: in Rust 2018, this closure would implement `Send` as `fptr` implements `Send`, but in Rust 2021, this closure will no longer implement `Send` as `fptr.0` does not implement `Send`
15
+
//~^ 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`
17
17
//~| NOTE: for more information, see
18
18
//~| HELP: add a dummy let to cause `fptr` to be fully captured
//~| NOTE: in Rust 2018, this closure would implement `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`
35
+
//~^ 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`
37
37
//~| NOTE: for more information, see
38
38
//~| HELP: add a dummy let to cause `fptr` to be fully captured
39
39
*fptr.0.0 = 20;
@@ -56,8 +56,8 @@ impl Clone for U {
56
56
fntest_clone_trait(){
57
57
let f = U(S(String::from("Hello World")),T(0));
58
58
let c = || {
59
-
//~^ ERROR: `Clone` closure trait implementation, and drop order
60
-
//~| NOTE: in Rust 2018, this closure would implement `Clone` as `f` implements `Clone`, but in Rust 2021, this closure will no longer implement `Clone` as `f.1` does not implement `Clone`
59
+
//~^ 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`
61
61
//~| NOTE: for more information, see
62
62
//~| 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
+20-45Lines changed: 20 additions & 45 deletions
Original file line number
Diff line number
Diff line change
@@ -1,19 +1,11 @@
1
-
error: changes to closure capture in Rust 2021 will affect `Send` closure trait implementation
1
+
error: changes to closure capture in Rust 2021 will affect `Send` trait implementation for closure
2
2
--> $DIR/auto_traits.rs:14:19
3
3
|
4
-
LL | thread::spawn(move || unsafe {
5
-
| ^ - in Rust 2018, this closure would implement `Send` as `fptr` implements `Send`, but in Rust 2021, this closure will no longer implement `Send` as `fptr.0` does not implement `Send`
6
-
| ___________________|
7
-
| |
8
-
LL | |
9
-
LL | |
10
-
LL | |
11
-
LL | |
12
-
LL | | *fptr.0 = 20;
13
-
| | ------- in Rust 2018, closure captures all of `fptr`, but in Rust 2021, it only captures `fptr.0`
14
-
LL | |
15
-
LL | | });
16
-
| |_____^
4
+
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`
6
+
...
7
+
LL | *fptr.0 = 20;
8
+
| ------- in Rust 2018, closure captures all of `fptr`, but in Rust 2021, it only captures `fptr.0`
17
9
|
18
10
note: the lint level is defined here
19
11
--> $DIR/auto_traits.rs:2:9
@@ -31,22 +23,14 @@ LL |
31
23
LL | *fptr.0 = 20;
32
24
...
33
25
34
-
error: changes to closure capture in Rust 2021 will affect `Sync`, `Send` closure trait implementation
26
+
error: changes to closure capture in Rust 2021 will affect `Sync`, `Send` trait implementation for closure
35
27
--> $DIR/auto_traits.rs:34:19
36
28
|
37
-
LL | thread::spawn(move || unsafe {
38
-
| ^ - in Rust 2018, this closure would implement `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`
39
-
| ___________________|
40
-
| |
41
-
LL | |
42
-
LL | |
43
-
LL | |
44
-
LL | |
45
-
LL | | *fptr.0.0 = 20;
46
-
| | --------- in Rust 2018, closure captures all of `fptr`, but in Rust 2021, it only captures `fptr.0.0`
47
-
LL | |
48
-
LL | | });
49
-
| |_____^
29
+
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`
31
+
...
32
+
LL | *fptr.0.0 = 20;
33
+
| --------- in Rust 2018, closure captures all of `fptr`, but in Rust 2021, it only captures `fptr.0.0`
50
34
|
51
35
= note: for more information, see <https://doc.rust-lang.org/nightly/edition-guide/rust-2021/disjoint-capture-in-closures.html>
52
36
help: add a dummy let to cause `fptr` to be fully captured
@@ -59,26 +43,17 @@ LL |
59
43
LL | *fptr.0.0 = 20;
60
44
...
61
45
62
-
error: changes to closure capture in Rust 2021 will affect `Clone` closure trait implementation, and drop order
46
+
error: changes to closure capture in Rust 2021 will affect `Clone` trait implementation for closure, and drop order
63
47
--> $DIR/auto_traits.rs:58:13
64
48
|
65
-
LL | let c = || {
66
-
| ^ - in Rust 2018, this closure would implement `Clone` as `f` implements `Clone`, but in Rust 2021, this closure will no longer implement `Clone` as `f.1` does not implement `Clone`
67
-
| _____________|
68
-
| |
69
-
LL | |
70
-
LL | |
71
-
LL | |
72
-
LL | |
73
-
LL | | let f_1 = f.1;
74
-
| | --- in Rust 2018, closure captures all of `f`, but in Rust 2021, it only captures `f.1`
75
-
LL | |
76
-
LL | | println!("{:?}", f_1.0);
77
-
LL | | };
78
-
| |_____^
49
+
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`
51
+
...
52
+
LL | let f_1 = f.1;
53
+
| --- in Rust 2018, closure captures all of `f`, but in Rust 2021, it only captures `f.1`
79
54
...
80
-
LL | }
81
-
| - in Rust 2018, `f` would be dropped here, but in Rust 2021, only `f.1` would be dropped here alongside the closure
55
+
LL | }
56
+
| - in Rust 2018, `f` would be dropped here, but in Rust 2021, only `f.1` would be dropped here alongside the closure
82
57
|
83
58
= note: for more information, see <https://doc.rust-lang.org/nightly/edition-guide/rust-2021/disjoint-capture-in-closures.html>
84
59
help: add a dummy let to cause `f` to be fully captured
0 commit comments