|
3 | 3 | use std::fmt; |
4 | 4 | use std::iter; |
5 | 5 | use std::panic::{self, PanicInfo}; |
| 6 | +#[cfg(super_unstable)] |
| 7 | +use std::path::PathBuf; |
6 | 8 | use std::str::FromStr; |
7 | 9 |
|
8 | 10 | use proc_macro; |
@@ -382,52 +384,40 @@ impl fmt::Debug for TokenTreeIter { |
382 | 384 | } |
383 | 385 | } |
384 | 386 |
|
385 | | -pub use stable::FileName; |
386 | | - |
387 | | -// NOTE: We have to generate our own filename object here because we can't wrap |
388 | | -// the one provided by proc_macro. |
389 | 387 | #[derive(Clone, PartialEq, Eq)] |
390 | 388 | #[cfg(super_unstable)] |
391 | 389 | pub enum SourceFile { |
392 | | - Nightly(proc_macro::SourceFile, FileName), |
| 390 | + Nightly(proc_macro::SourceFile), |
393 | 391 | Stable(stable::SourceFile), |
394 | 392 | } |
395 | 393 |
|
396 | 394 | #[cfg(super_unstable)] |
397 | 395 | impl SourceFile { |
398 | 396 | fn nightly(sf: proc_macro::SourceFile) -> Self { |
399 | | - let filename = stable::file_name(sf.path().display().to_string()); |
400 | | - SourceFile::Nightly(sf, filename) |
| 397 | + SourceFile::Nightly(sf) |
401 | 398 | } |
402 | 399 |
|
403 | 400 | /// Get the path to this source file as a string. |
404 | | - pub fn path(&self) -> &FileName { |
| 401 | + pub fn path(&self) -> PathBuf { |
405 | 402 | match self { |
406 | | - SourceFile::Nightly(_, f) => f, |
| 403 | + SourceFile::Nightly(a) => a.path(), |
407 | 404 | SourceFile::Stable(a) => a.path(), |
408 | 405 | } |
409 | 406 | } |
410 | 407 |
|
411 | 408 | pub fn is_real(&self) -> bool { |
412 | 409 | match self { |
413 | | - SourceFile::Nightly(a, _) => a.is_real(), |
| 410 | + SourceFile::Nightly(a) => a.is_real(), |
414 | 411 | SourceFile::Stable(a) => a.is_real(), |
415 | 412 | } |
416 | 413 | } |
417 | 414 | } |
418 | 415 |
|
419 | | -#[cfg(super_unstable)] |
420 | | -impl AsRef<FileName> for SourceFile { |
421 | | - fn as_ref(&self) -> &FileName { |
422 | | - self.path() |
423 | | - } |
424 | | -} |
425 | | - |
426 | 416 | #[cfg(super_unstable)] |
427 | 417 | impl fmt::Debug for SourceFile { |
428 | 418 | fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { |
429 | 419 | match self { |
430 | | - SourceFile::Nightly(a, _) => a.fmt(f), |
| 420 | + SourceFile::Nightly(a) => a.fmt(f), |
431 | 421 | SourceFile::Stable(a) => a.fmt(f), |
432 | 422 | } |
433 | 423 | } |
|
0 commit comments