@@ -13,7 +13,7 @@ use rustc_hir::intravisit::{walk_expr, Visitor};
1313use rustc_middle:: hir:: map:: Map ;
1414use rustc_middle:: hir:: nested_filter;
1515use rustc_middle:: mir:: coverage:: {
16- CodeRegion , CoverageKind , DecisionInfo , FunctionCoverageInfo , Mapping , MappingKind ,
16+ CoverageKind , DecisionInfo , FunctionCoverageInfo , Mapping , MappingKind , SourceRegion ,
1717} ;
1818use rustc_middle:: mir:: {
1919 self , BasicBlock , BasicBlockData , SourceInfo , Statement , StatementKind , Terminator ,
@@ -159,7 +159,7 @@ fn create_mappings<'tcx>(
159159 . expect ( "all BCBs with spans were given counters" )
160160 . as_term ( )
161161 } ;
162- let region_for_span = |span : Span | make_code_region ( source_map, file_name, span, body_span) ;
162+ let region_for_span = |span : Span | make_source_region ( source_map, file_name, span, body_span) ;
163163
164164 // Fully destructure the mappings struct to make sure we don't miss any kinds.
165165 let ExtractedMappings {
@@ -175,9 +175,9 @@ fn create_mappings<'tcx>(
175175 mappings. extend ( code_mappings. iter ( ) . filter_map (
176176 // Ordinary code mappings are the simplest kind.
177177 |& mappings:: CodeMapping { span, bcb } | {
178- let code_region = region_for_span ( span) ?;
178+ let source_region = region_for_span ( span) ?;
179179 let kind = MappingKind :: Code ( term_for_bcb ( bcb) ) ;
180- Some ( Mapping { kind, code_region } )
180+ Some ( Mapping { kind, source_region } )
181181 } ,
182182 ) ) ;
183183
@@ -186,29 +186,29 @@ fn create_mappings<'tcx>(
186186 let true_term = term_for_bcb ( true_bcb) ;
187187 let false_term = term_for_bcb ( false_bcb) ;
188188 let kind = MappingKind :: Branch { true_term, false_term } ;
189- let code_region = region_for_span ( span) ?;
190- Some ( Mapping { kind, code_region } )
189+ let source_region = region_for_span ( span) ?;
190+ Some ( Mapping { kind, source_region } )
191191 } ,
192192 ) ) ;
193193
194194 mappings. extend ( mcdc_branches. iter ( ) . filter_map (
195195 |& mappings:: MCDCBranch { span, true_bcb, false_bcb, condition_info, decision_depth : _ } | {
196- let code_region = region_for_span ( span) ?;
196+ let source_region = region_for_span ( span) ?;
197197 let true_term = term_for_bcb ( true_bcb) ;
198198 let false_term = term_for_bcb ( false_bcb) ;
199199 let kind = match condition_info {
200200 Some ( mcdc_params) => MappingKind :: MCDCBranch { true_term, false_term, mcdc_params } ,
201201 None => MappingKind :: Branch { true_term, false_term } ,
202202 } ;
203- Some ( Mapping { kind, code_region } )
203+ Some ( Mapping { kind, source_region } )
204204 } ,
205205 ) ) ;
206206
207207 mappings. extend ( mcdc_decisions. iter ( ) . filter_map (
208208 |& mappings:: MCDCDecision { span, bitmap_idx, num_conditions, .. } | {
209- let code_region = region_for_span ( span) ?;
209+ let source_region = region_for_span ( span) ?;
210210 let kind = MappingKind :: MCDCDecision ( DecisionInfo { bitmap_idx, num_conditions } ) ;
211- Some ( Mapping { kind, code_region } )
211+ Some ( Mapping { kind, source_region } )
212212 } ,
213213 ) ) ;
214214
@@ -363,12 +363,12 @@ fn inject_statement(mir_body: &mut mir::Body<'_>, counter_kind: CoverageKind, bb
363363/// or other expansions), and if it does happen then skipping a span or function is
364364/// better than an ICE or `llvm-cov` failure that the user might have no way to avoid.
365365#[ instrument( level = "debug" , skip( source_map) ) ]
366- fn make_code_region (
366+ fn make_source_region (
367367 source_map : & SourceMap ,
368368 file_name : Symbol ,
369369 span : Span ,
370370 body_span : Span ,
371- ) -> Option < CodeRegion > {
371+ ) -> Option < SourceRegion > {
372372 let lo = span. lo ( ) ;
373373 let hi = span. hi ( ) ;
374374
@@ -418,7 +418,7 @@ fn make_code_region(
418418 start_line = source_map. doctest_offset_line ( & file. name , start_line) ;
419419 end_line = source_map. doctest_offset_line ( & file. name , end_line) ;
420420
421- check_code_region ( CodeRegion {
421+ check_source_region ( SourceRegion {
422422 file_name,
423423 start_line : start_line as u32 ,
424424 start_col : start_col as u32 ,
@@ -427,12 +427,12 @@ fn make_code_region(
427427 } )
428428}
429429
430- /// If `llvm-cov` sees a code region that is improperly ordered (end < start),
430+ /// If `llvm-cov` sees a source region that is improperly ordered (end < start),
431431/// it will immediately exit with a fatal error. To prevent that from happening,
432432/// discard regions that are improperly ordered, or might be interpreted in a
433433/// way that makes them improperly ordered.
434- fn check_code_region ( code_region : CodeRegion ) -> Option < CodeRegion > {
435- let CodeRegion { file_name : _, start_line, start_col, end_line, end_col } = code_region ;
434+ fn check_source_region ( source_region : SourceRegion ) -> Option < SourceRegion > {
435+ let SourceRegion { file_name : _, start_line, start_col, end_line, end_col } = source_region ;
436436
437437 // Line/column coordinates are supposed to be 1-based. If we ever emit
438438 // coordinates of 0, `llvm-cov` might misinterpret them.
@@ -445,17 +445,17 @@ fn check_code_region(code_region: CodeRegion) -> Option<CodeRegion> {
445445 let is_ordered = ( start_line, start_col) <= ( end_line, end_col) ;
446446
447447 if all_nonzero && end_col_has_high_bit_unset && is_ordered {
448- Some ( code_region )
448+ Some ( source_region )
449449 } else {
450450 debug ! (
451- ?code_region ,
451+ ?source_region ,
452452 ?all_nonzero,
453453 ?end_col_has_high_bit_unset,
454454 ?is_ordered,
455- "Skipping code region that would be misinterpreted or rejected by LLVM"
455+ "Skipping source region that would be misinterpreted or rejected by LLVM"
456456 ) ;
457457 // If this happens in a debug build, ICE to make it easier to notice.
458- debug_assert ! ( false , "Improper code region: {code_region :?}" ) ;
458+ debug_assert ! ( false , "Improper source region: {source_region :?}" ) ;
459459 None
460460 }
461461}
0 commit comments