From eb6308fc34bf6e88f5af59b0fddbd9af07cdf327 Mon Sep 17 00:00:00 2001 From: Michael Woerister Date: Tue, 25 Apr 2017 10:59:29 +0200 Subject: [PATCH] remap-path-prefix: Validate number of commandline arguments passed. --- src/librustc/session/config.rs | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/src/librustc/session/config.rs b/src/librustc/session/config.rs index 888ed2a6d18..99c98f85c32 100644 --- a/src/librustc/session/config.rs +++ b/src/librustc/session/config.rs @@ -1443,6 +1443,23 @@ pub fn build_session_options_and_crate_config(matches: &getopts::Matches) output_types.insert(OutputType::Exe, None); } + let remap_path_prefix_sources = debugging_opts.remap_path_prefix_from.len(); + let remap_path_prefix_targets = debugging_opts.remap_path_prefix_from.len(); + + if remap_path_prefix_targets < remap_path_prefix_sources { + for source in &debugging_opts.remap_path_prefix_from[remap_path_prefix_targets..] { + early_error(error_format, + &format!("option `-Zremap-path-prefix-from='{}'` does not have \ + a corresponding `-Zremap-path-prefix-to`", source)) + } + } else if remap_path_prefix_targets > remap_path_prefix_sources { + for target in &debugging_opts.remap_path_prefix_to[remap_path_prefix_sources..] { + early_error(error_format, + &format!("option `-Zremap-path-prefix-to='{}'` does not have \ + a corresponding `-Zremap-path-prefix-from`", target)) + } + } + let mut cg = build_codegen_options(matches, error_format); // Issue #30063: if user requests llvm-related output to one