Skip to content

Commit 3b28c69

Browse files
committed
bless tests
yay, I fixed the bug/missing feature :')
1 parent 9b832b1 commit 3b28c69

7 files changed

+95
-232
lines changed

tests/ui/cast/ptr-to-trait-obj-wrap-add-auto.rs

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -12,16 +12,14 @@ struct X<T: ?Sized>(T);
1212

1313
fn unwrap(a: *const W<dyn A>) -> *const (dyn A + Send) {
1414
a as _
15-
//~^ error
16-
//~| error
17-
//~| error
15+
//~^ error: adding an auto trait `Send` to a trait object in a pointer cast may cause UB later on
16+
//~| warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
1817
}
1918

2019
fn unwrap_nested(a: *const W<W<dyn A>>) -> *const W<dyn A + Send> {
2120
a as _
22-
//~^ error
23-
//~| error
24-
//~| error
21+
//~^ error: adding an auto trait `Send` to a trait object in a pointer cast may cause UB later on
22+
//~| warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
2523
}
2624

2725
fn rewrap(a: *const W<dyn A>) -> *const X<dyn A + Send> {

tests/ui/cast/ptr-to-trait-obj-wrap-add-auto.stderr

Lines changed: 41 additions & 76 deletions
Original file line numberDiff line numberDiff line change
@@ -1,87 +1,58 @@
1-
error[E0277]: the trait bound `W<(dyn A + 'static)>: A` is not satisfied
1+
error: adding an auto trait `Send` to a trait object in a pointer cast may cause UB later on
22
--> $DIR/ptr-to-trait-obj-wrap-add-auto.rs:14:5
33
|
44
LL | a as _
5-
| ^ the trait `A` is not implemented for `W<(dyn A + 'static)>`
5+
| ^^^^^^
66
|
7-
help: this trait has no implementations, consider adding one
8-
--> $DIR/ptr-to-trait-obj-wrap-add-auto.rs:8:1
7+
= warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
8+
= note: for more information, see issue #127323 <https://github.com/rust-lang/rust/issues/127323>
9+
note: the lint level is defined here
10+
--> $DIR/ptr-to-trait-obj-wrap-add-auto.rs:6:9
911
|
10-
LL | trait A {}
11-
| ^^^^^^^
12-
= note: required for the cast from `*const W<(dyn A + 'static)>` to `*const dyn A + Send`
12+
LL | #![deny(ptr_cast_add_auto_to_object)]
13+
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^
1314

14-
error[E0277]: `(dyn A + 'static)` cannot be sent between threads safely
15-
--> $DIR/ptr-to-trait-obj-wrap-add-auto.rs:14:5
15+
error: adding an auto trait `Send` to a trait object in a pointer cast may cause UB later on
16+
--> $DIR/ptr-to-trait-obj-wrap-add-auto.rs:20:5
1617
|
1718
LL | a as _
18-
| ^ `(dyn A + 'static)` cannot be sent between threads safely
19-
|
20-
= help: within `W<(dyn A + 'static)>`, the trait `Send` is not implemented for `(dyn A + 'static)`
21-
note: required because it appears within the type `W<(dyn A + 'static)>`
22-
--> $DIR/ptr-to-trait-obj-wrap-add-auto.rs:10:8
19+
| ^^^^^^
2320
|
24-
LL | struct W<T: ?Sized>(T);
25-
| ^
26-
= note: required for the cast from `*const W<(dyn A + 'static)>` to `*const dyn A + Send`
21+
= warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
22+
= note: for more information, see issue #127323 <https://github.com/rust-lang/rust/issues/127323>
2723

28-
error[E0277]: the size for values of type `(dyn A + 'static)` cannot be known at compilation time
29-
--> $DIR/ptr-to-trait-obj-wrap-add-auto.rs:14:5
24+
error: adding an auto trait `Send` to a trait object in a pointer cast may cause UB later on
25+
--> $DIR/ptr-to-trait-obj-wrap-add-auto.rs:26:5
3026
|
3127
LL | a as _
32-
| ^ doesn't have a size known at compile-time
33-
|
34-
= help: within `W<(dyn A + 'static)>`, the trait `Sized` is not implemented for `(dyn A + 'static)`
35-
note: required because it appears within the type `W<(dyn A + 'static)>`
36-
--> $DIR/ptr-to-trait-obj-wrap-add-auto.rs:10:8
28+
| ^^^^^^
3729
|
38-
LL | struct W<T: ?Sized>(T);
39-
| ^
40-
= note: required for the cast from `*const W<(dyn A + 'static)>` to `*const dyn A + Send`
30+
= warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
31+
= note: for more information, see issue #127323 <https://github.com/rust-lang/rust/issues/127323>
4132

42-
error[E0277]: the trait bound `W<(dyn A + 'static)>: A` is not satisfied
43-
--> $DIR/ptr-to-trait-obj-wrap-add-auto.rs:21:5
33+
error: adding an auto trait `Send` to a trait object in a pointer cast may cause UB later on
34+
--> $DIR/ptr-to-trait-obj-wrap-add-auto.rs:32:5
4435
|
4536
LL | a as _
46-
| ^ the trait `A` is not implemented for `W<(dyn A + 'static)>`
47-
|
48-
help: this trait has no implementations, consider adding one
49-
--> $DIR/ptr-to-trait-obj-wrap-add-auto.rs:8:1
37+
| ^^^^^^
5038
|
51-
LL | trait A {}
52-
| ^^^^^^^
53-
= note: required for the cast from `*const W<W<(dyn A + 'static)>>` to `*const W<dyn A + Send>`
39+
= warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
40+
= note: for more information, see issue #127323 <https://github.com/rust-lang/rust/issues/127323>
5441

55-
error[E0277]: `(dyn A + 'static)` cannot be sent between threads safely
56-
--> $DIR/ptr-to-trait-obj-wrap-add-auto.rs:21:5
42+
error: adding an auto trait `Send` to a trait object in a pointer cast may cause UB later on
43+
--> $DIR/ptr-to-trait-obj-wrap-add-auto.rs:38:5
5744
|
5845
LL | a as _
59-
| ^ `(dyn A + 'static)` cannot be sent between threads safely
60-
|
61-
= help: within `W<(dyn A + 'static)>`, the trait `Send` is not implemented for `(dyn A + 'static)`
62-
note: required because it appears within the type `W<(dyn A + 'static)>`
63-
--> $DIR/ptr-to-trait-obj-wrap-add-auto.rs:10:8
46+
| ^^^^^^
6447
|
65-
LL | struct W<T: ?Sized>(T);
66-
| ^
67-
= note: required for the cast from `*const W<W<(dyn A + 'static)>>` to `*const W<dyn A + Send>`
48+
= warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
49+
= note: for more information, see issue #127323 <https://github.com/rust-lang/rust/issues/127323>
6850

69-
error[E0277]: the size for values of type `(dyn A + 'static)` cannot be known at compilation time
70-
--> $DIR/ptr-to-trait-obj-wrap-add-auto.rs:21:5
71-
|
72-
LL | a as _
73-
| ^ doesn't have a size known at compile-time
74-
|
75-
= help: within `W<(dyn A + 'static)>`, the trait `Sized` is not implemented for `(dyn A + 'static)`
76-
note: required because it appears within the type `W<(dyn A + 'static)>`
77-
--> $DIR/ptr-to-trait-obj-wrap-add-auto.rs:10:8
78-
|
79-
LL | struct W<T: ?Sized>(T);
80-
| ^
81-
= note: required for the cast from `*const W<W<(dyn A + 'static)>>` to `*const W<dyn A + Send>`
51+
error: aborting due to 5 previous errors
8252

53+
Future incompatibility report: Future breakage diagnostic:
8354
error: adding an auto trait `Send` to a trait object in a pointer cast may cause UB later on
84-
--> $DIR/ptr-to-trait-obj-wrap-add-auto.rs:28:5
55+
--> $DIR/ptr-to-trait-obj-wrap-add-auto.rs:14:5
8556
|
8657
LL | a as _
8758
| ^^^^^^
@@ -94,30 +65,24 @@ note: the lint level is defined here
9465
LL | #![deny(ptr_cast_add_auto_to_object)]
9566
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^
9667

68+
Future breakage diagnostic:
9769
error: adding an auto trait `Send` to a trait object in a pointer cast may cause UB later on
98-
--> $DIR/ptr-to-trait-obj-wrap-add-auto.rs:34:5
70+
--> $DIR/ptr-to-trait-obj-wrap-add-auto.rs:20:5
9971
|
10072
LL | a as _
10173
| ^^^^^^
10274
|
10375
= warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
10476
= note: for more information, see issue #127323 <https://github.com/rust-lang/rust/issues/127323>
105-
106-
error: adding an auto trait `Send` to a trait object in a pointer cast may cause UB later on
107-
--> $DIR/ptr-to-trait-obj-wrap-add-auto.rs:40:5
108-
|
109-
LL | a as _
110-
| ^^^^^^
77+
note: the lint level is defined here
78+
--> $DIR/ptr-to-trait-obj-wrap-add-auto.rs:6:9
11179
|
112-
= warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
113-
= note: for more information, see issue #127323 <https://github.com/rust-lang/rust/issues/127323>
114-
115-
error: aborting due to 9 previous errors
80+
LL | #![deny(ptr_cast_add_auto_to_object)]
81+
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^
11682

117-
For more information about this error, try `rustc --explain E0277`.
118-
Future incompatibility report: Future breakage diagnostic:
83+
Future breakage diagnostic:
11984
error: adding an auto trait `Send` to a trait object in a pointer cast may cause UB later on
120-
--> $DIR/ptr-to-trait-obj-wrap-add-auto.rs:28:5
85+
--> $DIR/ptr-to-trait-obj-wrap-add-auto.rs:26:5
12186
|
12287
LL | a as _
12388
| ^^^^^^
@@ -132,7 +97,7 @@ LL | #![deny(ptr_cast_add_auto_to_object)]
13297

13398
Future breakage diagnostic:
13499
error: adding an auto trait `Send` to a trait object in a pointer cast may cause UB later on
135-
--> $DIR/ptr-to-trait-obj-wrap-add-auto.rs:34:5
100+
--> $DIR/ptr-to-trait-obj-wrap-add-auto.rs:32:5
136101
|
137102
LL | a as _
138103
| ^^^^^^
@@ -147,7 +112,7 @@ LL | #![deny(ptr_cast_add_auto_to_object)]
147112

148113
Future breakage diagnostic:
149114
error: adding an auto trait `Send` to a trait object in a pointer cast may cause UB later on
150-
--> $DIR/ptr-to-trait-obj-wrap-add-auto.rs:40:5
115+
--> $DIR/ptr-to-trait-obj-wrap-add-auto.rs:38:5
151116
|
152117
LL | a as _
153118
| ^^^^^^

tests/ui/cast/ptr-to-trait-obj-wrap-different-args.rs

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,14 +11,12 @@ struct X<T: ?Sized>(T);
1111

1212
fn unwrap<F, G>(a: *const W<dyn A<F>>) -> *const dyn A<G> {
1313
a as _
14-
//~^ error
15-
//~| error
14+
//~^ error casting `*const W<(dyn A<F> + 'static)>` as `*const dyn A<G>` is invalid
1615
}
1716

1817
fn unwrap_nested<F, G>(a: *const W<W<dyn A<F>>>) -> *const W<dyn A<G>> {
1918
a as _
20-
//~^ error
21-
//~| error
19+
//~^ error casting `*const W<W<(dyn A<F> + 'static)>>` as `*const W<dyn A<G>>` is invalid
2220
}
2321

2422
fn rewrap<F, G>(a: *const W<dyn A<F>>) -> *const X<dyn A<G>> {
Lines changed: 12 additions & 51 deletions
Original file line numberDiff line numberDiff line change
@@ -1,82 +1,43 @@
1-
error[E0277]: the trait bound `W<(dyn A<F> + 'static)>: A<G>` is not satisfied
1+
error[E0606]: casting `*const W<(dyn A<F> + 'static)>` as `*const dyn A<G>` is invalid
22
--> $DIR/ptr-to-trait-obj-wrap-different-args.rs:13:5
33
|
44
LL | a as _
5-
| ^ the trait `A<G>` is not implemented for `W<(dyn A<F> + 'static)>`
6-
|
7-
help: this trait has no implementations, consider adding one
8-
--> $DIR/ptr-to-trait-obj-wrap-different-args.rs:7:1
9-
|
10-
LL | trait A<T> {}
11-
| ^^^^^^^^^^
12-
= note: required for the cast from `*const W<(dyn A<F> + 'static)>` to `*const dyn A<G>`
13-
14-
error[E0277]: the size for values of type `(dyn A<F> + 'static)` cannot be known at compilation time
15-
--> $DIR/ptr-to-trait-obj-wrap-different-args.rs:13:5
16-
|
17-
LL | a as _
18-
| ^ doesn't have a size known at compile-time
19-
|
20-
= help: within `W<(dyn A<F> + 'static)>`, the trait `Sized` is not implemented for `(dyn A<F> + 'static)`
21-
note: required because it appears within the type `W<(dyn A<F> + 'static)>`
22-
--> $DIR/ptr-to-trait-obj-wrap-different-args.rs:9:8
23-
|
24-
LL | struct W<T: ?Sized>(T);
25-
| ^
26-
= note: required for the cast from `*const W<(dyn A<F> + 'static)>` to `*const dyn A<G>`
27-
28-
error[E0277]: the trait bound `W<(dyn A<F> + 'static)>: A<G>` is not satisfied
29-
--> $DIR/ptr-to-trait-obj-wrap-different-args.rs:19:5
30-
|
31-
LL | a as _
32-
| ^ the trait `A<G>` is not implemented for `W<(dyn A<F> + 'static)>`
33-
|
34-
help: this trait has no implementations, consider adding one
35-
--> $DIR/ptr-to-trait-obj-wrap-different-args.rs:7:1
5+
| ^^^^^^
366
|
37-
LL | trait A<T> {}
38-
| ^^^^^^^^^^
39-
= note: required for the cast from `*const W<W<(dyn A<F> + 'static)>>` to `*const W<dyn A<G>>`
7+
= note: the trait objects may have different vtables
408

41-
error[E0277]: the size for values of type `(dyn A<F> + 'static)` cannot be known at compilation time
42-
--> $DIR/ptr-to-trait-obj-wrap-different-args.rs:19:5
9+
error[E0606]: casting `*const W<W<(dyn A<F> + 'static)>>` as `*const W<dyn A<G>>` is invalid
10+
--> $DIR/ptr-to-trait-obj-wrap-different-args.rs:18:5
4311
|
4412
LL | a as _
45-
| ^ doesn't have a size known at compile-time
46-
|
47-
= help: within `W<(dyn A<F> + 'static)>`, the trait `Sized` is not implemented for `(dyn A<F> + 'static)`
48-
note: required because it appears within the type `W<(dyn A<F> + 'static)>`
49-
--> $DIR/ptr-to-trait-obj-wrap-different-args.rs:9:8
13+
| ^^^^^^
5014
|
51-
LL | struct W<T: ?Sized>(T);
52-
| ^
53-
= note: required for the cast from `*const W<W<(dyn A<F> + 'static)>>` to `*const W<dyn A<G>>`
15+
= note: the trait objects may have different vtables
5416

5517
error[E0606]: casting `*const W<(dyn A<F> + 'static)>` as `*const X<dyn A<G>>` is invalid
56-
--> $DIR/ptr-to-trait-obj-wrap-different-args.rs:25:5
18+
--> $DIR/ptr-to-trait-obj-wrap-different-args.rs:23:5
5719
|
5820
LL | a as _
5921
| ^^^^^^
6022
|
6123
= note: the trait objects may have different vtables
6224

6325
error[E0606]: casting `*const W<W<(dyn A<F> + 'static)>>` as `*const W<X<dyn A<G>>>` is invalid
64-
--> $DIR/ptr-to-trait-obj-wrap-different-args.rs:30:5
26+
--> $DIR/ptr-to-trait-obj-wrap-different-args.rs:28:5
6527
|
6628
LL | a as _
6729
| ^^^^^^
6830
|
6931
= note: the trait objects may have different vtables
7032

7133
error[E0606]: casting `*const (dyn A<F> + 'static)` as `*const W<dyn A<G>>` is invalid
72-
--> $DIR/ptr-to-trait-obj-wrap-different-args.rs:35:5
34+
--> $DIR/ptr-to-trait-obj-wrap-different-args.rs:33:5
7335
|
7436
LL | a as _
7537
| ^^^^^^
7638
|
7739
= note: the trait objects may have different vtables
7840

79-
error: aborting due to 7 previous errors
41+
error: aborting due to 5 previous errors
8042

81-
Some errors have detailed explanations: E0277, E0606.
82-
For more information about an error, try `rustc --explain E0277`.
43+
For more information about this error, try `rustc --explain E0606`.

0 commit comments

Comments
 (0)