@@ -38,7 +38,7 @@ enum MiriCommand {
38
38
}
39
39
40
40
/// The information to run a crate with the given environment.
41
- #[ derive( Serialize , Deserialize , Clone ) ]
41
+ #[ derive( Serialize , Deserialize ) ]
42
42
struct CrateRunEnv {
43
43
/// The command-line arguments.
44
44
args : Vec < String > ,
@@ -52,13 +52,13 @@ struct CrateRunEnv {
52
52
53
53
impl CrateRunEnv {
54
54
/// Gather all the information we need.
55
- fn collect ( args : env:: Args ) -> Self {
55
+ fn collect ( args : env:: Args , capture_stdin : bool ) -> Self {
56
56
let args = args. collect ( ) ;
57
57
let env = env:: vars_os ( ) . collect ( ) ;
58
58
let current_dir = env:: current_dir ( ) . unwrap ( ) . into_os_string ( ) ;
59
59
60
60
let mut stdin = Vec :: new ( ) ;
61
- if env :: var_os ( "MIRI_CALLED_FROM_RUSTDOC" ) . is_some ( ) {
61
+ if capture_stdin {
62
62
std:: io:: stdin ( ) . lock ( ) . read_to_end ( & mut stdin) . expect ( "cannot read stdin" ) ;
63
63
}
64
64
@@ -669,17 +669,18 @@ fn phase_cargo_rustc(mut args: env::Args) {
669
669
let runnable_crate = !print && is_runnable_crate ( ) ;
670
670
671
671
if runnable_crate && target_crate {
672
+ let inside_rustdoc = env:: var_os ( "MIRI_CALLED_FROM_RUSTDOC" ) . is_some ( ) ;
672
673
// This is the binary or test crate that we want to interpret under Miri.
673
674
// But we cannot run it here, as cargo invoked us as a compiler -- our stdin and stdout are not
674
675
// like we want them.
675
676
// Instead of compiling, we write JSON into the output file with all the relevant command-line flags
676
677
// and environment variables; this is used when cargo calls us again in the CARGO_TARGET_RUNNER phase.
677
- let env = CrateRunEnv :: collect ( args) ;
678
+ let env = CrateRunEnv :: collect ( args, inside_rustdoc ) ;
678
679
679
680
// Rustdoc expects us to exit with an error code if the test is marked as `compile_fail`,
680
681
// just creating the JSON file is not enough: we need to detect syntax errors,
681
682
// so we need to run Miri with `MIRI_BE_RUSTC` for a check-only build.
682
- if std :: env :: var_os ( "MIRI_CALLED_FROM_RUSTDOC" ) . is_some ( ) {
683
+ if inside_rustdoc {
683
684
let mut cmd = miri ( ) ;
684
685
685
686
// Ensure --emit argument for a check-only build is present.
0 commit comments