diff --git a/src/tools/miri/miri b/src/tools/miri/miri
index 9e33f525c8f..48a46a76a12 100755
--- a/src/tools/miri/miri
+++ b/src/tools/miri/miri
@@ -330,7 +330,7 @@ run|run-dep)
     # Then run the actual command.
     
     if [ "$COMMAND" = "run-dep" ]; then
-        exec $CARGO test --test compiletest -- miri-run-dep-mode $CARGO_EXTRA_FLAGS --manifest-path "$MIRIDIR"/Cargo.toml -- $MIRIFLAGS "$@"
+        exec $CARGO test --test compiletest $CARGO_EXTRA_FLAGS --manifest-path "$MIRIDIR"/Cargo.toml -- --miri-run-dep-mode $MIRIFLAGS "$@"
     else
         exec $CARGO run $CARGO_EXTRA_FLAGS --manifest-path "$MIRIDIR"/Cargo.toml -- $MIRIFLAGS "$@"
     fi
diff --git a/src/tools/miri/tests/compiletest.rs b/src/tools/miri/tests/compiletest.rs
index 688b6519cbd..c027c7a7779 100644
--- a/src/tools/miri/tests/compiletest.rs
+++ b/src/tools/miri/tests/compiletest.rs
@@ -242,7 +242,7 @@ fn main() -> Result<()> {
     let target = get_target();
 
     if let Some(first) = std::env::args().nth(1) {
-        if first == "miri-run-dep-mode" {
+        if first == "--miri-run-dep-mode" {
             return run_dep_mode(target);
         }
     }
@@ -270,7 +270,7 @@ fn main() -> Result<()> {
 }
 
 fn run_dep_mode(target: String) -> Result<()> {
-    let files = std::env::args().skip_while(|arg| arg != "--").skip(1);
+    let files = std::env::args().skip(2);
     for path in files {
         let mut config = run_test_config(std::iter::empty(), &target, &path, Mode::Yolo, true);
         config.program.args.remove(0); // remove the `--error-format=json` argument