Skip to content

Commit 943f458

Browse files
authored
Merge pull request #266 from rmsyn/fixup/write-constraint-check
svd-rs: fix write constraint check
2 parents f4376aa + 973a46c commit 943f458

File tree

2 files changed

+8
-2
lines changed

2 files changed

+8
-2
lines changed

svd-rs/CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ and this project adheres to [Semantic Versioning](http://semver.org/).
1010
- Add `riscv` element for configuration parameters related to RISC-V targets.
1111
You must use the `unstable-riscv` feature to enable this exeperimental element.
1212
- Add `DataType`
13+
- Fix run-time panic for write constraint check
1314

1415
## [v0.14.8] - 2024-02-13
1516

svd-rs/src/field.rs

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -336,8 +336,13 @@ impl FieldInfo {
336336
}
337337
}
338338

339-
if let Some(WriteConstraint::Range(constraint)) = self.write_constraint {
340-
constraint.check_range(0..2_u64.pow(self.bit_range.width))?;
339+
match self.write_constraint {
340+
// If the bit_range has its maximum width, all values will of
341+
// course fit in so we can skip validation.
342+
Some(WriteConstraint::Range(constraint)) if self.bit_range.width < 64 => {
343+
constraint.check_range(0..2_u64.pow(self.bit_range.width))?;
344+
}
345+
_ => (),
341346
}
342347
}
343348

0 commit comments

Comments
 (0)