@@ -6,6 +6,7 @@ use rustc_ast::token::{self, Delimiter, IdentIsRaw, Lit, LitKind, Nonterminal, T
6
6
use rustc_ast:: tokenstream:: { DelimSpacing , DelimSpan , Spacing , TokenStream , TokenTree } ;
7
7
use rustc_data_structures:: fx:: FxHashMap ;
8
8
use rustc_data_structures:: sync:: Lrc ;
9
+ use rustc_data_structures:: unord:: UnordMap ;
9
10
use rustc_errors:: { Diag , DiagCtxtHandle , PResult , pluralize} ;
10
11
use rustc_parse:: lexer:: nfc_normalize;
11
12
use rustc_parse:: parser:: ParseNtResult ;
@@ -282,13 +283,17 @@ pub(super) fn transcribe<'a>(
282
283
}
283
284
MatchedSingle ( ParseNtResult :: Ident ( ident, is_raw) ) => {
284
285
marker. visit_span ( & mut sp) ;
285
- with_metavar_spans ( |mspans| mspans. insert ( ident. span , sp) ) ;
286
+ with_metavar_spans ( |mspans| {
287
+ mspans. write ( ) . insert ( ident. span , ( sp, false ) )
288
+ } ) ;
286
289
let kind = token:: NtIdent ( * ident, * is_raw) ;
287
290
TokenTree :: token_alone ( kind, sp)
288
291
}
289
292
MatchedSingle ( ParseNtResult :: Lifetime ( ident, is_raw) ) => {
290
293
marker. visit_span ( & mut sp) ;
291
- with_metavar_spans ( |mspans| mspans. insert ( ident. span , sp) ) ;
294
+ with_metavar_spans ( |mspans| {
295
+ mspans. write ( ) . insert ( ident. span , ( sp, false ) )
296
+ } ) ;
292
297
let kind = token:: NtLifetime ( * ident, * is_raw) ;
293
298
TokenTree :: token_alone ( kind, sp)
294
299
}
@@ -298,7 +303,9 @@ pub(super) fn transcribe<'a>(
298
303
// `Interpolated` is currently used for such groups in rustc parser.
299
304
marker. visit_span ( & mut sp) ;
300
305
let use_span = nt. use_span ( ) ;
301
- with_metavar_spans ( |mspans| mspans. insert ( use_span, sp) ) ;
306
+ with_metavar_spans ( |mspans| {
307
+ mspans. write ( ) . insert ( use_span, ( sp, false ) )
308
+ } ) ;
302
309
TokenTree :: token_alone ( token:: Interpolated ( Lrc :: clone ( nt) ) , sp)
303
310
}
304
311
MatchedSeq ( ..) => {
@@ -414,16 +421,17 @@ fn maybe_use_metavar_location(
414
421
return orig_tt. clone ( ) ;
415
422
}
416
423
417
- let insert = |mspans : & mut FxHashMap < _ , _ > , s, ms| match mspans. try_insert ( s, ms ) {
424
+ let insert = |mspans : & mut UnordMap < _ , _ > , s, ms| match mspans. try_insert ( s, ( ms , false ) ) {
418
425
Ok ( _) => true ,
419
- Err ( err) => * err. entry . get ( ) == ms, // Tried to insert the same span, still success
426
+ Err ( err) => err. entry . get ( ) . 0 == ms, // Tried to insert the same span, still success
420
427
} ;
421
428
marker. visit_span ( & mut metavar_span) ;
422
429
let no_collision = match orig_tt {
423
430
TokenTree :: Token ( token, ..) => {
424
- with_metavar_spans ( |mspans| insert ( mspans, token. span , metavar_span) )
431
+ with_metavar_spans ( |mspans| insert ( & mut mspans. write ( ) , token. span , metavar_span) )
425
432
}
426
433
TokenTree :: Delimited ( dspan, ..) => with_metavar_spans ( |mspans| {
434
+ let mspans = & mut mspans. write ( ) ;
427
435
insert ( mspans, dspan. open , metavar_span)
428
436
&& insert ( mspans, dspan. close , metavar_span)
429
437
&& insert ( mspans, dspan. entire ( ) , metavar_span)
@@ -438,13 +446,14 @@ fn maybe_use_metavar_location(
438
446
match orig_tt {
439
447
TokenTree :: Token ( Token { kind, span } , spacing) => {
440
448
let span = metavar_span. with_ctxt ( span. ctxt ( ) ) ;
441
- with_metavar_spans ( |mspans| insert ( mspans, span, metavar_span) ) ;
449
+ with_metavar_spans ( |mspans| insert ( & mut mspans. write ( ) , span, metavar_span) ) ;
442
450
TokenTree :: Token ( Token { kind : kind. clone ( ) , span } , * spacing)
443
451
}
444
452
TokenTree :: Delimited ( dspan, dspacing, delimiter, tts) => {
445
453
let open = metavar_span. with_ctxt ( dspan. open . ctxt ( ) ) ;
446
454
let close = metavar_span. with_ctxt ( dspan. close . ctxt ( ) ) ;
447
455
with_metavar_spans ( |mspans| {
456
+ let mspans = & mut mspans. write ( ) ;
448
457
insert ( mspans, open, metavar_span) && insert ( mspans, close, metavar_span)
449
458
} ) ;
450
459
let dspan = DelimSpan :: from_pair ( open, close) ;
0 commit comments