@@ -218,10 +218,20 @@ impl fmt::Debug for LexError {
218218/// This type is semver exempt and not exposed by default.
219219#[ cfg( procmacro2_semver_exempt) ]
220220#[ derive( Clone , PartialEq , Eq ) ]
221- pub struct SourceFile ( imp:: SourceFile ) ;
221+ pub struct SourceFile {
222+ inner : imp:: SourceFile ,
223+ _marker : marker:: PhantomData < Rc < ( ) > > ,
224+ }
222225
223226#[ cfg( procmacro2_semver_exempt) ]
224227impl SourceFile {
228+ fn _new ( inner : imp:: SourceFile ) -> Self {
229+ SourceFile {
230+ inner : inner,
231+ _marker : marker:: PhantomData ,
232+ }
233+ }
234+
225235 /// Get the path to this source file.
226236 ///
227237 /// ### Note
@@ -236,20 +246,20 @@ impl SourceFile {
236246 ///
237247 /// [`is_real`]: #method.is_real
238248 pub fn path ( & self ) -> PathBuf {
239- self . 0 . path ( )
249+ self . inner . path ( )
240250 }
241251
242252 /// Returns `true` if this source file is a real source file, and not
243253 /// generated by an external macro's expansion.
244254 pub fn is_real ( & self ) -> bool {
245- self . 0 . is_real ( )
255+ self . inner . is_real ( )
246256 }
247257}
248258
249259#[ cfg( procmacro2_semver_exempt) ]
250260impl fmt:: Debug for SourceFile {
251261 fn fmt ( & self , f : & mut fmt:: Formatter ) -> fmt:: Result {
252- self . 0 . fmt ( f)
262+ self . inner . fmt ( f)
253263 }
254264}
255265
@@ -335,7 +345,7 @@ impl Span {
335345 /// This method is semver exempt and not exposed by default.
336346 #[ cfg( procmacro2_semver_exempt) ]
337347 pub fn source_file ( & self ) -> SourceFile {
338- SourceFile ( self . inner . source_file ( ) )
348+ SourceFile :: _new ( self . inner . source_file ( ) )
339349 }
340350
341351 /// Get the starting line/column in the source file for this span.
0 commit comments