dtolnay/cargo-expand

the option `Z` is only accepted on the nightly compiler

Goodjooy opened this issue ยท 7 comments

PS D:\RustProject\msg_chain> cargo expand
    Checking msg_chain v0.1.0 (D:\RustProject\msg_chain)
error: the option `Z` is only accepted on the nightly compiler
error: could not compile `msg_chain`
To learn more, run the command again with --verbose.

I am using stable tool chain

installed toolchains
--------------------

stable-x86_64-pc-windows-msvc (default)
nightly-x86_64-pc-windows-msvc

active toolchain
----------------

stable-x86_64-pc-windows-msvc (default)
rustc 1.53.0 (53cb7b09b 2021-06-17)

I think maybe cargo expand failure becuse my crate contain custom derive macro.
And I create a crate named ctest with default code
src/main.rs

fn main() {
    println!("Hello, world!");
}

but cargo expand report the same error

PS D:\RustProject\ctest> cargo expand
    Checking ctest v0.1.0 (D:\RustProject\ctest)
error: the option `Z` is only accepted on the nightly compiler
error: could not compile `ctest`
To learn more, run the command again with --verbose.

Try to run cargo expand --lib, or specify a custom path, like cargo expand --lib -- path::to::function

If that doesn't work out, try running it without cargo-expand: add --verbose to your cargo-expand command and you'll find the cargo rustc command being executed: you can modify it a bit and you'll hit gold

rozgo commented

This is the command passed to rustc that seems to be causing the issue:

-Zunpretty=expanded

I did not have nightly installed. After installing, expand worked.

Cargo expand requires a reasonably recent nightly compiler installed. As far as I can tell this is working correctly so I'll go ahead and close.

If someone believes they have nightly installed and it is not being found, that needs to be reported to https://github.com/gsquire/toolchain_find.

Would be lovely if cargo-expand could check it's at least found a nightly-channel compiler to provide a more informative error message.

It's close to a year later, and I have the latest standard compiler, and cargo-expand still requires a nightly compiler build. Are there nightly options that will never make it into the standard compiler?

mimoo commented

I managed to run it without nightly by doing this:

RUSTC_BOOTSTRAP=1 cargo expand
qrilka commented

@dtolnay the recipe above seems to work without nightly, could it be added into the project's README maybe?