@@ -23,19 +23,19 @@ pub fn entry(args: TokenStream, input: TokenStream) -> TokenStream {
2323 let mut res = String :: from ( "__ULP_MAGIC_" ) ;
2424 for & a in args {
2525 let t = & a. ty ;
26- let quoted = to_string ( & t) ;
26+ let quoted = to_string ( t) ;
2727 res. push_str ( & quoted) ;
28- res. push_str ( "$" ) ;
28+ res. push ( '$' ) ;
2929 }
3030
3131 res
3232 }
3333
3434 pub ( crate ) fn get_simplename ( t : & Type ) -> String {
35- String :: from ( match t {
36- Type :: Path ( p) => String :: from ( & p. path . segments . last ( ) . unwrap ( ) . ident . to_string ( ) ) ,
35+ match t {
36+ Type :: Path ( p) => p. path . segments . last ( ) . unwrap ( ) . ident . to_string ( ) ,
3737 _ => String :: new ( ) ,
38- } )
38+ }
3939 }
4040
4141 pub ( crate ) fn extract_pin ( ty : & Type ) -> u8 {
@@ -49,7 +49,7 @@ pub fn entry(args: TokenStream, input: TokenStream) -> TokenStream {
4949 res = extract_pin ( t) ;
5050 }
5151 GenericArgument :: Const ( c) => {
52- res = ( & quote ! { #c } . to_string ( ) ) . parse ( ) . unwrap ( ) ;
52+ res = quote ! { #c } . to_string ( ) . parse ( ) . unwrap ( ) ;
5353 }
5454 _ => ( ) ,
5555 }
@@ -68,11 +68,11 @@ pub fn entry(args: TokenStream, input: TokenStream) -> TokenStream {
6868 res. push_str ( & segment. ident . to_string ( ) ) ;
6969
7070 if let PathArguments :: AngleBracketed ( g) = & segment. arguments {
71- res. push_str ( "<" ) ;
71+ res. push ( '<' ) ;
7272 let mut pushed = false ;
7373 for arg in & g. args {
7474 if pushed {
75- res. push_str ( "," ) ;
75+ res. push ( ',' ) ;
7676 }
7777
7878 match arg {
@@ -87,7 +87,7 @@ pub fn entry(args: TokenStream, input: TokenStream) -> TokenStream {
8787 _ => ( ) ,
8888 }
8989 }
90- res. push_str ( ">" ) ;
90+ res. push ( '>' ) ;
9191 }
9292 }
9393
@@ -219,7 +219,7 @@ pub fn load_lp_code(input: TokenStream) -> TokenStream {
219219 } ;
220220
221221 let hal_crate = if let Ok ( FoundCrate :: Name ( ref name) ) = hal_crate {
222- let ident = Ident :: new ( & name, Span :: call_site ( ) . into ( ) ) ;
222+ let ident = Ident :: new ( name, Span :: call_site ( ) . into ( ) ) ;
223223 quote ! ( #ident )
224224 } else {
225225 quote ! ( crate )
@@ -261,12 +261,14 @@ pub fn load_lp_code(input: TokenStream) -> TokenStream {
261261
262262 let mut sections: Vec < Section > = sections
263263 . into_iter ( )
264- . filter ( |section| match section. kind ( ) {
265- SectionKind :: Text
266- | SectionKind :: ReadOnlyData
267- | SectionKind :: Data
268- | SectionKind :: UninitializedData => true ,
269- _ => false ,
264+ . filter ( |section| {
265+ matches ! (
266+ section. kind( ) ,
267+ SectionKind :: Text
268+ | SectionKind :: ReadOnlyData
269+ | SectionKind :: Data
270+ | SectionKind :: UninitializedData
271+ )
270272 } )
271273 . collect ( ) ;
272274 sections. sort_by ( |a, b| a. address ( ) . partial_cmp ( & b. address ( ) ) . unwrap ( ) ) ;
@@ -280,9 +282,8 @@ pub fn load_lp_code(input: TokenStream) -> TokenStream {
280282
281283 for section in sections {
282284 if section. address ( ) > last_address {
283- for _ in 0 ..( section. address ( ) - last_address) {
284- binary. push ( 0 ) ;
285- }
285+ let fill = section. address ( ) - last_address;
286+ binary. extend ( std:: iter:: repeat ( 0 ) . take ( fill as usize ) ) ;
286287 }
287288
288289 binary. extend_from_slice ( section. data ( ) . unwrap ( ) ) ;
@@ -293,21 +294,20 @@ pub fn load_lp_code(input: TokenStream) -> TokenStream {
293294 . symbols ( )
294295 . find ( |s| s. name ( ) . unwrap ( ) . starts_with ( "__ULP_MAGIC_" ) ) ;
295296
296- if let None = magic_symbol {
297+ let magic_symbol = if let Some ( magic_symbol) = magic_symbol {
298+ magic_symbol. name ( ) . unwrap ( )
299+ } else {
297300 return Error :: new (
298301 Span :: call_site ( ) . into ( ) ,
299302 "Given file doesn't seem to be an LP/ULP core application." ,
300303 )
301304 . to_compile_error ( )
302305 . into ( ) ;
303- }
304-
305- let magic_symbol = magic_symbol. unwrap ( ) . name ( ) . unwrap ( ) ;
306+ } ;
306307
307308 let magic_symbol = magic_symbol. trim_start_matches ( "__ULP_MAGIC_" ) ;
308309 let args: Vec < proc_macro2:: TokenStream > = magic_symbol
309310 . split ( "$" )
310- . into_iter ( )
311311 . map ( |t| {
312312 let t = if t. contains ( "OutputOpenDrain" ) {
313313 t. replace ( "OutputOpenDrain" , "LowPowerOutputOpenDrain" )
0 commit comments