diff options
| author | bors <bors@rust-lang.org> | 2023-10-21 09:09:05 +0000 |
|---|---|---|
| committer | bors <bors@rust-lang.org> | 2023-10-21 09:09:05 +0000 |
| commit | 6f97d838c644174b38413d920ed8d43b70cdc7db (patch) | |
| tree | 443e691d3ebb017ad2c75a8b38ccea91d0c98152 /compiler/rustc_mir_transform/src/coverage/spans.rs | |
| parent | 45a45c6e60835e15c92374be1f832bc756fc8b1a (diff) | |
| parent | e9d18f5f78dba3fbaf5763000715533994627eb1 (diff) | |
| download | rust-6f97d838c644174b38413d920ed8d43b70cdc7db.tar.gz rust-6f97d838c644174b38413d920ed8d43b70cdc7db.zip | |
Auto merge of #117013 - matthiaskrgr:rollup-mvgp54x, r=matthiaskrgr
Rollup of 8 pull requests Successful merges: - #114521 (std: freebsd build update.) - #116911 (Suggest relaxing implicit `type Assoc: Sized;` bound) - #116917 (coverage: Simplify the injection of coverage statements) - #116961 (Typo suggestion to change bindings with leading underscore) - #116964 (Add stable Instance::body() and RustcInternal trait) - #116974 (coverage: Fix inconsistent handling of function signature spans) - #116990 (Mention `into_iter` on borrow errors suggestions when appropriate) - #116995 (Point at assoc fn definition on type param divergence) r? `@ghost` `@rustbot` modify labels: rollup
Diffstat (limited to 'compiler/rustc_mir_transform/src/coverage/spans.rs')
| -rw-r--r-- | compiler/rustc_mir_transform/src/coverage/spans.rs | 42 |
1 files changed, 6 insertions, 36 deletions
diff --git a/compiler/rustc_mir_transform/src/coverage/spans.rs b/compiler/rustc_mir_transform/src/coverage/spans.rs index 3f7ba572510..704eea413e1 100644 --- a/compiler/rustc_mir_transform/src/coverage/spans.rs +++ b/compiler/rustc_mir_transform/src/coverage/spans.rs @@ -2,7 +2,7 @@ use std::cell::OnceCell; use rustc_data_structures::graph::WithNumNodes; use rustc_index::IndexVec; -use rustc_middle::mir::{self, AggregateKind, Rvalue, Statement, StatementKind}; +use rustc_middle::mir; use rustc_span::{BytePos, ExpnKind, MacroKind, Span, Symbol, DUMMY_SP}; use super::graph::{BasicCoverageBlock, CoverageGraph, START_BCB}; @@ -41,13 +41,8 @@ impl CoverageSpans { !self.bcb_to_spans[bcb].is_empty() } - pub(super) fn bcbs_with_coverage_spans( - &self, - ) -> impl Iterator<Item = (BasicCoverageBlock, &[Span])> { - self.bcb_to_spans.iter_enumerated().filter_map(|(bcb, spans)| { - // Only yield BCBs that have at least one coverage span. - (!spans.is_empty()).then_some((bcb, spans.as_slice())) - }) + pub(super) fn spans_for_bcb(&self, bcb: BasicCoverageBlock) -> &[Span] { + &self.bcb_to_spans[bcb] } } @@ -75,29 +70,15 @@ struct CoverageSpan { impl CoverageSpan { pub fn for_fn_sig(fn_sig_span: Span) -> Self { - Self { - span: fn_sig_span, - expn_span: fn_sig_span, - current_macro_or_none: Default::default(), - bcb: START_BCB, - merged_spans: vec![], - is_closure: false, - } + Self::new(fn_sig_span, fn_sig_span, START_BCB, false) } - pub fn for_statement( - statement: &Statement<'_>, + pub(super) fn new( span: Span, expn_span: Span, bcb: BasicCoverageBlock, + is_closure: bool, ) -> Self { - let is_closure = match statement.kind { - StatementKind::Assign(box (_, Rvalue::Aggregate(box ref kind, _))) => { - matches!(kind, AggregateKind::Closure(_, _) | AggregateKind::Coroutine(_, _, _)) - } - _ => false, - }; - Self { span, expn_span, @@ -108,17 +89,6 @@ impl CoverageSpan { } } - pub fn for_terminator(span: Span, expn_span: Span, bcb: BasicCoverageBlock) -> Self { - Self { - span, - expn_span, - current_macro_or_none: Default::default(), - bcb, - merged_spans: vec![span], - is_closure: false, - } - } - pub fn merge_from(&mut self, mut other: CoverageSpan) { debug_assert!(self.is_mergeable(&other)); self.span = self.span.to(other.span); |
