Skip to content

Commit cff4ac4

Browse files
authored
Merge pull request #746 from rust-embedded/derive-field
fix field derive
2 parents 8dd361f + ee3afce commit cff4ac4

File tree

5 files changed

+16
-12
lines changed

5 files changed

+16
-12
lines changed

.github/workflows/ci.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@ jobs:
7979
- { rust: stable, vendor: Toshiba, options: all }
8080
- { rust: stable, vendor: Toshiba, options: "" }
8181
# Test MSRV
82-
- { rust: 1.65.0, vendor: Nordic, options: "" }
82+
- { rust: 1.70.0, vendor: Nordic, options: "" }
8383
# Use nightly for architectures which don't support stable
8484
- { rust: nightly, vendor: MSP430, options: "--atomics" }
8585
- { rust: nightly, vendor: MSP430, options: "" }

CHANGELOG.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,9 @@ and this project adheres to [Semantic Versioning](https://semver.org/).
77

88
## [Unreleased]
99

10+
- Bump MSRV to 1.70
11+
- Fix `derivedFrom` on field
12+
1013
## [v0.30.0] - 2023-08-16
1114

1215
- Add `aarch64` target for releases, more readme badges

Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ name = "svd2rust"
2525
repository = "https://github.com/rust-embedded/svd2rust/"
2626
version = "0.30.0"
2727
readme = "README.md"
28-
rust-version = "1.65"
28+
rust-version = "1.70"
2929

3030
[package.metadata.deb]
3131
section = "rust"

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
![GitHub top language](https://img.shields.io/github/languages/top/rust-embedded/svd2rust)
2-
![Minimum Supported Rust Version](https://img.shields.io/badge/rustc-1.65+-blue.svg)
2+
![Minimum Supported Rust Version](https://img.shields.io/badge/rustc-1.70+-blue.svg)
33
[![crates.io](https://img.shields.io/crates/v/svd2rust.svg)](https://crates.io/crates/svd2rust)
44
[![crates.io](https://img.shields.io/crates/d/svd2rust.svg)](https://crates.io/crates/svd2rust)
55
[![Released API docs](https://docs.rs/svd2rust/badge.svg)](https://docs.rs/svd2rust)

src/generate/register.rs

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -554,12 +554,11 @@ pub fn fields(
554554
let inline = quote! { #[inline(always)] };
555555
for &f in fields.iter() {
556556
let mut f = f.clone();
557-
let mut fpath = None;
558-
let dpath = f.derived_from.take();
559-
if let Some(dpath) = dpath {
560-
fpath = derive_field(&mut f, &dpath, rpath, index)?;
557+
let mut fdpath = None;
558+
if let Some(dpath) = f.derived_from.take() {
559+
fdpath = derive_field(&mut f, &dpath, rpath, index)?;
561560
}
562-
let fpath = fpath.unwrap_or_else(|| rpath.new_field(&f.name));
561+
let fpath = rpath.new_field(&f.name);
563562
// TODO(AJM) - do we need to do anything with this range type?
564563
let BitRange { offset, width, .. } = f.bit_range;
565564

@@ -601,10 +600,12 @@ pub fn fields(
601600
let dpath = ev.derived_from.take();
602601
if let Some(dpath) = dpath {
603602
epath = Some(derive_enumerated_values(&mut ev, &dpath, &fpath, index)?);
604-
}
605-
// TODO: remove this hack
606-
if let Some(epath) = epath.as_ref() {
607-
ev = (*index.evs.get(epath).unwrap()).clone();
603+
// TODO: remove this hack
604+
if let Some(epath) = epath.as_ref() {
605+
ev = (*index.evs.get(epath).unwrap()).clone();
606+
}
607+
} else if let Some(path) = fdpath.as_ref() {
608+
epath = Some(path.new_enum(ev.name.clone().unwrap_or_else(|| path.name.clone())));
608609
}
609610
lookup_results.push((ev, epath));
610611
}

0 commit comments

Comments
 (0)