Skip to content

Commit fd7c268

Browse files
Chore: Address clippy warnings.
1 parent 5163499 commit fd7c268

1 file changed

Lines changed: 7 additions & 7 deletions

File tree

compiler/src/wasm.rs

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -13,32 +13,32 @@ mod runtime {
1313
static mut SRC: [u8; SZ] = [0; SZ];
1414
static mut OUT: [u8; SZ] = [0; SZ];
1515

16-
#[unsafe(no_mangle)] pub unsafe extern "C" fn src_ptr() -> *mut u8 { core::ptr::addr_of_mut!(SRC) as *mut u8 }
17-
#[unsafe(no_mangle)] pub unsafe extern "C" fn out_ptr() -> *const u8 { core::ptr::addr_of!(OUT) as *const u8 }
16+
#[unsafe(no_mangle)] pub unsafe extern "C" fn src_ptr() -> *mut u8 { unsafe { core::ptr::addr_of_mut!(SRC) as *mut u8 } }
17+
#[unsafe(no_mangle)] pub unsafe extern "C" fn out_ptr() -> *const u8 { unsafe { core::ptr::addr_of!(OUT) as *const u8 } }
1818

1919
#[unsafe(no_mangle)]
2020
pub unsafe extern "C" fn run(len: usize) -> usize {
2121
let len = len.min(SZ);
22-
let src = match core::str::from_utf8(core::slice::from_raw_parts(core::ptr::addr_of!(SRC) as *const u8, len)) {
22+
let src = match core::str::from_utf8(unsafe { core::slice::from_raw_parts(core::ptr::addr_of!(SRC) as *const u8, len) }) {
2323
Ok(s) => s,
24-
Err(e) => return write_out(&alloc::format!("input rejected: not valid utf-8 at byte {}", e.valid_up_to())),
24+
Err(e) => return unsafe { write_out(&alloc::format!("input rejected: not valid utf-8 at byte {}", e.valid_up_to())) },
2525
};
2626

2727
let (chunk, errs) = Parser::new(src, lexer(src)).parse();
28-
28+
2929
let out: alloc::string::String = if !errs.is_empty() {
3030
errs.iter().map(|e| alloc::format!("syntax error at line {}: {}", e.line + 1, e.msg)).collect::<alloc::vec::Vec<_>>().join("\n")
3131
} else {
3232
let mut vm = VM::with_limits(&chunk, Limits::sandbox());
3333
vm.run().map(|_| vm.output.join("\n")).unwrap_or_else(|e| alloc::format!("execution failed: {}", e))
3434
};
35-
write_out(&out)
35+
unsafe { write_out(&out) }
3636
}
3737

3838
unsafe fn write_out(s: &str) -> usize {
3939
let b = s.as_bytes();
4040
let n = b.len().min(SZ);
41-
core::slice::from_raw_parts_mut(core::ptr::addr_of_mut!(OUT) as *mut u8, n).copy_from_slice(&b[..n]);
41+
unsafe { core::slice::from_raw_parts_mut(core::ptr::addr_of_mut!(OUT) as *mut u8, n).copy_from_slice(&b[..n]); }
4242
n
4343
}
4444
}

0 commit comments

Comments
 (0)