Skip to content

Commit

Permalink
Rollup merge of rust-lang#100208 - RalfJung:dyn-upcast-nop, r=petroch…
Browse files Browse the repository at this point in the history
…enkov

make NOP dyn casts not require anything about the vtable

As suggested [on Zulip](https://rust-lang.zulipchat.com/#narrow/stream/144729-t-types/topic/dyn-upcasting.20stabilization/near/292151439). This matches what the codegen backends already do, and what Miri did do until rust-lang#99420 when I made it super extra paranoid.
  • Loading branch information
Dylan-DPC authored Aug 19, 2022
2 parents 1cde1a3 + 8520535 commit ee65a10
Showing 1 changed file with 1 addition and 0 deletions.
1 change: 1 addition & 0 deletions src/unsize.rs
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ pub(crate) fn unsized_info<'tcx>(
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() {
// A NOP cast that doesn't actually change anything, should be allowed even with invalid vtables.
return old_info;
}

Expand Down

0 comments on commit ee65a10

Please sign in to comment.