procout
- What: It prints the output of a procedural macro to a file.
- Wherefore: To ease debugging by clarifying the source of errors with explicit line numbers instead of the unavoidably opaque errors often produced when debugging procedural macros in Rust.
- Whereby: Add a function call to your proc macro and use the command-line feature.
This depends on the procedural macro compiling to code. If it's not at the stage where it compiles, it has to get there before this will produce useful output.
Whereby
Given a procedural macro's constructed as so,
use ;
use ;
use ;
use ;
Just insert a call to procout before the conversion and return step.
use ;
use ;
use ; // Look!
use ;
use ;
By calling cargo test --features procout, the code will print
to the a/valid/path/string specified as a file corresponding to module_ident.
By default, the path string is the local tests directory, so after the first run using the procout
feature, it's possible to run something like cargo test --test module_ident and get better errors
from the compiler.
Now with these splendid new capabilities:
- A unit test module will be generated with a no-op test that just imports the module named in
module_ident. module_identshould be the name of a generated module.- If no path is specified, the default path will be the current working directory's
testssubfolder, - If no
module_identis specified, the default will be a generic timestamp.
Warning:
This will overwrite whatever's at the specified path, so be careful when prototyping.
Features
procoutOutputs the macro to a file. Callingprocoutwith this feature disabled is an intentional no-op.formattedCallsrustfmton the created file. This is enabled by default and is recommended.notificationPrints a notification to stdout on success. This is enabled by default.
License: MIT