@@ -3,7 +3,7 @@ use std::path::{Component, Path};
3
3
4
4
use crate :: prelude:: * ;
5
5
6
- use rustc_span:: { CachingSourceMapView , FileName } ;
6
+ use rustc_span:: FileName ;
7
7
8
8
use cranelift_codegen:: binemit:: CodeOffset ;
9
9
@@ -74,12 +74,12 @@ fn line_program_add_file(
74
74
75
75
impl < ' tcx > DebugContext < ' tcx > {
76
76
pub ( super ) fn emit_location ( & mut self , entry_id : UnitEntryId , span : Span ) {
77
- let ( file , line , col ) = self . source_map . byte_pos_to_line_and_col ( span. lo ( ) ) . unwrap ( ) ;
77
+ let loc = self . tcx . sess . source_map ( ) . lookup_char_pos ( span. lo ( ) ) ;
78
78
79
79
let file_id = line_program_add_file (
80
80
& mut self . dwarf . unit . line_program ,
81
81
& mut self . dwarf . line_strings ,
82
- & file. name ,
82
+ & loc . file . name ,
83
83
) ;
84
84
85
85
let entry = self . dwarf . unit . get_mut ( entry_id) ;
@@ -90,12 +90,12 @@ impl<'tcx> DebugContext<'tcx> {
90
90
) ;
91
91
entry. set (
92
92
gimli:: DW_AT_decl_line ,
93
- AttributeValue :: Udata ( line as u64 ) ,
93
+ AttributeValue :: Udata ( loc . line as u64 ) ,
94
94
) ;
95
95
// FIXME: probably omit this
96
96
entry. set (
97
97
gimli:: DW_AT_decl_column ,
98
- AttributeValue :: Udata ( col. to_usize ( ) as u64 ) ,
98
+ AttributeValue :: Udata ( loc . col . to_usize ( ) as u64 ) ,
99
99
) ;
100
100
}
101
101
}
@@ -108,7 +108,6 @@ impl<'a, 'tcx> FunctionDebugContext<'a, 'tcx> {
108
108
source_info_set : & indexmap:: IndexSet < SourceInfo > ,
109
109
) -> CodeOffset {
110
110
let tcx = self . debug_context . tcx ;
111
- let mut source_map = CachingSourceMapView :: new ( tcx. sess . source_map ( ) ) ;
112
111
113
112
let line_program = & mut self . debug_context . dwarf . unit . line_program ;
114
113
@@ -125,25 +124,25 @@ impl<'a, 'tcx> FunctionDebugContext<'a, 'tcx> {
125
124
let line_strings = & mut self . debug_context . dwarf . line_strings ;
126
125
let mut last_file = None ;
127
126
let mut create_row_for_span = |line_program : & mut LineProgram , span : Span | {
128
- let ( file , line , col ) = source_map. byte_pos_to_line_and_col ( span. lo ( ) ) . unwrap ( ) ;
127
+ let loc = tcx . sess . source_map ( ) . lookup_char_pos ( span. lo ( ) ) ;
129
128
130
129
// line_program_add_file is very slow.
131
130
// Optimize for the common case of the current file not being changed.
132
131
let current_file_changed = if let Some ( last_file) = & mut last_file {
133
132
// If the allocations are not equal, then the files may still be equal, but that
134
133
// is not a problem, as this is just an optimization.
135
- !Lrc :: ptr_eq ( last_file, & file)
134
+ !Lrc :: ptr_eq ( last_file, & loc . file )
136
135
} else {
137
136
true
138
137
} ;
139
138
if current_file_changed {
140
- let file_id = line_program_add_file ( line_program, line_strings, & file. name ) ;
139
+ let file_id = line_program_add_file ( line_program, line_strings, & loc . file . name ) ;
141
140
line_program. row ( ) . file = file_id;
142
- last_file = Some ( file. clone ( ) ) ;
141
+ last_file = Some ( loc . file . clone ( ) ) ;
143
142
}
144
143
145
- line_program. row ( ) . line = line as u64 ;
146
- line_program. row ( ) . column = col. to_u32 ( ) as u64 + 1 ;
144
+ line_program. row ( ) . line = loc . line as u64 ;
145
+ line_program. row ( ) . column = loc . col . to_u32 ( ) as u64 + 1 ;
147
146
line_program. generate_row ( ) ;
148
147
} ;
149
148
0 commit comments