aboutsummaryrefslogtreecommitdiff
path: root/src/lib.rs
diff options
context:
space:
mode:
authorDavid Tolnay <dtolnay@gmail.com>2018-11-11 13:33:18 -0800
committerDavid Tolnay <dtolnay@gmail.com>2018-11-11 15:57:04 -0800
commit7e654a8bad9a9e07df568e582610f8a91b5ccffe (patch)
tree49f13481258b6365d895e1cb08703343224f4969 /src/lib.rs
parent102ee29e36c15ca68a6f6ec7d37b04571997a8f4 (diff)
downloadproc-macro2-7e654a8bad9a9e07df568e582610f8a91b5ccffe.tar.gz
Remove Send and Sync from SourceFile
Diffstat (limited to 'src/lib.rs')
-rw-r--r--src/lib.rs22
1 files changed, 16 insertions, 6 deletions
diff --git a/src/lib.rs b/src/lib.rs
index 2f632f6..784e456 100644
--- a/src/lib.rs
+++ b/src/lib.rs
@@ -220,10 +220,20 @@ pub use imp::FileName;
/// This type is semver exempt and not exposed by default.
#[cfg(procmacro2_semver_exempt)]
#[derive(Clone, PartialEq, Eq)]
-pub struct SourceFile(imp::SourceFile);
+pub struct SourceFile {
+ inner: imp::SourceFile,
+ _marker: marker::PhantomData<Rc<()>>,
+}
#[cfg(procmacro2_semver_exempt)]
impl SourceFile {
+ fn _new(inner: imp::SourceFile) -> Self {
+ SourceFile {
+ inner: inner,
+ _marker: marker::PhantomData,
+ }
+ }
+
/// Get the path to this source file.
///
/// ### Note
@@ -238,27 +248,27 @@ impl SourceFile {
///
/// [`is_real`]: #method.is_real
pub fn path(&self) -> &FileName {
- self.0.path()
+ self.inner.path()
}
/// Returns `true` if this source file is a real source file, and not
/// generated by an external macro's expansion.
pub fn is_real(&self) -> bool {
- self.0.is_real()
+ self.inner.is_real()
}
}
#[cfg(procmacro2_semver_exempt)]
impl AsRef<FileName> for SourceFile {
fn as_ref(&self) -> &FileName {
- self.0.path()
+ self.inner.path()
}
}
#[cfg(procmacro2_semver_exempt)]
impl fmt::Debug for SourceFile {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
- self.0.fmt(f)
+ self.inner.fmt(f)
}
}
@@ -344,7 +354,7 @@ impl Span {
/// This method is semver exempt and not exposed by default.
#[cfg(procmacro2_semver_exempt)]
pub fn source_file(&self) -> SourceFile {
- SourceFile(self.inner.source_file())
+ SourceFile::_new(self.inner.source_file())
}
/// Get the starting line/column in the source file for this span.