@@ -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