Skip to content

Commit dc217a0

Browse files
committed
Auto merge of #3227 - rust-lang:rustup-2023-12-15, r=RalfJung
Automatic Rustup
2 parents 9daa30e + 2e952f1 commit dc217a0

File tree

3 files changed

+23
-2
lines changed

3 files changed

+23
-2
lines changed

rust-version

+1-1
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
e6d1b0ec9859e6f5c29aaa3b6525fb625bf354ad
1+
604f185fae9a4b0edf7e28f616a0f53880f8f074

src/diagnostics.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -512,7 +512,7 @@ pub fn report_msg<'tcx>(
512512
}
513513
}
514514

515-
handler.emit_diagnostic(&mut err);
515+
handler.emit_diagnostic(err);
516516
}
517517

518518
impl<'mir, 'tcx> MiriMachine<'mir, 'tcx> {

tests/pass/packed-struct-dyn-trait.rs

+21
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
// run-pass
2+
use std::ptr::addr_of;
3+
4+
// When the unsized tail is a `dyn Trait`, its alignments is only dynamically known. This means the
5+
// packed(2) needs to be applied at runtime: the actual alignment of the field is `min(2,
6+
// usual_alignment)`. Here we check that we do this right by comparing size, alignment, and field
7+
// offset before and after unsizing.
8+
fn main() {
9+
#[repr(C, packed(2))]
10+
struct Packed<T: ?Sized>(u8, core::mem::ManuallyDrop<T>);
11+
12+
let p = Packed(0, core::mem::ManuallyDrop::new(1));
13+
let p: &Packed<usize> = &p;
14+
let sized = (core::mem::size_of_val(p), core::mem::align_of_val(p));
15+
let sized_offset = unsafe { addr_of!(p.1).cast::<u8>().offset_from(addr_of!(p.0)) };
16+
let p: &Packed<dyn Send> = p;
17+
let un_sized = (core::mem::size_of_val(p), core::mem::align_of_val(p));
18+
let un_sized_offset = unsafe { addr_of!(p.1).cast::<u8>().offset_from(addr_of!(p.0)) };
19+
assert_eq!(sized, un_sized);
20+
assert_eq!(sized_offset, un_sized_offset);
21+
}

0 commit comments

Comments
 (0)