Skip to content

Commit 226894b

Browse files
committed
Fix argument alias handling for -g and -C debuginfo
1 parent 544d8e9 commit 226894b

File tree

1 file changed

+8
-3
lines changed

1 file changed

+8
-3
lines changed

src/librustc/session/config.rs

+8-3
Original file line numberDiff line numberDiff line change
@@ -2217,10 +2217,15 @@ pub fn build_session_options_and_crate_config(
22172217
}
22182218
};
22192219
let debug_assertions = cg.debug_assertions.unwrap_or(opt_level == OptLevel::No);
2220-
let debuginfo = if matches.opt_present("g") {
2221-
if cg.debuginfo.is_some() {
2222-
early_error(error_format, "-g and -C debuginfo both provided");
2220+
let max_g = matches.opt_positions("g").into_iter().max();
2221+
let max_c = matches.opt_strs_pos("C").into_iter().flat_map(|(i, s)| {
2222+
if let Some("debuginfo") = s.splitn(2, '=').next() {
2223+
Some(i)
2224+
} else {
2225+
None
22232226
}
2227+
}).max();
2228+
let debuginfo = if max_g > max_c {
22242229
DebugInfo::Full
22252230
} else {
22262231
match cg.debuginfo {

0 commit comments

Comments
 (0)