@@ -24,7 +24,7 @@ use rustc_middle::mir::{
24
24
use rustc_middle:: ty:: TyCtxt ;
25
25
use rustc_span:: def_id:: { DefId , LocalDefId } ;
26
26
use rustc_span:: source_map:: SourceMap ;
27
- use rustc_span:: { ExpnKind , SourceFile , Span , Symbol } ;
27
+ use rustc_span:: { ExpnKind , Span , Symbol } ;
28
28
29
29
/// Inserts `StatementKind::Coverage` statements that either instrument the binary with injected
30
30
/// counters, via intrinsic `llvm.instrprof.increment`, and/or inject metadata used during codegen
@@ -69,7 +69,6 @@ impl<'tcx> MirPass<'tcx> for InstrumentCoverage {
69
69
struct Instrumentor < ' a , ' tcx > {
70
70
tcx : TyCtxt < ' tcx > ,
71
71
mir_body : & ' a mut mir:: Body < ' tcx > ,
72
- source_file : Lrc < SourceFile > ,
73
72
fn_sig_span : Span ,
74
73
body_span : Span ,
75
74
function_source_hash : u64 ,
@@ -109,7 +108,6 @@ impl<'a, 'tcx> Instrumentor<'a, 'tcx> {
109
108
Self {
110
109
tcx,
111
110
mir_body,
112
- source_file,
113
111
fn_sig_span,
114
112
body_span,
115
113
function_source_hash,
@@ -160,9 +158,10 @@ impl<'a, 'tcx> Instrumentor<'a, 'tcx> {
160
158
let source_map = self . tcx . sess . source_map ( ) ;
161
159
let body_span = self . body_span ;
162
160
161
+ let source_file = source_map. lookup_source_file ( body_span. lo ( ) ) ;
163
162
use rustc_session:: RemapFileNameExt ;
164
163
let file_name =
165
- Symbol :: intern ( & self . source_file . name . for_codegen ( self . tcx . sess ) . to_string_lossy ( ) ) ;
164
+ Symbol :: intern ( & source_file. name . for_codegen ( self . tcx . sess ) . to_string_lossy ( ) ) ;
166
165
167
166
let mut mappings = Vec :: new ( ) ;
168
167
0 commit comments