Skip to content

Commit 76e3dd6

Browse files
author
Jorge Aparicio
committed
fix code generated from enumeratedValues.derivedFrom
1 parent 3ae3923 commit 76e3dd6

File tree

2 files changed

+26
-11
lines changed

2 files changed

+26
-11
lines changed

src/generate.rs

Lines changed: 25 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -821,14 +821,20 @@ pub fn fields(
821821
#[doc = #pc_w_doc]
822822
pub type #pc_w = super::#mod_::#base_pc_w;
823823
});
824+
825+
quote! {
826+
super::#mod_::#base_pc_w
827+
}
824828
} else {
825829
mod_items.push(quote! {
826830
#[doc = #pc_w_doc]
827831
pub type #pc_w = #base_pc_w;
828832
});
829-
}
830833

831-
base_pc_w
834+
quote! {
835+
#base_pc_w
836+
}
837+
}
832838
});
833839

834840
let variants = evs.values
@@ -907,14 +913,23 @@ pub fn fields(
907913
let sc = &v.sc;
908914

909915
let doc = util::respace(&v.doc);
910-
let enum_ = base_pc_w.as_ref().unwrap_or(&pc_w);
911-
proxy_items.push(quote! {
912-
#[doc = #doc]
913-
#[inline(always)]
914-
pub fn #sc(self) -> &'a mut W {
915-
self.variant(#enum_::#pc)
916-
}
917-
});
916+
if let Some(enum_) = base_pc_w.as_ref() {
917+
proxy_items.push(quote! {
918+
#[doc = #doc]
919+
#[inline(always)]
920+
pub fn #sc(self) -> &'a mut W {
921+
self.variant(#enum_::#pc)
922+
}
923+
});
924+
} else {
925+
proxy_items.push(quote! {
926+
#[doc = #doc]
927+
#[inline(always)]
928+
pub fn #sc(self) -> &'a mut W {
929+
self.variant(#pc_w::#pc)
930+
}
931+
});
932+
}
918933
}
919934
}
920935

src/util.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -225,7 +225,7 @@ pub fn unsuffixed(n: u64) -> Lit {
225225
Lit::Int(n, IntTy::Unsuffixed)
226226
}
227227

228-
#[derive(Clone)]
228+
#[derive(Clone, Debug)]
229229
pub struct Base<'a> {
230230
pub register: Option<&'a str>,
231231
pub field: &'a str,

0 commit comments

Comments
 (0)