File tree 4 files changed +28
-0
lines changed
4 files changed +28
-0
lines changed Original file line number Diff line number Diff line change @@ -57,6 +57,10 @@ fn main() {
57
57
println ! ( "cargo:rustc-cfg=span_locations" ) ;
58
58
}
59
59
60
+ if version. minor >= 45 {
61
+ println ! ( "cargo:rustc-cfg=hygiene" ) ;
62
+ }
63
+
60
64
let target = env:: var ( "TARGET" ) . unwrap ( ) ;
61
65
if !enable_use_proc_macro ( & target) {
62
66
return ;
Original file line number Diff line number Diff line change @@ -374,6 +374,11 @@ impl Span {
374
374
Span { lo : 0 , hi : 0 }
375
375
}
376
376
377
+ #[ cfg( hygiene) ]
378
+ pub fn mixed_site ( ) -> Span {
379
+ Span :: call_site ( )
380
+ }
381
+
377
382
#[ cfg( procmacro2_semver_exempt) ]
378
383
pub fn def_site ( ) -> Span {
379
384
Span :: call_site ( )
Original file line number Diff line number Diff line change @@ -348,6 +348,16 @@ impl Span {
348
348
Span :: _new ( imp:: Span :: call_site ( ) )
349
349
}
350
350
351
+ /// The span located at the invocation of the procedural macro, but with
352
+ /// local variables, labels, and `$crate` resolved at the definition site
353
+ /// of the macro. This is the same hygiene behavior as `macro_rules`.
354
+ ///
355
+ /// This function requires Rust 1.45 or later.
356
+ #[ cfg( hygiene) ]
357
+ pub fn mixed_site ( ) -> Span {
358
+ Span :: _new ( imp:: Span :: mixed_site ( ) )
359
+ }
360
+
351
361
/// A span that resolves at the macro definition site.
352
362
///
353
363
/// This method is semver exempt and not exposed by default.
Original file line number Diff line number Diff line change @@ -376,6 +376,15 @@ impl Span {
376
376
}
377
377
}
378
378
379
+ #[ cfg( hygiene) ]
380
+ pub fn mixed_site ( ) -> Span {
381
+ if inside_proc_macro ( ) {
382
+ Span :: Compiler ( proc_macro:: Span :: mixed_site ( ) )
383
+ } else {
384
+ Span :: Fallback ( fallback:: Span :: mixed_site ( ) )
385
+ }
386
+ }
387
+
379
388
#[ cfg( super_unstable) ]
380
389
pub fn def_site ( ) -> Span {
381
390
if inside_proc_macro ( ) {
You can’t perform that action at this time.
0 commit comments