@@ -1075,11 +1075,38 @@ pub trait FnPtr: Copy + Clone {
1075
1075
fn addr ( self ) -> * const ( ) ;
1076
1076
}
1077
1077
1078
- /// Derive macro generating impls of traits related to smart pointers.
1078
+ /// Derive macro generating implementations of traits
1079
+ /// in relation to coercion of types to unsized or dynamic-sized types
1080
+ /// with dynamic dispatching.
1081
+ ///
1082
+ /// This macro will enable the target structure to equip with capabilities
1083
+ /// to weaken a concrete type in its generic parameters to its unsized
1084
+ /// variants.
1085
+ /// For instance, it admits coercion of a `[T; SIZE]` to `[T]` where `SIZE`
1086
+ /// is a constant; and coercion of a concrete type `T` to `dyn Trait` when
1087
+ /// `T` implements an object-safe trait `Trait`.
1088
+ /// See the [DST coercion RFC][RFC982] and
1089
+ /// [the nomicon entry on coercion][nomicon-coerce] on the topics of this coercion.
1090
+ ///
1091
+ /// The macro would choose a generic parameter labelled by a `#[pointee]` attribute first,
1092
+ /// and resorts to the first type parameter from the left of
1093
+ /// the list of generics as the target parameter that
1094
+ /// the weakening is allowed.
1095
+ ///
1096
+ /// # Pre-requisites
1097
+ /// Applying this macro demands the following pre-requisites on the target item.
1098
+ /// - The target item is a `struct`.
1099
+ /// - The `struct` has a transparent data layout via `#[repr(transparent)]`.
1100
+ /// - The `struct` has at least one data field.
1101
+ /// - The `struct` has at least one generic type parameter.
1102
+ /// - The `struct` has at most one generic type parameter
1103
+ /// with macro attribute `#[pointee]` attached.
1104
+ ///
1105
+ /// [nomicon-coerce]: ../../nomicon/coercions.html
1106
+ /// [RFC982]: https://github.com/rust-lang/rfcs/blob/master/text/0982-dst-coercion.md
1079
1107
#[ rustc_builtin_macro( CoercePointee , attributes( pointee) ) ]
1080
1108
#[ allow_internal_unstable( dispatch_from_dyn, coerce_unsized, unsize) ]
1081
- #[ unstable( feature = "derive_coerce_pointee" , issue = "123430" ) ]
1082
- #[ cfg( not( bootstrap) ) ]
1109
+ #[ stable( feature = "derive_coerce_pointee" , since = "CURRENT_RUSTC_VERSION" ) ]
1083
1110
pub macro CoercePointee ( $item: item) {
1084
1111
/* compiler built-in */
1085
1112
}
0 commit comments