File tree Expand file tree Collapse file tree 1 file changed +10
-2
lines changed Expand file tree Collapse file tree 1 file changed +10
-2
lines changed Original file line number Diff line number Diff line change @@ -306,8 +306,16 @@ impl Span {
306306    /// Returns `true` if this span comes from any kind of macro, desugaring or inlining. 
307307#[ inline]  
308308    pub  fn  from_expansion ( self )  -> bool  { 
309-         // If the span is fully inferred then ctxt > MAX_CTXT 
310-         self . inline_ctxt ( ) . map_or ( true ,  |ctxt| !ctxt. is_root ( ) ) 
309+       // Optimizes much better than `inline_ctxt` since it avoids comparing against `lo_or_index`. 
310+       let  ctxt = match_span_kind !  { 
311+           self , 
312+           InlineCtxt ( span)  => SyntaxContext :: from_u16( span. ctxt) , 
313+           InlineParent ( _span)  => SyntaxContext :: root( ) , 
314+           PartiallyInterned ( span)  => SyntaxContext :: from_u16( span. ctxt) , 
315+           // Must be the value stored in `ctxt_or_parent_or_marker` to optimize properly. 
316+           Interned ( _span)  => SyntaxContext :: from_u16( CTXT_INTERNED_MARKER ) , 
317+       } ; 
318+       !ctxt. is_root ( ) 
311319    } 
312320
313321    /// Returns `true` if this is a dummy span with any hygienic context. 
 
 
   
 
     
   
   
          
    
    
     
    
      
     
     
    You can’t perform that action at this time.
  
 
    
  
    
      
        
     
       
      
     
   
 
    
    
  
 
  
 
     
    
0 commit comments