Make struct layout not depend on unsizeable tail
This commit is contained in:
parent
70e04bd88d
commit
381b778d27
2 changed files with 31 additions and 2 deletions
25
tests/ui/layout/issue-112048-unsizing-field-order.rs
Normal file
25
tests/ui/layout/issue-112048-unsizing-field-order.rs
Normal file
|
|
@ -0,0 +1,25 @@
|
|||
// run-pass
|
||||
|
||||
// Check that unsizing doesn't reorder fields.
|
||||
|
||||
#![allow(dead_code)]
|
||||
|
||||
use std::fmt::Debug;
|
||||
|
||||
#[derive(Debug)]
|
||||
struct GcNode<T: ?Sized> {
|
||||
gets_swapped_with_next: usize,
|
||||
next: Option<&'static GcNode<dyn Debug>>,
|
||||
tail: T,
|
||||
}
|
||||
|
||||
fn main() {
|
||||
let node: Box<GcNode<dyn Debug>> = Box::new(GcNode {
|
||||
gets_swapped_with_next: 42,
|
||||
next: None,
|
||||
tail: Box::new(1),
|
||||
});
|
||||
|
||||
assert_eq!(node.gets_swapped_with_next, 42);
|
||||
assert!(node.next.is_none());
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue