@@ -3,6 +3,7 @@ use crate::svd::{
3
3
RegisterProperties , Usage , WriteConstraint ,
4
4
} ;
5
5
use cast:: u64;
6
+ use core:: u64;
6
7
use log:: warn;
7
8
use proc_macro2:: { Ident , Punct , Spacing , Span , TokenStream } ;
8
9
use quote:: { quote, ToTokens } ;
@@ -254,6 +255,7 @@ pub fn render(
254
255
Ok ( out)
255
256
}
256
257
258
+ #[ allow( clippy:: too_many_arguments) ]
257
259
pub fn fields (
258
260
fields : & [ Field ] ,
259
261
parent : & Register ,
@@ -291,7 +293,7 @@ pub fn fields(
291
293
&& ( f. access != Some ( Access :: WriteOnce ) ) ;
292
294
let can_write = can_write && ( f. access != Some ( Access :: ReadOnly ) ) ;
293
295
294
- let mask = 1u64 . wrapping_neg ( ) >> ( 64 - width) ;
296
+ let mask = u64 :: MAX >> ( 64 - width) ;
295
297
let hexmask = & util:: hex ( mask) ;
296
298
let offset = u64:: from ( offset) ;
297
299
let rv = reset_value. map ( |rv| ( rv >> offset) & mask) ;
@@ -749,8 +751,7 @@ pub fn fields(
749
751
fn unsafety ( write_constraint : Option < & WriteConstraint > , width : u32 ) -> Option < Ident > {
750
752
match & write_constraint {
751
753
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) =>
754
755
{
755
756
// the SVD has acknowledged that it's safe to write
756
757
// any value that can fit in the field
@@ -1052,8 +1053,7 @@ fn lookup_in_peripheral<'p>(
1052
1053
if let Some ( register) = all_registers. iter ( ) . find ( |r| r. name == base_register) {
1053
1054
if let Some ( field) = register
1054
1055
. fields
1055
- . as_ref ( )
1056
- . map ( |fs| & * * fs)
1056
+ . as_deref ( )
1057
1057
. unwrap_or ( & [ ] )
1058
1058
. iter ( )
1059
1059
. find ( |f| f. name == base_field)
@@ -1082,7 +1082,7 @@ fn lookup_in_field<'f>(
1082
1082
field : & ' f Field ,
1083
1083
) -> Result < ( & ' f EnumeratedValues , Option < Base < ' f > > ) > {
1084
1084
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) {
1086
1086
return Ok ( (
1087
1087
evs,
1088
1088
Some ( Base {
@@ -1107,11 +1107,11 @@ fn lookup_in_register<'r>(
1107
1107
) -> Result < ( & ' r EnumeratedValues , Option < Base < ' r > > ) > {
1108
1108
let mut matches = vec ! [ ] ;
1109
1109
1110
- for f in register. fields . as_ref ( ) . map ( |v| & * * v ) . unwrap_or ( & [ ] ) {
1110
+ for f in register. fields . as_deref ( ) . unwrap_or ( & [ ] ) {
1111
1111
if let Some ( evs) = f
1112
1112
. enumerated_values
1113
1113
. iter ( )
1114
- . find ( |evs| evs. name . as_ref ( ) . map ( |s| & * * s ) == Some ( base_evs) )
1114
+ . find ( |evs| evs. name . as_deref ( ) == Some ( base_evs) )
1115
1115
{
1116
1116
matches. push ( ( evs, & f. name ) )
1117
1117
}
@@ -1168,7 +1168,7 @@ fn lookup_in_peripherals<'p>(
1168
1168
}
1169
1169
}
1170
1170
1171
- fn periph_all_registers < ' a > ( p : & ' a Peripheral ) -> Vec < & ' a Register > {
1171
+ fn periph_all_registers ( p : & Peripheral ) -> Vec < & Register > {
1172
1172
let mut par: Vec < & Register > = Vec :: new ( ) ;
1173
1173
let mut rem: Vec < & RegisterCluster > = Vec :: new ( ) ;
1174
1174
if p. registers . is_none ( ) {
0 commit comments