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 @@ -4638,12 +4638,13 @@ fn unsupported_abi_diagnostic(
4638
4638
..
4639
4639
} ) = location. cloned ( )
4640
4640
{
4641
- let file_path = file. path ( ) ;
4642
- if let Ok ( Some ( source) ) = get_line ( & file_path, line) {
4641
+ if let Ok ( Some ( source) ) = get_line ( file. path ( ) , line) {
4643
4642
let mut slice = Slice :: default ( ) ;
4644
- slice
4645
- . with_source ( source)
4646
- . with_location ( file_path, line, column) ;
4643
+ slice. with_source ( source) . with_location (
4644
+ file. name ( ) ,
4645
+ line,
4646
+ column,
4647
+ ) ;
4647
4648
diag. add_slice ( slice) ;
4648
4649
}
4649
4650
}
@@ -4680,12 +4681,13 @@ fn variadic_fn_diagnostic(
4680
4681
..
4681
4682
} ) = location. cloned ( )
4682
4683
{
4683
- let file_path = file. path ( ) ;
4684
- if let Ok ( Some ( source) ) = get_line ( & file_path, line) {
4684
+ if let Ok ( Some ( source) ) = get_line ( file. path ( ) , line) {
4685
4685
let mut slice = Slice :: default ( ) ;
4686
- slice
4687
- . with_source ( source)
4688
- . with_location ( file_path, line, column) ;
4686
+ slice. with_source ( source) . with_location (
4687
+ file. name ( ) ,
4688
+ line,
4689
+ column,
4690
+ ) ;
4689
4691
diag. add_slice ( slice) ;
4690
4692
}
4691
4693
}
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 @@ -512,11 +512,10 @@ fn duplicated_macro_diagnostic(
512
512
file, line, column, ..
513
513
} = location
514
514
{
515
- let file_path = file. path ( ) ;
516
- if let Ok ( Some ( code) ) = get_line ( & file_path, line) {
515
+ if let Ok ( Some ( code) ) = get_line ( file. path ( ) , line) {
517
516
source = code. into ( ) ;
518
517
}
519
- slice. with_location ( file_path , line, column) ;
518
+ slice. with_location ( file . name ( ) , line, column) ;
520
519
}
521
520
522
521
slice. with_source ( source) ;
You can’t perform that action at this time.
0 commit comments