Close the set of traits accepted by generate_trait_thunks#1469
Open
copybara-service[bot] wants to merge 1 commit into
Open
Close the set of traits accepted by generate_trait_thunks#1469copybara-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. |
copybara-service
Bot
force-pushed
the
test_951030364
branch
2 times, most recently
from
July 21, 2026 15:47
190bd4b to
3a26e91
Compare
This CL adds `SupportedTrait`, which means that `generate_trait_thunks` will not work for just any trait anymore. This is particularly useful for upcoming opaque types like compiler generated types, because often times they cannot be spelled out like regular types. For example without this, I was running into issues in some followups where it would try to format the param to `Drop::drop` as `&mut impl Future<...>`, since we were creating `substs` and then a `FnSig` on a not-fully-revealed opaque type. And we can't fully reveal the opaque type, because sometimes we can't spell it like if it's the future from an async fn. By controlling the set of functions we support for now, we can carefully construct the correct signatures for each trait to handle opaques correctly. For example, the extern C signature of `Drop::drop` of an opaque should just erase the type of the pointer completely, and then use the `fn inner<F: FnOnce() -> T>(_: F, erased: *mut ())` trick to bind the anonymous type to `T`. PiperOrigin-RevId: 951030364
copybara-service
Bot
force-pushed
the
test_951030364
branch
from
July 21, 2026 16:09
3a26e91 to
535e0dd
Compare
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.
Close the set of traits accepted by generate_trait_thunks
This CL adds
SupportedTrait, which means thatgenerate_trait_thunkswill not work for just any trait anymore. This is particularly useful for upcoming opaque types like compiler generated types, because often times they cannot be spelled out like regular types. For example without this, I was running into issues in some followups where it would try to format the param toDrop::dropas&mut impl Future<...>, since we were creatingsubstsand then aFnSigon a not-fully-revealed opaque type. And we can't fully reveal the opaque type, because sometimes we can't spell it like if it's the future from an async fn.By controlling the set of functions we support for now, we can carefully construct the correct signatures for each trait to handle opaques correctly. For example, the extern C signature of
Drop::dropof an opaque should just erase the type of the pointer completely, and then use thefn inner<F: FnOnce() -> T>(_: F, erased: *mut ())trick to bind the anonymous type toT.