From 70a8d8dcf3c07c3a43c3ee0561dfe5ce594ae365 Mon Sep 17 00:00:00 2001 From: Michael Goulet Date: Fri, 6 Jan 2023 08:47:35 +0000 Subject: [PATCH] Allow codegen to unsize dyn* to dyn --- compiler/rustc_codegen_ssa/src/base.rs | 4 +--- tests/ui/dyn-star/dyn-star-to-dyn.rs | 9 +++++++++ tests/ui/dyn-star/dyn-star-to-dyn.stderr | 11 +++++++++++ 3 files changed, 21 insertions(+), 3 deletions(-) create mode 100644 tests/ui/dyn-star/dyn-star-to-dyn.rs create mode 100644 tests/ui/dyn-star/dyn-star-to-dyn.stderr diff --git a/compiler/rustc_codegen_ssa/src/base.rs b/compiler/rustc_codegen_ssa/src/base.rs index d318c15d34221..f7312f6fcdafd 100644 --- a/compiler/rustc_codegen_ssa/src/base.rs +++ b/compiler/rustc_codegen_ssa/src/base.rs @@ -153,9 +153,7 @@ pub fn unsized_info<'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>>( ( &ty::Dynamic(ref data_a, _, src_dyn_kind), &ty::Dynamic(ref data_b, _, target_dyn_kind), - ) => { - assert_eq!(src_dyn_kind, target_dyn_kind); - + ) if src_dyn_kind == target_dyn_kind => { let old_info = old_info.expect("unsized_info: missing old info for trait upcasting coercion"); if data_a.principal_def_id() == data_b.principal_def_id() { diff --git a/tests/ui/dyn-star/dyn-star-to-dyn.rs b/tests/ui/dyn-star/dyn-star-to-dyn.rs new file mode 100644 index 0000000000000..a6d9df9523af8 --- /dev/null +++ b/tests/ui/dyn-star/dyn-star-to-dyn.rs @@ -0,0 +1,9 @@ +// build-pass + +#![feature(dyn_star)] +//~^ WARN the feature `dyn_star` is incomplete and may not be safe to use and/or cause compiler crashes + +fn main() { + let x: dyn* Send = &(); + let x = Box::new(x) as Box; +} diff --git a/tests/ui/dyn-star/dyn-star-to-dyn.stderr b/tests/ui/dyn-star/dyn-star-to-dyn.stderr new file mode 100644 index 0000000000000..03aedf5f797a5 --- /dev/null +++ b/tests/ui/dyn-star/dyn-star-to-dyn.stderr @@ -0,0 +1,11 @@ +warning: the feature `dyn_star` is incomplete and may not be safe to use and/or cause compiler crashes + --> $DIR/dyn-star-to-dyn.rs:3:12 + | +LL | #![feature(dyn_star)] + | ^^^^^^^^ + | + = note: see issue #102425 for more information + = note: `#[warn(incomplete_features)]` on by default + +warning: 1 warning emitted +