fix the error code document

This commit is contained in:
Ding Xiang Fei 2025-02-10 03:02:13 +08:00
parent 18483434ae
commit aea5595c86
No known key found for this signature in database
GPG key ID: 3CD748647EEF6359

View file

@ -6,6 +6,8 @@ Erroneous code examples:
The target data is not a `struct`.
```compile_fail,E0802
#![feature(coerce_pointee)]
use std::marker::CoercePointee;
#[derive(CoercePointee)]
enum NotStruct<'a, T: ?Sized> {
Variant(&'a T),
@ -16,6 +18,8 @@ The target data has a layout that is not transparent, or `repr(transparent)`
in other words.
```compile_fail,E0802
#![feature(coerce_pointee)]
use std::marker::CoercePointee;
#[derive(CoercePointee)]
struct NotTransparent<'a, #[pointee] T: ?Sized> {
ptr: &'a T,
@ -25,6 +29,8 @@ struct NotTransparent<'a, #[pointee] T: ?Sized> {
The target data has no data field.
```compile_fail,E0802
#![feature(coerce_pointee)]
use std::marker::CoercePointee;
#[derive(CoercePointee)]
#[repr(transparent)]
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.
```compile_fail,E0802
#![feature(coerce_pointee)]
use std::marker::CoercePointee;
#[derive(CoercePointee)]
#[repr(transparent)]
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.
```compile_fail,E0802
#![feature(coerce_pointee)]
use std::marker::CoercePointee;
#[derive(CoercePointee)]
#[repr(transparent)]
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.
```compile_fail,E0802
#![feature(coerce_pointee)]
use std::marker::CoercePointee;
#[derive(CoercePointee)]
#[repr(transparent)]
struct TooManyPointees<
@ -65,6 +77,8 @@ struct TooManyPointees<
The type parameter that is designated as a pointee is not marked `?Sized`.
```compile_fail,E0802
#![feature(coerce_pointee)]
use std::marker::CoercePointee;
#[derive(CoercePointee)]
#[repr(transparent)]
struct NoMaybeSized<'a, #[pointee] T> {