From ea9269929157c777fded06b8b1edd30cebcd3dc9 Mon Sep 17 00:00:00 2001 From: Valentine Valyaeff Date: Tue, 24 Dec 2019 12:53:48 +0200 Subject: [PATCH] Reformat with use_small_heuristics = "Max" --- rustfmt.toml | 2 ++ src/periph/gpio/head.rs | 12 ++---------- src/periph/gpio/lib.rs | 12 ++---------- svd/src/adc.rs | 6 ++---- svd/src/lib.rs | 24 +++--------------------- svd/src/rcc.rs | 8 +++----- 6 files changed, 14 insertions(+), 50 deletions(-) diff --git a/rustfmt.toml b/rustfmt.toml index b4aed7a..95c67fe 100644 --- a/rustfmt.toml +++ b/rustfmt.toml @@ -5,6 +5,8 @@ format_strings = true merge_imports = true newline_style = "Unix" overflow_delimited_expr = true +reorder_impl_items = true unstable_features = true use_field_init_shorthand = true +use_small_heuristics = "Max" version = "Two" diff --git a/src/periph/gpio/head.rs b/src/periph/gpio/head.rs index 1b36f0b..d19c125 100644 --- a/src/periph/gpio/head.rs +++ b/src/periph/gpio/head.rs @@ -238,11 +238,7 @@ map_gpio_port_head! { IOPESMEN, } -#[cfg(any( - stm32_mcu = "stm32f100", - stm32_mcu = "stm32f101", - stm32_mcu = "stm32f103" -))] +#[cfg(any(stm32_mcu = "stm32f100", stm32_mcu = "stm32f101", stm32_mcu = "stm32f103"))] map_gpio_port_head! { "Extracts GPIO port F head register tokens.", periph_gpio_f_head, @@ -257,11 +253,7 @@ map_gpio_port_head! { IOPFSMEN, } -#[cfg(any( - stm32_mcu = "stm32f100", - stm32_mcu = "stm32f101", - stm32_mcu = "stm32f103" -))] +#[cfg(any(stm32_mcu = "stm32f100", stm32_mcu = "stm32f101", stm32_mcu = "stm32f103"))] map_gpio_port_head! { "Extracts GPIO port G head register tokens.", periph_gpio_g_head, diff --git a/src/periph/gpio/lib.rs b/src/periph/gpio/lib.rs index 1343323..619ab10 100644 --- a/src/periph/gpio/lib.rs +++ b/src/periph/gpio/lib.rs @@ -1134,11 +1134,7 @@ map_gpio_port! { (), } -#[cfg(any( - stm32_mcu = "stm32f100", - stm32_mcu = "stm32f101", - stm32_mcu = "stm32f103" -))] +#[cfg(any(stm32_mcu = "stm32f100", stm32_mcu = "stm32f101", stm32_mcu = "stm32f103"))] map_gpio_port! { "Extracts GPIO port F register tokens.", periph_gpio_f, @@ -1154,11 +1150,7 @@ map_gpio_port! { (), } -#[cfg(any( - stm32_mcu = "stm32f100", - stm32_mcu = "stm32f101", - stm32_mcu = "stm32f103" -))] +#[cfg(any(stm32_mcu = "stm32f100", stm32_mcu = "stm32f101", stm32_mcu = "stm32f103"))] map_gpio_port! { "Extracts GPIO port G register tokens.", periph_gpio_g, diff --git a/svd/src/adc.rs b/svd/src/adc.rs index 83f66aa..7aa660f 100644 --- a/svd/src/adc.rs +++ b/svd/src/adc.rs @@ -28,10 +28,8 @@ pub fn fix_adc1_1(dev: &mut Device) -> Result<()> { pub fn fix_adc_1(dev: &mut Device) -> Result<()> { dev.periph("ADC").reg("SMPR1").remove_field("SMPPLUS"); for i in 1..=4 { - dev.periph("ADC") - .reg(&format!("JDR{}", i)) - .field(&format!("JDATA{}", i)) - .name = "JDATA".to_string(); + dev.periph("ADC").reg(&format!("JDR{}", i)).field(&format!("JDATA{}", i)).name = + "JDATA".to_string(); } Ok(()) } diff --git a/svd/src/lib.rs b/svd/src/lib.rs index 28aee74..218c224 100644 --- a/svd/src/lib.rs +++ b/svd/src/lib.rs @@ -23,16 +23,7 @@ pub use anyhow::{bail, Result}; use drone_svd::Device; use std::{env, fs::File, path::Path}; -const REG_EXCLUDE: &[&str] = &[ - "FPU", - "FPU_CPACR", - "ITM", - "MPU", - "NVIC", - "SCB", - "STK", - "TPIU", -]; +const REG_EXCLUDE: &[&str] = &["FPU", "FPU_CPACR", "ITM", "MPU", "NVIC", "SCB", "STK", "TPIU"]; /// Generates code for register mappings. pub fn generate_regs(pool_number: usize, pool_size: usize) -> Result<()> { @@ -50,12 +41,7 @@ pub fn generate_rest() -> Result<()> { let dev = svd_deserialize()?; let mut reg_tokens = File::create(out_dir.join("svd_reg_index.rs"))?; let mut interrupts = File::create(out_dir.join("svd_interrupts.rs"))?; - dev.generate_rest( - &mut reg_tokens, - &mut interrupts, - REG_EXCLUDE, - "stm32_reg_tokens", - ) + dev.generate_rest(&mut reg_tokens, &mut interrupts, REG_EXCLUDE, "stm32_reg_tokens") } fn svd_deserialize() -> Result { @@ -422,11 +408,7 @@ fn copy_field( reg_name: &str, field_name: &str, ) { - let field = dev - .periph(periph_from) - .reg(reg_name) - .field(field_name) - .clone(); + let field = dev.periph(periph_from).reg(reg_name).field(field_name).clone(); dev.periph(periph_to).reg(reg_name).add_field(field); } diff --git a/svd/src/rcc.rs b/svd/src/rcc.rs index 1194883..7136c68 100644 --- a/svd/src/rcc.rs +++ b/svd/src/rcc.rs @@ -57,11 +57,9 @@ pub fn fix_2(dev: &mut Device) -> Result<()> { } pub fn fix_3(dev: &mut Device) -> Result<()> { - for (reg_name, field_name) in &[ - ("AHB1ENR", "GPIOIEN"), - ("AHB1RSTR", "GPIOIRST"), - ("AHB1LPENR", "GPIOILPEN"), - ] { + for (reg_name, field_name) in + &[("AHB1ENR", "GPIOIEN"), ("AHB1RSTR", "GPIOIRST"), ("AHB1LPENR", "GPIOILPEN")] + { for (name, description, offset) in &[("GPIOJ", "port J", 1), ("GPIOK", "port K", 2)] { let mut field = dev.periph("RCC").reg(reg_name).field(field_name).clone(); field.name = field.name.replace("GPIOI", name);