Skip to content

Commit

Permalink
Rollup merge of rust-lang#58345 - RalfJung:2nd-filename, r=matthewjasper
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
GuillaumeGomez authored Feb 10, 2019
2 parents c3aa847 + 3a3691f commit 53e9a65
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion src/librustc_driver/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -838,7 +838,15 @@ impl<'a> CompilerCalls<'a> for RustcDefaultCalls {
early_error(sopts.error_format, "no input filename given");
}
1 => panic!("make_input should have provided valid inputs"),
_ => early_error(sopts.error_format, "multiple input filenames provided"),
_ =>
early_error(
sopts.error_format,
&format!(
"multiple input filenames provided (first two filenames are `{}` and `{}`)",
matches.free[0],
matches.free[1],
),
)
}
}

Expand Down

0 comments on commit 53e9a65

Please sign in to comment.