File tree Expand file tree Collapse file tree 2 files changed +10
-9
lines changed Expand file tree Collapse file tree 2 files changed +10
-9
lines changed Original file line number Diff line number Diff line change @@ -564,12 +564,6 @@ impl Span {
564
564
!self . is_dummy ( ) && sm. is_span_accessible ( self )
565
565
}
566
566
567
- /// Returns `true` if this span comes from any kind of macro, desugaring or inlining.
568
- #[ inline]
569
- pub fn from_expansion ( self ) -> bool {
570
- !self . ctxt ( ) . is_root ( )
571
- }
572
-
573
567
/// Returns `true` if `span` originates in a derive-macro's expansion.
574
568
pub fn in_derive_expansion ( self ) -> bool {
575
569
matches ! ( self . ctxt( ) . outer_expn_data( ) . kind, ExpnKind :: Macro ( MacroKind :: Derive , _) )
Original file line number Diff line number Diff line change @@ -305,6 +305,13 @@ impl Span {
305
305
}
306
306
}
307
307
308
+ /// Returns `true` if this span comes from any kind of macro, desugaring or inlining.
309
+ #[ inline]
310
+ pub fn from_expansion ( self ) -> bool {
311
+ // If the span is fully inferred then ctxt > MAX_CTXT
312
+ self . inline_ctxt ( ) . map_or ( true , |ctxt| !ctxt. is_root ( ) )
313
+ }
314
+
308
315
/// Returns `true` if this is a dummy span with any hygienic context.
309
316
#[ inline]
310
317
pub fn is_dummy ( self ) -> bool {
@@ -372,9 +379,9 @@ impl Span {
372
379
pub fn eq_ctxt ( self , other : Span ) -> bool {
373
380
match ( self . inline_ctxt ( ) , other. inline_ctxt ( ) ) {
374
381
( Ok ( ctxt1) , Ok ( ctxt2) ) => ctxt1 == ctxt2,
375
- ( Ok ( ctxt ) , Err ( index ) ) | ( Err ( index ) , Ok ( ctxt) ) => {
376
- with_span_interner ( |interner| ctxt == interner . spans [ index ] . ctxt )
377
- }
382
+ // Ok: ctxt <= MAX_CTXT
383
+ // Err: ctxt > MAX_CTXT
384
+ ( Ok ( _ ) , Err ( _ ) ) | ( Err ( _ ) , Ok ( _ ) ) => false ,
378
385
( Err ( index1) , Err ( index2) ) => with_span_interner ( |interner| {
379
386
interner. spans [ index1] . ctxt == interner. spans [ index2] . ctxt
380
387
} ) ,
You can’t perform that action at this time.
0 commit comments