Skip to content
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

Work around ICE in rustc: the naive layout isn't refined by the actual layout #62

Merged
merged 2 commits into from
Jul 22, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
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
2 changes: 1 addition & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ jobs:
toolchain: ${{matrix.rust}}
- name: Enable type layout randomization
run: echo RUSTFLAGS=${RUSTFLAGS}\ -Zrandomize-layout >> $GITHUB_ENV
if: startsWith(matrix.rust, 'nightly')
if: startsWith(matrix.rust, 'nightly') && false # FIXME https://github.com/rust-lang/rust/issues/113941
- run: cargo test

clippy:
Expand Down
4 changes: 3 additions & 1 deletion src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -246,7 +246,9 @@ document_iter! {
mod void_iter {
enum Void {}

pub struct Iter<T>([*const T; 0], Void);
// https://github.com/rust-lang/rust/issues/113941
const WORK_AROUND_RUST_ISSUE_113941: usize = 1;
pub struct Iter<T>([*const T; WORK_AROUND_RUST_ISSUE_113941], Void);

unsafe impl<T> Send for Iter<T> {}
unsafe impl<T> Sync for Iter<T> {}
Expand Down
5 changes: 3 additions & 2 deletions tests/test.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ struct Thing(usize);

#[test]
fn test_iter() {
assert_eq!(0, mem::size_of::<inventory::iter<Thing>>());
assert_eq!(1, mem::align_of::<inventory::iter<Thing>>());
// https://github.com/rust-lang/rust/issues/113941
assert_eq!(16, mem::size_of::<inventory::iter<Thing>>()); // FIXME
assert_eq!(8, mem::align_of::<inventory::iter<Thing>>()); // FIXME
}