Skip to content

Commit 9f287dd

Browse files
committed
Change the documented implicit value of -C instrument-coverage to =yes
1 parent b77e018 commit 9f287dd

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
@@ -590,7 +590,7 @@ fn test_codegen_options_tracking_hash() {
590590
tracked!(force_frame_pointers, Some(false));
591591
tracked!(force_unwind_tables, Some(true));
592592
tracked!(inline_threshold, Some(0xf007ba11));
593-
tracked!(instrument_coverage, InstrumentCoverage::All);
593+
tracked!(instrument_coverage, InstrumentCoverage::Yes);
594594
tracked!(link_dead_code, Some(true));
595595
tracked!(linker_plugin_lto, LinkerPluginLto::LinkerPluginAuto);
596596
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
@@ -146,17 +146,17 @@ pub enum LtoCli {
146146
/// unless the function has type parameters.
147147
#[derive(Clone, Copy, PartialEq, Hash, Debug)]
148148
pub enum InstrumentCoverage {
149-
/// Default `-C instrument-coverage` or `-C instrument-coverage=statement`
150-
All,
149+
/// `-C instrument-coverage=no` (or `off`, `false` etc.)
150+
No,
151+
/// `-C instrument-coverage` or `-C instrument-coverage=yes`
152+
Yes,
151153
/// Additionally, instrument branches and output branch coverage.
152154
/// `-Zunstable-options -C instrument-coverage=branch`
153155
Branch,
154156
/// `-Zunstable-options -C instrument-coverage=except-unused-generics`
155157
ExceptUnusedGenerics,
156158
/// `-Zunstable-options -C instrument-coverage=except-unused-functions`
157159
ExceptUnusedFunctions,
158-
/// `-C instrument-coverage=off` (or `no`, etc.)
159-
Off,
160160
}
161161

162162
/// Settings for `-Z instrument-xray` flag.
@@ -2722,7 +2722,7 @@ pub fn build_session_options(early_dcx: &mut EarlyDiagCtxt, matches: &getopts::M
27222722
// This is what prevents them from being used on stable compilers.
27232723
match cg.instrument_coverage {
27242724
// Stable values:
2725-
InstrumentCoverage::All | InstrumentCoverage::Off => {}
2725+
InstrumentCoverage::Yes | InstrumentCoverage::No => {}
27262726
// Unstable values:
27272727
InstrumentCoverage::Branch
27282728
| InstrumentCoverage::ExceptUnusedFunctions
@@ -2736,7 +2736,7 @@ pub fn build_session_options(early_dcx: &mut EarlyDiagCtxt, matches: &getopts::M
27362736
}
27372737
}
27382738

2739-
if cg.instrument_coverage != InstrumentCoverage::Off {
2739+
if cg.instrument_coverage != InstrumentCoverage::No {
27402740
if cg.profile_generate.enabled() || cg.profile_use.is_some() {
27412741
early_dcx.early_fatal(
27422742
"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
@@ -394,8 +394,7 @@ mod desc {
394394
pub const parse_linker_flavor: &str = ::rustc_target::spec::LinkerFlavorCli::one_of();
395395
pub const parse_optimization_fuel: &str = "crate=integer";
396396
pub const parse_dump_mono_stats: &str = "`markdown` (default) or `json`";
397-
pub const parse_instrument_coverage: &str =
398-
"`all` (default), `branch`, `except-unused-generics`, `except-unused-functions`, or `off`";
397+
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`";
399398
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`";
400399
pub const parse_unpretty: &str = "`string` or `string=string`";
401400
pub const parse_treat_err_as_bug: &str = "either no value or a non-negative number";
@@ -918,26 +917,26 @@ mod parse {
918917
if v.is_some() {
919918
let mut bool_arg = false;
920919
if parse_bool(&mut bool_arg, v) {
921-
*slot = if bool_arg { InstrumentCoverage::All } else { InstrumentCoverage::Off };
920+
*slot = if bool_arg { InstrumentCoverage::Yes } else { InstrumentCoverage::No };
922921
return true;
923922
}
924923
}
925924

926925
let Some(v) = v else {
927-
*slot = InstrumentCoverage::All;
926+
*slot = InstrumentCoverage::Yes;
928927
return true;
929928
};
930929

931930
*slot = match v {
932-
"all" => InstrumentCoverage::All,
931+
"all" => InstrumentCoverage::Yes,
933932
"branch" => InstrumentCoverage::Branch,
934933
"except-unused-generics" | "except_unused_generics" => {
935934
InstrumentCoverage::ExceptUnusedGenerics
936935
}
937936
"except-unused-functions" | "except_unused_functions" => {
938937
InstrumentCoverage::ExceptUnusedFunctions
939938
}
940-
"off" | "no" | "n" | "false" | "0" => InstrumentCoverage::Off,
939+
"0" => InstrumentCoverage::No,
941940
_ => return false,
942941
};
943942
true
@@ -1444,15 +1443,15 @@ options! {
14441443
inline_threshold: Option<u32> = (None, parse_opt_number, [TRACKED],
14451444
"set the threshold for inlining a function"),
14461445
#[rustc_lint_opt_deny_field_access("use `Session::instrument_coverage` instead of this field")]
1447-
instrument_coverage: InstrumentCoverage = (InstrumentCoverage::Off, parse_instrument_coverage, [TRACKED],
1446+
instrument_coverage: InstrumentCoverage = (InstrumentCoverage::No, parse_instrument_coverage, [TRACKED],
14481447
"instrument the generated code to support LLVM source-based code coverage \
14491448
reports (note, the compiler build config must include `profiler = true`); \
14501449
implies `-C symbol-mangling-version=v0`. Optional values are:
1451-
`=all` (implicit value)
1452-
`=branch`
1453-
`=except-unused-generics`
1454-
`=except-unused-functions`
1455-
`=off` (default)"),
1450+
`=no` `=n` `=off` `=false` (default)
1451+
`=yes` `=y` `=on` `=true` (implicit value)
1452+
`=branch` (unstable)
1453+
`=except-unused-generics` (unstable)
1454+
`=except-unused-functions` (unstable)"),
14561455
link_arg: (/* redirected to link_args */) = ((), parse_string_push, [UNTRACKED],
14571456
"a single extra argument to append to the linker invocation (can be used several times)"),
14581457
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
@@ -352,7 +352,7 @@ impl Session {
352352
}
353353

354354
pub fn instrument_coverage(&self) -> bool {
355-
self.opts.cg.instrument_coverage() != InstrumentCoverage::Off
355+
self.opts.cg.instrument_coverage() != InstrumentCoverage::No
356356
}
357357

358358
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)