From 5fabdb8f7fd0c2c48d47ce08126d27ade5beefd9 Mon Sep 17 00:00:00 2001 From: ltdk Date: Sat, 28 May 2022 17:20:43 -0400 Subject: Add E0788 for improper #[no_coverage] usage --- compiler/rustc_error_codes/src/error_codes.rs | 1 + compiler/rustc_error_codes/src/error_codes/E0788.md | 21 +++++++++++++++++++++ 2 files changed, 22 insertions(+) create mode 100644 compiler/rustc_error_codes/src/error_codes/E0788.md (limited to 'compiler/rustc_error_codes/src') diff --git a/compiler/rustc_error_codes/src/error_codes.rs b/compiler/rustc_error_codes/src/error_codes.rs index 61a177f291b..0114461e388 100644 --- a/compiler/rustc_error_codes/src/error_codes.rs +++ b/compiler/rustc_error_codes/src/error_codes.rs @@ -491,6 +491,7 @@ E0784: include_str!("./error_codes/E0784.md"), E0785: include_str!("./error_codes/E0785.md"), E0786: include_str!("./error_codes/E0786.md"), E0787: include_str!("./error_codes/E0787.md"), +E0788: include_str!("./error_codes/E0788.md"), ; // E0006, // merged with E0005 // E0008, // cannot bind by-move into a pattern guard diff --git a/compiler/rustc_error_codes/src/error_codes/E0788.md b/compiler/rustc_error_codes/src/error_codes/E0788.md new file mode 100644 index 00000000000..68bd53cea6f --- /dev/null +++ b/compiler/rustc_error_codes/src/error_codes/E0788.md @@ -0,0 +1,21 @@ +A `#[no_coverage]` attribute was incorrectly placed on something that couldn't +be covered. + +Example of erroneous code: + +```compile_fail,E0788 +#[no_coverage] +struct Foo; + +#[no_coverage] +const FOO: Foo = Foo; +``` + +`#[no_coverage]` tells the compiler to not generate coverage instrumentation for +a piece of code when the `-C instrument-coverage` flag is passed. Things like +structs and consts are not coverable code, and thus cannot do anything with this +attribute. + +If you wish to apply this attribute to all methods in an impl or module, +manually annotate each method; it is not possible to annotate the entire impl +with a `#[no_coverage]` attribute. -- cgit 1.4.1-3-g733a5