Auto merge of #118133 - Urgau:stabilize_trait_upcasting, r=WaffleLapkin

Stabilize RFC3324 dyn upcasting coercion

This PR stabilize the `trait_upcasting` feature, aka https://github.com/rust-lang/rfcs/pull/3324.

The FCP was completed here: https://github.com/rust-lang/rust/issues/65991#issuecomment-1817552398.

~~And also remove the `deref_into_dyn_supertrait` lint which is now handled by dyn upcasting coercion.~~

Heavily inspired by https://github.com/rust-lang/rust/pull/101718
Fixes https://github.com/rust-lang/rust/issues/65991
This commit is contained in:
bors 2023-11-22 16:15:34 +00:00
commit 6d2b84b3ed
69 changed files with 107 additions and 357 deletions

View file

@ -1,27 +0,0 @@
# `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;
```

View file

@ -11,7 +11,7 @@
#![feature(round_ties_even)]
#![feature(let_chains)]
#![feature(lint_reasons)]
#![feature(trait_upcasting)]
#![cfg_attr(bootstrap, feature(trait_upcasting))]
// Configure clippy and other lints
#![allow(
clippy::collapsible_else_if,

View file

@ -1,6 +1,3 @@
#![feature(trait_upcasting)]
#![allow(incomplete_features)]
trait Foo: PartialEq<i32> + std::fmt::Debug + Send + Sync {
fn a(&self) -> i32 {
10

View file

@ -1,7 +1,6 @@
//@revisions: stack tree
//@[tree]compile-flags: -Zmiri-tree-borrows
#![allow(incomplete_features)] // for trait upcasting
#![feature(allocator_api, trait_upcasting)]
#![feature(allocator_api)]
use std::alloc::Layout;
use std::alloc::{AllocError, Allocator};

View file

@ -1,6 +1,3 @@
#![feature(trait_upcasting)]
#![allow(incomplete_features)]
fn main() {
basic();
diamond();