Skip to content

Commit

Permalink
clippy fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
burrbull committed Aug 22, 2024
1 parent 0e08668 commit c5be07f
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 22 deletions.
4 changes: 2 additions & 2 deletions svd-encoder/src/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,7 @@ where
NumberFormat::UpperHex => format!("{:#X}", value),
NumberFormat::UpperHex8 => format!("{:#010X}", value),
NumberFormat::UpperHex16 => {
if value.into() > std::u32::MAX as u64 {
if value.into() > u32::MAX as u64 {
format!("{:#018X}", value)
} else {
format!("{:#010X}", value)
Expand All @@ -139,7 +139,7 @@ where
NumberFormat::LowerHex => format!("{:#x}", value),
NumberFormat::LowerHex8 => format!("{:#010x}", value),
NumberFormat::LowerHex16 => {
if value.into() > std::u32::MAX as u64 {
if value.into() > u32::MAX as u64 {
format!("{:#018x}", value)
} else {
format!("{:#010x}", value)
Expand Down
9 changes: 2 additions & 7 deletions svd-rs/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -101,22 +101,17 @@ pub mod riscv;
pub use self::riscv::Riscv;

/// Level of validation
#[derive(Clone, Copy, Debug, PartialEq, Eq)]
#[derive(Clone, Copy, Debug, Default, PartialEq, Eq)]
pub enum ValidateLevel {
/// No validation.
Disabled,
/// Weak validation.
#[default]
Weak,
/// Strict validation.
Strict,
}

impl Default for ValidateLevel {
fn default() -> Self {
ValidateLevel::Weak
}
}

impl ValidateLevel {
/// Returns true if validation is disabled.
pub fn is_disabled(self) -> bool {
Expand Down
2 changes: 1 addition & 1 deletion svd-rs/src/registerproperties.rs
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,7 @@ pub(crate) fn check_reset_value(
mask: Option<u64>,
lvl: ValidateLevel,
) -> Result<(), Error> {
const MAX_BITS: u32 = core::u64::MAX.count_ones();
const MAX_BITS: u32 = u64::MAX.count_ones();

if let (Some(size), Some(value)) = (size, value) {
if MAX_BITS - value.leading_zeros() > size {
Expand Down
15 changes: 3 additions & 12 deletions svd-rs/src/riscv.rs
Original file line number Diff line number Diff line change
Expand Up @@ -99,18 +99,9 @@ impl RiscvBuilder {
/// Validate and build a [`Riscv`].
pub fn build(self, lvl: ValidateLevel) -> Result<Riscv, SvdError> {
let riscv = Riscv {
core_interrupts: match self.core_interrupts {
Some(core_interrupts) => core_interrupts,
None => Vec::new(),
},
exceptions: match self.exceptions {
Some(exceptions) => exceptions,
None => Vec::new(),
},
priorities: match self.priorities {
Some(priorities) => priorities,
None => Vec::new(),
},
core_interrupts: self.core_interrupts.unwrap_or_default(),
exceptions: self.exceptions.unwrap_or_default(),
priorities: self.priorities.unwrap_or_default(),
harts: self
.harts
.ok_or_else(|| BuildError::Uninitialized("harts".to_string()))?,
Expand Down

0 comments on commit c5be07f

Please sign in to comment.