Skip to content

Commit efb6ff4

Browse files
committed
Fix argument alias handling for -g and -C debuginfo
1 parent 688fdab commit efb6ff4

File tree

1 file changed

+8
-3
lines changed

1 file changed

+8
-3
lines changed

src/librustc/session/config.rs

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2214,10 +2214,15 @@ pub fn build_session_options_and_crate_config(
22142214
}
22152215
};
22162216
let debug_assertions = cg.debug_assertions.unwrap_or(opt_level == OptLevel::No);
2217-
let debuginfo = if matches.opt_present("g") {
2218-
if cg.debuginfo.is_some() {
2219-
early_error(error_format, "-g and -C debuginfo both provided");
2217+
let max_g = matches.opt_positions("g").into_iter().max();
2218+
let max_c = matches.opt_strs_pos("C").into_iter().flat_map(|(i, s)| {
2219+
if let Some("debuginfo") = s.splitn(2, '=').next() {
2220+
Some(i)
2221+
} else {
2222+
None
22202223
}
2224+
}).max();
2225+
let debuginfo = if max_g > max_c {
22212226
DebugInfo::Full
22222227
} else {
22232228
match cg.debuginfo {

0 commit comments

Comments
 (0)