diff options
| author | Matthias Krüger <matthias.krueger@famsik.de> | 2024-11-27 22:23:25 +0100 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2024-11-27 22:23:25 +0100 |
| commit | adf9b5fcd1de43eaf0a779e10612caee8b47bede (patch) | |
| tree | 289ba0f5d1eeb373af710778bf4b2eaf27b4e2b0 /compiler/rustc_middle | |
| parent | af1ca153d4aed5ffe22445273aa388a8d3f8f4ae (diff) | |
| parent | 2748009aade554a31dd4ea3312cf7a8314f6105d (diff) | |
Rollup merge of #133418 - Zalathar:spans, r=jieyouxu
coverage: Store coverage source regions as `Span` until codegen Historically, coverage spans were converted into line/column coordinates during the MIR instrumentation pass. This PR moves that conversion step into codegen, so that coverage spans spend most of their time stored as `Span` instead. In addition to being conceptually nicer, this also reduces the size of coverage mappings in MIR, because `Span` is smaller than 4x u32. --- There should be no changes to coverage output.
Diffstat (limited to 'compiler/rustc_middle')
| -rw-r--r-- | compiler/rustc_middle/src/mir/coverage.rs | 18 | ||||
| -rw-r--r-- | compiler/rustc_middle/src/mir/pretty.rs | 4 |
2 files changed, 3 insertions, 19 deletions
diff --git a/compiler/rustc_middle/src/mir/coverage.rs b/compiler/rustc_middle/src/mir/coverage.rs index 11a4e7f89a7..33f9a2bdca6 100644 --- a/compiler/rustc_middle/src/mir/coverage.rs +++ b/compiler/rustc_middle/src/mir/coverage.rs @@ -155,22 +155,6 @@ impl Debug for CoverageKind { } } -#[derive(Clone, TyEncodable, TyDecodable, Hash, HashStable, PartialEq, Eq, PartialOrd, Ord)] -#[derive(TypeFoldable, TypeVisitable)] -pub struct SourceRegion { - pub start_line: u32, - pub start_col: u32, - pub end_line: u32, - pub end_col: u32, -} - -impl Debug for SourceRegion { - fn fmt(&self, fmt: &mut Formatter<'_>) -> fmt::Result { - let &Self { start_line, start_col, end_line, end_col } = self; - write!(fmt, "{start_line}:{start_col} - {end_line}:{end_col}") - } -} - #[derive(Copy, Clone, Debug, PartialEq, Eq, Hash, HashStable)] #[derive(TyEncodable, TyDecodable, TypeFoldable, TypeVisitable)] pub enum Op { @@ -232,7 +216,7 @@ impl MappingKind { #[derive(TyEncodable, TyDecodable, Hash, HashStable, TypeFoldable, TypeVisitable)] pub struct Mapping { pub kind: MappingKind, - pub source_region: SourceRegion, + pub span: Span, } /// Stores per-function coverage information attached to a `mir::Body`, diff --git a/compiler/rustc_middle/src/mir/pretty.rs b/compiler/rustc_middle/src/mir/pretty.rs index 2bfcd0a6227..ece468947c2 100644 --- a/compiler/rustc_middle/src/mir/pretty.rs +++ b/compiler/rustc_middle/src/mir/pretty.rs @@ -603,8 +603,8 @@ fn write_function_coverage_info( for (id, expression) in expressions.iter_enumerated() { writeln!(w, "{INDENT}coverage {id:?} => {expression:?};")?; } - for coverage::Mapping { kind, source_region } in mappings { - writeln!(w, "{INDENT}coverage {kind:?} => {source_region:?};")?; + for coverage::Mapping { kind, span } in mappings { + writeln!(w, "{INDENT}coverage {kind:?} => {span:?};")?; } writeln!(w)?; |
