@@ -17,7 +17,9 @@ use rustc_middle::ty::{self, Ty, TyCtxt, Variance};
17
17
use rustc_span:: def_id:: { CrateNum , DefId , LOCAL_CRATE } ;
18
18
use rustc_target:: abi:: FieldIdx ;
19
19
use stable_mir:: mir:: { CopyNonOverlapping , Statement , UserTypeProjection , VariantIdx } ;
20
- use stable_mir:: ty:: { FloatTy , GenericParamDef , IntTy , Movability , RigidTy , Span , TyKind , UintTy } ;
20
+ use stable_mir:: ty:: {
21
+ FloatTy , GenericParamDef , IntTy , LineInfo , Movability , RigidTy , Span , TyKind , UintTy ,
22
+ } ;
21
23
use stable_mir:: { self , opaque, Context , Filename } ;
22
24
use tracing:: debug;
23
25
@@ -50,7 +52,7 @@ impl<'tcx> Context for Tables<'tcx> {
50
52
self . tcx . def_path_str ( self [ def_id] )
51
53
}
52
54
53
- fn print_span ( & self , span : stable_mir:: ty:: Span ) -> String {
55
+ fn span_to_string ( & self , span : stable_mir:: ty:: Span ) -> String {
54
56
self . tcx . sess . source_map ( ) . span_to_diagnostic_string ( self [ span] )
55
57
}
56
58
@@ -61,27 +63,14 @@ impl<'tcx> Context for Tables<'tcx> {
61
63
. sess
62
64
. source_map ( )
63
65
. span_to_filename ( self [ * span] )
64
- . display ( rustc_span:: FileNameDisplayPreference :: Short )
66
+ . display ( rustc_span:: FileNameDisplayPreference :: Local )
65
67
. to_string ( ) ,
66
68
)
67
69
}
68
70
69
- fn get_lines ( & self , span : & Span ) -> Vec < stable_mir:: ty:: LineInfo > {
70
- let lines = & self
71
- . tcx
72
- . sess
73
- . source_map ( )
74
- . span_to_lines ( self [ * span] )
75
- . unwrap ( )
76
- . lines
77
- . iter ( )
78
- . map ( |line| stable_mir:: ty:: LineInfo {
79
- line_index : line. line_index + 1 ,
80
- start_col : line. start_col . 0 + 1 ,
81
- end_col : line. end_col . 0 + 1 ,
82
- } )
83
- . collect :: < Vec < stable_mir:: ty:: LineInfo > > ( ) ;
84
- lines. to_vec ( )
71
+ fn get_lines ( & self , span : & Span ) -> LineInfo {
72
+ let lines = & self . tcx . sess . source_map ( ) . span_to_location_info ( self [ * span] ) ;
73
+ LineInfo { start_line : lines. 1 , start_col : lines. 2 , end_line : lines. 3 , end_col : lines. 4 }
85
74
}
86
75
87
76
fn def_kind ( & mut self , def_id : stable_mir:: DefId ) -> stable_mir:: DefKind {
0 commit comments