Skip to content

Commit 4d93125

Browse files
authored
Unrolled build for rust-lang#117207
Rollup merge of rust-lang#117207 - Zalathar:no-option, r=compiler-errors The value of `-Cinstrument-coverage=` doesn't need to be `Option` (Extracted from rust-lang#117199, since this is a purely internal cleanup that can land independently.) Not using this flag is identical to passing `-Cinstrument-coverage=off`, so there's no need to distinguish between `None` and `Some(Off)`.
2 parents 698db85 + 9f5fc02 commit 4d93125

File tree

3 files changed

+15
-17
lines changed

3 files changed

+15
-17
lines changed

compiler/rustc_interface/src/tests.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -614,7 +614,7 @@ fn test_codegen_options_tracking_hash() {
614614
tracked!(force_frame_pointers, Some(false));
615615
tracked!(force_unwind_tables, Some(true));
616616
tracked!(inline_threshold, Some(0xf007ba11));
617-
tracked!(instrument_coverage, Some(InstrumentCoverage::All));
617+
tracked!(instrument_coverage, InstrumentCoverage::All);
618618
tracked!(link_dead_code, Some(true));
619619
tracked!(linker_plugin_lto, LinkerPluginLto::LinkerPluginAuto);
620620
tracked!(llvm_args, vec![String::from("1"), String::from("2")]);

compiler/rustc_session/src/config.rs

+5-7
Original file line numberDiff line numberDiff line change
@@ -2743,13 +2743,11 @@ pub fn build_session_options(
27432743
// This is what prevents them from being used on stable compilers.
27442744
match cg.instrument_coverage {
27452745
// Stable values:
2746-
Some(InstrumentCoverage::All | InstrumentCoverage::Off) | None => {}
2746+
InstrumentCoverage::All | InstrumentCoverage::Off => {}
27472747
// Unstable values:
2748-
Some(
2749-
InstrumentCoverage::Branch
2750-
| InstrumentCoverage::ExceptUnusedFunctions
2751-
| InstrumentCoverage::ExceptUnusedGenerics,
2752-
) => {
2748+
InstrumentCoverage::Branch
2749+
| InstrumentCoverage::ExceptUnusedFunctions
2750+
| InstrumentCoverage::ExceptUnusedGenerics => {
27532751
if !unstable_opts.unstable_options {
27542752
handler.early_error(
27552753
"`-C instrument-coverage=branch` and `-C instrument-coverage=except-*` \
@@ -2759,7 +2757,7 @@ pub fn build_session_options(
27592757
}
27602758
}
27612759

2762-
if cg.instrument_coverage.is_some() && cg.instrument_coverage != Some(InstrumentCoverage::Off) {
2760+
if cg.instrument_coverage != InstrumentCoverage::Off {
27632761
if cg.profile_generate.enabled() || cg.profile_use.is_some() {
27642762
handler.early_error(
27652763
"option `-C instrument-coverage` is not compatible with either `-C profile-use` \

compiler/rustc_session/src/options.rs

+9-9
Original file line numberDiff line numberDiff line change
@@ -294,7 +294,7 @@ impl CodegenOptions {
294294
// JUSTIFICATION: defn of the suggested wrapper fn
295295
#[allow(rustc::bad_opt_access)]
296296
pub fn instrument_coverage(&self) -> InstrumentCoverage {
297-
self.instrument_coverage.unwrap_or(InstrumentCoverage::Off)
297+
self.instrument_coverage
298298
}
299299
}
300300

@@ -913,23 +913,23 @@ mod parse {
913913
}
914914

915915
pub(crate) fn parse_instrument_coverage(
916-
slot: &mut Option<InstrumentCoverage>,
916+
slot: &mut InstrumentCoverage,
917917
v: Option<&str>,
918918
) -> bool {
919919
if v.is_some() {
920-
let mut bool_arg = None;
921-
if parse_opt_bool(&mut bool_arg, v) {
922-
*slot = bool_arg.unwrap().then_some(InstrumentCoverage::All);
920+
let mut bool_arg = false;
921+
if parse_bool(&mut bool_arg, v) {
922+
*slot = if bool_arg { InstrumentCoverage::All } else { InstrumentCoverage::Off };
923923
return true;
924924
}
925925
}
926926

927927
let Some(v) = v else {
928-
*slot = Some(InstrumentCoverage::All);
928+
*slot = InstrumentCoverage::All;
929929
return true;
930930
};
931931

932-
*slot = Some(match v {
932+
*slot = match v {
933933
"all" => InstrumentCoverage::All,
934934
"branch" => InstrumentCoverage::Branch,
935935
"except-unused-generics" | "except_unused_generics" => {
@@ -940,7 +940,7 @@ mod parse {
940940
}
941941
"off" | "no" | "n" | "false" | "0" => InstrumentCoverage::Off,
942942
_ => return false,
943-
});
943+
};
944944
true
945945
}
946946

@@ -1352,7 +1352,7 @@ options! {
13521352
inline_threshold: Option<u32> = (None, parse_opt_number, [TRACKED],
13531353
"set the threshold for inlining a function"),
13541354
#[rustc_lint_opt_deny_field_access("use `Session::instrument_coverage` instead of this field")]
1355-
instrument_coverage: Option<InstrumentCoverage> = (None, parse_instrument_coverage, [TRACKED],
1355+
instrument_coverage: InstrumentCoverage = (InstrumentCoverage::Off, parse_instrument_coverage, [TRACKED],
13561356
"instrument the generated code to support LLVM source-based code coverage \
13571357
reports (note, the compiler build config must include `profiler = true`); \
13581358
implies `-C symbol-mangling-version=v0`. Optional values are:

0 commit comments

Comments
 (0)