Skip to content

Commit 6593fcd

Browse files
committed
Require -Zunstable-options for -C instrument-coverage=except-* options
These options primarily exist to work around bugs, and those bugs have largely been fixed. Avoid stabilizing them, so that we don't have to support them indefinitely.
1 parent e14bd48 commit 6593fcd

File tree

4 files changed

+15
-8
lines changed

4 files changed

+15
-8
lines changed

compiler/rustc_session/src/config.rs

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -135,8 +135,8 @@ pub enum MirSpanview {
135135
/// selected, code structure, and enabled attributes. If errors are encountered,
136136
/// either while compiling or when generating `llvm-cov show` reports, consider
137137
/// lowering the optimization level, including or excluding `-C link-dead-code`,
138-
/// or using `-C instrument-coverage=except-unused-functions` or `-C
139-
/// instrument-coverage=except-unused-generics`.
138+
/// or using `-Zunstable-options -C instrument-coverage=except-unused-functions`
139+
/// or `-Zunstable-options -C instrument-coverage=except-unused-generics`.
140140
///
141141
/// Note that `ExceptUnusedFunctions` means: When `mapgen.rs` generates the
142142
/// coverage map, it will not attempt to generate synthetic functions for unused
@@ -150,9 +150,9 @@ pub enum MirSpanview {
150150
pub enum InstrumentCoverage {
151151
/// Default `-C instrument-coverage` or `-C instrument-coverage=statement`
152152
All,
153-
/// `-C instrument-coverage=except-unused-generics`
153+
/// `-Zunstable-options -C instrument-coverage=except-unused-generics`
154154
ExceptUnusedGenerics,
155-
/// `-C instrument-coverage=except-unused-functions`
155+
/// `-Zunstable-options -C instrument-coverage=except-unused-functions`
156156
ExceptUnusedFunctions,
157157
/// `-C instrument-coverage=off` (or `no`, etc.)
158158
Off,
@@ -2154,6 +2154,13 @@ pub fn build_session_options(matches: &getopts::Matches) -> Options {
21542154
and `-Z instrument-coverage`",
21552155
);
21562156
}
2157+
(Some(InstrumentCoverage::Off | InstrumentCoverage::All), _) => {}
2158+
(Some(_), _) if !debugging_opts.unstable_options => {
2159+
early_error(
2160+
error_format,
2161+
"`-C instrument-coverage=except-*` requires `-Z unstable-options`",
2162+
);
2163+
}
21572164
(None, None) => {}
21582165
(None, ic) => {
21592166
early_warn(

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -318,9 +318,9 @@ $ llvm-cov report \
318318
## `-C instrument-coverage=<options>`
319319

320320
- `-C instrument-coverage=all`: Instrument all functions, including unused functions and unused generics. (This is the same as `-C instrument-coverage`, with no value.)
321-
- `-C instrument-coverage=except-unused-generics`: Instrument all functions except unused generics.
322-
- `-C instrument-coverage=except-unused-functions`: Instrument only used (called) functions and instantiated generic functions.
323321
- `-C instrument-coverage=off`: Do not instrument any functions. (This is the same as simply not including the `-C instrument-coverage` option.)
322+
- `-Zunstable-options -C instrument-coverage=except-unused-generics`: Instrument all functions except unused generics.
323+
- `-Zunstable-options -C instrument-coverage=except-unused-functions`: Instrument only used (called) functions and instantiated generic functions.
324324

325325
## Other references
326326

src/test/run-make-fulldeps/coverage-reports/expected_show_coverage.uses_crate.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -125,7 +125,7 @@
125125
78| |// generic functions with:
126126
79| |//
127127
80| |// ```shell
128-
81| |// $ `rustc -C instrument-coverage=except-unused-generics ...`
128+
81| |// $ `rustc -Zunstable-options -C instrument-coverage=except-unused-generics ...`
129129
82| |// ```
130130
83| |//
131131
84| |// Even though this function is used by `uses_crate.rs` (and

src/test/run-make-fulldeps/coverage/lib/used_crate.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@ fn use_this_lib_crate() {
7878
// generic functions with:
7979
//
8080
// ```shell
81-
// $ `rustc -C instrument-coverage=except-unused-generics ...`
81+
// $ `rustc -Zunstable-options -C instrument-coverage=except-unused-generics ...`
8282
// ```
8383
//
8484
// Even though this function is used by `uses_crate.rs` (and

0 commit comments

Comments
 (0)