Skip to content

Commit 7de0e6a

Browse files
committed
Change the documented implicit value of -C instrument-coverage to =on
1 parent 9f5fc02 commit 7de0e6a

File tree

7 files changed

+44
-26
lines changed

7 files changed

+44
-26
lines changed

compiler/rustc_interface/src/tests.rs

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

compiler/rustc_session/src/config.rs

+6-6
Original file line numberDiff line numberDiff line change
@@ -167,17 +167,17 @@ pub enum MirSpanview {
167167
/// unless the function has type parameters.
168168
#[derive(Clone, Copy, PartialEq, Hash, Debug)]
169169
pub enum InstrumentCoverage {
170-
/// Default `-C instrument-coverage` or `-C instrument-coverage=statement`
171-
All,
170+
/// `-C instrument-coverage=no` (or `off`, `false` etc.)
171+
No,
172+
/// `-C instrument-coverage` or `-C instrument-coverage=yes`
173+
Yes,
172174
/// Additionally, instrument branches and output branch coverage.
173175
/// `-Zunstable-options -C instrument-coverage=branch`
174176
Branch,
175177
/// `-Zunstable-options -C instrument-coverage=except-unused-generics`
176178
ExceptUnusedGenerics,
177179
/// `-Zunstable-options -C instrument-coverage=except-unused-functions`
178180
ExceptUnusedFunctions,
179-
/// `-C instrument-coverage=off` (or `no`, etc.)
180-
Off,
181181
}
182182

183183
/// Settings for `-Z instrument-xray` flag.
@@ -2743,7 +2743,7 @@ 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-
InstrumentCoverage::All | InstrumentCoverage::Off => {}
2746+
InstrumentCoverage::Yes | InstrumentCoverage::No => {}
27472747
// Unstable values:
27482748
InstrumentCoverage::Branch
27492749
| InstrumentCoverage::ExceptUnusedFunctions
@@ -2757,7 +2757,7 @@ pub fn build_session_options(
27572757
}
27582758
}
27592759

