Skip to content

Commit c685730

Browse files
authored
Merge pull request #646 from nicholasbishop/bishop-fix-packed-slice
Fix new lints related to derives on a packed struct
2 parents aa9e485 + c44bf3e commit c685730

File tree

1 file changed

+47
-3
lines changed
  • uefi/src/proto/device_path

1 file changed

+47
-3
lines changed

uefi/src/proto/device_path/mod.rs

+47-3
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,7 @@ pub use device_path_gen::{
8383

8484
use crate::proto::{unsafe_protocol, ProtocolPointer};
8585
use core::ffi::c_void;
86+
use core::fmt::{self, Debug, Formatter};
8687
use core::marker::{PhantomData, PhantomPinned};
8788
use core::mem;
8889
use ptr_meta::Pointee;
@@ -119,7 +120,7 @@ pub struct DevicePathHeader {
119120
/// See the [module-level documentation] for more details.
120121
///
121122
/// [module-level documentation]: crate::proto::device_path
122-
#[derive(Debug, Eq, PartialEq, Pointee)]
123+
#[derive(Eq, Pointee)]
123124
#[repr(C, packed)]
124125
pub struct DevicePathNode {
125126
header: DevicePathHeader,
@@ -186,6 +187,21 @@ impl DevicePathNode {
186187
}
187188
}
188189

190+
impl Debug for DevicePathNode {
191+
fn fmt(&self, f: &mut Formatter) -> fmt::Result {
192+
f.debug_struct("DevicePathNode")
193+
.field("header", &self.header)
194+
.field("data", &&self.data)
195+
.finish()
196+
}
197+
}
198+
199+
impl PartialEq for DevicePathNode {
200+
fn eq(&self, other: &Self) -> bool {
201+
self.header == other.header && self.data == other.data
202+
}
203+
}
204+
189205
/// A single device path instance that ends with either an [`END_INSTANCE`]
190206
/// or [`END_ENTIRE`] node. Use [`DevicePath::instance_iter`] to get the
191207
/// path instances in a [`DevicePath`].
@@ -196,7 +212,7 @@ impl DevicePathNode {
196212
/// [`END_INSTANCE`]: DeviceSubType::END_INSTANCE
197213
/// [module-level documentation]: crate::proto::device_path
198214
#[repr(C, packed)]
199-
#[derive(Debug, Eq, PartialEq, Pointee)]
215+
#[derive(Eq, Pointee)]
200216
pub struct DevicePathInstance {
201217
data: [u8],
202218
}
@@ -216,6 +232,20 @@ impl DevicePathInstance {
216232
}
217233
}
218234

235+
impl Debug for DevicePathInstance {
236+
fn fmt(&self, f: &mut Formatter) -> fmt::Result {
237+
f.debug_struct("DevicePathInstance")
238+
.field("data", &&self.data)
239+
.finish()
240+
}
241+
}
242+
243+
impl PartialEq for DevicePathInstance {
244+
fn eq(&self, other: &Self) -> bool {
245+
self.data == other.data
246+
}
247+
}
248+
219249
/// Device path protocol.
220250
///
221251
/// A device path contains one or more device path instances made of up
@@ -227,7 +257,7 @@ impl DevicePathInstance {
227257
/// [`END_ENTIRE`]: DeviceSubType::END_ENTIRE
228258
#[repr(C, packed)]
229259
#[unsafe_protocol("09576e91-6d3f-11d2-8e39-00a0c969723b")]
230-
#[derive(Debug, Eq, PartialEq, Pointee)]
260+
#[derive(Eq, Pointee)]
231261
pub struct DevicePath {
232262
data: [u8],
233263
}
@@ -302,6 +332,20 @@ impl DevicePath {
302332
}
303333
}
304334

335+
impl Debug for DevicePath {
336+
fn fmt(&self, f: &mut Formatter) -> fmt::Result {
337+
f.debug_struct("DevicePath")
338+
.field("data", &&self.data)
339+
.finish()
340+
}
341+
}
342+
343+
impl PartialEq for DevicePath {
344+
fn eq(&self, other: &Self) -> bool {
345+
self.data == other.data
346+
}
347+
}
348+
305349
/// Iterator over the [`DevicePathInstance`]s in a [`DevicePath`].
306350
///
307351
/// This struct is returned by [`DevicePath::instance_iter`].

0 commit comments

Comments
 (0)