-
Notifications
You must be signed in to change notification settings - Fork 4
Open
Description
When using params as the first argument to a map module, clippy will report:
error: this public function might dereference a raw pointer but is not marked `unsafe`
#[substreams::handlers::map]
pub fn map_pools_created(params: String, block: Block) -> Result<Pools, Error> {
// ...
}This doesn't prevent code compilation but is definitely quite annoying. Adding the unsafe keyword to my module function definition doesn't solve the problem, because (I suspect) the underlying macro produces output that doesn't have the unsafe keyword.
I see the following when I expand the map proc macro:
#[no_mangle]
pub extern "C" fn map_pools_created(
params_ptr: *mut u8,
params_len: usize,
block_ptr: *mut u8,
block_len: usize,
) {
substreams::register_panic_hook();
let func = || -> Result<Pools, Error> {
let params: String = std::mem::ManuallyDrop::new(unsafe {
String::from_raw_parts(params_ptr, params_len, params_len)
})
.to_string();
// ...
}which indeed contains some unsafe code.
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels