@@ -220,10 +220,20 @@ pub use imp::FileName;
220
220
/// This type is semver exempt and not exposed by default.
221
221
#[ cfg( procmacro2_semver_exempt) ]
222
222
#[ derive( Clone , PartialEq , Eq ) ]
223
- pub struct SourceFile ( imp:: SourceFile ) ;
223
+ pub struct SourceFile {
224
+ inner : imp:: SourceFile ,
225
+ _marker : marker:: PhantomData < Rc < ( ) > > ,
226
+ }
224
227
225
228
#[ cfg( procmacro2_semver_exempt) ]
226
229
impl SourceFile {
230
+ fn _new ( inner : imp:: SourceFile ) -> Self {
231
+ SourceFile {
232
+ inner : inner,
233
+ _marker : marker:: PhantomData ,
234
+ }
235
+ }
236
+
227
237
/// Get the path to this source file.
228
238
///
229
239
/// ### Note
@@ -238,27 +248,27 @@ impl SourceFile {
238
248
///
239
249
/// [`is_real`]: #method.is_real
240
250
pub fn path ( & self ) -> & FileName {
241
- self . 0 . path ( )
251
+ self . inner . path ( )
242
252
}
243
253
244
254
/// Returns `true` if this source file is a real source file, and not
245
255
/// generated by an external macro's expansion.
246
256
pub fn is_real ( & self ) -> bool {
247
- self . 0 . is_real ( )
257
+ self . inner . is_real ( )
248
258
}
249
259
}
250
260
251
261
#[ cfg( procmacro2_semver_exempt) ]
252
262
impl AsRef < FileName > for SourceFile {
253
263
fn as_ref ( & self ) -> & FileName {
254
- self . 0 . path ( )
264
+ self . inner . path ( )
255
265
}
256
266
}
257
267
258
268
#[ cfg( procmacro2_semver_exempt) ]
259
269
impl fmt:: Debug for SourceFile {
260
270
fn fmt ( & self , f : & mut fmt:: Formatter ) -> fmt:: Result {
261
- self . 0 . fmt ( f)
271
+ self . inner . fmt ( f)
262
272
}
263
273
}
264
274
@@ -344,7 +354,7 @@ impl Span {
344
354
/// This method is semver exempt and not exposed by default.
345
355
#[ cfg( procmacro2_semver_exempt) ]
346
356
pub fn source_file ( & self ) -> SourceFile {
347
- SourceFile ( self . inner . source_file ( ) )
357
+ SourceFile :: _new ( self . inner . source_file ( ) )
348
358
}
349
359
350
360
/// Get the starting line/column in the source file for this span.
0 commit comments