Skip to content

Commit bf41228

Browse files
authored
Remove Display for {Alignment,ArchitectureSize} (#1738)
These display representations are easy to get confused with the previous return values of `u32` which do implement `Display`, but the `Display` here isn't as applicable as it used to be. As a stopgap remove the `Display` implementations entirely to help identify locations that need to be updated to explicitly use an accessor or otherwise to calculate the size/align information.
1 parent fbb8abd commit bf41228

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

crates/wit-parser/src/sizealign.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ use std::{
66
use crate::{FlagsRepr, Int, Resolve, Type, TypeDef, TypeDefKind};
77

88
/// Architecture specific alignment
9-
#[derive(Eq, PartialEq, PartialOrd, Clone, Copy, Debug)]
9+
#[derive(Eq, PartialEq, PartialOrd, Clone, Copy)]
1010
pub enum Alignment {
1111
/// This represents 4 byte alignment on 32bit and 8 byte alignment on 64bit architectures
1212
Pointer,
@@ -20,7 +20,7 @@ impl Default for Alignment {
2020
}
2121
}
2222

23-
impl std::fmt::Display for Alignment {
23+
impl std::fmt::Debug for Alignment {
2424
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
2525
match self {
2626
Alignment::Pointer => f.write_str("ptr"),
@@ -82,7 +82,7 @@ impl Alignment {
8282
/// Architecture specific measurement of position,
8383
/// the combined amount in bytes is
8484
/// `bytes + pointers * core::mem::size_of::<*const u8>()`
85-
#[derive(Default, Clone, Copy, Eq, PartialEq, Debug)]
85+
#[derive(Default, Clone, Copy, Eq, PartialEq)]
8686
pub struct ArchitectureSize {
8787
/// architecture independent bytes
8888
pub bytes: usize,
@@ -114,7 +114,7 @@ impl From<Alignment> for ArchitectureSize {
114114
}
115115
}
116116

117-
impl std::fmt::Display for ArchitectureSize {
117+
impl std::fmt::Debug for ArchitectureSize {
118118
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
119119
f.write_str(&self.format("ptrsz"))
120120
}

0 commit comments

Comments
 (0)