@@ -192,20 +192,20 @@ macro_rules! match_span_kind {
192192 if $span. len_with_tag_or_marker != BASE_LEN_INTERNED_MARKER {
193193 if $span. len_with_tag_or_marker & PARENT_TAG == 0 {
194194 // Inline-context format.
195- let $span1: & mut InlineCtxt = unsafe { transmute( & mut * $span) } ;
195+ let $span1: InlineCtxt = unsafe { transmute( $span) } ;
196196 $arm1
197197 } else {
198198 // Inline-parent format.
199- let $span2: & mut InlineParent = unsafe { transmute( & mut * $span) } ;
199+ let $span2: InlineParent = unsafe { transmute( $span) } ;
200200 $arm2
201201 }
202202 } else if $span. ctxt_or_parent_or_marker != CTXT_INTERNED_MARKER {
203203 // Partially-interned format.
204- let $span3: & mut PartiallyInterned = unsafe { transmute( & mut * $span) } ;
204+ let $span3: PartiallyInterned = unsafe { transmute( $span) } ;
205205 $arm3
206206 } else {
207207 // Interned format.
208- let $span4: & mut Interned = unsafe { transmute( & mut * $span) } ;
208+ let $span4: Interned = unsafe { transmute( $span) } ;
209209 $arm4
210210 }
211211 } ;
@@ -273,9 +273,9 @@ impl Span {
273273 /// Internal function to translate between an encoded span and the expanded representation.
274274 /// This function must not be used outside the incremental engine.
275275 #[ inline]
276- pub fn data_untracked ( mut self ) -> SpanData {
276+ pub fn data_untracked ( self ) -> SpanData {
277277 match_span_kind ! {
278- & mut self ,
278+ self ,
279279 InlineCtxt ( span) => span. data( ) ,
280280 InlineParent ( span) => span. data( ) ,
281281 PartiallyInterned ( span) => span. data( ) ,
@@ -304,7 +304,7 @@ impl Span {
304304 // update doesn't change format. All non-inline or format changing scenarios require accessing
305305 // interner and can fall back to `Span::new`.
306306 #[ inline]
307- pub fn update_ctxt ( & mut self , update : impl FnOnce ( SyntaxContext ) -> SyntaxContext ) {
307+ pub fn map_ctxt ( self , update : impl FnOnce ( SyntaxContext ) -> SyntaxContext ) -> Span {
308308 let ( updated_ctxt32, data) ;
309309 match_span_kind ! {
310310 self ,
@@ -313,8 +313,7 @@ impl Span {
313313 update( SyntaxContext :: from_u32( span. ctxt as u32 ) ) . as_u32( ) ;
314314 // Any small new context including zero will preserve the format.
315315 if updated_ctxt32 <= MAX_CTXT {
316- span. ctxt = updated_ctxt32 as u16 ;
317- return ;
316+ return InlineCtxt :: span( span. lo, span. len, updated_ctxt32 as u16 ) ;
318317 }
319318 data = span. data( ) ;
320319 } ,
@@ -323,7 +322,7 @@ impl Span {
323322 // Only if the new context is zero the format will be preserved.
324323 if updated_ctxt32 == 0 {
325324 // Do nothing.
326- return ;
325+ return self ;
327326 }
328327 data = span. data( ) ;
329328 } ,
@@ -332,8 +331,7 @@ impl Span {
332331 // Any small new context excluding zero will preserve the format.
333332 // Zero may change the format to `InlineParent` if parent and len are small enough.
334333 if updated_ctxt32 <= MAX_CTXT && updated_ctxt32 != 0 {
335- span. ctxt = updated_ctxt32 as u16 ;
336- return ;
334+ return PartiallyInterned :: span( span. index, updated_ctxt32 as u16 ) ;
337335 }
338336 data = span. data( ) ;
339337 } ,
@@ -344,15 +342,15 @@ impl Span {
344342 }
345343
346344 // We could not keep the span in the same inline format, fall back to the complete logic.
347- * self = data. with_ctxt ( SyntaxContext :: from_u32 ( updated_ctxt32) ) ;
345+ data. with_ctxt ( SyntaxContext :: from_u32 ( updated_ctxt32) )
348346 }
349347
350348 // Returns either syntactic context, if it can be retrieved without taking the interner lock,
351349 // or an index into the interner if it cannot.
352350 #[ inline]
353- fn inline_ctxt ( mut self ) -> Result < SyntaxContext , usize > {
351+ fn inline_ctxt ( self ) -> Result < SyntaxContext , usize > {
354352 match_span_kind ! {
355- & mut self ,
353+ self ,
356354 InlineCtxt ( span) => Ok ( SyntaxContext :: from_u32( span. ctxt as u32 ) ) ,
357355 InlineParent ( _span) => Ok ( SyntaxContext :: root( ) ) ,
358356 PartiallyInterned ( span) => Ok ( SyntaxContext :: from_u32( span. ctxt as u32 ) ) ,
0 commit comments