@@ -220,10 +220,20 @@ pub use imp::FileName;
220220/// This type is semver exempt and not exposed by default.
221221#[ cfg( procmacro2_semver_exempt) ]
222222#[ derive( Clone , PartialEq , Eq ) ]
223- pub struct SourceFile ( imp:: SourceFile ) ;
223+ pub struct SourceFile {
224+ inner : imp:: SourceFile ,
225+ _marker : marker:: PhantomData < Rc < ( ) > > ,
226+ }
224227
225228#[ cfg( procmacro2_semver_exempt) ]
226229impl SourceFile {
230+ fn _new ( inner : imp:: SourceFile ) -> Self {
231+ SourceFile {
232+ inner : inner,
233+ _marker : marker:: PhantomData ,
234+ }
235+ }
236+
227237 /// Get the path to this source file.
228238 ///
229239 /// ### Note
@@ -238,27 +248,27 @@ impl SourceFile {
238248 ///
239249 /// [`is_real`]: #method.is_real
240250 pub fn path ( & self ) -> & FileName {
241- self . 0 . path ( )
251+ self . inner . path ( )
242252 }
243253
244254 /// Returns `true` if this source file is a real source file, and not
245255 /// generated by an external macro's expansion.
246256 pub fn is_real ( & self ) -> bool {
247- self . 0 . is_real ( )
257+ self . inner . is_real ( )
248258 }
249259}
250260
251261#[ cfg( procmacro2_semver_exempt) ]
252262impl AsRef < FileName > for SourceFile {
253263 fn as_ref ( & self ) -> & FileName {
254- self . 0 . path ( )
264+ self . inner . path ( )
255265 }
256266}
257267
258268#[ cfg( procmacro2_semver_exempt) ]
259269impl fmt:: Debug for SourceFile {
260270 fn fmt ( & self , f : & mut fmt:: Formatter ) -> fmt:: Result {
261- self . 0 . fmt ( f)
271+ self . inner . fmt ( f)
262272 }
263273}
264274
@@ -344,7 +354,7 @@ impl Span {
344354 /// This method is semver exempt and not exposed by default.
345355 #[ cfg( procmacro2_semver_exempt) ]
346356 pub fn source_file ( & self ) -> SourceFile {
347- SourceFile ( self . inner . source_file ( ) )
357+ SourceFile :: _new ( self . inner . source_file ( ) )
348358 }
349359
350360 /// Get the starting line/column in the source file for this span.
0 commit comments