@@ -21,7 +21,7 @@ pub fn render(
21
21
let name = util:: name_of ( register) ;
22
22
let span = Span :: call_site ( ) ;
23
23
let name_pc = Ident :: new ( & name. to_sanitized_upper_case ( ) , span) ;
24
- let _name_pc = Ident :: new ( & format ! ( "_{}" , & name. to_sanitized_upper_case( ) ) , span) ;
24
+ let u_name_pc = Ident :: new ( & format ! ( "_{}" , & name. to_sanitized_upper_case( ) ) , span) ;
25
25
let name_sc = Ident :: new ( & name. to_sanitized_snake_case ( ) , span) ;
26
26
let rsize = register
27
27
. size
@@ -152,11 +152,11 @@ pub fn render(
152
152
}
153
153
out. extend ( quote ! {
154
154
#[ doc = #doc]
155
- pub type #name_pc = crate :: Reg <#rty, #_name_pc >;
155
+ pub type #name_pc = crate :: Reg <#rty, #u_name_pc >;
156
156
157
157
#[ allow( missing_docs) ]
158
158
#[ doc( hidden) ]
159
- pub struct #_name_pc ;
159
+ pub struct #u_name_pc ;
160
160
} ) ;
161
161
162
162
if can_read {
@@ -217,8 +217,8 @@ pub fn fields(
217
217
// TODO(AJM) - do we need to do anything with this range type?
218
218
let BitRange { offset, width, .. } = f. bit_range ;
219
219
let name = util:: replace_suffix ( & f. name , "" ) ;
220
- let sc = Ident :: new ( & name. to_sanitized_snake_case ( ) , span) ;
221
- let pc = name. to_sanitized_upper_case ( ) ;
220
+ let name_sc = Ident :: new ( & name. to_sanitized_snake_case ( ) , span) ;
221
+ let name_pc = name. to_sanitized_upper_case ( ) ;
222
222
let bits = Ident :: new ( if width == 1 { "bit" } else { "bits" } , span) ;
223
223
let description = if let Some ( d) = & f. description {
224
224
util:: respace ( & util:: escape_brackets ( d) )
@@ -249,8 +249,8 @@ pub fn fields(
249
249
250
250
// Reader and writer use one common `Enum_A` unless a fields have two `enumeratedValues`,
251
251
// then we have one for read-only `Enum_A` and another for write-only `Enum_AW`
252
- let pc_r = Ident :: new ( & ( pc . clone ( ) + "_A" ) , span) ;
253
- let mut pc_w = & pc_r ;
252
+ let name_pc_a = Ident :: new ( & ( name_pc . clone ( ) + "_A" ) , span) ;
253
+ let mut name_pc_aw = & name_pc_a ;
254
254
255
255
let mut evs_r = None ;
256
256
@@ -298,7 +298,7 @@ pub fn fields(
298
298
String :: from ( "Reader of field " ) + & quotedfield
299
299
} ;
300
300
301
- let _pc_r = Ident :: new ( & ( pc . clone ( ) + "_R" ) , span) ;
301
+ let name_pc_r = Ident :: new ( & ( name_pc . clone ( ) + "_R" ) , span) ;
302
302
303
303
let cast = if width == 1 {
304
304
quote ! { != 0 }
@@ -323,8 +323,8 @@ pub fn fields(
323
323
r_impl_items. extend ( quote ! {
324
324
#[ doc = #doc]
325
325
#inline
326
- pub unsafe fn #sc ( & self , n: usize ) -> #_pc_r {
327
- #_pc_r :: new ( #value )
326
+ pub unsafe fn #name_sc ( & self , n: usize ) -> #name_pc_r {
327
+ #name_pc_r :: new ( #value )
328
328
}
329
329
} ) ;
330
330
for ( i, suffix) in ( 0 ..* dim) . zip ( suffixes. iter ( ) ) {
@@ -339,7 +339,7 @@ pub fn fields(
339
339
( self . bits & #hexmask) #cast
340
340
}
341
341
} ;
342
- let sc_n = Ident :: new (
342
+ let name_sc_n = Ident :: new (
343
343
& util:: replace_suffix ( & f. name . to_sanitized_snake_case ( ) , & suffix) ,
344
344
Span :: call_site ( ) ,
345
345
) ;
@@ -350,8 +350,8 @@ pub fn fields(
350
350
r_impl_items. extend ( quote ! {
351
351
#[ doc = #doc]
352
352
#inline
353
- pub fn #sc_n ( & self ) -> #_pc_r {
354
- #_pc_r :: new ( #value )
353
+ pub fn #name_sc_n ( & self ) -> #name_pc_r {
354
+ #name_pc_r :: new ( #value )
355
355
}
356
356
} ) ;
357
357
}
@@ -360,8 +360,8 @@ pub fn fields(
360
360
r_impl_items. extend ( quote ! {
361
361
#[ doc = #doc]
362
362
#inline
363
- pub fn #sc ( & self ) -> #_pc_r {
364
- #_pc_r :: new ( #value )
363
+ pub fn #name_sc ( & self ) -> #name_pc_r {
364
+ #name_pc_r :: new ( #value )
365
365
}
366
366
} ) ;
367
367
}
@@ -373,17 +373,17 @@ pub fn fields(
373
373
let pc = util:: replace_suffix ( base. field , "" ) ;
374
374
let pc = pc. to_sanitized_upper_case ( ) ;
375
375
let base_pc_r = Ident :: new ( & ( pc + "_A" ) , span) ;
376
- derive_from_base ( mod_items, & base, & pc_r , & base_pc_r, & description) ;
376
+ derive_from_base ( mod_items, & base, & name_pc_a , & base_pc_r, & description) ;
377
377
378
378
mod_items. extend ( quote ! {
379
379
#[ doc = #readerdoc]
380
- pub type #_pc_r = crate :: R <#fty, #pc_r >;
380
+ pub type #name_pc_r = crate :: R <#fty, #name_pc_a >;
381
381
} ) ;
382
382
} else {
383
383
let has_reserved_variant = evs. values . len ( ) != ( 1 << width) ;
384
384
let variants = Variant :: from_enumerated_values ( evs) ?;
385
385
386
- add_from_variants ( mod_items, & variants, & pc_r , & fty, & description, rv) ;
386
+ add_from_variants ( mod_items, & variants, & name_pc_a , & fty, & description, rv) ;
387
387
388
388
let mut enum_items = TokenStream :: new ( ) ;
389
389
@@ -393,9 +393,9 @@ pub fn fields(
393
393
let pc = & v. pc ;
394
394
395
395
if has_reserved_variant {
396
- quote ! { #i => Val ( #pc_r :: #pc) , }
396
+ quote ! { #i => Val ( #name_pc_a :: #pc) , }
397
397
} else {
398
- quote ! { #i => #pc_r :: #pc, }
398
+ quote ! { #i => #name_pc_a :: #pc, }
399
399
}
400
400
} ) {
401
401
arms. extend ( v) ;
@@ -415,7 +415,7 @@ pub fn fields(
415
415
enum_items. extend ( quote ! {
416
416
///Get enumerated values variant
417
417
#inline
418
- pub fn variant( & self ) -> crate :: Variant <#fty, #pc_r > {
418
+ pub fn variant( & self ) -> crate :: Variant <#fty, #name_pc_a > {
419
419
use crate :: Variant :: * ;
420
420
match self . bits {
421
421
#arms
@@ -426,7 +426,7 @@ pub fn fields(
426
426
enum_items. extend ( quote ! {
427
427
///Get enumerated values variant
428
428
#inline
429
- pub fn variant( & self ) -> #pc_r {
429
+ pub fn variant( & self ) -> #name_pc_a {
430
430
match self . bits {
431
431
#arms
432
432
}
@@ -452,30 +452,30 @@ pub fn fields(
452
452
#[ doc = #doc]
453
453
#inline
454
454
pub fn #is_variant( & self ) -> bool {
455
- * self == #pc_r :: #pc
455
+ * self == #name_pc_a :: #pc
456
456
}
457
457
} ) ;
458
458
}
459
459
460
460
mod_items. extend ( quote ! {
461
461
#[ doc = #readerdoc]
462
- pub type #_pc_r = crate :: R <#fty, #pc_r >;
463
- impl #_pc_r {
462
+ pub type #name_pc_r = crate :: R <#fty, #name_pc_a >;
463
+ impl #name_pc_r {
464
464
#enum_items
465
465
}
466
466
} ) ;
467
467
}
468
468
} else {
469
469
mod_items. extend ( quote ! {
470
470
#[ doc = #readerdoc]
471
- pub type #_pc_r = crate :: R <#fty, #fty>;
471
+ pub type #name_pc_r = crate :: R <#fty, #fty>;
472
472
} )
473
473
}
474
474
}
475
475
476
476
if can_write {
477
- let new_pc_w = Ident :: new ( & ( pc . clone ( ) + "_AW" ) , span) ;
478
- let _pc_w = Ident :: new ( & ( pc . clone ( ) + "_W" ) , span) ;
477
+ let new_pc_aw = Ident :: new ( & ( name_pc . clone ( ) + "_AW" ) , span) ;
478
+ let name_pc_w = Ident :: new ( & ( name_pc . clone ( ) + "_W" ) , span) ;
479
479
480
480
let mut proxy_items = TokenStream :: new ( ) ;
481
481
let mut unsafety = unsafety ( f. write_constraint . as_ref ( ) , width) ;
@@ -488,22 +488,22 @@ pub fn fields(
488
488
}
489
489
490
490
if Some ( evs) != evs_r. as_ref ( ) {
491
- pc_w = & new_pc_w ;
491
+ name_pc_aw = & new_pc_aw ;
492
492
if let Some ( base) = base {
493
493
let pc = util:: replace_suffix ( base. field , "" ) ;
494
494
let pc = pc. to_sanitized_upper_case ( ) ;
495
495
let base_pc_w = Ident :: new ( & ( pc + "_AW" ) , span) ;
496
- derive_from_base ( mod_items, & base, & pc_w , & base_pc_w, & description)
496
+ derive_from_base ( mod_items, & base, & name_pc_aw , & base_pc_w, & description)
497
497
} else {
498
- add_from_variants ( mod_items, & variants, pc_w , & fty, & description, rv) ;
498
+ add_from_variants ( mod_items, & variants, name_pc_aw , & fty, & description, rv) ;
499
499
}
500
500
}
501
501
502
502
if unsafety. is_some ( ) {
503
503
proxy_items. extend ( quote ! {
504
504
///Writes `variant` to the field
505
505
#inline
506
- pub fn variant( self , variant: #pc_w ) -> & ' a mut W {
506
+ pub fn variant( self , variant: #name_pc_aw ) -> & ' a mut W {
507
507
unsafe {
508
508
self . #bits( variant. into( ) )
509
509
}
@@ -513,7 +513,7 @@ pub fn fields(
513
513
proxy_items. extend ( quote ! {
514
514
///Writes `variant` to the field
515
515
#inline
516
- pub fn variant( self , variant: #pc_w ) -> & ' a mut W {
516
+ pub fn variant( self , variant: #name_pc_aw ) -> & ' a mut W {
517
517
self . #bits( variant. into( ) )
518
518
}
519
519
} ) ;
@@ -528,7 +528,7 @@ pub fn fields(
528
528
#[ doc = #doc]
529
529
#inline
530
530
pub fn #sc( self ) -> & ' a mut W {
531
- self . variant( #pc_w :: #pc)
531
+ self . variant( #name_pc_aw :: #pc)
532
532
}
533
533
} ) ;
534
534
}
@@ -595,12 +595,12 @@ pub fn fields(
595
595
596
596
mod_items. extend ( quote ! {
597
597
#[ doc = #doc]
598
- pub struct #_pc_w <' a> {
598
+ pub struct #name_pc_w <' a> {
599
599
w: & ' a mut W ,
600
600
#offset_entry
601
601
}
602
602
603
- impl <' a> #_pc_w <' a> {
603
+ impl <' a> #name_pc_w <' a> {
604
604
#proxy_items
605
605
}
606
606
} ) ;
@@ -611,13 +611,13 @@ pub fn fields(
611
611
w_impl_items. extend ( quote ! {
612
612
#[ doc = #doc]
613
613
#inline
614
- pub unsafe fn #sc ( & mut self , n: usize ) -> #_pc_w {
615
- #_pc_w { w: self , offset: #offset_calc }
614
+ pub unsafe fn #name_sc ( & mut self , n: usize ) -> #name_pc_w {
615
+ #name_pc_w { w: self , offset: #offset_calc }
616
616
}
617
617
} ) ;
618
618
for ( i, suffix) in ( 0 ..* dim) . zip ( suffixes. iter ( ) ) {
619
619
let sub_offset = offset + ( i as u64 ) * ( * increment as u64 ) ;
620
- let sc_n = Ident :: new (
620
+ let name_sc_n = Ident :: new (
621
621
& util:: replace_suffix ( & f. name . to_sanitized_snake_case ( ) , & suffix) ,
622
622
Span :: call_site ( ) ,
623
623
) ;
@@ -629,8 +629,8 @@ pub fn fields(
629
629
w_impl_items. extend ( quote ! {
630
630
#[ doc = #doc]
631
631
#inline
632
- pub fn #sc_n ( & mut self ) -> #_pc_w {
633
- #_pc_w { w: self , offset: #sub_offset }
632
+ pub fn #name_sc_n ( & mut self ) -> #name_pc_w {
633
+ #name_pc_w { w: self , offset: #sub_offset }
634
634
}
635
635
} ) ;
636
636
}
@@ -639,8 +639,8 @@ pub fn fields(
639
639
w_impl_items. extend ( quote ! {
640
640
#[ doc = #doc]
641
641
#inline
642
- pub fn #sc ( & mut self ) -> #_pc_w {
643
- #_pc_w { w: self }
642
+ pub fn #name_sc ( & mut self ) -> #name_pc_w {
643
+ #name_pc_w { w: self }
644
644
}
645
645
} ) ;
646
646
}
0 commit comments