@@ -491,12 +491,6 @@ impl Span {
491491        Span ( bridge:: client:: Span :: mixed_site ( ) ) 
492492    } 
493493
494-     /// The original source file into which this span points. 
495- #[ unstable( feature = "proc_macro_span" ,  issue = "54725" ) ]  
496-     pub  fn  source_file ( & self )  -> SourceFile  { 
497-         SourceFile ( self . 0 . source_file ( ) ) 
498-     } 
499- 
500494    /// The `Span` for the tokens in the previous macro expansion from which 
501495/// `self` was generated from, if any. 
502496#[ unstable( feature = "proc_macro_span" ,  issue = "54725" ) ]  
@@ -546,6 +540,25 @@ impl Span {
546540        self . 0 . column ( ) 
547541    } 
548542
543+     /// The path to the source file in which this span occurs, for display purposes. 
544+ /// 
545+ /// This might not correspond to a valid file system path. 
546+ /// It might be remapped, or might be an artificial path such as `"<macro expansion>"`. 
547+ #[ unstable( feature = "proc_macro_span" ,  issue = "54725" ) ]  
548+     pub  fn  file ( & self )  -> String  { 
549+         self . 0 . file ( ) 
550+     } 
551+ 
552+     /// The path to the source file in which this span occurs on disk. 
553+ /// 
554+ /// This is the actual path on disk. It is unaffected by path remapping. 
555+ /// 
556+ /// This path should not be embedded in the output of the macro; prefer `file()` instead. 
557+ #[ unstable( feature = "proc_macro_span" ,  issue = "54725" ) ]  
558+     pub  fn  local_file ( & self )  -> Option < PathBuf >  { 
559+         self . 0 . local_file ( ) . map ( |s| PathBuf :: from ( s) ) 
560+     } 
561+ 
549562    /// Creates a new span encompassing `self` and `other`. 
550563/// 
551564/// Returns `None` if `self` and `other` are from different files. 
@@ -614,58 +627,6 @@ impl fmt::Debug for Span {
614627    } 
615628} 
616629
617- /// The source file of a given `Span`. 
618- #[ unstable( feature = "proc_macro_span" ,  issue = "54725" ) ]  
619- #[ derive( Clone ) ]  
620- pub  struct  SourceFile ( bridge:: client:: SourceFile ) ; 
621- 
622- impl  SourceFile  { 
623-     /// Gets the path to this source file. 
624- /// 
625- /// ### Note 
626- /// If the code span associated with this `SourceFile` was generated by an external macro, this 
627- /// macro, this might not be an actual path on the filesystem. Use [`is_real`] to check. 
628- /// 
629- /// Also note that even if `is_real` returns `true`, if `--remap-path-prefix` was passed on 
630- /// the command line, the path as given might not actually be valid. 
631- /// 
632- /// [`is_real`]: Self::is_real 
633- #[ unstable( feature = "proc_macro_span" ,  issue = "54725" ) ]  
634-     pub  fn  path ( & self )  -> PathBuf  { 
635-         PathBuf :: from ( self . 0 . path ( ) ) 
636-     } 
637- 
638-     /// Returns `true` if this source file is a real source file, and not generated by an external 
639- /// macro's expansion. 
640- #[ unstable( feature = "proc_macro_span" ,  issue = "54725" ) ]  
641-     pub  fn  is_real ( & self )  -> bool  { 
642-         // This is a hack until intercrate spans are implemented and we can have real source files 
643-         // for spans generated in external macros. 
644-         // https://github.com/rust-lang/rust/pull/43604#issuecomment-333334368 
645-         self . 0 . is_real ( ) 
646-     } 
647- } 
648- 
649- #[ unstable( feature = "proc_macro_span" ,  issue = "54725" ) ]  
650- impl  fmt:: Debug  for  SourceFile  { 
651-     fn  fmt ( & self ,  f :  & mut  fmt:: Formatter < ' _ > )  -> fmt:: Result  { 
652-         f. debug_struct ( "SourceFile" ) 
653-             . field ( "path" ,  & self . path ( ) ) 
654-             . field ( "is_real" ,  & self . is_real ( ) ) 
655-             . finish ( ) 
656-     } 
657- } 
658- 
659- #[ unstable( feature = "proc_macro_span" ,  issue = "54725" ) ]  
660- impl  PartialEq  for  SourceFile  { 
661-     fn  eq ( & self ,  other :  & Self )  -> bool  { 
662-         self . 0 . eq ( & other. 0 ) 
663-     } 
664- } 
665- 
666- #[ unstable( feature = "proc_macro_span" ,  issue = "54725" ) ]  
667- impl  Eq  for  SourceFile  { } 
668- 
669630/// A single token or a delimited sequence of token trees (e.g., `[1, (), ..]`). 
670631#[ stable( feature = "proc_macro_lib2" ,  since = "1.29.0" ) ]  
671632#[ derive( Clone ) ]  
0 commit comments