File tree Expand file tree Collapse file tree 4 files changed +24
-15
lines changed Expand file tree Collapse file tree 4 files changed +24
-15
lines changed Original file line number Diff line number Diff line change 1414// procmacro2_semver_exempt surface area is implemented by using the
1515// nightly-only proc_macro API.
1616//
17+ // "hygiene"
18+ // Enable Span::mixed_site() and non-dummy behavior of Span::resolved_at
19+ // and Span::located_at. Enabled on Rust 1.45+.
20+ //
1721// "proc_macro_span"
1822// Enable non-dummy behavior of Span::start and Span::end methods which
1923// requires an unstable compiler feature. Enabled when building with
Original file line number Diff line number Diff line change @@ -384,17 +384,12 @@ impl Span {
384384 Span :: call_site ( )
385385 }
386386
387- #[ cfg( procmacro2_semver_exempt) ]
388- pub fn resolved_at ( & self , _other : Span ) -> Span {
389- // Stable spans consist only of line/column information, so
390- // `resolved_at` and `located_at` only select which span the
391- // caller wants line/column information from.
392- * self
387+ pub fn resolved_at ( & self , other : Span ) -> Span {
388+ other
393389 }
394390
395- #[ cfg( procmacro2_semver_exempt) ]
396- pub fn located_at ( & self , other : Span ) -> Span {
397- other
391+ pub fn located_at ( & self , _other : Span ) -> Span {
392+ * self
398393 }
399394
400395 #[ cfg( procmacro2_semver_exempt) ]
Original file line number Diff line number Diff line change @@ -369,17 +369,17 @@ impl Span {
369369 /// Creates a new span with the same line/column information as `self` but
370370 /// that resolves symbols as though it were at `other`.
371371 ///
372- /// This method is semver exempt and not exposed by default.
373- # [ cfg ( procmacro2_semver_exempt ) ]
372+ /// On versions of Rust prior to 1.45, this returns `self` to preserve the
373+ /// name resolution behavior while discarding location information.
374374 pub fn resolved_at ( & self , other : Span ) -> Span {
375375 Span :: _new ( self . inner . resolved_at ( other. inner ) )
376376 }
377377
378378 /// Creates a new span with the same name resolution behavior as `self` but
379379 /// with the line/column information of `other`.
380380 ///
381- /// This method is semver exempt and not exposed by default.
382- # [ cfg ( procmacro2_semver_exempt ) ]
381+ /// On versions of Rust prior to 1.45, this returns `self` to preserve the
382+ /// name resolution behavior while discarding location information.
383383 pub fn located_at ( & self , other : Span ) -> Span {
384384 Span :: _new ( self . inner . located_at ( other. inner ) )
385385 }
Original file line number Diff line number Diff line change @@ -394,19 +394,29 @@ impl Span {
394394 }
395395 }
396396
397- #[ cfg( super_unstable) ]
398397 pub fn resolved_at ( & self , other : Span ) -> Span {
399398 match ( self , other) {
399+ #[ cfg( hygiene) ]
400400 ( Span :: Compiler ( a) , Span :: Compiler ( b) ) => Span :: Compiler ( a. resolved_at ( b) ) ,
401+
402+ // Name resolution affects semantics, but location is only cosmetic
403+ #[ cfg( not( hygiene) ) ]
404+ ( Span :: Compiler ( _) , Span :: Compiler ( _) ) => other,
405+
401406 ( Span :: Fallback ( a) , Span :: Fallback ( b) ) => Span :: Fallback ( a. resolved_at ( b) ) ,
402407 _ => mismatch ( ) ,
403408 }
404409 }
405410
406- #[ cfg( super_unstable) ]
407411 pub fn located_at ( & self , other : Span ) -> Span {
408412 match ( self , other) {
413+ #[ cfg( hygiene) ]
409414 ( Span :: Compiler ( a) , Span :: Compiler ( b) ) => Span :: Compiler ( a. located_at ( b) ) ,
415+
416+ // Name resolution affects semantics, but location is only cosmetic
417+ #[ cfg( not( hygiene) ) ]
418+ ( Span :: Compiler ( _) , Span :: Compiler ( _) ) => * self ,
419+
410420 ( Span :: Fallback ( a) , Span :: Fallback ( b) ) => Span :: Fallback ( a. located_at ( b) ) ,
411421 _ => mismatch ( ) ,
412422 }
You can’t perform that action at this time.
0 commit comments