Skip to content

Commit e664cb2

Browse files
authored
Rollup merge of #106532 - compiler-errors:dyn-star-to-dyn, r=jackh726
Allow codegen to unsize `dyn*` to `dyn` `dyn* Trait` is just another type that implements `Trait`, so we should be able to unsize `&dyn* Trait` into `&dyn Trait` perfectly fine, same for `Box` and other unsizeable types. Fixes #106488
2 parents 9b538e8 + 70a8d8d commit e664cb2

File tree

3 files changed

+21
-3
lines changed

3 files changed

+21
-3
lines changed

compiler/rustc_codegen_ssa/src/base.rs

+1-3
Original file line numberDiff line numberDiff line change
@@ -153,9 +153,7 @@ pub fn unsized_info<'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>>(
153153
(
154154
&ty::Dynamic(ref data_a, _, src_dyn_kind),
155155
&ty::Dynamic(ref data_b, _, target_dyn_kind),
156-
) => {
157-
assert_eq!(src_dyn_kind, target_dyn_kind);
158-
156+
) if src_dyn_kind == target_dyn_kind => {
159157
let old_info =
160158
old_info.expect("unsized_info: missing old info for trait upcasting coercion");
161159
if data_a.principal_def_id() == data_b.principal_def_id() {

tests/ui/dyn-star/dyn-star-to-dyn.rs

+9
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
// build-pass
2+
3+
#![feature(dyn_star)]
4+
//~^ WARN the feature `dyn_star` is incomplete and may not be safe to use and/or cause compiler crashes
5+
6+
fn main() {
7+
let x: dyn* Send = &();
8+
let x = Box::new(x) as Box<dyn Send>;
9+
}
+11
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
warning: the feature `dyn_star` is incomplete and may not be safe to use and/or cause compiler crashes
2+
--> $DIR/dyn-star-to-dyn.rs:3:12
3+
|
4+
LL | #![feature(dyn_star)]
5+
| ^^^^^^^^
6+
|
7+
= note: see issue #102425 <https://github.com/rust-lang/rust/issues/102425> for more information
8+
= note: `#[warn(incomplete_features)]` on by default
9+
10+
warning: 1 warning emitted
11+

0 commit comments

Comments
 (0)