@@ -24,7 +24,7 @@ use rustc_middle::mir::{
2424use rustc_middle:: ty:: TyCtxt ;
2525use rustc_span:: def_id:: { DefId , LocalDefId } ;
2626use rustc_span:: source_map:: SourceMap ;
27- use rustc_span:: { ExpnKind , SourceFile , Span , Symbol } ;
27+ use rustc_span:: { ExpnKind , Span , Symbol } ;
2828
2929/// Inserts `StatementKind::Coverage` statements that either instrument the binary with injected
3030/// counters, via intrinsic `llvm.instrprof.increment`, and/or inject metadata used during codegen
@@ -69,7 +69,6 @@ impl<'tcx> MirPass<'tcx> for InstrumentCoverage {
6969struct Instrumentor < ' a , ' tcx > {
7070 tcx : TyCtxt < ' tcx > ,
7171 mir_body : & ' a mut mir:: Body < ' tcx > ,
72- source_file : Lrc < SourceFile > ,
7372 fn_sig_span : Span ,
7473 body_span : Span ,
7574 function_source_hash : u64 ,
@@ -109,7 +108,6 @@ impl<'a, 'tcx> Instrumentor<'a, 'tcx> {
109108 Self {
110109 tcx,
111110 mir_body,
112- source_file,
113111 fn_sig_span,
114112 body_span,
115113 function_source_hash,
@@ -160,9 +158,10 @@ impl<'a, 'tcx> Instrumentor<'a, 'tcx> {
160158 let source_map = self . tcx . sess . source_map ( ) ;
161159 let body_span = self . body_span ;
162160
161+ let source_file = source_map. lookup_source_file ( body_span. lo ( ) ) ;
163162 use rustc_session:: RemapFileNameExt ;
164163 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 ( ) ) ;
166165
167166 let mut mappings = Vec :: new ( ) ;
168167
0 commit comments