From 6593fcd82498b749f5a1e187fe4b76026ab5ce8e Mon Sep 17 00:00:00 2001 From: Josh Triplett Date: Sat, 1 Jan 2022 16:15:36 -0800 Subject: [PATCH] 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. --- compiler/rustc_session/src/config.rs | 15 +++++++++++---- src/doc/rustc/src/instrument-coverage.md | 4 ++-- .../expected_show_coverage.uses_crate.txt | 2 +- .../run-make-fulldeps/coverage/lib/used_crate.rs | 2 +- 4 files changed, 15 insertions(+), 8 deletions(-) diff --git a/compiler/rustc_session/src/config.rs b/compiler/rustc_session/src/config.rs index fa14a95bb0c2a..7e8e4a75b37e6 100644 --- a/compiler/rustc_session/src/config.rs +++ b/compiler/rustc_session/src/config.rs @@ -135,8 +135,8 @@ pub enum MirSpanview { /// selected, code structure, and enabled attributes. If errors are encountered, /// either while compiling or when generating `llvm-cov show` reports, consider /// lowering the optimization level, including or excluding `-C link-dead-code`, -/// or using `-C instrument-coverage=except-unused-functions` or `-C -/// instrument-coverage=except-unused-generics`. +/// or using `-Zunstable-options -C instrument-coverage=except-unused-functions` +/// or `-Zunstable-options -C instrument-coverage=except-unused-generics`. /// /// Note that `ExceptUnusedFunctions` means: When `mapgen.rs` generates the /// coverage map, it will not attempt to generate synthetic functions for unused @@ -150,9 +150,9 @@ pub enum MirSpanview { pub enum InstrumentCoverage { /// Default `-C instrument-coverage` or `-C instrument-coverage=statement` All, - /// `-C instrument-coverage=except-unused-generics` + /// `-Zunstable-options -C instrument-coverage=except-unused-generics` ExceptUnusedGenerics, - /// `-C instrument-coverage=except-unused-functions` + /// `-Zunstable-options -C instrument-coverage=except-unused-functions` ExceptUnusedFunctions, /// `-C instrument-coverage=off` (or `no`, etc.) Off, @@ -2154,6 +2154,13 @@ pub fn build_session_options(matches: &getopts::Matches) -> Options { and `-Z instrument-coverage`", ); } + (Some(InstrumentCoverage::Off | InstrumentCoverage::All), _) => {} + (Some(_), _) if !debugging_opts.unstable_options => { + early_error( + error_format, + "`-C instrument-coverage=except-*` requires `-Z unstable-options`", + ); + } (None, None) => {} (None, ic) => { early_warn( diff --git a/src/doc/rustc/src/instrument-coverage.md b/src/doc/rustc/src/instrument-coverage.md index 49ef2309e73ca..b94989161ccfc 100644 --- a/src/doc/rustc/src/instrument-coverage.md +++ b/src/doc/rustc/src/instrument-coverage.md @@ -318,9 +318,9 @@ $ llvm-cov report \ ## `-C instrument-coverage=` - `-C instrument-coverage=all`: Instrument all functions, including unused functions and unused generics. (This is the same as `-C instrument-coverage`, with no value.) -- `-C instrument-coverage=except-unused-generics`: Instrument all functions except unused generics. -- `-C instrument-coverage=except-unused-functions`: Instrument only used (called) functions and instantiated generic functions. - `-C instrument-coverage=off`: Do not instrument any functions. (This is the same as simply not including the `-C instrument-coverage` option.) +- `-Zunstable-options -C instrument-coverage=except-unused-generics`: Instrument all functions except unused generics. +- `-Zunstable-options -C instrument-coverage=except-unused-functions`: Instrument only used (called) functions and instantiated generic functions. ## Other references diff --git a/src/test/run-make-fulldeps/coverage-reports/expected_show_coverage.uses_crate.txt b/src/test/run-make-fulldeps/coverage-reports/expected_show_coverage.uses_crate.txt index 8d6a9eb902c17..96c066e0623dd 100644 --- a/src/test/run-make-fulldeps/coverage-reports/expected_show_coverage.uses_crate.txt +++ b/src/test/run-make-fulldeps/coverage-reports/expected_show_coverage.uses_crate.txt @@ -125,7 +125,7 @@ 78| |// generic functions with: 79| |// 80| |// ```shell - 81| |// $ `rustc -C instrument-coverage=except-unused-generics ...` + 81| |// $ `rustc -Zunstable-options -C instrument-coverage=except-unused-generics ...` 82| |// ``` 83| |// 84| |// Even though this function is used by `uses_crate.rs` (and diff --git a/src/test/run-make-fulldeps/coverage/lib/used_crate.rs b/src/test/run-make-fulldeps/coverage/lib/used_crate.rs index 9c3b147ac59fe..8b8b1f7f351fd 100644 --- a/src/test/run-make-fulldeps/coverage/lib/used_crate.rs +++ b/src/test/run-make-fulldeps/coverage/lib/used_crate.rs @@ -78,7 +78,7 @@ fn use_this_lib_crate() { // generic functions with: // // ```shell -// $ `rustc -C instrument-coverage=except-unused-generics ...` +// $ `rustc -Zunstable-options -C instrument-coverage=except-unused-generics ...` // ``` // // Even though this function is used by `uses_crate.rs` (and