Skip to content

Commit 371b88a

Browse files
committed
Auto merge of #111696 - lukas-code:offset-of-erase-regions-harder, r=compiler-errors
don't skip inference for type in `offset_of!` Fixes rust-lang/rust#111678 by no longer skipping inference on the type in `offset_of!`. Simply erasing the regions the during writeback isn't enough and can cause ICEs. A test case for this is included. This reverts rust-lang/rust#111661, because it becomes redundant, since inference already erases the regions.
2 parents 5d1d2b6 + 4546c8c commit 371b88a

File tree

1 file changed

+5
-0
lines changed

1 file changed

+5
-0
lines changed

core/tests/mem.rs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -394,13 +394,18 @@ fn offset_of() {
394394
z: T
395395
}
396396

397+
trait Trait {}
398+
397399
// Ensure that this type of generics works
398400
fn offs_of_z<T>() -> usize {
399401
offset_of!(Generic<T>, z)
400402
}
401403

402404
assert_eq!(offset_of!(Generic<u8>, z), 8);
403405
assert_eq!(offs_of_z::<u8>(), 8);
406+
407+
// Ensure that it works with the implicit lifetime in `Box<dyn Trait + '_>`.
408+
assert_eq!(offset_of!(Generic<Box<dyn Trait>>, z), 8);
404409
}
405410

406411
#[test]

0 commit comments

Comments
 (0)