File tree Expand file tree Collapse file tree 1 file changed +11
-2
lines changed Expand file tree Collapse file tree 1 file changed +11
-2
lines changed Original file line number Diff line number Diff line change @@ -362,7 +362,7 @@ impl FileInfo {
362362 span. lo >= self . span . lo && span. hi <= self . span . hi
363363 }
364364
365- fn source_text ( & self , span : Span ) -> String {
365+ fn source_text ( & mut self , span : Span ) -> String {
366366 let lo = ( span. lo - self . span . lo ) as usize ;
367367 let trunc_lo = match self . source_text . char_indices ( ) . nth ( lo) {
368368 Some ( ( offset, _ch) ) => & self . source_text [ offset..] ,
@@ -448,6 +448,15 @@ impl SourceMap {
448448 }
449449 unreachable ! ( "Invalid span with no related FileInfo!" ) ;
450450 }
451+
452+ fn fileinfo_mut ( & mut self , span : Span ) -> & mut FileInfo {
453+ for file in & mut self . files {
454+ if file. span_within ( span) {
455+ return file;
456+ }
457+ }
458+ unreachable ! ( "Invalid span with no related FileInfo!" ) ;
459+ }
451460}
452461
453462#[ derive( Clone , Copy , PartialEq , Eq ) ]
@@ -572,7 +581,7 @@ impl Span {
572581 if self . is_call_site ( ) {
573582 None
574583 } else {
575- Some ( SOURCE_MAP . with ( |cm| cm. borrow ( ) . fileinfo ( * self ) . source_text ( * self ) ) )
584+ Some ( SOURCE_MAP . with ( |cm| cm. borrow_mut ( ) . fileinfo_mut ( * self ) . source_text ( * self ) ) )
576585 }
577586 }
578587 }
You can’t perform that action at this time.
0 commit comments