@@ -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 } ;
@@ -250,6 +251,7 @@ pub fn render(
250
251
Ok ( out)
251
252
}
252
253
254
+ #[ allow( clippy:: too_many_arguments) ]
253
255
pub fn fields (
254
256
fields : & [ Field ] ,
255
257
parent : & Register ,
@@ -287,7 +289,7 @@ pub fn fields(
287
289
&& ( f. access != Some ( Access :: WriteOnce ) ) ;
288
290
let can_write = can_write && ( f. access != Some ( Access :: ReadOnly ) ) ;
289
291
290
- let mask = 1u64 . wrapping_neg ( ) >> ( 64 - width) ;
292
+ let mask = u64 :: MAX >> ( 64 - width) ;
291
293
let hexmask = & util:: hex ( mask) ;
292
294
let offset = u64:: from ( offset) ;
293
295
let rv = reset_value. map ( |rv| ( rv >> offset) & mask) ;
@@ -741,8 +743,7 @@ pub fn fields(
741
743
fn unsafety ( write_constraint : Option < & WriteConstraint > , width : u32 ) -> Option < Ident > {
742
744
match & write_constraint {
743
745
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) =>
746
747
{
747
748
// the SVD has acknowledged that it's safe to write
748
749
// any value that can fit in the field
@@ -1044,8 +1045,7 @@ fn lookup_in_peripheral<'p>(
1044
1045
if let Some ( register) = all_registers. iter ( ) . find ( |r| r. name == base_register) {
1045
1046
if let Some ( field) = register
1046
1047
. fields
1047
- . as_ref ( )
1048
- . map ( |fs| & * * fs)
1048
+ . as_deref ( )
1049
1049
. unwrap_or ( & [ ] )
1050
1050
. iter ( )
1051
1051
. find ( |f| f. name == base_field)
@@ -1074,7 +1074,7 @@ fn lookup_in_field<'f>(
1074
1074
field : & ' f Field ,
1075
1075
) -> Result < ( & ' f EnumeratedValues , Option < Base < ' f > > ) > {
1076
1076
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) {
1078
1078
return Ok ( (
1079
1079
evs,
1080
1080
Some ( Base {
@@ -1099,11 +1099,11 @@ fn lookup_in_register<'r>(
1099
1099
) -> Result < ( & ' r EnumeratedValues , Option < Base < ' r > > ) > {
1100
1100
let mut matches = vec ! [ ] ;
1101
1101
1102
- for f in register. fields . as_ref ( ) . map ( |v| & * * v ) . unwrap_or ( & [ ] ) {
1102
+ for f in register. fields . as_deref ( ) . unwrap_or ( & [ ] ) {
1103
1103
if let Some ( evs) = f
1104
1104
. enumerated_values
1105
1105
. iter ( )
1106
- . find ( |evs| evs. name . as_ref ( ) . map ( |s| & * * s ) == Some ( base_evs) )
1106
+ . find ( |evs| evs. name . as_deref ( ) == Some ( base_evs) )
1107
1107
{
1108
1108
matches. push ( ( evs, & f. name ) )
1109
1109
}
@@ -1160,7 +1160,7 @@ fn lookup_in_peripherals<'p>(
1160
1160
}
1161
1161
}
1162
1162
1163
- fn periph_all_registers < ' a > ( p : & ' a Peripheral ) -> Vec < & ' a Register > {
1163
+ fn periph_all_registers ( p : & Peripheral ) -> Vec < & Register > {
1164
1164
let mut par: Vec < & Register > = Vec :: new ( ) ;
1165
1165
let mut rem: Vec < & RegisterCluster > = Vec :: new ( ) ;
1166
1166
if p. registers . is_none ( ) {
0 commit comments