Stabilize RFC3324 dyn upcasting coercion

Aka trait_upcasting feature.

And also adjust the `deref_into_dyn_supertrait` lint.
This commit is contained in:
Urgau 2023-11-21 13:58:01 +01:00
parent 855c6836b7
commit 4c2d6de70e
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();