Skip to content

Commit

Permalink
Merge pull request #746 from rust-embedded/derive-field
Browse files Browse the repository at this point in the history
fix field derive
  • Loading branch information
Emilgardis authored Oct 1, 2023
2 parents 8dd361f + ee3afce commit cff4ac4
Show file tree
Hide file tree
Showing 5 changed files with 16 additions and 12 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ jobs:
- { rust: stable, vendor: Toshiba, options: all }
- { rust: stable, vendor: Toshiba, options: "" }
# Test MSRV
- { rust: 1.65.0, vendor: Nordic, options: "" }
- { rust: 1.70.0, vendor: Nordic, options: "" }
# Use nightly for architectures which don't support stable
- { rust: nightly, vendor: MSP430, options: "--atomics" }
- { rust: nightly, vendor: MSP430, options: "" }
Expand Down
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,9 @@ and this project adheres to [Semantic Versioning](https://semver.org/).

## [Unreleased]

- Bump MSRV to 1.70
- Fix `derivedFrom` on field

## [v0.30.0] - 2023-08-16

- Add `aarch64` target for releases, more readme badges
Expand Down
2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ name = "svd2rust"
repository = "https://github.com/rust-embedded/svd2rust/"
version = "0.30.0"
readme = "README.md"
rust-version = "1.65"
rust-version = "1.70"

[package.metadata.deb]
section = "rust"
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
![GitHub top language](https://img.shields.io/github/languages/top/rust-embedded/svd2rust)
![Minimum Supported Rust Version](https://img.shields.io/badge/rustc-1.65+-blue.svg)
![Minimum Supported Rust Version](https://img.shields.io/badge/rustc-1.70+-blue.svg)
[![crates.io](https://img.shields.io/crates/v/svd2rust.svg)](https://crates.io/crates/svd2rust)
[![crates.io](https://img.shields.io/crates/d/svd2rust.svg)](https://crates.io/crates/svd2rust)
[![Released API docs](https://docs.rs/svd2rust/badge.svg)](https://docs.rs/svd2rust)
Expand Down
19 changes: 10 additions & 9 deletions src/generate/register.rs
Original file line number Diff line number Diff line change
Expand Up @@ -554,12 +554,11 @@ pub fn fields(
let inline = quote! { #[inline(always)] };
for &f in fields.iter() {
let mut f = f.clone();
let mut fpath = None;
let dpath = f.derived_from.take();
if let Some(dpath) = dpath {
fpath = derive_field(&mut f, &dpath, rpath, index)?;
let mut fdpath = None;
if let Some(dpath) = f.derived_from.take() {
fdpath = derive_field(&mut f, &dpath, rpath, index)?;
}
let fpath = fpath.unwrap_or_else(|| rpath.new_field(&f.name));
let fpath = rpath.new_field(&f.name);
// TODO(AJM) - do we need to do anything with this range type?
let BitRange { offset, width, .. } = f.bit_range;

Expand Down Expand Up @@ -601,10 +600,12 @@ pub fn fields(
let dpath = ev.derived_from.take();
if let Some(dpath) = dpath {
epath = Some(derive_enumerated_values(&mut ev, &dpath, &fpath, index)?);
}
// TODO: remove this hack
if let Some(epath) = epath.as_ref() {
ev = (*index.evs.get(epath).unwrap()).clone();
// TODO: remove this hack
if let Some(epath) = epath.as_ref() {
ev = (*index.evs.get(epath).unwrap()).clone();
}
} else if let Some(path) = fdpath.as_ref() {
epath = Some(path.new_enum(ev.name.clone().unwrap_or_else(|| path.name.clone())));
}
lookup_results.push((ev, epath));
}
Expand Down

0 comments on commit cff4ac4

Please sign in to comment.