Skip to content

Commit

Permalink
generic register Debug
Browse files Browse the repository at this point in the history
  • Loading branch information
burrbull committed May 10, 2024
1 parent ae239a2 commit 05bc353
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 15 deletions.
2 changes: 1 addition & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/).

## [Unreleased]

- Yet more clean field `Debug`
- Yet more clean field & register `Debug`

## [v0.33.2] - 2024-05-07

Expand Down
9 changes: 9 additions & 0 deletions src/generate/generic.rs
Original file line number Diff line number Diff line change
Expand Up @@ -258,6 +258,15 @@ impl<REG: Readable + Writable> Reg<REG> {
}
}

impl<REG: Readable> core::fmt::Debug for crate::generic::Reg<REG>
where
R<REG>: core::fmt::Debug
{
fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result {
core::fmt::Debug::fmt(&self.read(), f)
}
}

#[doc(hidden)]
pub mod raw {
use super::{marker, BitM, FieldSpec, RegisterSpec, Unsafe, Writable};
Expand Down
14 changes: 0 additions & 14 deletions src/generate/register.rs
Original file line number Diff line number Diff line change
Expand Up @@ -331,12 +331,6 @@ pub fn render_register_mod(
write!(f, "{}", self.bits())
}
}
#debug_feature
impl core::fmt::Debug for crate::generic::Reg<#regspec_ty> {
fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result {
core::fmt::Debug::fmt(&self.read(), f)
}
}
});
}

Expand Down Expand Up @@ -492,14 +486,6 @@ fn render_register_mod_debug(
#close
#close
});
r_debug_impl.extend(quote! {
#debug_feature
impl core::fmt::Debug for crate::generic::Reg<#regspec_ty> {
fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result {
core::fmt::Debug::fmt(&self.read(), f)
}
}
});
} else if !access.can_read() || register.read_action.is_some() {
r_debug_impl.extend(quote! {
#debug_feature
Expand Down

0 comments on commit 05bc353

Please sign in to comment.