11use std:: ops:: { Bound , Range } ;
2- use std:: sync:: Arc ;
32
43use ast:: token:: IdentIsRaw ;
54use pm:: bridge:: {
@@ -18,7 +17,7 @@ use rustc_parse::parser::Parser;
1817use rustc_parse:: { exp, new_parser_from_source_str, source_str_to_stream, unwrap_or_emit_fatal} ;
1918use rustc_session:: parse:: ParseSess ;
2019use 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} ;
2221use smallvec:: { SmallVec , smallvec} ;
2322
2423use crate :: base:: ExtCtxt ;
@@ -458,7 +457,6 @@ impl<'a, 'b> Rustc<'a, 'b> {
458457impl server:: Types for Rustc < ' _ , ' _ > {
459458 type FreeFunctions = FreeFunctions ;
460459 type TokenStream = TokenStream ;
461- type SourceFile = Arc < SourceFile > ;
462460 type Span = Span ;
463461 type Symbol = Symbol ;
464462}
@@ -664,28 +662,6 @@ impl server::TokenStream for Rustc<'_, '_> {
664662 }
665663}
666664
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-
689665impl server:: Span for Rustc < ' _ , ' _ > {
690666 fn debug ( & mut self , span : Self :: Span ) -> String {
691667 if self . ecx . ecfg . span_debug {
@@ -695,8 +671,29 @@ impl server::Span for Rustc<'_, '_> {
695671 }
696672 }
697673
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+ } )
700697 }
701698
702699 fn parent ( & mut self , span : Self :: Span ) -> Option < Self :: Span > {
0 commit comments