diff --git a/esp-hal-procmacros/src/lib.rs b/esp-hal-procmacros/src/lib.rs index 3d08c4154a..8c37d8b8c7 100644 --- a/esp-hal-procmacros/src/lib.rs +++ b/esp-hal-procmacros/src/lib.rs @@ -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] diff --git a/esp-hal/src/spi/master.rs b/esp-hal/src/spi/master.rs index 05dbefd7fb..a2afac382c 100644 --- a/esp-hal/src/spi/master.rs +++ b/esp-hal/src/spi/master.rs @@ -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, } } } @@ -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(())