Fix unaligned load in librustc_metadata::index.
This commit is contained in:
parent
fd2f8a4536
commit
5eaa7c2d7d
1 changed files with 9 additions and 1 deletions
|
|
@ -96,9 +96,17 @@ impl<'tcx> LazySeq<Index> {
|
|||
}
|
||||
|
||||
#[repr(packed)]
|
||||
#[derive(Copy, Clone)]
|
||||
#[derive(Copy)]
|
||||
struct Unaligned<T>(T);
|
||||
|
||||
// The derived Clone impl is unsafe for this packed struct since it needs to pass a reference to
|
||||
// the field to `T::clone`, but this reference may not be properly aligned.
|
||||
impl<T: Copy> Clone for Unaligned<T> {
|
||||
fn clone(&self) -> Self {
|
||||
*self
|
||||
}
|
||||
}
|
||||
|
||||
impl<T> Unaligned<T> {
|
||||
fn get(self) -> T { self.0 }
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue