mirror of
https://github.com/rust-lang/rust.git
synced 2026-04-27 18:57:42 +03:00
only free lifetimes may get erased
(cherry picked from commit 3b0e1d23b7)
This commit is contained in:
@@ -1132,10 +1132,12 @@ fn fmt(&self, fmt: &mut fmt::Formatter<'_>) -> fmt::Result {
|
||||
///
|
||||
/// [Reference]: ../../reference/items/enumerations.html#custom-discriminant-values-for-fieldless-enumerations
|
||||
///
|
||||
/// The value of a [`Discriminant<T>`] is independent of any *lifetimes* in `T`. As such, reading
|
||||
/// or writing a `Discriminant<Foo<'a>>` as a `Discriminant<Foo<'b>>` (whether via [`transmute`] or
|
||||
/// otherwise) is always sound. Note that this is **not** true for other kinds of generic
|
||||
/// parameters; `Discriminant<Foo<A>>` and `Discriminant<Foo<B>>` might be incompatible.
|
||||
/// The value of a [`Discriminant<T>`] is independent of any *free lifetimes* in `T`. As such,
|
||||
/// reading or writing a `Discriminant<Foo<'a>>` as a `Discriminant<Foo<'b>>` (whether via
|
||||
/// [`transmute`] or otherwise) is always sound. Note that this is **not** true for other kinds
|
||||
/// of generic parameters and for higher-ranked lifetimes; `Discriminant<Foo<A>>` and
|
||||
/// `Discriminant<Foo<B>>` as well as `Discriminant<Bar<dyn for<'a> Trait<'a>>>` and
|
||||
/// `Discriminant<Bar<dyn Trait<'static>>>` may be incompatible.
|
||||
///
|
||||
/// # Examples
|
||||
///
|
||||
|
||||
Reference in New Issue
Block a user