fix the error code document
This commit is contained in:
parent
18483434ae
commit
aea5595c86
1 changed files with 14 additions and 0 deletions
|
@ -6,6 +6,8 @@ Erroneous code examples:
|
||||||
The target data is not a `struct`.
|
The target data is not a `struct`.
|
||||||
|
|
||||||
```compile_fail,E0802
|
```compile_fail,E0802
|
||||||
|
#![feature(coerce_pointee)]
|
||||||
|
use std::marker::CoercePointee;
|
||||||
#[derive(CoercePointee)]
|
#[derive(CoercePointee)]
|
||||||
enum NotStruct<'a, T: ?Sized> {
|
enum NotStruct<'a, T: ?Sized> {
|
||||||
Variant(&'a T),
|
Variant(&'a T),
|
||||||
|
@ -16,6 +18,8 @@ The target data has a layout that is not transparent, or `repr(transparent)`
|
||||||
in other words.
|
in other words.
|
||||||
|
|
||||||
```compile_fail,E0802
|
```compile_fail,E0802
|
||||||
|
#![feature(coerce_pointee)]
|
||||||
|
use std::marker::CoercePointee;
|
||||||
#[derive(CoercePointee)]
|
#[derive(CoercePointee)]
|
||||||
struct NotTransparent<'a, #[pointee] T: ?Sized> {
|
struct NotTransparent<'a, #[pointee] T: ?Sized> {
|
||||||
ptr: &'a T,
|
ptr: &'a T,
|
||||||
|
@ -25,6 +29,8 @@ struct NotTransparent<'a, #[pointee] T: ?Sized> {
|
||||||
The target data has no data field.
|
The target data has no data field.
|
||||||
|
|
||||||
```compile_fail,E0802
|
```compile_fail,E0802
|
||||||
|
#![feature(coerce_pointee)]
|
||||||
|
use std::marker::CoercePointee;
|
||||||
#[derive(CoercePointee)]
|
#[derive(CoercePointee)]
|
||||||
#[repr(transparent)]
|
#[repr(transparent)]
|
||||||
struct NoField<'a, #[pointee] T: ?Sized> {}
|
struct NoField<'a, #[pointee] T: ?Sized> {}
|
||||||
|
@ -33,6 +39,8 @@ struct NoField<'a, #[pointee] T: ?Sized> {}
|
||||||
The target data is not generic over any data, or has no generic type parameter.
|
The target data is not generic over any data, or has no generic type parameter.
|
||||||
|
|
||||||
```compile_fail,E0802
|
```compile_fail,E0802
|
||||||
|
#![feature(coerce_pointee)]
|
||||||
|
use std::marker::CoercePointee;
|
||||||
#[derive(CoercePointee)]
|
#[derive(CoercePointee)]
|
||||||
#[repr(transparent)]
|
#[repr(transparent)]
|
||||||
struct NoGeneric<'a>(&'a u8);
|
struct NoGeneric<'a>(&'a u8);
|
||||||
|
@ -42,6 +50,8 @@ The target data has multiple generic type parameters, but none is designated as
|
||||||
a pointee for coercion.
|
a pointee for coercion.
|
||||||
|
|
||||||
```compile_fail,E0802
|
```compile_fail,E0802
|
||||||
|
#![feature(coerce_pointee)]
|
||||||
|
use std::marker::CoercePointee;
|
||||||
#[derive(CoercePointee)]
|
#[derive(CoercePointee)]
|
||||||
#[repr(transparent)]
|
#[repr(transparent)]
|
||||||
struct AmbiguousPointee<'a, T1: ?Sized, T2: ?Sized> {
|
struct AmbiguousPointee<'a, T1: ?Sized, T2: ?Sized> {
|
||||||
|
@ -53,6 +63,8 @@ The target data has multiple generic type parameters that are designated as
|
||||||
pointees for coercion.
|
pointees for coercion.
|
||||||
|
|
||||||
```compile_fail,E0802
|
```compile_fail,E0802
|
||||||
|
#![feature(coerce_pointee)]
|
||||||
|
use std::marker::CoercePointee;
|
||||||
#[derive(CoercePointee)]
|
#[derive(CoercePointee)]
|
||||||
#[repr(transparent)]
|
#[repr(transparent)]
|
||||||
struct TooManyPointees<
|
struct TooManyPointees<
|
||||||
|
@ -65,6 +77,8 @@ struct TooManyPointees<
|
||||||
The type parameter that is designated as a pointee is not marked `?Sized`.
|
The type parameter that is designated as a pointee is not marked `?Sized`.
|
||||||
|
|
||||||
```compile_fail,E0802
|
```compile_fail,E0802
|
||||||
|
#![feature(coerce_pointee)]
|
||||||
|
use std::marker::CoercePointee;
|
||||||
#[derive(CoercePointee)]
|
#[derive(CoercePointee)]
|
||||||
#[repr(transparent)]
|
#[repr(transparent)]
|
||||||
struct NoMaybeSized<'a, #[pointee] T> {
|
struct NoMaybeSized<'a, #[pointee] T> {
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue