diff options
| author | Eduard-Mihai Burtescu <edy.burt@gmail.com> | 2018-03-16 17:04:14 +0200 |
|---|---|---|
| committer | Eduard-Mihai Burtescu <edy.burt@gmail.com> | 2018-07-20 00:15:11 +0300 |
| commit | e5e29d1a1976ff7d0b39ade8706ca0e3ddebe7a9 (patch) | |
| tree | 36127827b34643f8e497402d2d29012e44600e09 /src | |
| parent | 56aaa532781e8591c1c5b50aafa2e64634a2de80 (diff) | |
| download | rust-e5e29d1a1976ff7d0b39ade8706ca0e3ddebe7a9.tar.gz rust-e5e29d1a1976ff7d0b39ade8706ca0e3ddebe7a9.zip | |
proc_macro: don't expose compiler-internal FileName in public API.
Diffstat (limited to 'src')
| -rw-r--r-- | src/libproc_macro/lib.rs | 23 |
1 files changed, 7 insertions, 16 deletions
diff --git a/src/libproc_macro/lib.rs b/src/libproc_macro/lib.rs index c88a245d3b3..f85235278f8 100644 --- a/src/libproc_macro/lib.rs +++ b/src/libproc_macro/lib.rs @@ -50,6 +50,7 @@ mod diagnostic; pub use diagnostic::{Diagnostic, Level}; use std::{ascii, fmt, iter}; +use std::path::PathBuf; use rustc_data_structures::sync::Lrc; use std::str::FromStr; @@ -421,8 +422,11 @@ impl SourceFile { /// /// [`is_real`]: #method.is_real #[unstable(feature = "proc_macro_span", issue = "38356")] - pub fn path(&self) -> &FileName { - &self.filemap.name + pub fn path(&self) -> PathBuf { + match self.filemap.name { + FileName::Real(ref path) => path.clone(), + _ => PathBuf::from(self.filemap.name.to_string()) + } } /// Returns `true` if this source file is a real source file, and not generated by an external @@ -436,18 +440,12 @@ impl SourceFile { } } -#[unstable(feature = "proc_macro_span", issue = "38356")] -impl AsRef<FileName> for SourceFile { - fn as_ref(&self) -> &FileName { - self.path() - } -} #[unstable(feature = "proc_macro_span", issue = "38356")] impl fmt::Debug for SourceFile { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { f.debug_struct("SourceFile") - .field("path", self.path()) + .field("path", &self.path()) .field("is_real", &self.is_real()) .finish() } @@ -463,13 +461,6 @@ impl PartialEq for SourceFile { #[unstable(feature = "proc_macro_span", issue = "38356")] impl Eq for SourceFile {} -#[unstable(feature = "proc_macro_span", issue = "38356")] -impl PartialEq<FileName> for SourceFile { - fn eq(&self, other: &FileName) -> bool { - self.as_ref() == other - } -} - /// A single token or a delimited sequence of token trees (e.g. `[1, (), ..]`). #[stable(feature = "proc_macro_lib2", since = "1.29.0")] #[derive(Clone)] |
