File tree Expand file tree Collapse file tree 3 files changed +16
-7
lines changed
tests/rust_guests/simpleguest/src Expand file tree Collapse file tree 3 files changed +16
-7
lines changed Original file line number Diff line number Diff line change @@ -26,7 +26,10 @@ pub(crate) unsafe fn load_idt() { unsafe {
2626
2727 let idt_size = 256 * size_of :: < IdtEntry > ( ) ;
2828 let expected_base = addr_of ! ( IDT ) as * const _ as u64 ;
29-
30- IDTR . init ( expected_base, idt_size as u16 ) ;
31- IDTR . load ( ) ;
29+
30+ // Use &raw mut to get a mutable raw pointer, then dereference it
31+ // this is to avoid the clippy warning "shared reference to mutable static"
32+ let idtr = & mut * ( & raw mut IDTR ) ;
33+ idtr. init ( expected_base, idt_size as u16 ) ;
34+ idtr. load ( ) ;
3235} }
Original file line number Diff line number Diff line change @@ -43,8 +43,9 @@ pub(crate) fn call_guest_function(function_call: FunctionCall) -> Result<Vec<u8>
4343 }
4444
4545 // Find the function definition for the function call.
46- if let Some ( registered_function_definition) =
47- unsafe { REGISTERED_GUEST_FUNCTIONS . get ( & function_call. function_name ) }
46+ // Use &raw const to get an immutable reference to the static HashMap
47+ // this is to avoid the clippy warning "shared reference to mutable static"
48+ if let Some ( registered_function_definition) = unsafe { ( * ( & raw const REGISTERED_GUEST_FUNCTIONS ) ) . get ( & function_call. function_name ) }
4849 {
4950 let function_call_parameter_types: Vec < ParameterType > = function_call
5051 . parameters
Original file line number Diff line number Diff line change @@ -56,10 +56,15 @@ static mut BIGARRAY: [i32; 1024 * 1024] = [0; 1024 * 1024];
5656
5757fn set_static ( _: & FunctionCall ) -> Result < Vec < u8 > > {
5858 unsafe {
59- for val in BIGARRAY . iter_mut ( ) {
59+ // Use &raw mut to get a mutable raw pointer, then dereference it
60+ // this is to avoid the clippy warning "shared reference to mutable static"
61+ let bigarray = & mut * ( & raw mut BIGARRAY ) ;
62+ for val in bigarray. iter_mut ( ) {
6063 * val = 1 ;
6164 }
62- Ok ( get_flatbuffer_result ( BIGARRAY . len ( ) as i32 ) )
65+ // Use &raw const to get a raw pointer, then dereference it
66+ // this is to avoid the clippy warning "shared reference to mutable static"
67+ Ok ( get_flatbuffer_result ( ( * ( & raw const BIGARRAY ) ) . len ( ) as i32 ) )
6368 }
6469}
6570
You can’t perform that action at this time.
0 commit comments