@@ -6,6 +6,8 @@ Erroneous code examples:
6
6
The target data is not a ` struct ` .
7
7
8
8
``` compile_fail,E0802
9
+ #![feature(coerce_pointee)]
10
+ use std::marker::CoercePointee;
9
11
#[derive(CoercePointee)]
10
12
enum NotStruct<'a, T: ?Sized> {
11
13
Variant(&'a T),
@@ -16,6 +18,8 @@ The target data has a layout that is not transparent, or `repr(transparent)`
16
18
in other words.
17
19
18
20
``` compile_fail,E0802
21
+ #![feature(coerce_pointee)]
22
+ use std::marker::CoercePointee;
19
23
#[derive(CoercePointee)]
20
24
struct NotTransparent<'a, #[pointee] T: ?Sized> {
21
25
ptr: &'a T,
@@ -25,6 +29,8 @@ struct NotTransparent<'a, #[pointee] T: ?Sized> {
25
29
The target data has no data field.
26
30
27
31
``` compile_fail,E0802
32
+ #![feature(coerce_pointee)]
33
+ use std::marker::CoercePointee;
28
34
#[derive(CoercePointee)]
29
35
#[repr(transparent)]
30
36
struct NoField<'a, #[pointee] T: ?Sized> {}
@@ -33,6 +39,8 @@ struct NoField<'a, #[pointee] T: ?Sized> {}
33
39
The target data is not generic over any data, or has no generic type parameter.
34
40
35
41
``` compile_fail,E0802
42
+ #![feature(coerce_pointee)]
43
+ use std::marker::CoercePointee;
36
44
#[derive(CoercePointee)]
37
45
#[repr(transparent)]
38
46
struct NoGeneric<'a>(&'a u8);
@@ -42,6 +50,8 @@ The target data has multiple generic type parameters, but none is designated as
42
50
a pointee for coercion.
43
51
44
52
``` compile_fail,E0802
53
+ #![feature(coerce_pointee)]
54
+ use std::marker::CoercePointee;
45
55
#[derive(CoercePointee)]
46
56
#[repr(transparent)]
47
57
struct AmbiguousPointee<'a, T1: ?Sized, T2: ?Sized> {
@@ -53,6 +63,8 @@ The target data has multiple generic type parameters that are designated as
53
63
pointees for coercion.
54
64
55
65
``` compile_fail,E0802
66
+ #![feature(coerce_pointee)]
67
+ use std::marker::CoercePointee;
56
68
#[derive(CoercePointee)]
57
69
#[repr(transparent)]
58
70
struct TooManyPointees<
@@ -65,6 +77,8 @@ struct TooManyPointees<
65
77
The type parameter that is designated as a pointee is not marked ` ?Sized ` .
66
78
67
79
``` compile_fail,E0802
80
+ #![feature(coerce_pointee)]
81
+ use std::marker::CoercePointee;
68
82
#[derive(CoercePointee)]
69
83
#[repr(transparent)]
70
84
struct NoMaybeSized<'a, #[pointee] T> {
0 commit comments