-
Notifications
You must be signed in to change notification settings - Fork 1.4k
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
Validate import names given to trappable_imports
#9057
Validate import names given to trappable_imports
#9057
Conversation
I realize it'd be more difficult, but would you be up for seeing how to validate that all the entries in this list are used in addition to them being valid? Or rather validation wouldn't be required if they're validated to be used. IIRC we already require that all I ask this because it feels like the most robust solution here in terms of ensuring we actually use all of the input and helping to catch typos/misconfiguration. Also as for negative tests you're right in that we don't have any. They're unfortunately difficult to add because rustc's output changes over time, but we should probably look in to adding them at some point in the future. |
Yep, I'll have a look at doing that instead 👍 |
I've reworked it to track the import names that get used, and check that all names specified in the list initially get used. If none are used, a similar error to the handling of the One wrinkle here is that I had to mark names as used if |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks reasonable to me!
It's easy to accidentally use the generated name when passing names to the
trappable_imports
field of thebindgen!
macro, yielding generated bindings that don't use the expectedtrappable_error_type
. This PR adds some validation, ensuring that arguments totrappable_imports
are used during binding generation and raising an error if any are ignored.It doesn't appear that we have negative tests for wasmtime-component-macro, but I'm happy to add them if I've missed something there.