@@ -17,7 +17,9 @@ use rustc_middle::ty::{self, Ty, TyCtxt, Variance};
1717use rustc_span:: def_id:: { CrateNum , DefId , LOCAL_CRATE } ;
1818use rustc_target:: abi:: FieldIdx ;
1919use 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+ } ;
2123use stable_mir:: { self , opaque, Context , Filename } ;
2224use tracing:: debug;
2325
@@ -50,7 +52,7 @@ impl<'tcx> Context for Tables<'tcx> {
5052 self . tcx . def_path_str ( self [ def_id] )
5153 }
5254
53- fn print_span ( & self , span : stable_mir:: ty:: Span ) -> String {
55+ fn span_to_string ( & self , span : stable_mir:: ty:: Span ) -> String {
5456 self . tcx . sess . source_map ( ) . span_to_diagnostic_string ( self [ span] )
5557 }
5658
@@ -61,27 +63,14 @@ impl<'tcx> Context for Tables<'tcx> {
6163 . sess
6264 . source_map ( )
6365 . span_to_filename ( self [ * span] )
64- . display ( rustc_span:: FileNameDisplayPreference :: Short )
66+ . display ( rustc_span:: FileNameDisplayPreference :: Local )
6567 . to_string ( ) ,
6668 )
6769 }
6870
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 }
8574 }
8675
8776 fn def_kind ( & mut self , def_id : stable_mir:: DefId ) -> stable_mir:: DefKind {
0 commit comments