@@ -601,7 +601,6 @@ impl FetchMetadata {
601
601
}
602
602
command. current_dir ( current_dir) ;
603
603
604
- let mut needs_nightly = false ;
605
604
let mut other_options = vec ! [ ] ;
606
605
// cargo metadata only supports a subset of flags of what cargo usually accepts, and usually
607
606
// the only relevant flags for metadata here are unstable ones, so we pass those along
@@ -611,15 +610,13 @@ impl FetchMetadata {
611
610
if arg == "-Z"
612
611
&& let Some ( arg) = extra_args. next ( )
613
612
{
614
- needs_nightly = true ;
615
613
other_options. push ( "-Z" . to_owned ( ) ) ;
616
614
other_options. push ( arg. to_owned ( ) ) ;
617
615
}
618
616
}
619
617
620
618
let mut lockfile_path = None ;
621
619
if cargo_toml. is_rust_manifest ( ) {
622
- needs_nightly = true ;
623
620
other_options. push ( "-Zscript" . to_owned ( ) ) ;
624
621
} else if config
625
622
. toolchain_version
@@ -637,10 +634,6 @@ impl FetchMetadata {
637
634
638
635
command. other_options ( other_options. clone ( ) ) ;
639
636
640
- if needs_nightly {
641
- command. env ( "__CARGO_TEST_CHANNEL_OVERRIDE_DO_NOT_USE_THIS" , "nightly" ) ;
642
- }
643
-
644
637
// Pre-fetch basic metadata using `--no-deps`, which:
645
638
// - avoids fetching registries like crates.io,
646
639
// - skips dependency resolution and does not modify lockfiles,
@@ -710,7 +703,7 @@ impl FetchMetadata {
710
703
other_options. push ( target_lockfile. to_string ( ) ) ;
711
704
using_lockfile_copy = true ;
712
705
}
713
- if using_lockfile_copy {
706
+ if using_lockfile_copy || other_options . iter ( ) . any ( |it| it . starts_with ( "-Z" ) ) {
714
707
command. env ( "__CARGO_TEST_CHANNEL_OVERRIDE_DO_NOT_USE_THIS" , "nightly" ) ;
715
708
other_options. push ( "-Zunstable-options" . to_owned ( ) ) ;
716
709
}
0 commit comments