diff options
| author | Ding Xiang Fei <dingxiangfei2009@protonmail.ch> | 2025-02-10 03:02:13 +0800 |
|---|---|---|
| committer | Ding Xiang Fei <dingxiangfei2009@protonmail.ch> | 2025-02-10 04:36:49 +0800 |
| commit | aea5595c8613425c74791586b4c7fcff017fc14e (patch) | |
| tree | dd8469eae9c0b3af7ff5546b667f782338b63a53 /compiler/rustc_error_codes | |
| parent | 18483434ae377d215fa87c890cbf26884f3fae5c (diff) | |
| download | rust-aea5595c8613425c74791586b4c7fcff017fc14e.tar.gz rust-aea5595c8613425c74791586b4c7fcff017fc14e.zip | |
fix the error code document
Diffstat (limited to 'compiler/rustc_error_codes')
| -rw-r--r-- | compiler/rustc_error_codes/src/error_codes/E0802.md | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/compiler/rustc_error_codes/src/error_codes/E0802.md b/compiler/rustc_error_codes/src/error_codes/E0802.md index 9088b100886..59061ff0435 100644 --- a/compiler/rustc_error_codes/src/error_codes/E0802.md +++ b/compiler/rustc_error_codes/src/error_codes/E0802.md @@ -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> { |
