diff options
| author | Matthias Krüger <matthias.krueger@famsik.de> | 2023-11-17 23:04:24 +0100 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2023-11-17 23:04:24 +0100 |
| commit | e06a6d3ebefdd091f1ae4ca4917a1875adb64daf (patch) | |
| tree | 1ebdcb979773d70a6cde8954ab909fc682f5a70a | |
| parent | 8792e81f29f105efff5ae926b5ae21e5ff7d3d56 (diff) | |
| parent | 3b0e1d23b7fff6b57a634f529ee19d0d173a95f7 (diff) | |
| download | rust-e06a6d3ebefdd091f1ae4ca4917a1875adb64daf.tar.gz rust-e06a6d3ebefdd091f1ae4ca4917a1875adb64daf.zip | |
Rollup merge of #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
| -rw-r--r-- | library/core/src/mem/mod.rs | 10 |
1 files changed, 6 insertions, 4 deletions
diff --git a/library/core/src/mem/mod.rs b/library/core/src/mem/mod.rs index b810318fe7d..bf10ada0176 100644 --- a/library/core/src/mem/mod.rs +++ b/library/core/src/mem/mod.rs @@ -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 /// |
