Skip to content

Commit eb6308f

Browse files
remap-path-prefix: Validate number of commandline arguments passed.
1 parent 39ffea3 commit eb6308f

File tree

1 file changed

+17
-0
lines changed

1 file changed

+17
-0
lines changed

src/librustc/session/config.rs

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1443,6 +1443,23 @@ pub fn build_session_options_and_crate_config(matches: &getopts::Matches)
14431443
output_types.insert(OutputType::Exe, None);
14441444
}
14451445

1446+
let remap_path_prefix_sources = debugging_opts.remap_path_prefix_from.len();
1447+
let remap_path_prefix_targets = debugging_opts.remap_path_prefix_from.len();
1448+
1449+
if remap_path_prefix_targets < remap_path_prefix_sources {
1450+
for source in &debugging_opts.remap_path_prefix_from[remap_path_prefix_targets..] {
1451+
early_error(error_format,
1452+
&format!("option `-Zremap-path-prefix-from='{}'` does not have \
1453+
a corresponding `-Zremap-path-prefix-to`", source))
1454+
}
1455+
} else if remap_path_prefix_targets > remap_path_prefix_sources {
1456+
for target in &debugging_opts.remap_path_prefix_to[remap_path_prefix_sources..] {
1457+
early_error(error_format,
1458+
&format!("option `-Zremap-path-prefix-to='{}'` does not have \
1459+
a corresponding `-Zremap-path-prefix-from`", target))
1460+
}
1461+
}
1462+
14461463
let mut cg = build_codegen_options(matches, error_format);
14471464

14481465
// Issue #30063: if user requests llvm-related output to one

0 commit comments

Comments
 (0)