@@ -112,7 +112,7 @@ where
112112 table. length as usize - mem:: size_of :: < SdtHeader > ( ) ,
113113 )
114114 } ;
115- interpreter. load_table ( stream) . map_err ( |err| AcpiError :: Aml ( err ) ) ?;
115+ interpreter. load_table ( stream) . map_err ( AcpiError :: Aml ) ?;
116116 Ok ( ( ) )
117117 }
118118
@@ -308,7 +308,7 @@ where
308308 Opcode :: Increment | Opcode :: Decrement => {
309309 let [ Argument :: Object ( operand) ] = & op. arguments [ ..] else { panic ! ( ) } ;
310310 let token = self . object_token . lock ( ) ;
311- let Object :: Integer ( operand) = ( unsafe { operand. gain_mut ( & * token) } ) else {
311+ let Object :: Integer ( operand) = ( unsafe { operand. gain_mut ( & token) } ) else {
312312 Err ( AmlError :: ObjectNotOfExpectedType {
313313 expected : ObjectType :: Integer ,
314314 got : operand. typ ( ) ,
@@ -564,7 +564,7 @@ where
564564 }
565565 Opcode :: Store => {
566566 let [ Argument :: Object ( object) , target] = & op. arguments [ ..] else { panic ! ( ) } ;
567- self . do_store ( & target, object. clone ( ) ) ?;
567+ self . do_store ( target, object. clone ( ) ) ?;
568568 context. retire_op ( op) ;
569569 }
570570 Opcode :: RefOf => {
@@ -788,7 +788,7 @@ where
788788 }
789789 }
790790 BlockKind :: Scope { old_scope } => {
791- assert ! ( context. block_stack. len ( ) > 0 ) ;
791+ assert ! ( ! context. block_stack. is_empty ( ) ) ;
792792 context. current_block = context. block_stack . pop ( ) . unwrap ( ) ;
793793 context. current_scope = old_scope;
794794 // Go round the loop again to get the next opcode for the new block
@@ -804,7 +804,7 @@ where
804804 * *distinct* uninitialized objects, and go round again to complete the
805805 * in-flight op.
806806 */
807- assert ! ( context. block_stack. len ( ) > 0 ) ;
807+ assert ! ( ! context. block_stack. is_empty ( ) ) ;
808808
809809 if let Some ( package_op) = context. in_flight . last_mut ( )
810810 && ( package_op. op == Opcode :: Package || package_op. op == Opcode :: VarPackage )
@@ -1626,7 +1626,7 @@ where
16261626 * Apparently, the NT interpreter always uses the first 8 bytes of the buffer.
16271627 */
16281628 let mut to_interpret = [ 0u8 ; 8 ] ;
1629- ( to_interpret[ 0 ..usize:: min ( bytes. len ( ) , 8 ) ] ) . copy_from_slice ( & bytes) ;
1629+ ( to_interpret[ 0 ..usize:: min ( bytes. len ( ) , 8 ) ] ) . copy_from_slice ( bytes) ;
16301630 Object :: Integer ( u64:: from_le_bytes ( to_interpret) )
16311631 }
16321632 Object :: String ( ref value) => {
@@ -1642,8 +1642,9 @@ where
16421642 } ) ?;
16431643 Object :: Integer ( parsed)
16441644 } else {
1645- let parsed = u64:: from_str_radix ( value, 10 ) . map_err ( |_| {
1646- AmlError :: InvalidOperationOnObject { op : Operation :: ToInteger , typ : ObjectType :: String }
1645+ let parsed = str:: parse :: < u64 > ( value) . map_err ( |_| AmlError :: InvalidOperationOnObject {
1646+ op : Operation :: ToInteger ,
1647+ typ : ObjectType :: String ,
16471648 } ) ?;
16481649 Object :: Integer ( parsed)
16491650 }
@@ -1694,7 +1695,7 @@ where
16941695 Object :: String ( ref value) => Object :: String ( value. clone ( ) ) ,
16951696 Object :: Integer ( value) => match op. op {
16961697 Opcode :: ToDecimalString => Object :: String ( value. to_string ( ) ) ,
1697- Opcode :: ToHexString => Object :: String ( alloc:: format!( "{:#x}" , value ) ) ,
1698+ Opcode :: ToHexString => Object :: String ( alloc:: format!( "{value :#x}" ) ) ,
16981699 _ => panic ! ( ) ,
16991700 } ,
17001701 Object :: Buffer ( ref bytes) => {
@@ -1704,8 +1705,8 @@ where
17041705 let mut string = String :: new ( ) ;
17051706 for byte in bytes {
17061707 let as_str = match op. op {
1707- Opcode :: ToDecimalString => alloc:: format!( "{}," , byte ) ,
1708- Opcode :: ToHexString => alloc:: format!( "{:#04X}," , byte ) ,
1708+ Opcode :: ToDecimalString => alloc:: format!( "{byte }," ) ,
1709+ Opcode :: ToHexString => alloc:: format!( "{byte :#04X}," ) ,
17091710 _ => panic ! ( ) ,
17101711 } ;
17111712 string. push_str ( & as_str) ;
@@ -1773,15 +1774,15 @@ where
17731774 fn resolve_as_string ( obj : & Object ) -> String {
17741775 match obj {
17751776 Object :: Uninitialized => "[Uninitialized Object]" . to_string ( ) ,
1776- Object :: Buffer ( bytes) => String :: from_utf8_lossy ( & bytes) . into_owned ( ) ,
1777+ Object :: Buffer ( bytes) => String :: from_utf8_lossy ( bytes) . into_owned ( ) ,
17771778 Object :: BufferField { .. } => "[Buffer Field]" . to_string ( ) ,
17781779 Object :: Device => "[Device]" . to_string ( ) ,
17791780 Object :: Event => "[Event]" . to_string ( ) ,
17801781 Object :: FieldUnit ( _) => "[Field]" . to_string ( ) ,
17811782 Object :: Integer ( value) => value. to_string ( ) ,
17821783 Object :: Method { .. } | Object :: NativeMethod { .. } => "[Control Method]" . to_string ( ) ,
17831784 Object :: Mutex { .. } => "[Mutex]" . to_string ( ) ,
1784- Object :: Reference { inner, .. } => resolve_as_string ( & * ( inner. clone ( ) . unwrap_reference ( ) ) ) ,
1785+ Object :: Reference { inner, .. } => resolve_as_string ( & ( inner. clone ( ) . unwrap_reference ( ) ) ) ,
17851786 Object :: OpRegion ( _) => "[Operation Region]" . to_string ( ) ,
17861787 Object :: Package ( _) => "[Package]" . to_string ( ) ,
17871788 Object :: PowerResource { .. } => "[Power Resource]" . to_string ( ) ,
@@ -1813,7 +1814,7 @@ where
18131814 buffer. extend ( source2. to_buffer ( if self . dsdt_revision >= 2 { 8 } else { 4 } ) ?) ;
18141815 Object :: Buffer ( buffer) . wrap ( )
18151816 }
1816- ObjectType :: String | _ => {
1817+ _ => {
18171818 let source1 = resolve_as_string ( & source1) ;
18181819 let source2 = resolve_as_string ( & source2) ;
18191820 Object :: String ( source1 + & source2) . wrap ( )
@@ -1944,14 +1945,14 @@ where
19441945 let to_return = object. clone ( ) ;
19451946
19461947 match target {
1947- Argument :: Object ( target) => match unsafe { target. gain_mut ( & * token) } {
1948- Object :: Integer ( target) => match unsafe { object. gain_mut ( & * token) } {
1948+ Argument :: Object ( target) => match unsafe { target. gain_mut ( & token) } {
1949+ Object :: Integer ( target) => match unsafe { object. gain_mut ( & token) } {
19491950 Object :: Integer ( value) => {
19501951 * target = * value;
19511952 }
19521953 Object :: BufferField { .. } => {
19531954 let mut buffer = [ 0u8 ; 8 ] ;
1954- unsafe { object. gain_mut ( & * token) } . read_buffer_field ( & mut buffer) ?;
1955+ unsafe { object. gain_mut ( & token) } . read_buffer_field ( & mut buffer) ?;
19551956 let value = u64:: from_le_bytes ( buffer) ;
19561957 * target = value;
19571958 }
@@ -1964,12 +1965,12 @@ where
19641965 * target = as_integer;
19651966 }
19661967 } ,
1967- Object :: BufferField { .. } => match unsafe { object. gain_mut ( & * token) } {
1968+ Object :: BufferField { .. } => match unsafe { object. gain_mut ( & token) } {
19681969 Object :: Integer ( value) => {
1969- unsafe { target. gain_mut ( & * token) } . write_buffer_field ( & value. to_le_bytes ( ) , & * token) ?;
1970+ unsafe { target. gain_mut ( & token) } . write_buffer_field ( & value. to_le_bytes ( ) , & token) ?;
19701971 }
19711972 Object :: Buffer ( value) => {
1972- unsafe { target. gain_mut ( & * token) } . write_buffer_field ( & value. as_slice ( ) , & * token) ?;
1973+ unsafe { target. gain_mut ( & token) } . write_buffer_field ( value. as_slice ( ) , & token) ?;
19731974 }
19741975 _ => panic ! ( ) ,
19751976 } ,
@@ -1982,20 +1983,20 @@ where
19821983 // TODO: this should store into the reference, potentially doing an
19831984 // implicit cast
19841985 unsafe {
1985- * inner_inner. gain_mut ( & * token) = object. gain_mut ( & * token) . clone ( ) ;
1986+ * inner_inner. gain_mut ( & token) = object. gain_mut ( & token) . clone ( ) ;
19861987 }
19871988 } else {
19881989 // Overwrite the value
19891990 unsafe {
1990- * inner. gain_mut ( & * token) = object. gain_mut ( & * token) . clone ( ) ;
1991+ * inner. gain_mut ( & token) = object. gain_mut ( & token) . clone ( ) ;
19911992 }
19921993 }
19931994 }
19941995 ReferenceKind :: Unresolved => todo ! ( ) ,
19951996 }
19961997 }
19971998 Object :: Debug => {
1998- self . handler . handle_debug ( & * object) ;
1999+ self . handler . handle_debug ( & object) ;
19992000 }
20002001 _ => panic ! ( "Stores to objects like {:?} are not yet supported" , target) ,
20012002 } ,
@@ -2090,7 +2091,7 @@ where
20902091
20912092 let value_bytes = match & * value {
20922093 Object :: Integer ( value) => & value. to_le_bytes ( ) as & [ u8 ] ,
2093- Object :: Buffer ( bytes) => & bytes,
2094+ Object :: Buffer ( bytes) => bytes,
20942095 _ => Err ( AmlError :: ObjectNotOfExpectedType { expected : ObjectType :: Integer , got : value. typ ( ) } ) ?,
20952096 } ;
20962097 let access_width_bits = field. flags . access_type_bytes ( ) ? * 8 ;
@@ -2173,7 +2174,7 @@ where
21732174 1 => self . handler . read_u8 ( address) as u64 ,
21742175 2 => self . handler . read_u16 ( address) as u64 ,
21752176 4 => self . handler . read_u32 ( address) as u64 ,
2176- 8 => self . handler . read_u64 ( address) as u64 ,
2177+ 8 => self . handler . read_u64 ( address) ,
21772178 _ => panic ! ( ) ,
21782179 }
21792180 } ) ,
@@ -2230,7 +2231,7 @@ where
22302231 ) ;
22312232
22322233 match region. space {
2233- RegionSpace :: SystemMemory => Ok ( {
2234+ RegionSpace :: SystemMemory => {
22342235 let address = region. base as usize + offset;
22352236 match length {
22362237 1 => self . handler . write_u8 ( address, value as u8 ) ,
@@ -2239,16 +2240,18 @@ where
22392240 8 => self . handler . write_u64 ( address, value) ,
22402241 _ => panic ! ( ) ,
22412242 }
2242- } ) ,
2243- RegionSpace :: SystemIO => Ok ( {
2243+ Ok ( ( ) )
2244+ }
2245+ RegionSpace :: SystemIO => {
22442246 let address = region. base as u16 + offset as u16 ;
22452247 match length {
22462248 1 => self . handler . write_io_u8 ( address, value as u8 ) ,
22472249 2 => self . handler . write_io_u16 ( address, value as u16 ) ,
22482250 4 => self . handler . write_io_u32 ( address, value as u32 ) ,
22492251 _ => panic ! ( ) ,
22502252 }
2251- } ) ,
2253+ Ok ( ( ) )
2254+ }
22522255 RegionSpace :: PciConfig => {
22532256 let address = self . pci_address_for_device ( & region. parent_device_path ) ?;
22542257 match length {
@@ -2434,10 +2437,10 @@ impl MethodContext {
24342437 }
24352438
24362439 fn contribute_arg ( & mut self , arg : Argument ) {
2437- if let Some ( in_flight) = self . in_flight . last_mut ( ) {
2438- if in_flight. arguments . len ( ) < in_flight. expected_arguments {
2439- in_flight . arguments . push ( arg ) ;
2440- }
2440+ if let Some ( in_flight) = self . in_flight . last_mut ( )
2441+ && in_flight. arguments . len ( ) < in_flight. expected_arguments
2442+ {
2443+ in_flight . arguments . push ( arg ) ;
24412444 }
24422445 }
24432446
0 commit comments