@@ -4,12 +4,13 @@ use rustc_middle::mir::{
4
4
self , AggregateKind , FakeReadCause , Rvalue , Statement , StatementKind , Terminator ,
5
5
TerminatorKind ,
6
6
} ;
7
- use rustc_span:: { ExpnKind , MacroKind , Span , Symbol } ;
7
+ use rustc_span:: { Span , Symbol } ;
8
8
9
9
use crate :: coverage:: graph:: {
10
10
BasicCoverageBlock , BasicCoverageBlockData , CoverageGraph , START_BCB ,
11
11
} ;
12
12
use crate :: coverage:: spans:: Covspan ;
13
+ use crate :: coverage:: unexpand:: unexpand_into_body_span_with_visible_macro;
13
14
use crate :: coverage:: ExtractedHirInfo ;
14
15
15
16
pub ( crate ) struct ExtractedCovspans {
@@ -215,59 +216,6 @@ fn filtered_terminator_span(terminator: &Terminator<'_>) -> Option<Span> {
215
216
}
216
217
}
217
218
218
- /// Returns an extrapolated span (pre-expansion[^1]) corresponding to a range
219
- /// within the function's body source. This span is guaranteed to be contained
220
- /// within, or equal to, the `body_span`. If the extrapolated span is not
221
- /// contained within the `body_span`, `None` is returned.
222
- ///
223
- /// [^1]Expansions result from Rust syntax including macros, syntactic sugar,
224
- /// etc.).
225
- pub ( crate ) fn unexpand_into_body_span_with_visible_macro (
226
- original_span : Span ,
227
- body_span : Span ,
228
- ) -> Option < ( Span , Option < Symbol > ) > {
229
- let ( span, prev) = unexpand_into_body_span_with_prev ( original_span, body_span) ?;
230
-
231
- let visible_macro = prev
232
- . map ( |prev| match prev. ctxt ( ) . outer_expn_data ( ) . kind {
233
- ExpnKind :: Macro ( MacroKind :: Bang , name) => Some ( name) ,
234
- _ => None ,
235
- } )
236
- . flatten ( ) ;
237
-
238
- Some ( ( span, visible_macro) )
239
- }
240
-
241
- /// Walks through the expansion ancestors of `original_span` to find a span that
242
- /// is contained in `body_span` and has the same [`SyntaxContext`] as `body_span`.
243
- /// The ancestor that was traversed just before the matching span (if any) is
244
- /// also returned.
245
- ///
246
- /// For example, a return value of `Some((ancestor, Some(prev))` means that:
247
- /// - `ancestor == original_span.find_ancestor_inside_same_ctxt(body_span)`
248
- /// - `ancestor == prev.parent_callsite()`
249
- ///
250
- /// [`SyntaxContext`]: rustc_span::SyntaxContext
251
- fn unexpand_into_body_span_with_prev (
252
- original_span : Span ,
253
- body_span : Span ,
254
- ) -> Option < ( Span , Option < Span > ) > {
255
- let mut prev = None ;
256
- let mut curr = original_span;
257
-
258
- while !body_span. contains ( curr) || !curr. eq_ctxt ( body_span) {
259
- prev = Some ( curr) ;
260
- curr = curr. parent_callsite ( ) ?;
261
- }
262
-
263
- debug_assert_eq ! ( Some ( curr) , original_span. find_ancestor_in_same_ctxt( body_span) ) ;
264
- if let Some ( prev) = prev {
265
- debug_assert_eq ! ( Some ( curr) , prev. parent_callsite( ) ) ;
266
- }
267
-
268
- Some ( ( curr, prev) )
269
- }
270
-
271
219
#[ derive( Debug ) ]
272
220
pub ( crate ) struct Hole {
273
221
pub ( crate ) span : Span ,
0 commit comments