Skip to content

[beta] backport #113000

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 8 commits into from
Jun 24, 2023
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Add test case for unsizing with niche
  • Loading branch information
wesleywiser authored and Mark-Simulacrum committed Jun 24, 2023
commit f8052fca8300b98ce0d631e96d1533bc070a418b
30 changes: 30 additions & 0 deletions tests/ui/layout/issue-112048-unsizing-niche.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
// run-pass

// Check that unsizing does not change which field is considered for niche layout.

#![feature(offset_of)]
#![allow(dead_code)]

#[derive(Clone)]
struct WideptrField<T: ?Sized> {
first: usize,
second: usize,
niche: NicheAtEnd,
tail: T,
}

#[derive(Clone)]
#[repr(C)]
struct NicheAtEnd {
arr: [u8; 7],
b: bool,
}

type Tail = [bool; 8];

fn main() {
assert_eq!(
core::mem::offset_of!(WideptrField<Tail>, niche),
core::mem::offset_of!(WideptrField<dyn Send>, niche)
);
}