diff options
Diffstat (limited to 'src/libproc_macro/lib.rs')
| -rw-r--r-- | src/libproc_macro/lib.rs | 20 |
1 files changed, 10 insertions, 10 deletions
diff --git a/src/libproc_macro/lib.rs b/src/libproc_macro/lib.rs index 4a6841aedca..625edc02b77 100644 --- a/src/libproc_macro/lib.rs +++ b/src/libproc_macro/lib.rs @@ -59,7 +59,7 @@ use syntax::parse::{self, token}; use syntax::symbol::Symbol; use syntax::tokenstream; use syntax_pos::DUMMY_SP; -use syntax_pos::{FileMap, Pos, SyntaxContext}; +use syntax_pos::{FileMap, Pos, SyntaxContext, FileName}; use syntax_pos::hygiene::Mark; /// The main type provided by this crate, representing an abstract stream of @@ -89,7 +89,7 @@ impl FromStr for TokenStream { fn from_str(src: &str) -> Result<TokenStream, LexError> { __internal::with_sess(|(sess, mark)| { let src = src.to_string(); - let name = "<proc-macro source code>".to_string(); + let name = FileName::ProcMacroSourceCode; let expn_info = mark.expn_info().unwrap(); let call_site = expn_info.call_site; // notify the expansion info that it is unhygienic @@ -279,7 +279,7 @@ pub struct SourceFile { } impl SourceFile { - /// Get the path to this source file as a string. + /// Get the path to this source file. /// /// ### Note /// If the code span associated with this `SourceFile` was generated by an external macro, this @@ -290,7 +290,7 @@ impl SourceFile { /// /// [`is_real`]: #method.is_real # [unstable(feature = "proc_macro", issue = "38356")] - pub fn as_str(&self) -> &str { + pub fn path(&self) -> &FileName { &self.filemap.name } @@ -306,9 +306,9 @@ impl SourceFile { } #[unstable(feature = "proc_macro", issue = "38356")] -impl AsRef<str> for SourceFile { - fn as_ref(&self) -> &str { - self.as_str() +impl AsRef<FileName> for SourceFile { + fn as_ref(&self) -> &FileName { + self.path() } } @@ -316,7 +316,7 @@ impl AsRef<str> for SourceFile { impl fmt::Debug for SourceFile { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { f.debug_struct("SourceFile") - .field("path", &self.as_str()) + .field("path", self.path()) .field("is_real", &self.is_real()) .finish() } @@ -333,8 +333,8 @@ impl PartialEq for SourceFile { impl Eq for SourceFile {} #[unstable(feature = "proc_macro", issue = "38356")] -impl PartialEq<str> for SourceFile { - fn eq(&self, other: &str) -> bool { +impl PartialEq<FileName> for SourceFile { + fn eq(&self, other: &FileName) -> bool { self.as_ref() == other } } |
