Skip to content

Fix derivedFrom enumerated values #476

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Sep 23, 2020

Conversation

couchand
Copy link
Contributor

@couchand couchand commented Sep 23, 2020

derivedFrom FieldReaders should always be a type alias for the base FieldReader, rather than each their own newtype.

I believe this fixes #474, however I'm having trouble getting a working development environment set up for the esp32 project.

@MabezDev, would you mind giving this a spin and posting a diff of the generated code?

Figured out my issue, the generated code looks good, e.g.:

diff --git a/src/rtccntl/wdtconfig0.rs b/src/rtccntl/wdtconfig0.rs
index 6851bff..089e4e1 100644
--- a/src/rtccntl/wdtconfig0.rs
+++ b/src/rtccntl/wdtconfig0.rs
@@ -186,19 +186,7 @@ impl<'a> WDT_STG0_W<'a> {
 #[doc = ""]
 pub type WDT_STG1_A = WDT_STG0_A;
 #[doc = "Field `WDT_STG1` reader - "]
-pub struct WDT_STG1_R(crate::FieldReader<u8, WDT_STG1_A>);
-impl WDT_STG1_R {
-    pub(crate) fn new(bits: u8) -> Self {
-        WDT_STG1_R(crate::FieldReader::new(bits))
-    }
-}
-impl core::ops::Deref for WDT_STG1_R {
-    type Target = crate::FieldReader<u8, WDT_STG1_A>;
-    #[inline(always)]
-    fn deref(&self) -> &Self::Target {
-        &self.0
-    }
-}
+pub type WDT_STG1_R = WDT_STG0_R;
 #[doc = "Field `WDT_STG1` writer - "]
 pub struct WDT_STG1_W<'a> {
     w: &'a mut W,

@couchand couchand requested a review from a team as a code owner September 23, 2020 06:21
@rust-highfive
Copy link

r? @burrbull

(rust_highfive has picked a reviewer for you, use r? to override)

@rust-highfive rust-highfive added S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. T-tools labels Sep 23, 2020
Copy link
Contributor

@therealprof therealprof left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, too. Thanks!

bors r+

@bors bors bot merged commit 29129c0 into rust-embedded:master Sep 23, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. T-tools
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Enumerated values derivedFrom regression
4 participants