diff --git a/CHANGELOG.md b/CHANGELOG.md index 9cb951ad..d2a047f7 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -6,6 +6,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/) and this project adheres to [Semantic Versioning](https://semver.org/). ## [Unreleased] +- Fix dangling implicit derives ## [v0.28.0] - 2022-12-25 diff --git a/src/generate/peripheral.rs b/src/generate/peripheral.rs index 8a069d29..0486c1cd 100644 --- a/src/generate/peripheral.rs +++ b/src/generate/peripheral.rs @@ -859,7 +859,7 @@ fn compare_this_against_prev( Ok(None) } -/// Compare the given type name against previous regexs, then inspect fields +/// Compare previous type names against the given regex, then inspect fields fn compare_prev_against_this( reg: &MaybeArray, ty_name: &str, @@ -913,6 +913,21 @@ fn compare_prev_against_this( } } } + if let DeriveInfo::Implicit(my_rpath) = &my_derive_info { + match prev_derive_info { + DeriveInfo::Implicit(their_rpath) => { + if their_rpath.name == ty_name { + (_, *their_rpath) = find_root(&my_rpath.name, path, index)?; + } + } + DeriveInfo::Explicit(their_rpath) => { + if their_rpath.name == ty_name { + (_, *their_rpath) = find_root(&my_rpath.name, path, index)?; + } + } + _ => {} + } + } } } Ok(my_derive_info)