Repository navigation
Use raw pointers for NonNull and cpp_type wrappers in callable invokers. - #3279
Open
copybara-service[bot] wants to merge 1 commit into
Open
copybara-service[bot] wants to merge 1 commit into
copybara-service[bot] wants to merge 1 commit into
Conversation
|
Thanks for your pull request! It looks like this may be your first contribution to a Google open source project. Before we can look at your pull request, you'll need to sign a Contributor License Agreement (CLA). View this failed invocation of the CLA check for more information. For the most up to date status, view the checks section at the bottom of the pull request. |
Rust calls a C++ callable through `__invoker`. Cross-language CFI stops this call when a param or the return value is a `NonNull<T>` or a `repr(transparent)` wrapper with a pointer `cpp_type` (such as a proto view). Clang encodes the C++ type as a pointer. Rustc encodes the wrapper as its field and `NonNull` as a pattern type. Thus the two type IDs are different. The invoker signature spells these types as raw pointers, as it does for `&T`. `NonNull<T>` becomes `*mut T`. A pointer `cpp_type` wrapper becomes `*const c_void` or `*mut c_void`, with the `const` qualifier from `cpp_type`, because the Rust field is always `*const`. Return values get the same change, because the return type is part of the type ID. Returned pointees use `'static` lifetimes, which also fixes an old E0106 compile error for callables that return references with lifetimes. This change does not apply to unsized pointees, to a `cpp_type` with more than one `*`, or to `Pin<&T>`. PiperOrigin-RevId: 1035279474
copybara-service
Bot
force-pushed
the
test_1035279474
branch
from
December 4, 2026 17:36
3805d80 to
9f21f7b
Compare
This branch has not been deployed
This file contains hidden or 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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Use raw pointers for NonNull and cpp_type wrappers in callable invokers.
Rust calls a C++ callable through
__invoker. Cross-language CFI stops this call when a param or the return value is aNonNull<T>or arepr(transparent)wrapper with a pointercpp_type(such as a proto view). Clang encodes the C++ type as a pointer. Rustc encodes the wrapper as its field andNonNullas a pattern type. Thus the two type IDs are different.The invoker signature spells these types as raw pointers, as it does for
&T.NonNull<T>becomes*mut T. A pointercpp_typewrapper becomes*const c_voidor*mut c_void, with theconstqualifier fromcpp_type, because the Rust field is always*const. Return values get the same change, because the return type is part of the type ID. Returned pointees use'staticlifetimes, which also fixes an old E0106 compile error for callables that return references with lifetimes.This change does not apply to unsized pointees, to a
cpp_typewith more than one*, or toPin<&T>.