Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Specify auto trait trait object upcasting #513

Merged
merged 1 commit into from
Jul 8, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions src/changelog.rst
Original file line number Diff line number Diff line change
Expand Up @@ -145,6 +145,8 @@ Language changes in Rust 1.78.0

* `\`trait Trait: Auto {}\`: allow upcasting from \`dyn Trait\` to \`dyn Trait + Auto\` <https://github.com/rust-lang/rust/pull/119338>`_

* New paragraph: :p:`fls_SYnFJBhi0IWj`

language changes in Rust 1.77.0
-------------------------------

Expand Down
8 changes: 8 additions & 0 deletions src/glossary.rst
Original file line number Diff line number Diff line change
Expand Up @@ -5057,6 +5057,14 @@ primitive representation
:dt:`Primitive representation` is the :t:`type representation` of
:t:`[integer type]s`.

.. _fls_mk3sa7OvtJvB:

principal trait
^^^^^^^^^^^^^^^

:dp:`fls_YtYOHoPaMPFX`
The :dt:`principal trait` of :t:`trait object type` is its first :t:`trait bound`.

.. _fls_v1u1mevpj0kj:

private visibility
Expand Down
15 changes: 12 additions & 3 deletions src/types-and-traits.rst
Original file line number Diff line number Diff line change
Expand Up @@ -1156,10 +1156,14 @@ Trait Object Types
A :t:`trait object type` is a :t:`type` that implements a :t:`trait`, where the
:t:`type` is not known at compile time.

:dp:`fls_eWac7zOda3lh`
The :t:`principal trait` of :t:`trait object type` is the first :t:`trait bound`.
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This definition isn't used not (thought I'd need the term when describing this at first), but it will become relevant in the future when full upcasting exists


:dp:`fls_9z8oleh0wdel`
The first :t:`trait bound` of a :t:`trait object type` shall denote an
:t:`object safe` :t:`trait`. Any subsequent :t:`[trait bound]s` shall denote
:t:`[auto trait]s`.
The :t:`principal trait` shall denote an :t:`object safe` :t:`trait`.

:dp:`fls_hJII8XYAtZeY`
All non-:t:`principal trait` :t:`[trait bound]s` shall denote :t:`[auto trait]s`.

:dp:`fls_s0oy2c8t4yz9`
A :t:`trait object type` shall not contain :t:`[opt-out trait bound]s`.
Expand Down Expand Up @@ -1992,6 +1996,11 @@ occur when:
The source :t:`type` is the :t:`never type` and the target :t:`type` is any
:t:`type`.

* :dp:`fls_SYnFJBhi0IWj`
The source :t:`type` is a :t:`trait object type` and the target :t:`type` is a
:t:`trait object type` with the same :t:`[trait bound]s` and additional
:t:`[auto trait]s`.

:dp:`fls_iiiu2q7pym4p`
An :t:`unsized coercion` is a :t:`type coercion` that converts a :t:`sized type`
into an :t:`unsized type`. :t:`Unsized coercion` from a source :t:`type` to a
Expand Down
Loading