-
-
Notifications
You must be signed in to change notification settings - Fork 760
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Multiple "custom extension" callbacks with same signature share indices #2342
Comments
TypeId doesn't soley depend on the function signature. Two closures with the same signature will have distinct type IDs: https://play.rust-lang.org/?version=stable&mode=debug&edition=2015&gist=2cbed57c6704def2b82e7ef890c83c16 |
Hmm. I'm not sure why they are not the same in the case you provided. However, I have another snippet that illustrates the point more clearly: https://play.rust-lang.org/?version=stable&mode=debug&edition=2015&gist=b7409b138b7e33cacf7c630753ac49f2 Notice how they are not even "the same closure" (i.e. they have different instructions) but they still have the same I have experienced this problem first-hand when dealing with custom extensions with |
If you coerce them to function pointers they'll have the same type id, sure. |
I added the following test to the PR I opened:
Don't you think this use case deserves to be addressed? |
When using the function
add_custom_ext
the callbacks are stored using indices that depend solely on their function signature, as implemented oncached_ex_index
. More specifically, aTypeId
of the signature is used to generate the key.This means that two different callbacks with the same signature will overwrite each other.
The key for the index should depend on its identifier (a.k.a. "extension type") as there should be a one-to-one relation between an extension type and its callbacks.
The text was updated successfully, but these errors were encountered: