diff options
| author | Stuart Cook <Zalathar@users.noreply.github.com> | 2025-07-29 23:50:35 +1000 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2025-07-29 23:50:35 +1000 |
| commit | f8370285cf81e8af24c7f95b77cbb83c3d6db1cf (patch) | |
| tree | bbe35d24a1ca049bb13fb494e3004152d6545b1f /compiler/rustc_attr_data_structures/src | |
| parent | 7278554d82fa474a4e8b5c67afb009e11e41a841 (diff) | |
| parent | 682f744f89e1c014e91b2fd7058c75f2056ac870 (diff) | |
| download | rust-f8370285cf81e8af24c7f95b77cbb83c3d6db1cf.tar.gz rust-f8370285cf81e8af24c7f95b77cbb83c3d6db1cf.zip | |
Rollup merge of #144560 - Zalathar:auto-derived, r=compiler-errors
coverage: Treat `#[automatically_derived]` as `#[coverage(off)]` One of the contributing factors behind https://github.com/rust-lang/rust/issues/141577#issuecomment-3120667286 was the presence of derive-macro-generated code containing nested closures. Coverage instrumentation already has a heuristic for skipping code marked with `#[automatically_derived]` (rust-lang/rust#120185), because derived code is usually not worth instrumenting, and also has a tendency to trigger vexing edge-case bugs in coverage instrumentation or coverage codegen. However, the existing heuristic only applied to the associated items directly within an auto-derived impl block, and had no effect on closures or nested items within those associated items. This PR therefore extends the search for `#[coverage(..)]` attributes to also treat `#[automatically_derived]` as an implied `#[coverage(off)]` for the purposes of coverage instrumentation. --- This change doesn’t rule out an entire category of bugs, because it only affects code that actually uses the auto-derived attribute. But it should reduce the overall chance of edge-case macro span bugs being observed in the wild.
Diffstat (limited to 'compiler/rustc_attr_data_structures/src')
| -rw-r--r-- | compiler/rustc_attr_data_structures/src/attributes.rs | 20 |
1 files changed, 6 insertions, 14 deletions
diff --git a/compiler/rustc_attr_data_structures/src/attributes.rs b/compiler/rustc_attr_data_structures/src/attributes.rs index 610c93a253c..55019cd57a7 100644 --- a/compiler/rustc_attr_data_structures/src/attributes.rs +++ b/compiler/rustc_attr_data_structures/src/attributes.rs @@ -110,18 +110,10 @@ pub enum DeprecatedSince { Err, } -#[derive( - Copy, - Debug, - Eq, - PartialEq, - Encodable, - Decodable, - Clone, - HashStable_Generic, - PrintAttribute -)] -pub enum CoverageStatus { +/// Successfully-parsed value of a `#[coverage(..)]` attribute. +#[derive(Copy, Debug, Eq, PartialEq, Encodable, Decodable, Clone)] +#[derive(HashStable_Generic, PrintAttribute)] +pub enum CoverageAttrKind { On, Off, } @@ -304,8 +296,8 @@ pub enum AttributeKind { /// Represents `#[const_trait]`. ConstTrait(Span), - /// Represents `#[coverage]`. - Coverage(Span, CoverageStatus), + /// Represents `#[coverage(..)]`. + Coverage(Span, CoverageAttrKind), ///Represents `#[rustc_deny_explicit_impl]`. DenyExplicitImpl(Span), |
