-
Notifications
You must be signed in to change notification settings - Fork 342
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Suppress
unused_unsafe
warnings within the generated code.
Sometimes Rust functions declared inside the `#[cxx::bridge]` have to be marked as unsafe (e.g. if they need to use an explicit lifetime). When the actual, wrapped function is _not_ unsafe, then the generated code will result in an `unused_unsafe` warning. For example: ``` Compiling cxx-test-suite v0.0.0 (/usr/local/google/home/lukasza/src/github/cxx/tests/ffi) error: unnecessary `unsafe` block --> tests/ffi/lib.rs:276:19 | 276 | unsafe fn r_return_str_via_out_param<'a>(shared: &'a Shared, out_param: &mut &'a str); | ^^^^^^^^^^^^^^^^^^^^^^^^^^ unnecessary `unsafe` block | note: the lint level is defined here --> tests/ffi/lib.rs:20:9 | 20 | #![deny(warnings)] // Check that expansion of `cxx::bridge` doesn't trigger warnings. | ^^^^^^^^ = note: `#[deny(unused_unsafe)]` implied by `#[deny(warnings)]` ``` The warning above comes from the following expansion: ``` unsafe fn __r_return_str_via_out_param<'a>(...) { // The `unsafe` block below is unnecessary if the actual, wrapped // function is *not* `unsafe`. unsafe { super::r_return_str_via_out_param(...) } } ``` This commit avoids the warning by including an explicit `#[allow(unused_unsafe)]` in the generated code.
- Loading branch information
1 parent
3190072
commit 86e8c0c
Showing
4 changed files
with
19 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters