@@ -32,15 +32,16 @@ impl MiriEnv {
32
32
&mut self,
33
33
quiet: bool,
34
34
target: Option<impl AsRef<OsStr>>,
35
+ features: &[String],
35
36
) -> Result<PathBuf> {
36
37
if let Some(miri_sysroot) = self.sh.var_os("MIRI_SYSROOT") {
37
38
// Sysroot already set, use that.
38
39
return Ok(miri_sysroot.into());
39
40
}
40
41
41
42
// Make sure everything is built. Also Miri itself.
42
- self.build(".", &[], quiet)?;
43
- self.build("cargo-miri", &[], quiet)?;
43
+ self.build(".", features, &[], quiet)?;
44
+ self.build("cargo-miri", &[], &[], quiet)?;
44
45
45
46
let target_flag = if let Some(target) = &target {
46
47
vec![OsStr::new("--target"), target.as_ref()]
@@ -58,7 +59,7 @@ impl MiriEnv {
58
59
}
59
60
60
61
let mut cmd = self
61
- .cargo_cmd("cargo-miri", "run")
62
+ .cargo_cmd("cargo-miri", "run", &[] )
62
63
.arg("--quiet")
63
64
.arg("--")
64
65
.args(&["miri", "setup", "--print-sysroot"])
@@ -90,7 +91,9 @@ impl Command {
90
91
Self::fmt(vec![])?;
91
92
}
92
93
if auto_clippy {
93
- Self::clippy(vec![])?;
94
+ // no features for auto actions, see
95
+ // https://github.com/rust-lang/miri/pull/4396#discussion_r2149654845
96
+ Self::clippy(vec![], vec![])?;
94
97
}
95
98
96
99
Ok(())
@@ -175,16 +178,16 @@ impl Command {
175
178
}
176
179
// Then run the actual command.
177
180
match self {
178
- Command::Install { flags } => Self::install(flags),
179
- Command::Build { flags } => Self::build(flags),
180
- Command::Check { flags } => Self::check(flags),
181
- Command::Test { bless, flags, target, coverage } =>
182
- Self::test(bless, flags, target, coverage),
183
- Command::Run { dep, verbose, target, edition, flags } =>
184
- Self::run(dep, verbose, target, edition, flags),
185
- Command::Doc { flags } => Self::doc(flags),
181
+ Command::Install { features, flags } => Self::install(features, flags),
182
+ Command::Build { features, flags } => Self::build(features, flags),
183
+ Command::Check { features, flags } => Self::check(features, flags),
184
+ Command::Test { bless, target, coverage, features, flags } =>
185
+ Self::test(bless, target, coverage, features, flags ),
186
+ Command::Run { dep, verbose, target, edition, features, flags } =>
187
+ Self::run(dep, verbose, target, edition, features, flags),
188
+ Command::Doc { features, flags } => Self::doc(features, flags),
186
189
Command::Fmt { flags } => Self::fmt(flags),
187
- Command::Clippy { flags } => Self::clippy(flags),
190
+ Command::Clippy { features, flags } => Self::clippy(features, flags),
188
191
Command::Bench { target, no_install, save_baseline, load_baseline, benches } =>
189
192
Self::bench(target, no_install, save_baseline, load_baseline, benches),
190
193
Command::Toolchain { flags } => Self::toolchain(flags),
@@ -494,7 +497,7 @@ impl Command {
494
497
495
498
if !no_install {
496
499
// Make sure we have an up-to-date Miri installed and selected the right toolchain.
497
- Self::install(vec![])?;
500
+ Self::install(vec![], vec![] )?;
498
501
}
499
502
let results_json_dir = if save_baseline.is_some() || load_baseline.is_some() {
500
503
Some(TempDir::new()?)
@@ -601,47 +604,48 @@ impl Command {
601
604
Ok(())
602
605
}
603
606
604
- fn install(flags: Vec<String>) -> Result<()> {
607
+ fn install(features: Vec<String>, flags: Vec<String>) -> Result<()> {
605
608
let e = MiriEnv::new()?;
606
- e.install_to_sysroot(e.miri_dir.clone() , &flags)?;
607
- e.install_to_sysroot(path!(e.miri_dir / "cargo-miri") , &flags)?;
609
+ e.install_to_sysroot(".", &features , &flags)?;
610
+ e.install_to_sysroot("cargo-miri", &[] , &flags)?;
608
611
Ok(())
609
612
}
610
613
611
- fn build(flags: Vec<String>) -> Result<()> {
614
+ fn build(features: Vec<String>, flags: Vec<String>) -> Result<()> {
612
615
let e = MiriEnv::new()?;
613
- e.build(".", &flags, /* quiet */ false)?;
614
- e.build("cargo-miri", &flags, /* quiet */ false)?;
616
+ e.build(".", &features, & flags, /* quiet */ false)?;
617
+ e.build("cargo-miri", &[], & flags, /* quiet */ false)?;
615
618
Ok(())
616
619
}
617
620
618
- fn check(flags: Vec<String>) -> Result<()> {
621
+ fn check(features: Vec<String>, flags: Vec<String>) -> Result<()> {
619
622
let e = MiriEnv::new()?;
620
- e.check(".", &flags)?;
621
- e.check("cargo-miri", &flags)?;
623
+ e.check(".", &features, & flags)?;
624
+ e.check("cargo-miri", &[], & flags)?;
622
625
Ok(())
623
626
}
624
627
625
- fn doc(flags: Vec<String>) -> Result<()> {
628
+ fn doc(features: Vec<String>, flags: Vec<String>) -> Result<()> {
626
629
let e = MiriEnv::new()?;
627
- e.doc(".", &flags)?;
628
- e.doc("cargo-miri", &flags)?;
630
+ e.doc(".", &features, & flags)?;
631
+ e.doc("cargo-miri", &[], & flags)?;
629
632
Ok(())
630
633
}
631
634
632
- fn clippy(flags: Vec<String>) -> Result<()> {
635
+ fn clippy(features: Vec<String>, flags: Vec<String>) -> Result<()> {
633
636
let e = MiriEnv::new()?;
634
- e.clippy(".", &flags)?;
635
- e.clippy("cargo-miri", &flags)?;
636
- e.clippy("miri-script", &flags)?;
637
+ e.clippy(".", &features, & flags)?;
638
+ e.clippy("cargo-miri", &[], & flags)?;
639
+ e.clippy("miri-script", &[], & flags)?;
637
640
Ok(())
638
641
}
639
642
640
643
fn test(
641
644
bless: bool,
642
- mut flags: Vec<String>,
643
645
target: Option<String>,
644
646
coverage: bool,
647
+ features: Vec<String>,
648
+ mut flags: Vec<String>,
645
649
) -> Result<()> {
646
650
let mut e = MiriEnv::new()?;
647
651
@@ -652,7 +656,7 @@ impl Command {
652
656
}
653
657
654
658
// Prepare a sysroot. (Also builds cargo-miri, which we need.)
655
- e.build_miri_sysroot(/* quiet */ false, target.as_deref())?;
659
+ e.build_miri_sysroot(/* quiet */ false, target.as_deref(), &features )?;
656
660
657
661
// Forward information to test harness.
658
662
if bless {
@@ -672,10 +676,10 @@ impl Command {
672
676
673
677
// Then test, and let caller control flags.
674
678
// Only in root project as `cargo-miri` has no tests.
675
- e.test(".", &flags)?;
679
+ e.test(".", &features, & flags)?;
676
680
677
681
if let Some(coverage) = &coverage {
678
- coverage.show_coverage_report(&e)?;
682
+ coverage.show_coverage_report(&e, &features )?;
679
683
}
680
684
681
685
Ok(())
@@ -686,14 +690,17 @@ impl Command {
686
690
verbose: bool,
687
691
target: Option<String>,
688
692
edition: Option<String>,
693
+ features: Vec<String>,
689
694
flags: Vec<String>,
690
695
) -> Result<()> {
691
696
let mut e = MiriEnv::new()?;
692
697
693
698
// Preparation: get a sysroot, and get the miri binary.
694
- let miri_sysroot = e.build_miri_sysroot(/* quiet */ !verbose, target.as_deref())?;
695
- let miri_bin =
696
- e.build_get_binary(".").context("failed to get filename of miri executable")?;
699
+ let miri_sysroot =
700
+ e.build_miri_sysroot(/* quiet */ !verbose, target.as_deref(), &features)?;
701
+ let miri_bin = e
702
+ .build_get_binary(".", &features)
703
+ .context("failed to get filename of miri executable")?;
697
704
698
705
// More flags that we will pass before `flags`
699
706
// (because `flags` may contain `--`).
@@ -718,7 +725,7 @@ impl Command {
718
725
// The basic command that executes the Miri driver.
719
726
let mut cmd = if dep {
720
727
// We invoke the test suite as that has all the logic for running with dependencies.
721
- e.cargo_cmd(".", "test")
728
+ e.cargo_cmd(".", "test", &features )
722
729
.args(&["--test", "ui"])
723
730
.args(quiet_flag)
724
731
.arg("--")
0 commit comments