-
Couldn't load subscription status.
- Fork 20
Description
I have the following top level question:
Is it possible to validate and verify a macro and then use the macro in my code without any worries ?
Procedural Macros
I don't think it is possible to prove that any procedural macro is correctly generate code for any input.
A procedural macro by manipulating the AST is almost as powerful as a compiler.
Usually compiler safety manual requires to test the generated code because it is not possible to prove the correctness of generated code for any input program. Therefore I see the following top level direction:
- Require that all code generated by the macro call is tested following the same rules (depends on safety standard) as regular Rust code. (I read somewhere that the code generated by cargo expand of procedural macro can be compiled as regular code)
- Restrict the usage of procedural macro until we are quite sure that the macro is correct and there is no need to test generated code.
Declarative Macros
I have the feeling that it should be possible in principle to validate and verify because they are not very powerful and they more a template.