Skip to content

Commit 7a30e41

Browse files
authored
Rollup merge of #58345 - RalfJung:2nd-filename, r=matthewjasper
When there are multiple filenames, print what got interpreted as filenames I have written code that crafts command lines for rustc, and when I get "multiple input filenames provided" it can be quite hard to figure out where in this long list of arguments the mistake is hiding. Probably I passed an argument to a flag that does not expect an argument, but which flag would that be? This changes the error message to print the first two filenames, to make it easier to debug what is going on.
2 parents 6023911 + 3a3691f commit 7a30e41

File tree

1 file changed

+9
-1
lines changed

1 file changed

+9
-1
lines changed

src/librustc_driver/lib.rs

+9-1
Original file line numberDiff line numberDiff line change
@@ -838,7 +838,15 @@ impl<'a> CompilerCalls<'a> for RustcDefaultCalls {
838838
early_error(sopts.error_format, "no input filename given");
839839
}
840840
1 => panic!("make_input should have provided valid inputs"),
841-
_ => early_error(sopts.error_format, "multiple input filenames provided"),
841+
_ =>
842+
early_error(
843+
sopts.error_format,
844+
&format!(
845+
"multiple input filenames provided (first two filenames are `{}` and `{}`)",
846+
matches.free[0],
847+
matches.free[1],
848+
),
849+
)
842850
}
843851
}
844852

0 commit comments

Comments
 (0)