I am writing rust macros and came across an error about my macro I can't understand. In hope of understanding it better, I tried to follow the compiler's advice by setting the -Z macro-backtrace
unstable option and compiling again. Here is said advice:
note: this error originates in a macro (in Nightly builds, run with -Z macro-backtrace for more info)
But doing this:
cargo run -Z macro-backtrace
Results in this:
error: unknown `-Z` flag specified: macro-backtrace
I already switched to the nightly toolchain entirely by running rustup override nightly
in the project directory and rustup default nightly
for future uses of this feature, but still the error presists.
In diggin through the web, I found a way to list all -Z
options with cargo -Z help
:
Available unstable (nightly-only) flags: -Z avoid-dev-deps -- Avoid installing dev-dependencies if possible -Z minimal-versions -- Install minimal dependency versions instead of maximum -Z no-index-update -- Do not update the registry, avoids a network request for benchmarking -Z unstable-options -- Allow the usage of unstable options -Z timings -- Display concurrency information -Z doctest-xcompile -- Compile and run doctests for non-host target using runner config -Z terminal-width -- Provide a terminal width to rustc for error truncation Run with 'cargo -Z [FLAG] [SUBCOMMAND]' See https://doc.rust-lang.org/nightly/cargo/reference/unstable.html for more information about these flags.
No -Z macro-backtrace
... I went to the specified link, butr even there a search for macro-backtrace
yields no results.
So I am stuck... I would pretty much like to use this feature and yet can't seem to find a way to activate it.
Any help will be appreciated.
-Z macro-backtrace
is a rustc
flag, not a cargo
flag. You should be able to pass it to rustc
using cargo +nightly rustc -- -Z macro-backtrace
. (The +nightly
in the command line is optional if you already switched to the nightly compiler as the default.)
Alternatively, you can set the RUSTFLAGS
environment variable:
export RUSTFLAGS="-Z macro-backtrace"
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With