about summary refs log tree commit diff
diff options
context:
space:
mode:
authorbors <bors@rust-lang.org>2023-07-02 17:37:21 +0000
committerbors <bors@rust-lang.org>2023-07-02 17:37:21 +0000
commit7d12d2f08ba37e0b1f0d1847abda7e8e378034a5 (patch)
treeff3f9ea8fd69a53185712f9e37ef8a0478ef61c4
parenta6eb25aca269b26a5b75dd5276dd542ba978f92b (diff)
parentcc4670f54d70ba690463427aba9983f5511c1c14 (diff)
downloadrust-7d12d2f08ba37e0b1f0d1847abda7e8e378034a5.tar.gz
rust-7d12d2f08ba37e0b1f0d1847abda7e8e378034a5.zip
Auto merge of #2950 - icewind1991:cargo-miri-rustc-error, r=RalfJung
cargo-miri: better error message when RUSTC is not set

Currently, when running `cargo-miri` instead of `cargo miri` you get a very confusing.

```
thread 'main' panicked at 'called `Result::unwrap()` on an `Err` value: NotPresent', src/tools/miri/cargo-miri/src/main.rs:83:41
```

error. This replaces that with a message telling them to use `cargo miri`
-rw-r--r--src/tools/miri/cargo-miri/src/main.rs6
1 files changed, 5 insertions, 1 deletions
diff --git a/src/tools/miri/cargo-miri/src/main.rs b/src/tools/miri/cargo-miri/src/main.rs
index 85c9cdad7df..6178670b4f0 100644
--- a/src/tools/miri/cargo-miri/src/main.rs
+++ b/src/tools/miri/cargo-miri/src/main.rs
@@ -80,7 +80,11 @@ fn main() {
     match first.as_str() {
         "miri" => phase_cargo_miri(args),
         "runner" => phase_runner(args, RunnerPhase::Cargo),
-        arg if arg == env::var("RUSTC").unwrap() => {
+        arg if arg == env::var("RUSTC").unwrap_or_else(|_| {
+            show_error!(
+                "`cargo-miri` called without RUSTC set; please only invoke this binary through `cargo miri`"
+            )
+        }) => {
             // If the first arg is equal to the RUSTC env variable (which should be set at this
             // point), then we need to behave as rustc. This is the somewhat counter-intuitive
             // behavior of having both RUSTC and RUSTC_WRAPPER set