@@ -327,43 +327,24 @@ impl Span {
327327 // interner and can fall back to `Span::new`.
328328 #[ inline]
329329 pub fn map_ctxt ( self , update : impl FnOnce ( SyntaxContext ) -> SyntaxContext ) -> Span {
330- let ( updated_ctxt32, data) ;
331330 match_span_kind ! {
332331 self ,
333332 InlineCtxt ( span) => {
334- updated_ctxt32 = update( SyntaxContext :: from_u16( span. ctxt) ) . as_u32( ) ;
333+ let updated_ctxt32 = update( SyntaxContext :: from_u16( span. ctxt) ) . as_u32( ) ;
335334 // Any small new context including zero will preserve the format.
336- if updated_ctxt32 <= MAX_CTXT {
337- return InlineCtxt :: span( span. lo, span. len, updated_ctxt32 as u16 ) ;
338- }
339- data = span. data( ) ;
340- } ,
341- InlineParent ( span) => {
342- updated_ctxt32 = update( SyntaxContext :: root( ) ) . as_u32( ) ;
343- // Only if the new context is zero the format will be preserved.
344- if updated_ctxt32 == 0 {
345- // Do nothing.
346- return self ;
347- }
348- data = span. data( ) ;
349- } ,
350- PartiallyInterned ( span) => {
351- updated_ctxt32 = update( SyntaxContext :: from_u16( span. ctxt) ) . as_u32( ) ;
352- // Any small new context excluding zero will preserve the format.
353- // Zero may change the format to `InlineParent` if parent and len are small enough.
354- if updated_ctxt32 <= MAX_CTXT && updated_ctxt32 != 0 {
355- return PartiallyInterned :: span( span. index, updated_ctxt32 as u16 ) ;
356- }
357- data = span. data( ) ;
358- } ,
359- Interned ( span) => {
360- data = span. data( ) ;
361- updated_ctxt32 = update( data. ctxt) . as_u32( ) ;
335+ return if updated_ctxt32 <= MAX_CTXT {
336+ InlineCtxt :: span( span. lo, span. len, updated_ctxt32 as u16 )
337+ } else {
338+ span. data( ) . with_ctxt( SyntaxContext :: from_u32( updated_ctxt32) )
339+ } ;
362340 } ,
341+ InlineParent ( _span) => { } ,
342+ PartiallyInterned ( _span) => { } ,
343+ Interned ( _span) => { } ,
363344 }
364345
365- // We could not keep the span in the same inline format, fall back to the complete logic.
366- data. with_ctxt ( SyntaxContext :: from_u32 ( updated_ctxt32 ) )
346+ let data = self . data_untracked ( ) ;
347+ data. with_ctxt ( update ( data . ctxt ) )
367348 }
368349
369350 // Returns either syntactic context, if it can be retrieved without taking the interner lock,
0 commit comments