Skip to content

Commit 2c1a1ed

Browse files
committed
use prettyplease to format
1 parent bd0df64 commit 2c1a1ed

File tree

4 files changed

+16
-9
lines changed

4 files changed

+16
-9
lines changed

ci/svd2rust-regress/Cargo.toml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,3 +13,5 @@ anyhow = "1"
1313
thiserror = "1"
1414
serde = "1"
1515
serde_json = "1"
16+
prettyplease = "0.2"
17+
syn = "2"

ci/svd2rust-regress/src/main.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -182,11 +182,11 @@ impl Tests {
182182
}
183183
}
184184
});
185-
Ok(if any_fails.load(Ordering::Acquire) {
185+
if any_fails.load(Ordering::Acquire) {
186186
exit(1);
187187
} else {
188188
exit(0);
189-
})
189+
}
190190
}
191191
}
192192

ci/svd2rust-regress/src/svd_test.rs

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -247,6 +247,16 @@ impl TestCase {
247247
}
248248
_ => {}
249249
}
250+
let lib_rs =
251+
fs::read_to_string(&lib_rs_file).with_context(|| "Failed to read lib.rs file")?;
252+
let file = syn::parse_file(&lib_rs)
253+
.with_context(|| format!("couldn't parse {}", lib_rs_file.display()))?;
254+
File::options()
255+
.write(true)
256+
.open(&lib_rs_file)
257+
.with_context(|| format!("couldn't open {}", lib_rs_file.display()))?
258+
.write(prettyplease::unparse(&file).as_bytes())
259+
.with_context(|| format!("couldn't write {}", lib_rs_file.display()))?;
250260
let rustfmt_err_file = path_helper_base(&chip_dir, &["rustfmt.err.log"]);
251261
if let Some(rustfmt_bin_path) = rustfmt_bin_path {
252262
// Run `cargo fmt`, capturing stderr to a log file

src/generate/peripheral.rs

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -245,20 +245,15 @@ pub fn render(p_original: &Peripheral, index: &Index, config: &Config) -> Result
245245

246246
/// An enum describing the derivation status of an erc, which allows for disjoint arrays to be
247247
/// implicitly derived from a common type.
248-
#[derive(Debug, PartialEq)]
248+
#[derive(Debug, PartialEq, Default)]
249249
enum DeriveInfo {
250+
#[default]
250251
Root,
251252
Explicit(RegisterPath),
252253
Implicit(RegisterPath),
253254
Cluster, // don't do anything different for clusters
254255
}
255256

256-
impl Default for DeriveInfo {
257-
fn default() -> Self {
258-
DeriveInfo::Root
259-
}
260-
}
261-
262257
impl fmt::Display for DeriveInfo {
263258
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
264259
write!(f, "{self:?}")

0 commit comments

Comments
 (0)