diff options
| author | bors <bors@rust-lang.org> | 2024-01-22 22:04:50 +0000 |
|---|---|---|
| committer | bors <bors@rust-lang.org> | 2024-01-22 22:04:50 +0000 |
| commit | d6b151fc77e213bf637db0f12c1965ace3ffe255 (patch) | |
| tree | e420a6d4c1774e65195f08e30fe1d6c70df1b002 /src/doc | |
| parent | d5fd0997291ca0135401a39dff25c8a9c13b8961 (diff) | |
| parent | a787232abb960290eb62051e8236b8449113407c (diff) | |
| download | rust-d6b151fc77e213bf637db0f12c1965ace3ffe255.tar.gz rust-d6b151fc77e213bf637db0f12c1965ace3ffe255.zip | |
Auto merge of #120251 - matthiaskrgr:rollup-gttrw68, r=matthiaskrgr
Rollup of 8 pull requests
Successful merges:
- #119664 (Fix tty detection for msys2's `/dev/ptmx`)
- #120104 (never_patterns: Count `!` bindings as diverging)
- #120109 (Move cmath into `sys`)
- #120143 (Consolidate logic around resolving built-in coroutine trait impls)
- #120159 (Track `verbose` and `verbose_internals`)
- #120216 (Fix a `trimmed_def_paths` assertion failure.)
- #120220 (Document `Token{Stream,Tree}::Display` more thoroughly.)
- #120233 (Revert stabilization of trait_upcasting feature)
r? `@ghost`
`@rustbot` modify labels: rollup
Diffstat (limited to 'src/doc')
| -rw-r--r-- | src/doc/unstable-book/src/language-features/trait-upcasting.md | 27 |
1 files changed, 27 insertions, 0 deletions
diff --git a/src/doc/unstable-book/src/language-features/trait-upcasting.md b/src/doc/unstable-book/src/language-features/trait-upcasting.md new file mode 100644 index 00000000000..3697ae38f9d --- /dev/null +++ b/src/doc/unstable-book/src/language-features/trait-upcasting.md @@ -0,0 +1,27 @@ +# `trait_upcasting` + +The tracking issue for this feature is: [#65991] + +[#65991]: https://github.com/rust-lang/rust/issues/65991 + +------------------------ + +The `trait_upcasting` feature adds support for trait upcasting coercion. This allows a +trait object of type `dyn Bar` to be cast to a trait object of type `dyn Foo` +so long as `Bar: Foo`. + +```rust,edition2018 +#![feature(trait_upcasting)] +#![allow(incomplete_features)] + +trait Foo {} + +trait Bar: Foo {} + +impl Foo for i32 {} + +impl<T: Foo + ?Sized> Bar for T {} + +let bar: &dyn Bar = &123; +let foo: &dyn Foo = bar; +``` |
