File tree Expand file tree Collapse file tree 1 file changed +6
-8
lines changed
library/std/src/sys/pal/unix Expand file tree Collapse file tree 1 file changed +6
-8
lines changed Original file line number Diff line number Diff line change @@ -740,29 +740,27 @@ impl Iterator for ReadDir {
740740 // to `byte_offset` and thus does not require the full extent of `*entry_ptr`
741741 // to be in bounds of the same allocation, only the offset of the field
742742 // being referenced.
743- macro_rules! entry_field_ptr {
744- ( $field: ident) => {
745- & raw const ( * entry_ptr) . $field
746- } ;
747- }
748743
749744 // d_name is guaranteed to be null-terminated.
750- let name = CStr :: from_ptr ( entry_field_ptr ! ( d_name) . cast ( ) ) ;
745+ let name = CStr :: from_ptr ( ( & raw const ( * entry_ptr ) . d_name ) . cast ( ) ) ;
751746 let name_bytes = name. to_bytes ( ) ;
752747 if name_bytes == b"." || name_bytes == b".." {
753748 continue ;
754749 }
755750
751+ // When loading from a field, we can skip the `&raw const`; `(*entry_ptr).d_ino` as
752+ // a value expression will do the right thing: `byte_offset` to the field and then
753+ // only access those bytes.
756754 #[ cfg( not( target_os = "vita" ) ) ]
757755 let entry = dirent64_min {
758- d_ino : * entry_field_ptr ! ( d_ino ) as u64 ,
756+ d_ino : ( * entry_ptr ) . d_ino as u64 ,
759757 #[ cfg( not( any(
760758 target_os = "solaris" ,
761759 target_os = "illumos" ,
762760 target_os = "aix" ,
763761 target_os = "nto" ,
764762 ) ) ) ]
765- d_type : * entry_field_ptr ! ( d_type ) as u8 ,
763+ d_type : ( * entry_ptr ) . d_type as u8 ,
766764 } ;
767765
768766 #[ cfg( target_os = "vita" ) ]
You can’t perform that action at this time.
0 commit comments