@@ -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 } ;
@@ -254,6 +255,7 @@ pub fn render(
254255 Ok ( out)
255256}
256257
258+ #[ allow( clippy:: too_many_arguments) ]
257259pub fn fields (
258260 fields : & [ Field ] ,
259261 parent : & Register ,
@@ -291,7 +293,7 @@ pub fn fields(
291293 && ( f. access != Some ( Access :: WriteOnce ) ) ;
292294 let can_write = can_write && ( f. access != Some ( Access :: ReadOnly ) ) ;
293295
294- let mask = 1u64 . wrapping_neg ( ) >> ( 64 - width) ;
296+ let mask = u64 :: MAX >> ( 64 - width) ;
295297 let hexmask = & util:: hex ( mask) ;
296298 let offset = u64:: from ( offset) ;
297299 let rv = reset_value. map ( |rv| ( rv >> offset) & mask) ;
@@ -749,8 +751,7 @@ pub fn fields(
749751fn unsafety ( write_constraint : Option < & WriteConstraint > , width : u32 ) -> Option < Ident > {
750752 match & write_constraint {
751753 Some ( & WriteConstraint :: Range ( range) )
752- if u64:: from ( range. min ) == 0
753- && u64:: from ( range. max ) == 1u64 . wrapping_neg ( ) >> ( 64 - width) =>
754+ if range. min == 0 && range. max == u64:: MAX >> ( 64 - width) =>
754755 {
755756 // the SVD has acknowledged that it's safe to write
756757 // any value that can fit in the field
@@ -1052,8 +1053,7 @@ fn lookup_in_peripheral<'p>(
10521053 if let Some ( register) = all_registers. iter ( ) . find ( |r| r. name == base_register) {
10531054 if let Some ( field) = register
10541055 . fields
1055- . as_ref ( )
1056- . map ( |fs| & * * fs)
1056+ . as_deref ( )
10571057 . unwrap_or ( & [ ] )
10581058 . iter ( )
10591059 . find ( |f| f. name == base_field)
@@ -1082,7 +1082,7 @@ fn lookup_in_field<'f>(
10821082 field : & ' f Field ,
10831083) -> Result < ( & ' f EnumeratedValues , Option < Base < ' f > > ) > {
10841084 for evs in & field. enumerated_values {
1085- if evs. name . as_ref ( ) . map ( |s| & * * s ) == Some ( base_evs) {
1085+ if evs. name . as_deref ( ) == Some ( base_evs) {
10861086 return Ok ( (
10871087 evs,
10881088 Some ( Base {
@@ -1107,11 +1107,11 @@ fn lookup_in_register<'r>(
11071107) -> Result < ( & ' r EnumeratedValues , Option < Base < ' r > > ) > {
11081108 let mut matches = vec ! [ ] ;
11091109
1110- for f in register. fields . as_ref ( ) . map ( |v| & * * v ) . unwrap_or ( & [ ] ) {
1110+ for f in register. fields . as_deref ( ) . unwrap_or ( & [ ] ) {
11111111 if let Some ( evs) = f
11121112 . enumerated_values
11131113 . iter ( )
1114- . find ( |evs| evs. name . as_ref ( ) . map ( |s| & * * s ) == Some ( base_evs) )
1114+ . find ( |evs| evs. name . as_deref ( ) == Some ( base_evs) )
11151115 {
11161116 matches. push ( ( evs, & f. name ) )
11171117 }
@@ -1168,7 +1168,7 @@ fn lookup_in_peripherals<'p>(
11681168 }
11691169}
11701170
1171- fn periph_all_registers < ' a > ( p : & ' a Peripheral ) -> Vec < & ' a Register > {
1171+ fn periph_all_registers ( p : & Peripheral ) -> Vec < & Register > {
11721172 let mut par: Vec < & Register > = Vec :: new ( ) ;
11731173 let mut rem: Vec < & RegisterCluster > = Vec :: new ( ) ;
11741174 if p. registers . is_none ( ) {
0 commit comments