File tree 3 files changed +21
-21
lines changed
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(
4385
4385
..
4386
4386
} ) = location. cloned ( )
4387
4387
{
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) {
4390
4389
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
+ ) ;
4394
4395
diag. add_slice ( slice) ;
4395
4396
}
4396
4397
}
@@ -4427,12 +4428,13 @@ fn variadic_fn_diagnostic(
4427
4428
..
4428
4429
} ) = location. cloned ( )
4429
4430
{
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) {
4432
4432
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
+ ) ;
4436
4438
diag. add_slice ( slice) ;
4437
4439
}
4438
4440
}
Original file line number Diff line number Diff line change @@ -110,7 +110,7 @@ impl<'a> Diagnostic<'a> {
110
110
slices. push ( ExtSlice {
111
111
source : source. as_ref ( ) ,
112
112
line_start : slice. line . unwrap_or_default ( ) ,
113
- origin : slice. filename . as_deref ( ) ,
113
+ origin : slice. origin . as_deref ( ) ,
114
114
annotations : vec ! [ ] ,
115
115
fold : false ,
116
116
} )
@@ -146,9 +146,9 @@ impl<'a> Diagnostic<'a> {
146
146
/// A slice of source code.
147
147
#[ derive( Default ) ]
148
148
pub ( crate ) struct Slice < ' a > {
149
- source : Option < Cow < ' a , str > > ,
150
- filename : Option < String > ,
151
149
line : Option < usize > ,
150
+ origin : Option < String > ,
151
+ source : Option < Cow < ' a , str > > ,
152
152
}
153
153
154
154
impl < ' a > Slice < ' a > {
@@ -162,15 +162,14 @@ impl<'a> Slice<'a> {
162
162
}
163
163
164
164
/// Set the file, line and column.
165
- pub ( crate ) fn with_location < P : AsRef < Path > > (
165
+ pub ( crate ) fn with_location (
166
166
& mut self ,
167
- path : P ,
167
+ file_name : & str ,
168
168
line : usize ,
169
- col : usize ,
169
+ column : usize ,
170
170
) -> & mut Self {
171
- self . filename =
172
- Some ( format ! ( "{}:{}:{}" , path. as_ref( ) . display( ) , line, col) ) ;
173
171
self . line = Some ( line) ;
172
+ self . origin = Some ( format ! ( "{file_name}:{line}:{column}" ) ) ;
174
173
self
175
174
}
176
175
}
Original file line number Diff line number Diff line change @@ -474,11 +474,10 @@ fn duplicated_macro_diagnostic(
474
474
file, line, column, ..
475
475
} = location
476
476
{
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) {
479
478
source = code. into ( ) ;
480
479
}
481
- slice. with_location ( file_path , line, column) ;
480
+ slice. with_location ( file . name ( ) , line, column) ;
482
481
}
483
482
484
483
slice. with_source ( source) ;
You can’t perform that action at this time.
0 commit comments