-
Notifications
You must be signed in to change notification settings - Fork 60
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
Safety/soundness of macros #278
Comments
The obvious definition would be similar to That being said, the reality of macros is way more brittle than what this definition expects. Indeed, until we get more advanced hygiene (privacy-wise, I mean), global paths are resolved from the call-site environment, rather than the macro environment.
On top of that, procedural macros don't have the luxury of having a From there, one could relax a bit the rules of soundness to take this reality into account, with the following "amendment": Suggested ruleA macro is considered unsound if a user can cause UB using it, provided they didn't:
From there, here comes the "sound macro checklist":
Quid of
|
This is the definition for safe But once we have such a definition, then I agree that this is the obvious definition for soundness. Thanks for assembling the list of consequences of that choice, this is very helpful! |
It is not entirely clear what it means for a macro to be "safe", and by extension, what it means for a macro to be "sound". This is what underlies the old discussion at rustsec/advisory-db#275, and also has some up in other discussions:
We should figure out some proper definition for when a macro is considered to be "sound".
The text was updated successfully, but these errors were encountered: