-
Notifications
You must be signed in to change notification settings - Fork 1.8k
Closed
Labels
C-bugCategory: Clippy is not doing the correct thingCategory: Clippy is not doing the correct thingE-mediumCall for participation: Medium difficulty level problem and requires some initial experience.Call for participation: Medium difficulty level problem and requires some initial experience.
Description
Probably, needless_pass_by_value
can be disabled for the extern functions. I'm not sure that it will be correct for all situations, so I'm going to describe my problem.
I'm using jni-rs crate that provides a thin wrapper around Java JNI interface pointer:
#[repr(C)]
pub struct JNIEnv<'a> {
internal: *mut sys::JNIEnv,
lifetime: PhantomData<&'a ()>,
}
It is passed by value to all functions that should be accessed from the Java side. For example:
#[no_mangle]
#[allow(non_snake_case)]
#[cfg_attr(feature = "cargo-clippy", allow(needless_pass_by_value))]
pub extern "C" fn Java_com_..._foo(
env: JNIEnv,
_: JClass,
...
) {
...
}
I don't like to suppress this warning for the entire project, but adding allow(needless_pass_by_value)
to all extern functions isn't nice, either. Perhaps, jni-rs can pass such parameters by reference, but it will be just reference to pointer. What is the best approach here? 🤔
supercurio
Metadata
Metadata
Assignees
Labels
C-bugCategory: Clippy is not doing the correct thingCategory: Clippy is not doing the correct thingE-mediumCall for participation: Medium difficulty level problem and requires some initial experience.Call for participation: Medium difficulty level problem and requires some initial experience.