File tree 1 file changed +12
-4
lines changed
1 file changed +12
-4
lines changed Original file line number Diff line number Diff line change @@ -70,7 +70,7 @@ impl<'tcx> LazySeq<Index> {
70
70
index,
71
71
words. len( ) ) ;
72
72
73
- let position = u32:: from_le ( words[ index] ) ;
73
+ let position = u32:: from_le ( words[ index] . get ( ) ) ;
74
74
if position == u32:: MAX {
75
75
debug ! ( "Index::lookup: position=u32::MAX" ) ;
76
76
None
@@ -84,7 +84,7 @@ impl<'tcx> LazySeq<Index> {
84
84
bytes : & ' a [ u8 ] )
85
85
-> impl Iterator < Item = ( DefIndex , Lazy < Entry < ' tcx > > ) > + ' a {
86
86
let words = & bytes_to_words ( & bytes[ self . position ..] ) [ ..self . len ] ;
87
- words. iter ( ) . enumerate ( ) . filter_map ( |( index, & position) | {
87
+ words. iter ( ) . map ( |word| word . get ( ) ) . enumerate ( ) . filter_map ( |( index, position) | {
88
88
if position == u32:: MAX {
89
89
None
90
90
} else {
@@ -95,8 +95,16 @@ impl<'tcx> LazySeq<Index> {
95
95
}
96
96
}
97
97
98
- fn bytes_to_words ( b : & [ u8 ] ) -> & [ u32 ] {
99
- unsafe { slice:: from_raw_parts ( b. as_ptr ( ) as * const u32 , b. len ( ) / 4 ) }
98
+ #[ repr( packed) ]
99
+ #[ derive( Copy , Clone ) ]
100
+ struct Unaligned < T > ( T ) ;
101
+
102
+ impl < T > Unaligned < T > {
103
+ fn get ( self ) -> T { self . 0 }
104
+ }
105
+
106
+ fn bytes_to_words ( b : & [ u8 ] ) -> & [ Unaligned < u32 > ] {
107
+ unsafe { slice:: from_raw_parts ( b. as_ptr ( ) as * const Unaligned < u32 > , b. len ( ) / 4 ) }
100
108
}
101
109
102
110
fn words_to_bytes ( w : & [ u32 ] ) -> & [ u8 ] {
You can’t perform that action at this time.
0 commit comments