Skip to content

Commit

Permalink
Clippy
Browse files Browse the repository at this point in the history
  • Loading branch information
bugadani committed Jan 7, 2025
1 parent 681f048 commit 8bcea53
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 25 deletions.
35 changes: 13 additions & 22 deletions esp-hal-procmacros/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -455,31 +455,22 @@ pub fn builder_lite_derive(item: TokenStream) -> TokenStream {
_ => None,
});

let convert_parameter = field
.attrs
.iter()
.any(|attr| attr.path().is_ident("builder_lite_into"));

let (field_type, field_assigns) = if convert_parameter {
if let Some(inner_type) = maybe_path_type {
(
quote! { impl Into<#inner_type> },
quote! { Some(#field_ident .into()) },
)
} else {
(
quote! { impl Into<#field_type> },
quote! { #field_ident .into() },
)
}
let (mut field_type, mut field_assigns) = if let Some(inner_type) = maybe_path_type {
(quote! { #inner_type }, quote! { Some(#field_ident) })
} else {
if let Some(inner_type) = maybe_path_type {
(quote! { #inner_type }, quote! { Some(#field_ident) })
} else {
(quote! { #field_type }, quote! { #field_ident })
}
(quote! { #field_type }, quote! { #field_ident })
};

// Wrap type and assignment with `Into` if needed.
if field
.attrs
.iter()
.any(|attr| attr.path().is_ident("builder_lite_into"))
{
field_type = quote! { impl Into<#field_type> };
field_assigns = quote! { #field_ident .into() };
}

fns.push(quote! {
#[doc = concat!(" Assign the given value to the `", stringify!(#field_ident) ,"` field.")]
#[must_use]
Expand Down
6 changes: 3 additions & 3 deletions esp-hal/src/spi/master.rs
Original file line number Diff line number Diff line change
Expand Up @@ -464,8 +464,8 @@ impl Clone for BusClockConfig {

Self {
reg: self.reg.clone(),
frequency: self.frequency.clone(),
clock_source: self.clock_source.clone(),
frequency: self.frequency,
clock_source: self.clock_source,
}
}
}
Expand Down Expand Up @@ -2989,7 +2989,7 @@ impl Driver {
}

fn apply_config(&self, config: &Config) -> Result<(), ConfigError> {
self.ch_bus_freq(&config.clock);
self.ch_bus_freq(&config.clock)?;
self.set_bit_order(config.read_bit_order, config.write_bit_order);
self.set_data_mode(config.mode);
Ok(())
Expand Down

0 comments on commit 8bcea53

Please sign in to comment.