Skip to content

Commit

Permalink
Unrolled build for rust-lang#118006
Browse files Browse the repository at this point in the history
Rollup merge of rust-lang#118006 - lcnr:discriminant-docs, r=compiler-errors

clarify `fn discriminant` guarantees: only free lifetimes may get erased

cc https://github.com/rust-lang/rust/pull/104299/files#r1397082347

don't think this necessitates a backport by itself, but should imo be included if one were to exist.

r? types
  • Loading branch information
rust-timer authored Nov 18, 2023
2 parents 2831701 + 3b0e1d2 commit bf71534
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions library/core/src/mem/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1132,10 +1132,12 @@ impl<T> fmt::Debug for Discriminant<T> {
///
/// [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
///
Expand Down

0 comments on commit bf71534

Please sign in to comment.