Skip to content

Commit 572d4f7

Browse files
committed
start to describe trait upcasting
1 parent 1ea35c0 commit 572d4f7

File tree

2 files changed

+20
-0
lines changed

2 files changed

+20
-0
lines changed

src/changelog.rst

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,13 @@ with the change that has been applied due to it.
1818
just the language changes that had an impact to the FLS. See the `release
1919
notes`_ for a full list of changes.
2020

21+
Language changes in Rust 1.86.0
22+
-------------------------------
23+
24+
- `Stabilize upcasting trait objects to supertraits. <https://github.com/rust-lang/rust/pull/134367>`_
25+
26+
- New paragraph: :p:`fls_QB4c6FNKxaPl`
27+
2128
Language changes in Rust 1.85.0
2229
-------------------------------
2330

src/types-and-traits.rst

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2048,6 +2048,19 @@ occur when:
20482048
* :dp:`fls_SYnFJBhi0IWj`
20492049
The source :t:`type` is a :t:`trait object type` and the target :t:`type` is a :t:`trait object type` with the same or no :t:`[principal trait bound]`, and the target :t:`type` has the same or less non-:t:`principal trait` :t:`[trait bound]s`.
20502050

2051+
* :dp:`fls_QB4c6FNKxaPl`
2052+
The source :t:`type` is ``dyn T`` and the target :t:`type` is ``dyn U``,
2053+
where ``U`` is a :t:`supertrait` of ``T``.
2054+
2055+
.. code-block:: rust
2056+
2057+
trait Sub: Super {}
2058+
trait Super {}
2059+
2060+
fn upcast(x: &dyn Sub) -> &dyn Super {
2061+
x // implicit coercion
2062+
}
2063+
20512064
:dp:`fls_iiiu2q7pym4p`
20522065
An :t:`unsized coercion` is a :t:`type coercion` that converts a :t:`sized type`
20532066
into an :t:`unsized type`. :t:`Unsized coercion` from a source :t:`type` to a

0 commit comments

Comments
 (0)