Allow unsafe operations in unsafe functions in generated code.
This will soon be denied by default, but we trust that what cxx does is
correct. Also added a missing safety comment.
Bug: 290018030
Test: m rust
Change-Id: I55e3cad8cdfcd2053d01adfb7eb1e60858b813fd
diff --git a/services/inputflinger/rust/lib.rs b/services/inputflinger/rust/lib.rs
index c0561d7..501e435 100644
--- a/services/inputflinger/rust/lib.rs
+++ b/services/inputflinger/rust/lib.rs
@@ -32,6 +32,7 @@
const LOG_TAG: &str = "inputflinger_bootstrap";
#[cxx::bridge]
+#[allow(unsafe_op_in_unsafe_fn)]
mod ffi {
extern "C++" {
include!("InputFlingerBootstrap.h");
@@ -67,7 +68,9 @@
panic!("create_inputflinger_rust cannot be called with a null callback");
}
- let Some(callback) = new_spibinder(callback) else {
+ // SAFETY: Our caller guaranteed that `callback` is a valid pointer to an `AIBinder` and its
+ // reference count has been incremented..
+ let Some(callback) = (unsafe { new_spibinder(callback) }) else {
panic!("Failed to get SpAIBinder from raw callback pointer");
};