@@ -3,6 +3,7 @@ use crate::svd::{
33 RegisterProperties , Usage , WriteConstraint ,
44} ;
55use cast:: u64;
6+ use core:: u64;
67use log:: warn;
78use proc_macro2:: { Ident , Punct , Spacing , Span , TokenStream } ;
89use quote:: { quote, ToTokens } ;
@@ -250,6 +251,7 @@ pub fn render(
250251 Ok ( out)
251252}
252253
254+ #[ allow( clippy:: too_many_arguments) ]
253255pub fn fields (
254256 fields : & [ Field ] ,
255257 parent : & Register ,
@@ -287,7 +289,7 @@ pub fn fields(
287289 && ( f. access != Some ( Access :: WriteOnce ) ) ;
288290 let can_write = can_write && ( f. access != Some ( Access :: ReadOnly ) ) ;
289291
290- let mask = 1u64 . wrapping_neg ( ) >> ( 64 - width) ;
292+ let mask = u64 :: MAX >> ( 64 - width) ;
291293 let hexmask = & util:: hex ( mask) ;
292294 let offset = u64:: from ( offset) ;
293295 let rv = reset_value. map ( |rv| ( rv >> offset) & mask) ;
@@ -741,8 +743,7 @@ pub fn fields(
741743fn unsafety ( write_constraint : Option < & WriteConstraint > , width : u32 ) -> Option < Ident > {
742744 match & write_constraint {
743745 Some ( & WriteConstraint :: Range ( range) )
744- if u64:: from ( range. min ) == 0
745- && u64:: from ( range. max ) == 1u64 . wrapping_neg ( ) >> ( 64 - width) =>
746+ if range. min == 0 && range. max == u64:: MAX >> ( 64 - width) =>
746747 {
747748 // the SVD has acknowledged that it's safe to write
748749 // any value that can fit in the field
@@ -1044,8 +1045,7 @@ fn lookup_in_peripheral<'p>(
10441045 if let Some ( register) = all_registers. iter ( ) . find ( |r| r. name == base_register) {
10451046 if let Some ( field) = register
10461047 . fields
1047- . as_ref ( )
1048- . map ( |fs| & * * fs)
1048+ . as_deref ( )
10491049 . unwrap_or ( & [ ] )
10501050 . iter ( )
10511051 . find ( |f| f. name == base_field)
@@ -1074,7 +1074,7 @@ fn lookup_in_field<'f>(
10741074 field : & ' f Field ,
10751075) -> Result < ( & ' f EnumeratedValues , Option < Base < ' f > > ) > {
10761076 for evs in & field. enumerated_values {
1077- if evs. name . as_ref ( ) . map ( |s| & * * s ) == Some ( base_evs) {
1077+ if evs. name . as_deref ( ) == Some ( base_evs) {
10781078 return Ok ( (
10791079 evs,
10801080 Some ( Base {
@@ -1099,11 +1099,11 @@ fn lookup_in_register<'r>(
10991099) -> Result < ( & ' r EnumeratedValues , Option < Base < ' r > > ) > {
11001100 let mut matches = vec ! [ ] ;
11011101
1102- for f in register. fields . as_ref ( ) . map ( |v| & * * v ) . unwrap_or ( & [ ] ) {
1102+ for f in register. fields . as_deref ( ) . unwrap_or ( & [ ] ) {
11031103 if let Some ( evs) = f
11041104 . enumerated_values
11051105 . iter ( )
1106- . find ( |evs| evs. name . as_ref ( ) . map ( |s| & * * s ) == Some ( base_evs) )
1106+ . find ( |evs| evs. name . as_deref ( ) == Some ( base_evs) )
11071107 {
11081108 matches. push ( ( evs, & f. name ) )
11091109 }
@@ -1160,7 +1160,7 @@ fn lookup_in_peripherals<'p>(
11601160 }
11611161}
11621162
1163- fn periph_all_registers < ' a > ( p : & ' a Peripheral ) -> Vec < & ' a Register > {
1163+ fn periph_all_registers ( p : & Peripheral ) -> Vec < & Register > {
11641164 let mut par: Vec < & Register > = Vec :: new ( ) ;
11651165 let mut rem: Vec < & RegisterCluster > = Vec :: new ( ) ;
11661166 if p. registers . is_none ( ) {
0 commit comments