Skip to content

Commit c5be07f

Browse files
committed
clippy fixes
1 parent 0e08668 commit c5be07f

File tree

4 files changed

+8
-22
lines changed

4 files changed

+8
-22
lines changed

svd-encoder/src/config.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -130,7 +130,7 @@ where
130130
NumberFormat::UpperHex => format!("{:#X}", value),
131131
NumberFormat::UpperHex8 => format!("{:#010X}", value),
132132
NumberFormat::UpperHex16 => {
133-
if value.into() > std::u32::MAX as u64 {
133+
if value.into() > u32::MAX as u64 {
134134
format!("{:#018X}", value)
135135
} else {
136136
format!("{:#010X}", value)
@@ -139,7 +139,7 @@ where
139139
NumberFormat::LowerHex => format!("{:#x}", value),
140140
NumberFormat::LowerHex8 => format!("{:#010x}", value),
141141
NumberFormat::LowerHex16 => {
142-
if value.into() > std::u32::MAX as u64 {
142+
if value.into() > u32::MAX as u64 {
143143
format!("{:#018x}", value)
144144
} else {
145145
format!("{:#010x}", value)

svd-rs/src/lib.rs

+2-7
Original file line numberDiff line numberDiff line change
@@ -101,22 +101,17 @@ pub mod riscv;
101101
pub use self::riscv::Riscv;
102102

103103
/// Level of validation
104-
#[derive(Clone, Copy, Debug, PartialEq, Eq)]
104+
#[derive(Clone, Copy, Debug, Default, PartialEq, Eq)]
105105
pub enum ValidateLevel {
106106
/// No validation.
107107
Disabled,
108108
/// Weak validation.
109+
#[default]
109110
Weak,
110111
/// Strict validation.
111112
Strict,
112113
}
113114

114-
impl Default for ValidateLevel {
115-
fn default() -> Self {
116-
ValidateLevel::Weak
117-
}
118-
}
119-
120115
impl ValidateLevel {
121116
/// Returns true if validation is disabled.
122117
pub fn is_disabled(self) -> bool {

svd-rs/src/registerproperties.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -133,7 +133,7 @@ pub(crate) fn check_reset_value(
133133
mask: Option<u64>,
134134
lvl: ValidateLevel,
135135
) -> Result<(), Error> {
136-
const MAX_BITS: u32 = core::u64::MAX.count_ones();
136+
const MAX_BITS: u32 = u64::MAX.count_ones();
137137

138138
if let (Some(size), Some(value)) = (size, value) {
139139
if MAX_BITS - value.leading_zeros() > size {

svd-rs/src/riscv.rs

+3-12
Original file line numberDiff line numberDiff line change
@@ -99,18 +99,9 @@ impl RiscvBuilder {
9999
/// Validate and build a [`Riscv`].
100100
pub fn build(self, lvl: ValidateLevel) -> Result<Riscv, SvdError> {
101101
let riscv = Riscv {
102-
core_interrupts: match self.core_interrupts {
103-
Some(core_interrupts) => core_interrupts,
104-
None => Vec::new(),
105-
},
106-
exceptions: match self.exceptions {
107-
Some(exceptions) => exceptions,
108-
None => Vec::new(),
109-
},
110-
priorities: match self.priorities {
111-
Some(priorities) => priorities,
112-
None => Vec::new(),
113-
},
102+
core_interrupts: self.core_interrupts.unwrap_or_default(),
103+
exceptions: self.exceptions.unwrap_or_default(),
104+
priorities: self.priorities.unwrap_or_default(),
114105
harts: self
115106
.harts
116107
.ok_or_else(|| BuildError::Uninitialized("harts".to_string()))?,

0 commit comments

Comments
 (0)