Skip to content

Commit

Permalink
Allow codegen to unsize dyn* to dyn
Browse files Browse the repository at this point in the history
  • Loading branch information
compiler-errors committed Jan 9, 2023
1 parent 388538f commit 170e942
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 3 deletions.
4 changes: 1 addition & 3 deletions compiler/rustc_codegen_ssa/src/base.rs
Original file line number Diff line number Diff line change
Expand Up @@ -152,9 +152,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() {
Expand Down
9 changes: 9 additions & 0 deletions src/test/ui/dyn-star/dyn-star-to-dyn.rs
Original file line number Diff line number Diff line change
@@ -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<dyn Send>;
}
11 changes: 11 additions & 0 deletions src/test/ui/dyn-star/dyn-star-to-dyn.stderr
Original file line number Diff line number Diff line change
@@ -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 <https://github.com/rust-lang/rust/issues/102425> for more information
= note: `#[warn(incomplete_features)]` on by default

warning: 1 warning emitted

0 comments on commit 170e942

Please sign in to comment.