2760-
if cg.instrument_coverage != InstrumentCoverage::Off {
2760+
if cg.instrument_coverage != InstrumentCoverage::No {
27612761
if cg.profile_generate.enabled() || cg.profile_use.is_some() {
27622762
handler.early_error(
27632763
"option `-C instrument-coverage` is not compatible with either `-C profile-use` \

compiler/rustc_session/src/options.rs

+11-12
Original file line numberDiff line numberDiff line change
@@ -388,8 +388,7 @@ mod desc {
388388
pub const parse_optimization_fuel: &str = "crate=integer";
389389
pub const parse_mir_spanview: &str = "`statement` (default), `terminator`, or `block`";
390390
pub const parse_dump_mono_stats: &str = "`markdown` (default) or `json`";
391-
pub const parse_instrument_coverage: &str =
392-
"`all` (default), `branch`, `except-unused-generics`, `except-unused-functions`, or `off`";
391+
pub const parse_instrument_coverage: &str = "either a boolean (`yes`, `no`, `on`, `off`, etc) or (unstable) one of `branch`, `except-unused-generics`, `except-unused-functions`";
393392
pub const parse_instrument_xray: &str = "either a boolean (`yes`, `no`, `on`, `off`, etc), or a comma separated list of settings: `always` or `never` (mutually exclusive), `ignore-loops`, `instruction-threshold=N`, `skip-entry`, `skip-exit`";
394393
pub const parse_unpretty: &str = "`string` or `string=string`";
395394
pub const parse_treat_err_as_bug: &str = "either no value or a non-negative number";
@@ -919,26 +918,26 @@ mod parse {
919918
if v.is_some() {
920919
let mut bool_arg = false;
921920
if parse_bool(&mut bool_arg, v) {
922-
*slot = if bool_arg { InstrumentCoverage::All } else { InstrumentCoverage::Off };
921+
*slot = if bool_arg { InstrumentCoverage::Yes } else { InstrumentCoverage::No };
923922
return true;
924923
}
925924
}
926925

927926
let Some(v) = v else {
928-
*slot = InstrumentCoverage::All;
927+
*slot = InstrumentCoverage::Yes;
929928
return true;
930929
};
931930

932931
*slot = match v {
933-
"all" => InstrumentCoverage::All,
932+
"all" => InstrumentCoverage::Yes,
934933
"branch" => InstrumentCoverage::Branch,
935934
"except-unused-generics" | "except_unused_generics" => {
936935
InstrumentCoverage::ExceptUnusedGenerics
937936
}
938937
"except-unused-functions" | "except_unused_functions" => {
939938
InstrumentCoverage::ExceptUnusedFunctions
940939
}
941-
"off" | "no" | "n" | "false" | "0" => InstrumentCoverage::Off,
940+
"0" => InstrumentCoverage::No,
942941
_ => return false,
943942
};
944943
true
@@ -1352,15 +1351,15 @@ options! {
13521351
inline_threshold: Option<u32> = (None, parse_opt_number, [TRACKED],
13531352
"set the threshold for inlining a function"),
13541353
#[rustc_lint_opt_deny_field_access("use `Session::instrument_coverage` instead of this field")]
1355-
instrument_coverage: InstrumentCoverage = (InstrumentCoverage::Off, parse_instrument_coverage, [TRACKED],
1354+
instrument_coverage: InstrumentCoverage = (InstrumentCoverage::No, parse_instrument_coverage, [TRACKED],
13561355
"instrument the generated code to support LLVM source-based code coverage \
13571356
reports (note, the compiler build config must include `profiler = true`); \
13581357
implies `-C symbol-mangling-version=v0`. Optional values are:
1359-
`=all` (implicit value)
1360-
`=branch`
1361-
`=except-unused-generics`
1362-
`=except-unused-functions`
1363-
`=off` (default)"),
1358+
`=no` `=n` `=off` `=false` (default)
1359+
`=yes` `=y` `=on` `=true` (implicit value)
1360+
`=branch` (unstable)
1361+
`=except-unused-generics` (unstable)
1362+
`=except-unused-functions` (unstable)"),
13641363
link_arg: (/* redirected to link_args */) = ((), parse_string_push, [UNTRACKED],
13651364
"a single extra argument to append to the linker invocation (can be used several times)"),
13661365
link_args: Vec<String> = (Vec::new(), parse_list, [UNTRACKED],

compiler/rustc_session/src/session.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -699,7 +699,7 @@ impl Session {
699699
}
700700

701701
pub fn instrument_coverage(&self) -> bool {
702-
self.opts.cg.instrument_coverage() != InstrumentCoverage::Off
702+
self.opts.cg.instrument_coverage() != InstrumentCoverage::No
703703
}
704704

705705
pub fn instrument_coverage_branch(&self) -> bool {

src/doc/rustc/src/instrument-coverage.md

+23-4
Original file line numberDiff line numberDiff line change
@@ -331,10 +331,29 @@ $ llvm-cov report \
331331

332332
## `-C instrument-coverage=<options>`
333333

334-
- `-C instrument-coverage=all`: Instrument all functions, including unused functions and unused generics. (This is the same as `-C instrument-coverage`, with no value.)
335-
- `-C instrument-coverage=off`: Do not instrument any functions. (This is the same as simply not including the `-C instrument-coverage` option.)
336-
- `-Zunstable-options -C instrument-coverage=except-unused-generics`: Instrument all functions except unused generics.
337-
- `-Zunstable-options -C instrument-coverage=except-unused-functions`: Instrument only used (called) functions and instantiated generic functions.
334+
- `-C instrument-coverage=no` (or `n`/`off`/`false`):
335+
Don't enable coverage instrumentation. No functions will be instrumented for coverage.
336+
- This is the same as not using the `-C instrument-coverage` flag at all.
337+
- `-C instrument-coverage=yes` (or `y`/`on`/`true`):
338+
Enable coverage instrumentation with the default behaviour.
339+
Currently this instruments all functions, including unused functions and unused generics.
340+
- This is the same as `-C instrument-coverage` with no value.
341+
342+
### Other values
343+
344+
- `-C instrument-coverage=all`:
345+
Currently an alias for `yes`, but may behave differently in the future if
346+
more fine-grained coverage options are added.
347+
Using this value is currently not recommended.
348+
349+
### Unstable values
350+
351+
- `-Z unstable-options -C instrument-coverage=branch`:
352+
Placeholder for potential branch coverage support in the future.
353+
- `-Z unstable-options -C instrument-coverage=except-unused-generics`:
354+
Instrument all functions except unused generics.
355+
- `-Z unstable-options -C instrument-coverage=except-unused-functions`:
356+
Instrument only used (called) functions and instantiated generic functions.
338357

339358
## Other references
340359

Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
1-
error: incorrect value `bad-value` for codegen option `instrument-coverage` - `all` (default), `branch`, `except-unused-generics`, `except-unused-functions`, or `off` was expected
1+
error: incorrect value `bad-value` for codegen option `instrument-coverage` - either a boolean (`yes`, `no`, `on`, `off`, etc) or (unstable) one of `branch`, `except-unused-generics`, `except-unused-functions` was expected
22

Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
1-
error: incorrect value `` for codegen option `instrument-coverage` - `all` (default), `branch`, `except-unused-generics`, `except-unused-functions`, or `off` was expected
1+
error: incorrect value `` for codegen option `instrument-coverage` - either a boolean (`yes`, `no`, `on`, `off`, etc) or (unstable) one of `branch`, `except-unused-generics`, `except-unused-functions` was expected
22

0 commit comments

Comments
 (0)