@@ -6,13 +6,14 @@ 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 ;
12
13
use rustc_session:: parse:: { ParseSess , SymbolGallery } ;
13
14
use rustc_span:: hygiene:: { LocalExpnId , Transparency } ;
14
15
use rustc_span:: {
15
- Ident , MacroRulesNormalizedIdent , Span , Symbol , SyntaxContext , sym, with_metavar_spans ,
16
+ Ident , MacroRulesNormalizedIdent , Span , Symbol , SyntaxContext , sym, with_metavar_spans_mut ,
16
17
} ;
17
18
use smallvec:: { SmallVec , smallvec} ;
18
19
@@ -282,11 +283,13 @@ pub(super) fn transcribe<'a>(
282
283
}
283
284
MatchedSingle ( ParseNtResult :: Ident ( ident, is_raw) ) => {
284
285
marker. visit_span ( & mut sp) ;
286
+ with_metavar_spans_mut ( |mspans| mspans. insert ( ident. span , sp) ) ;
285
287
let kind = token:: NtIdent ( * ident, * is_raw) ;
286
288
TokenTree :: token_alone ( kind, sp)
287
289
}
288
290
MatchedSingle ( ParseNtResult :: Lifetime ( ident, is_raw) ) => {
289
291
marker. visit_span ( & mut sp) ;
292
+ with_metavar_spans_mut ( |mspans| mspans. insert ( ident. span , sp) ) ;
290
293
let kind = token:: NtLifetime ( * ident, * is_raw) ;
291
294
TokenTree :: token_alone ( kind, sp)
292
295
}
@@ -295,6 +298,8 @@ pub(super) fn transcribe<'a>(
295
298
// `Delimiter::Invisible` to maintain parsing priorities.
296
299
// `Interpolated` is currently used for such groups in rustc parser.
297
300
marker. visit_span ( & mut sp) ;
301
+ let use_span = nt. use_span ( ) ;
302
+ with_metavar_spans_mut ( |mspans| mspans. insert ( use_span, sp) ) ;
298
303
TokenTree :: token_alone ( token:: Interpolated ( Lrc :: clone ( nt) ) , sp)
299
304
}
300
305
MatchedSeq ( ..) => {
@@ -410,16 +415,16 @@ fn maybe_use_metavar_location(
410
415
return orig_tt. clone ( ) ;
411
416
}
412
417
413
- let insert = |mspans : & mut FxHashMap < _ , _ > , s, ms| match mspans. try_insert ( s, ms) {
418
+ let insert = |mspans : & mut UnordMap < _ , _ > , s, ms| match mspans. try_insert ( s, ms) {
414
419
Ok ( _) => true ,
415
420
Err ( err) => * err. entry . get ( ) == ms, // Tried to insert the same span, still success
416
421
} ;
417
422
marker. visit_span ( & mut metavar_span) ;
418
423
let no_collision = match orig_tt {
419
424
TokenTree :: Token ( token, ..) => {
420
- with_metavar_spans ( |mspans| insert ( mspans, token. span , metavar_span) )
425
+ with_metavar_spans_mut ( |mspans| insert ( mspans, token. span , metavar_span) )
421
426
}
422
- TokenTree :: Delimited ( dspan, ..) => with_metavar_spans ( |mspans| {
427
+ TokenTree :: Delimited ( dspan, ..) => with_metavar_spans_mut ( |mspans| {
423
428
insert ( mspans, dspan. open , metavar_span)
424
429
&& insert ( mspans, dspan. close , metavar_span)
425
430
&& insert ( mspans, dspan. entire ( ) , metavar_span)
@@ -434,13 +439,13 @@ fn maybe_use_metavar_location(
434
439
match orig_tt {
435
440
TokenTree :: Token ( Token { kind, span } , spacing) => {
436
441
let span = metavar_span. with_ctxt ( span. ctxt ( ) ) ;
437
- with_metavar_spans ( |mspans| insert ( mspans, span, metavar_span) ) ;
442
+ with_metavar_spans_mut ( |mspans| insert ( mspans, span, metavar_span) ) ;
438
443
TokenTree :: Token ( Token { kind : kind. clone ( ) , span } , * spacing)
439
444
}
440
445
TokenTree :: Delimited ( dspan, dspacing, delimiter, tts) => {
441
446
let open = metavar_span. with_ctxt ( dspan. open . ctxt ( ) ) ;
442
447
let close = metavar_span. with_ctxt ( dspan. close . ctxt ( ) ) ;
443
- with_metavar_spans ( |mspans| {
448
+ with_metavar_spans_mut ( |mspans| {
444
449
insert ( mspans, open, metavar_span) && insert ( mspans, close, metavar_span)
445
450
} ) ;
446
451
let dspan = DelimSpan :: from_pair ( open, close) ;
0 commit comments