Skip to content

Commit

Permalink
Work around ICE in rustc: the naive layout isn't refined by the actua…
Browse files Browse the repository at this point in the history
…l layout
  • Loading branch information
dtolnay committed Jul 22, 2023
1 parent b5c9757 commit f5a0c86
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 3 deletions.
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
4 changes: 2 additions & 2 deletions tests/test.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,6 @@ 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>>());
assert_eq!(16, mem::size_of::<inventory::iter<Thing>>());
assert_eq!(8, mem::align_of::<inventory::iter<Thing>>());
}

0 comments on commit f5a0c86

Please sign in to comment.