Skip to content

Commit

Permalink
Merge pull request #62 from dtolnay/workaround
Browse files Browse the repository at this point in the history
Work around ICE in rustc: the naive layout isn't refined by the actual layout
  • Loading branch information
dtolnay committed Jul 22, 2023
2 parents b5c9757 + 51412b3 commit 005724f
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 4 deletions.
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
}

0 comments on commit 005724f

Please sign in to comment.