Skip to content

Commit 5324992

Browse files
fix the error code document
1 parent 9aabb55 commit 5324992

File tree

1 file changed

+14
-0
lines changed
  • compiler/rustc_error_codes/src/error_codes

1 file changed

+14
-0
lines changed

compiler/rustc_error_codes/src/error_codes/E0802.md

+14
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,8 @@ Erroneous code examples:
66
The target data is not a `struct`.
77

88
```compile_fail,E0802
9+
#![feature(coerce_pointee)]
10+
use std::marker::CoercePointee;
911
#[derive(CoercePointee)]
1012
enum NotStruct<'a, T: ?Sized> {
1113
Variant(&'a T),
@@ -16,6 +18,8 @@ The target data has a layout that is not transparent, or `repr(transparent)`
1618
in other words.
1719

1820
```compile_fail,E0802
21+
#![feature(coerce_pointee)]
22+
use std::marker::CoercePointee;
1923
#[derive(CoercePointee)]
2024
struct NotTransparent<'a, #[pointee] T: ?Sized> {
2125
ptr: &'a T,
@@ -25,6 +29,8 @@ struct NotTransparent<'a, #[pointee] T: ?Sized> {
2529
The target data has no data field.
2630

2731
```compile_fail,E0802
32+
#![feature(coerce_pointee)]
33+
use std::marker::CoercePointee;
2834
#[derive(CoercePointee)]
2935
#[repr(transparent)]
3036
struct NoField<'a, #[pointee] T: ?Sized> {}
@@ -33,6 +39,8 @@ struct NoField<'a, #[pointee] T: ?Sized> {}
3339
The target data is not generic over any data, or has no generic type parameter.
3440

3541
```compile_fail,E0802
42+
#![feature(coerce_pointee)]
43+
use std::marker::CoercePointee;
3644
#[derive(CoercePointee)]
3745
#[repr(transparent)]
3846
struct NoGeneric<'a>(&'a u8);
@@ -42,6 +50,8 @@ The target data has multiple generic type parameters, but none is designated as
4250
a pointee for coercion.
4351

4452
```compile_fail,E0802
53+
#![feature(coerce_pointee)]
54+
use std::marker::CoercePointee;
4555
#[derive(CoercePointee)]
4656
#[repr(transparent)]
4757
struct AmbiguousPointee<'a, T1: ?Sized, T2: ?Sized> {
@@ -53,6 +63,8 @@ The target data has multiple generic type parameters that are designated as
5363
pointees for coercion.
5464

5565
```compile_fail,E0802
66+
#![feature(coerce_pointee)]
67+
use std::marker::CoercePointee;
5668
#[derive(CoercePointee)]
5769
#[repr(transparent)]
5870
struct TooManyPointees<
@@ -65,6 +77,8 @@ struct TooManyPointees<
6577
The type parameter that is designated as a pointee is not marked `?Sized`.
6678

6779
```compile_fail,E0802
80+
#![feature(coerce_pointee)]
81+
use std::marker::CoercePointee;
6882
#[derive(CoercePointee)]
6983
#[repr(transparent)]
7084
struct NoMaybeSized<'a, #[pointee] T> {

0 commit comments

Comments
 (0)