Skip to content

Commit 4546c8c

Browse files
author
Lukas Markeffsky
committed
don't skip inference for type in offset_of!
1 parent 3a3fbae commit 4546c8c

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)