diff options
| author | Scott Olson <scott@solson.me> | 2017-02-09 03:38:52 -0800 |
|---|---|---|
| committer | Scott Olson <scott@solson.me> | 2017-02-09 03:38:52 -0800 |
| commit | 5eaa7c2d7df58f186015a40778ea888428d008e8 (patch) | |
| tree | 2df777a35dd244e9534309fe4e065fd0e00f6463 | |
| parent | fd2f8a4536cb9b45abd72b8ff977ad48618602b3 (diff) | |
| download | rust-5eaa7c2d7df58f186015a40778ea888428d008e8.tar.gz rust-5eaa7c2d7df58f186015a40778ea888428d008e8.zip | |
Fix unaligned load in librustc_metadata::index.
| -rw-r--r-- | src/librustc_metadata/index.rs | 10 |
1 files changed, 9 insertions, 1 deletions
diff --git a/src/librustc_metadata/index.rs b/src/librustc_metadata/index.rs index 5b52b268849..db9fc870fa8 100644 --- a/src/librustc_metadata/index.rs +++ b/src/librustc_metadata/index.rs @@ -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 } } |
