1
1
use std:: ops:: { Bound , Range } ;
2
- use std:: sync:: Arc ;
3
2
4
3
use ast:: token:: IdentIsRaw ;
5
4
use pm:: bridge:: {
@@ -18,7 +17,7 @@ use rustc_parse::parser::Parser;
18
17
use rustc_parse:: { exp, new_parser_from_source_str, source_str_to_stream, unwrap_or_emit_fatal} ;
19
18
use rustc_session:: parse:: ParseSess ;
20
19
use rustc_span:: def_id:: CrateNum ;
21
- use rustc_span:: { BytePos , FileName , Pos , SourceFile , Span , Symbol , sym} ;
20
+ use rustc_span:: { BytePos , FileName , Pos , Span , Symbol , sym} ;
22
21
use smallvec:: { SmallVec , smallvec} ;
23
22
24
23
use crate :: base:: ExtCtxt ;
@@ -458,7 +457,6 @@ impl<'a, 'b> Rustc<'a, 'b> {
458
457
impl server:: Types for Rustc < ' _ , ' _ > {
459
458
type FreeFunctions = FreeFunctions ;
460
459
type TokenStream = TokenStream ;
461
- type SourceFile = Arc < SourceFile > ;
462
460
type Span = Span ;
463
461
type Symbol = Symbol ;
464
462
}
@@ -664,28 +662,6 @@ impl server::TokenStream for Rustc<'_, '_> {
664
662
}
665
663
}
666
664
667
- impl server:: SourceFile for Rustc < ' _ , ' _ > {
668
- fn eq ( & mut self , file1 : & Self :: SourceFile , file2 : & Self :: SourceFile ) -> bool {
669
- Arc :: ptr_eq ( file1, file2)
670
- }
671
-
672
- fn path ( & mut self , file : & Self :: SourceFile ) -> String {
673
- match & file. name {
674
- FileName :: Real ( name) => name
675
- . local_path ( )
676
- . expect ( "attempting to get a file path in an imported file in `proc_macro::SourceFile::path`" )
677
- . to_str ( )
678
- . expect ( "non-UTF8 file path in `proc_macro::SourceFile::path`" )
679
- . to_string ( ) ,
680
- _ => file. name . prefer_local ( ) . to_string ( ) ,
681
- }
682
- }
683
-
684
- fn is_real ( & mut self , file : & Self :: SourceFile ) -> bool {
685
- file. is_real_file ( )
686
- }
687
- }
688
-
689
665
impl server:: Span for Rustc < ' _ , ' _ > {
690
666
fn debug ( & mut self , span : Self :: Span ) -> String {
691
667
if self . ecx . ecfg . span_debug {
@@ -695,8 +671,29 @@ impl server::Span for Rustc<'_, '_> {
695
671
}
696
672
}
697
673
698
- fn source_file ( & mut self , span : Self :: Span ) -> Self :: SourceFile {
699
- self . psess ( ) . source_map ( ) . lookup_char_pos ( span. lo ( ) ) . file
674
+ fn file ( & mut self , span : Self :: Span ) -> String {
675
+ self . psess ( )
676
+ . source_map ( )
677
+ . lookup_char_pos ( span. lo ( ) )
678
+ . file
679
+ . name
680
+ . prefer_remapped_unconditionaly ( )
681
+ . to_string ( )
682
+ }
683
+
684
+ fn local_file ( & mut self , span : Self :: Span ) -> Option < String > {
685
+ self . psess ( )
686
+ . source_map ( )
687
+ . lookup_char_pos ( span. lo ( ) )
688
+ . file
689
+ . name
690
+ . clone ( )
691
+ . into_local_path ( )
692
+ . map ( |p| {
693
+ p. to_str ( )
694
+ . expect ( "non-UTF8 file path in `proc_macro::SourceFile::path`" )
695
+ . to_string ( )
696
+ } )
700
697
}
701
698
702
699
fn parent ( & mut self , span : Self :: Span ) -> Option < Self :: Span > {
0 commit comments