File tree Expand file tree Collapse file tree 3 files changed +21
-21
lines changed Expand file tree Collapse file tree 3 files changed +21
-21
lines changed Original file line number Diff line number Diff line change @@ -4385,12 +4385,13 @@ fn unsupported_abi_diagnostic(
43854385 ..
43864386 } ) = location. cloned ( )
43874387 {
4388- let file_path = file. path ( ) ;
4389- if let Ok ( Some ( source) ) = get_line ( & file_path, line) {
4388+ if let Ok ( Some ( source) ) = get_line ( file. path ( ) , line) {
43904389 let mut slice = Slice :: default ( ) ;
4391- slice
4392- . with_source ( source)
4393- . with_location ( file_path, line, column) ;
4390+ slice. with_source ( source) . with_location (
4391+ file. name ( ) ,
4392+ line,
4393+ column,
4394+ ) ;
43944395 diag. add_slice ( slice) ;
43954396 }
43964397 }
@@ -4427,12 +4428,13 @@ fn variadic_fn_diagnostic(
44274428 ..
44284429 } ) = location. cloned ( )
44294430 {
4430- let file_path = file. path ( ) ;
4431- if let Ok ( Some ( source) ) = get_line ( & file_path, line) {
4431+ if let Ok ( Some ( source) ) = get_line ( file. path ( ) , line) {
44324432 let mut slice = Slice :: default ( ) ;
4433- slice
4434- . with_source ( source)
4435- . with_location ( file_path, line, column) ;
4433+ slice. with_source ( source) . with_location (
4434+ file. name ( ) ,
4435+ line,
4436+ column,
4437+ ) ;
44364438 diag. add_slice ( slice) ;
44374439 }
44384440 }
Original file line number Diff line number Diff line change @@ -110,7 +110,7 @@ impl<'a> Diagnostic<'a> {
110110 slices. push ( ExtSlice {
111111 source : source. as_ref ( ) ,
112112 line_start : slice. line . unwrap_or_default ( ) ,
113- origin : slice. filename . as_deref ( ) ,
113+ origin : slice. origin . as_deref ( ) ,
114114 annotations : vec ! [ ] ,
115115 fold : false ,
116116 } )
@@ -146,9 +146,9 @@ impl<'a> Diagnostic<'a> {
146146/// A slice of source code.
147147#[ derive( Default ) ]
148148pub ( crate ) struct Slice < ' a > {
149- source : Option < Cow < ' a , str > > ,
150- filename : Option < String > ,
151149 line : Option < usize > ,
150+ origin : Option < String > ,
151+ source : Option < Cow < ' a , str > > ,
152152}
153153
154154impl < ' a > Slice < ' a > {
@@ -162,15 +162,14 @@ impl<'a> Slice<'a> {
162162 }
163163
164164 /// Set the file, line and column.
165- pub ( crate ) fn with_location < P : AsRef < Path > > (
165+ pub ( crate ) fn with_location (
166166 & mut self ,
167- path : P ,
167+ file_name : & str ,
168168 line : usize ,
169- col : usize ,
169+ column : usize ,
170170 ) -> & mut Self {
171- self . filename =
172- Some ( format ! ( "{}:{}:{}" , path. as_ref( ) . display( ) , line, col) ) ;
173171 self . line = Some ( line) ;
172+ self . origin = Some ( format ! ( "{file_name}:{line}:{column}" ) ) ;
174173 self
175174 }
176175}
Original file line number Diff line number Diff line change @@ -474,11 +474,10 @@ fn duplicated_macro_diagnostic(
474474 file, line, column, ..
475475 } = location
476476 {
477- let file_path = file. path ( ) ;
478- if let Ok ( Some ( code) ) = get_line ( & file_path, line) {
477+ if let Ok ( Some ( code) ) = get_line ( file. path ( ) , line) {
479478 source = code. into ( ) ;
480479 }
481- slice. with_location ( file_path , line, column) ;
480+ slice. with_location ( file . name ( ) , line, column) ;
482481 }
483482
484483 slice. with_source ( source) ;
You can’t perform that action at this time.
0 commit comments