From e65acf5ccf64563b4fc91320dd1075c520ef931a Mon Sep 17 00:00:00 2001 From: Vadim Kaushan Date: Wed, 22 Sep 2021 08:28:03 +0300 Subject: Prevent masking value variables with imports --- src/lib.rs | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) (limited to 'src/lib.rs') diff --git a/src/lib.rs b/src/lib.rs index 6122f01..52401d6 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -280,7 +280,11 @@ macro_rules! write_reg { use $periph::{*}; #[allow(unused_imports)] (*$instance).$reg.write( - $({ use $periph::{$reg::$field::{mask, offset, W::*, RW::*}}; ($value << offset) & mask }) | * + $({ + use $periph::{$reg::$field::{W::*, RW::*}}; + ($value << { use $periph::{$reg::$field::offset}; offset }) + & { use $periph::{$reg::$field::mask}; mask } + }) | * ); }}; ( $periph:path, $instance:expr, $reg:ident, $value:expr ) => {{ @@ -410,7 +414,12 @@ macro_rules! modify_reg { #[allow(unused_imports)] (*$instance).$reg.write( ((*$instance).$reg.read() & !( $({ use $periph::{$reg::$field::mask}; mask }) | * )) - | $({ use $periph::{$reg::$field::{mask, offset, W::*, RW::*}}; ($value << offset) & mask }) | *); + | $({ + use $periph::{$reg::$field::{W::*, RW::*}}; + ($value << { use $periph::{$reg::$field::offset}; offset }) + & { use $periph::{$reg::$field::mask}; mask } + }) | * + ); }}; ( $periph:path, $instance:expr, $reg:ident, $fn:expr ) => {{ #[allow(unused_imports)] -- cgit v1.2.3