Skip to content
This repository was archived by the owner on May 28, 2025. It is now read-only.

Commit eddb717

Browse files
committedNov 28, 2024·
Auto merge of rust-lang#133551 - matthiaskrgr:rollup-m0rr5oz, r=matthiaskrgr
Rollup of 5 pull requests Successful merges: - rust-lang#132410 (Some more refactorings towards removing driver queries) - rust-lang#133418 (coverage: Store coverage source regions as `Span` until codegen) - rust-lang#133498 (Add missing code examples on `LocalKey`) - rust-lang#133518 (Structurally resolve before checking `!` in HIR typeck) - rust-lang#133521 (Structurally resolve before matching on type of projection) r? `@ghost` `@rustbot` modify labels: rollup
2 parents 66adeaf + 5fc4f85 commit eddb717

File tree

64 files changed

+658
-531
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

64 files changed

+658
-531
lines changed
 

‎compiler/rustc_codegen_llvm/src/coverageinfo/ffi.rs

Lines changed: 10 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,4 @@
1-
use rustc_middle::mir::coverage::{CounterId, CovTerm, ExpressionId, SourceRegion};
2-
3-
use crate::coverageinfo::mapgen::LocalFileId;
1+
use rustc_middle::mir::coverage::{CounterId, CovTerm, ExpressionId};
42

53
/// Must match the layout of `LLVMRustCounterKind`.
64
#[derive(Copy, Clone, Debug)]
@@ -126,45 +124,31 @@ pub(crate) struct CoverageSpan {
126124
/// Local index into the function's local-to-global file ID table.
127125
/// The value at that index is itself an index into the coverage filename
128126
/// table in the CGU's `__llvm_covmap` section.
129-
file_id: u32,
127+
pub(crate) file_id: u32,
130128

131129
/// 1-based starting line of the source code span.
132-
start_line: u32,
130+
pub(crate) start_line: u32,
133131
/// 1-based starting column of the source code span.
134-
start_col: u32,
132+
pub(crate) start_col: u32,
135133
/// 1-based ending line of the source code span.
136-
end_line: u32,
134+
pub(crate) end_line: u32,
137135
/// 1-based ending column of the source code span. High bit must be unset.
138-
end_col: u32,
139-
}
140-
141-
impl CoverageSpan {
142-
pub(crate) fn from_source_region(
143-
local_file_id: LocalFileId,
144-
code_region: &SourceRegion,
145-
) -> Self {
146-
let file_id = local_file_id.as_u32();
147-
let &SourceRegion { start_line, start_col, end_line, end_col } = code_region;
148-
// Internally, LLVM uses the high bit of `end_col` to distinguish between
149-
// code regions and gap regions, so it can't be used by the column number.
150-
assert!(end_col & (1u32 << 31) == 0, "high bit of `end_col` must be unset: {end_col:#X}");
151-
Self { file_id, start_line, start_col, end_line, end_col }
152-
}
136+
pub(crate) end_col: u32,
153137
}
154138

155139
/// Must match the layout of `LLVMRustCoverageCodeRegion`.
156140
#[derive(Clone, Debug)]
157141
#[repr(C)]
158142
pub(crate) struct CodeRegion {
159-
pub(crate) span: CoverageSpan,
143+
pub(crate) cov_span: CoverageSpan,
160144
pub(crate) counter: Counter,
161145
}
162146

163147
/// Must match the layout of `LLVMRustCoverageBranchRegion`.
164148
#[derive(Clone, Debug)]
165149
#[repr(C)]
166150
pub(crate) struct BranchRegion {
167-
pub(crate) span: CoverageSpan,
151+
pub(crate) cov_span: CoverageSpan,
168152
pub(crate) true_counter: Counter,
169153
pub(crate) false_counter: Counter,
170154
}
@@ -173,7 +157,7 @@ pub(crate) struct BranchRegion {
173157
#[derive(Clone, Debug)]
174158
#[repr(C)]
175159
pub(crate) struct MCDCBranchRegion {
176-
pub(crate) span: CoverageSpan,
160+
pub(crate) cov_span: CoverageSpan,
177161
pub(crate) true_counter: Counter,
178162
pub(crate) false_counter: Counter,
179163
pub(crate) mcdc_branch_params: mcdc::BranchParameters,
@@ -183,6 +167,6 @@ pub(crate) struct MCDCBranchRegion {
183167
#[derive(Clone, Debug)]
184168
#[repr(C)]
185169
pub(crate) struct MCDCDecisionRegion {
186-
pub(crate) span: CoverageSpan,
170+
pub(crate) cov_span: CoverageSpan,
187171
pub(crate) mcdc_decision_params: mcdc::DecisionParameters,
188172
}

‎compiler/rustc_codegen_llvm/src/coverageinfo/map_data.rs

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,9 @@ use rustc_data_structures::fx::FxIndexSet;
33
use rustc_index::bit_set::BitSet;
44
use rustc_middle::mir::coverage::{
55
CounterId, CovTerm, Expression, ExpressionId, FunctionCoverageInfo, Mapping, MappingKind, Op,
6-
SourceRegion,
76
};
87
use rustc_middle::ty::Instance;
8+
use rustc_span::Span;
99
use tracing::{debug, instrument};
1010

1111
use crate::coverageinfo::ffi::{Counter, CounterExpression, ExprKind};
@@ -220,16 +220,16 @@ impl<'tcx> FunctionCoverage<'tcx> {
220220
})
221221
}
222222

223-
/// Converts this function's coverage mappings into an intermediate form
224-
/// that will be used by `mapgen` when preparing for FFI.
225-
pub(crate) fn counter_regions(
223+
/// Yields all this function's coverage mappings, after simplifying away
224+
/// unused counters and counter expressions.
225+
pub(crate) fn mapping_spans(
226226
&self,
227-
) -> impl Iterator<Item = (MappingKind, &SourceRegion)> + ExactSizeIterator {
227+
) -> impl Iterator<Item = (MappingKind, Span)> + ExactSizeIterator + Captures<'_> {
228228
self.function_coverage_info.mappings.iter().map(move |mapping| {
229-
let Mapping { kind, source_region } = mapping;
229+
let &Mapping { ref kind, span } = mapping;
230230
let kind =
231231
kind.map_terms(|term| if self.is_zero_term(term) { CovTerm::Zero } else { term });
232-
(kind, source_region)
232+
(kind, span)
233233
})
234234
}
235235

0 commit comments

Comments
 (0)
This repository has been archived.