@@ -338,57 +338,6 @@ impl Display for LexError {
338
338
339
339
impl Error for LexError { }
340
340
341
- /// The source file of a given `Span`.
342
- ///
343
- /// This type is semver exempt and not exposed by default.
344
- #[ cfg( all( procmacro2_semver_exempt, any( not( wrap_proc_macro) , super_unstable) ) ) ]
345
- #[ cfg_attr( docsrs, doc( cfg( procmacro2_semver_exempt) ) ) ]
346
- #[ derive( Clone , PartialEq , Eq ) ]
347
- pub struct SourceFile {
348
- inner : imp:: SourceFile ,
349
- _marker : ProcMacroAutoTraits ,
350
- }
351
-
352
- #[ cfg( all( procmacro2_semver_exempt, any( not( wrap_proc_macro) , super_unstable) ) ) ]
353
- impl SourceFile {
354
- fn _new ( inner : imp:: SourceFile ) -> Self {
355
- SourceFile {
356
- inner,
357
- _marker : MARKER ,
358
- }
359
- }
360
-
361
- /// Get the path to this source file.
362
- ///
363
- /// ### Note
364
- ///
365
- /// If the code span associated with this `SourceFile` was generated by an
366
- /// external macro, this may not be an actual path on the filesystem. Use
367
- /// [`is_real`] to check.
368
- ///
369
- /// Also note that even if `is_real` returns `true`, if
370
- /// `--remap-path-prefix` was passed on the command line, the path as given
371
- /// may not actually be valid.
372
- ///
373
- /// [`is_real`]: #method.is_real
374
- pub fn path ( & self ) -> PathBuf {
375
- self . inner . path ( )
376
- }
377
-
378
- /// Returns `true` if this source file is a real source file, and not
379
- /// generated by an external macro's expansion.
380
- pub fn is_real ( & self ) -> bool {
381
- self . inner . is_real ( )
382
- }
383
- }
384
-
385
- #[ cfg( all( procmacro2_semver_exempt, any( not( wrap_proc_macro) , super_unstable) ) ) ]
386
- impl Debug for SourceFile {
387
- fn fmt ( & self , f : & mut fmt:: Formatter ) -> fmt:: Result {
388
- Debug :: fmt ( & self . inner , f)
389
- }
390
- }
391
-
392
341
/// A region of source code, along with macro expansion information.
393
342
#[ derive( Copy , Clone ) ]
394
343
pub struct Span {
@@ -470,15 +419,6 @@ impl Span {
470
419
self . unwrap ( )
471
420
}
472
421
473
- /// The original source file into which this span points.
474
- ///
475
- /// This method is semver exempt and not exposed by default.
476
- #[ cfg( all( procmacro2_semver_exempt, any( not( wrap_proc_macro) , super_unstable) ) ) ]
477
- #[ cfg_attr( docsrs, doc( cfg( procmacro2_semver_exempt) ) ) ]
478
- pub fn source_file ( & self ) -> SourceFile {
479
- SourceFile :: _new ( self . inner . source_file ( ) )
480
- }
481
-
482
422
/// Returns the span's byte position range in the source file.
483
423
///
484
424
/// This method requires the `"span-locations"` feature to be enabled.
@@ -524,6 +464,33 @@ impl Span {
524
464
self . inner . end ( )
525
465
}
526
466
467
+ /// The path to the source file in which this span occurs, for display
468
+ /// purposes.
469
+ ///
470
+ /// This might not correspond to a valid file system path. It might be
471
+ /// remapped, or might be an artificial path such as `"<macro expansion>"`.
472
+ ///
473
+ /// This method is semver exempt and not exposed by default.
474
+ #[ cfg( all( procmacro2_semver_exempt, any( not( wrap_proc_macro) , super_unstable) ) ) ]
475
+ #[ cfg_attr( docsrs, doc( cfg( procmacro2_semver_exempt) ) ) ]
476
+ pub fn file ( & self ) -> String {
477
+ self . inner . file ( )
478
+ }
479
+
480
+ /// The path to the source file in which this span occurs on disk.
481
+ ///
482
+ /// This is the actual path on disk. It is unaffected by path remapping.
483
+ ///
484
+ /// This path should not be embedded in the output of the macro; prefer
485
+ /// `file()` instead.
486
+ ///
487
+ /// This method is semver exempt and not exposed by default.
488
+ #[ cfg( all( procmacro2_semver_exempt, any( not( wrap_proc_macro) , super_unstable) ) ) ]
489
+ #[ cfg_attr( docsrs, doc( cfg( procmacro2_semver_exempt) ) ) ]
490
+ pub fn local_file ( & self ) -> Option < PathBuf > {
491
+ self . inner . local_file ( )
492
+ }
493
+
527
494
/// Create a new span encompassing `self` and `other`.
528
495
///
529
496
/// Returns `None` if `self` and `other` are from different files.
0 commit comments