We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent fd2f8a4 commit 5eaa7c2Copy full SHA for 5eaa7c2
src/librustc_metadata/index.rs
@@ -96,9 +96,17 @@ impl<'tcx> LazySeq<Index> {
96
}
97
98
#[repr(packed)]
99
-#[derive(Copy, Clone)]
+#[derive(Copy)]
100
struct Unaligned<T>(T);
101
102
+// The derived Clone impl is unsafe for this packed struct since it needs to pass a reference to
103
+// the field to `T::clone`, but this reference may not be properly aligned.
104
+impl<T: Copy> Clone for Unaligned<T> {
105
+ fn clone(&self) -> Self {
106
+ *self
107
+ }
108
+}
109
+
110
impl<T> Unaligned<T> {
111
fn get(self) -> T { self.0 }
112
0 commit comments