about summary refs log tree commit diff
diff options
context:
space:
mode:
authorbors <bors@rust-lang.org>2023-08-02 16:33:31 +0000
committerbors <bors@rust-lang.org>2023-08-02 16:33:31 +0000
commit0ea879f9ceab7080d46d56f05338d6a2f261452f (patch)
treea50ee089290f718ee941e5971ff288bbdf4df607
parentf1280576ec204f1cf9060e6c3918c22a2f185ee5 (diff)
parent42269c35afdb113b0b826d50293a0afe64c17826 (diff)
downloadrust-0ea879f9ceab7080d46d56f05338d6a2f261452f.tar.gz
rust-0ea879f9ceab7080d46d56f05338d6a2f261452f.zip
Auto merge of #3005 - RalfJung:miriscript, r=RalfJung
miri-script: simplify flag computation a bit
-rw-r--r--src/tools/miri/miri-script/src/util.rs24
1 files changed, 12 insertions, 12 deletions
diff --git a/src/tools/miri/miri-script/src/util.rs b/src/tools/miri/miri-script/src/util.rs
index caebd88b14b..dfbffa2ae91 100644
--- a/src/tools/miri/miri-script/src/util.rs
+++ b/src/tools/miri/miri-script/src/util.rs
@@ -49,8 +49,8 @@ pub struct MiriEnv {
 
 impl MiriEnv {
     pub fn new() -> Result<Self> {
-        let sh = shell()?;
         let toolchain = active_toolchain()?;
+        let sh = shell()?; // we are preserving the current_dir on this one, so paths resolve properly!
         let miri_dir = miri_dir()?;
 
         let sysroot = cmd!(sh, "rustc +{toolchain} --print sysroot").read()?.into();
@@ -77,18 +77,18 @@ impl MiriEnv {
 
         // Compute rustflags.
         let rustflags = {
-            let env = std::env::var_os("RUSTFLAGS");
-            let mut flags_with_warnings = OsString::from(
-                "-Zunstable-options -Wrustc::internal -Wrust_2018_idioms -Wunused_lifetimes -Wsemicolon_in_expressions_from_macros ",
-            );
-            if let Some(value) = env {
-                flags_with_warnings.push(value);
-            }
+            let mut flags = OsString::new();
             // We set the rpath so that Miri finds the private rustc libraries it needs.
-            let mut flags_with_compiler_settings = OsString::from("-C link-args=-Wl,-rpath,");
-            flags_with_compiler_settings.push(&libdir);
-            flags_with_compiler_settings.push(flags_with_warnings);
-            flags_with_compiler_settings
+            flags.push("-C link-args=-Wl,-rpath,");
+            flags.push(libdir);
+            // Enable rustc-specific lints (ignored without `-Zunstable-options`).
+            flags.push(" -Zunstable-options -Wrustc::internal -Wrust_2018_idioms -Wunused_lifetimes -Wsemicolon_in_expressions_from_macros");
+            // Add user-defined flags.
+            if let Some(value) = std::env::var_os("RUSTFLAGS") {
+                flags.push(" ");
+                flags.push(value);
+            }
+            flags
         };
         sh.set_var("RUSTFLAGS", rustflags);