about summary refs log tree commit diff
path: root/src
diff options
context:
space:
mode:
authorbors <bors@rust-lang.org>2023-11-22 16:15:34 +0000
committerbors <bors@rust-lang.org>2023-11-22 16:15:34 +0000
commit6d2b84b3ed7848fd91b8d6151d4451b3103ed816 (patch)
treebe2f51dd080f22e4c6d99b48304cc3775d77bdb4 /src
parent73bc12199ea8c7651ed98b069c0dd6b0bb5fabcf (diff)
parent4c2d6de70e66f6e2c882acbc9be1c5a53d8a65e4 (diff)
downloadrust-6d2b84b3ed7848fd91b8d6151d4451b3103ed816.tar.gz
rust-6d2b84b3ed7848fd91b8d6151d4451b3103ed816.zip
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
Diffstat (limited to 'src')
-rw-r--r--src/doc/unstable-book/src/language-features/trait-upcasting.md27
-rw-r--r--src/tools/miri/src/lib.rs2
-rw-r--r--src/tools/miri/tests/fail/dyn-upcast-trait-mismatch.rs3
-rw-r--r--src/tools/miri/tests/pass/box-custom-alloc.rs3
-rw-r--r--src/tools/miri/tests/pass/dyn-upcast.rs3
5 files changed, 2 insertions, 36 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
deleted file mode 100644
index 3697ae38f9d..00000000000
--- a/src/doc/unstable-book/src/language-features/trait-upcasting.md
+++ /dev/null
@@ -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;
-```
diff --git a/src/tools/miri/src/lib.rs b/src/tools/miri/src/lib.rs
index 119ec555b2e..d906553ec40 100644
--- a/src/tools/miri/src/lib.rs
+++ b/src/tools/miri/src/lib.rs
@@ -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,
diff --git a/src/tools/miri/tests/fail/dyn-upcast-trait-mismatch.rs b/src/tools/miri/tests/fail/dyn-upcast-trait-mismatch.rs
index 648ac07c43e..7d46ecd8f6e 100644
--- a/src/tools/miri/tests/fail/dyn-upcast-trait-mismatch.rs
+++ b/src/tools/miri/tests/fail/dyn-upcast-trait-mismatch.rs
@@ -1,6 +1,3 @@
-#![feature(trait_upcasting)]
-#![allow(incomplete_features)]
-
 trait Foo: PartialEq<i32> + std::fmt::Debug + Send + Sync {
     fn a(&self) -> i32 {
         10
diff --git a/src/tools/miri/tests/pass/box-custom-alloc.rs b/src/tools/miri/tests/pass/box-custom-alloc.rs
index 155e3d74ab9..3d055961d15 100644
--- a/src/tools/miri/tests/pass/box-custom-alloc.rs
+++ b/src/tools/miri/tests/pass/box-custom-alloc.rs
@@ -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};
diff --git a/src/tools/miri/tests/pass/dyn-upcast.rs b/src/tools/miri/tests/pass/dyn-upcast.rs
index 8432012a9ba..ddaefeca3a3 100644
--- a/src/tools/miri/tests/pass/dyn-upcast.rs
+++ b/src/tools/miri/tests/pass/dyn-upcast.rs
@@ -1,6 +1,3 @@
-#![feature(trait_upcasting)]
-#![allow(incomplete_features)]
-
 fn main() {
     basic();
     diamond();