@@ -70,6 +70,7 @@ struct TranscrCtx<'psess, 'itp> {
70
70
71
71
impl < ' psess > TranscrCtx < ' psess , ' _ > {
72
72
/// Span marked with the correct expansion and transparency.
73
+ #[ inline( always) ]
73
74
fn visited_dspan ( & mut self , dspan : DelimSpan ) -> Span {
74
75
let mut span = dspan. entire ( ) ;
75
76
self . marker . mark_span ( & mut span) ;
@@ -86,6 +87,7 @@ struct Marker {
86
87
87
88
impl Marker {
88
89
/// Mark a span with the stored expansion ID and transparency.
90
+ #[ inline( always) ]
89
91
fn mark_span ( & mut self , span : & mut Span ) {
90
92
// `apply_mark` is a relatively expensive operation, both due to taking hygiene lock, and
91
93
// by itself. All tokens in a macro body typically have the same syntactic context, unless
@@ -113,6 +115,7 @@ enum FrameKind {
113
115
}
114
116
115
117
impl < ' a > Frame < ' a > {
118
+ #[ inline( always) ]
116
119
fn new_delimited ( src : & ' a mbe:: Delimited , span : DelimSpan , spacing : DelimSpacing ) -> Frame < ' a > {
117
120
Frame {
118
121
tts : & src. tts ,
@@ -121,6 +124,7 @@ impl<'a> Frame<'a> {
121
124
}
122
125
}
123
126
127
+ #[ inline( always) ]
124
128
fn new_sequence (
125
129
src : & ' a mbe:: SequenceRepetition ,
126
130
sep : Option < Token > ,
@@ -133,6 +137,7 @@ impl<'a> Frame<'a> {
133
137
impl < ' a > Iterator for Frame < ' a > {
134
138
type Item = & ' a mbe:: TokenTree ;
135
139
140
+ #[ inline( always) ]
136
141
fn next ( & mut self ) -> Option < & ' a mbe:: TokenTree > {
137
142
let res = self . tts . get ( self . idx ) ;
138
143
self . idx += 1 ;
@@ -289,6 +294,7 @@ pub(super) fn transcribe<'a>(
289
294
}
290
295
291
296
/// Turn `$(...)*` sequences into tokens.
297
+ #[ inline( always) ] // called once
292
298
fn transcribe_sequence < ' tx , ' itp > (
293
299
tscx : & mut TranscrCtx < ' tx , ' itp > ,
294
300
seq : & mbe:: TokenTree ,
@@ -357,6 +363,7 @@ fn transcribe_sequence<'tx, 'itp>(
357
363
/// producing "xyz", which is bad because it effectively merges tokens.
358
364
/// `Spacing::Alone` is the safer option. Fortunately, `space_between` will avoid
359
365
/// some of the unnecessary whitespace.
366
+ #[ inline( always) ] // called once
360
367
fn transcribe_metavar < ' tx > (
361
368
tscx : & mut TranscrCtx < ' tx , ' _ > ,
362
369
mut sp : Span ,
@@ -492,6 +499,7 @@ fn transcribe_metavar<'tx>(
492
499
}
493
500
494
501
/// Turn `${expr(...)}` metavariable expressionss into tokens.
502
+ #[ inline( always) ] // called once
495
503
fn transcribe_metavar_expr < ' tx > (
496
504
tscx : & mut TranscrCtx < ' tx , ' _ > ,
497
505
dspan : DelimSpan ,
@@ -502,7 +510,7 @@ fn transcribe_metavar_expr<'tx>(
502
510
MetaVarExpr :: Concat ( ref elements) => metavar_expr_concat ( tscx, dspan, elements) ?,
503
511
MetaVarExpr :: Count ( original_ident, depth) => {
504
512
let matched = matched_from_ident ( dcx, original_ident, tscx. interp ) ?;
505
- let count = count_repetitions ( dcx, depth, matched, & tscx. repeats , & dspan) ?;
513
+ let count = count_repetitions ( dcx, depth, matched, & tscx. repeats , dspan) ?;
506
514
TokenTree :: token_alone (
507
515
TokenKind :: lit ( token:: Integer , sym:: integer ( count) , None ) ,
508
516
tscx. visited_dspan ( dspan) ,
@@ -537,6 +545,7 @@ fn transcribe_metavar_expr<'tx>(
537
545
}
538
546
539
547
/// Handle the `${concat(...)}` metavariable expression.
548
+ #[ inline( always) ] // called once
540
549
fn metavar_expr_concat < ' tx > (
541
550
tscx : & mut TranscrCtx < ' tx , ' _ > ,
542
551
dspan : DelimSpan ,
@@ -617,6 +626,7 @@ fn metavar_expr_concat<'tx>(
617
626
/// These are typically used for passing larger amounts of code, and tokens in that code usually
618
627
/// combine with each other and not with tokens outside of the sequence.
619
628
/// - The metavariable span comes from a different crate, then we prefer the more local span.
629
+ #[ inline( always) ] // called once
620
630
fn maybe_use_metavar_location (
621
631
psess : & ParseSess ,
622
632
stack : & [ Frame < ' _ > ] ,
@@ -682,6 +692,7 @@ fn maybe_use_metavar_location(
682
692
/// See the definition of `repeats` in the `transcribe` function. `repeats` is used to descend
683
693
/// into the right place in nested matchers. If we attempt to descend too far, the macro writer has
684
694
/// made a mistake, and we return `None`.
695
+ #[ inline( always) ]
685
696
fn lookup_cur_matched < ' a > (
686
697
ident : MacroRulesNormalizedIdent ,
687
698
interpolations : & ' a FxHashMap < MacroRulesNormalizedIdent , NamedMatch > ,
@@ -722,6 +733,7 @@ impl LockstepIterSize {
722
733
/// - `Unconstrained` is compatible with everything.
723
734
/// - `Contradiction` is incompatible with everything.
724
735
/// - `Constraint(len)` is only compatible with other constraints of the same length.
736
+ #[ inline( always) ]
725
737
fn with ( self , other : LockstepIterSize ) -> LockstepIterSize {
726
738
match self {
727
739
LockstepIterSize :: Unconstrained => other,
@@ -759,6 +771,7 @@ impl LockstepIterSize {
759
771
/// declared at depths which weren't equal or there was a compiler bug. For example, if we have 3 repetitions of
760
772
/// the outer sequence and 4 repetitions of the inner sequence for `x`, we should have the same for
761
773
/// `y`; otherwise, we can't transcribe them both at the given depth.
774
+ #[ inline( always) ]
762
775
fn lockstep_iter_size (
763
776
tree : & mbe:: TokenTree ,
764
777
interpolations : & FxHashMap < MacroRulesNormalizedIdent , NamedMatch > ,
@@ -808,12 +821,13 @@ fn lockstep_iter_size(
808
821
/// * `[ $( ${count(foo, 0)} ),* ]` will be the same as `[ $( ${count(foo)} ),* ]`
809
822
/// * `[ $( ${count(foo, 1)} ),* ]` will return an error because `${count(foo, 1)}` is
810
823
/// declared inside a single repetition and the index `1` implies two nested repetitions.
824
+ #[ inline( always) ] // called once
811
825
fn count_repetitions < ' dx > (
812
826
dcx : DiagCtxtHandle < ' dx > ,
813
827
depth_user : usize ,
814
828
mut matched : & NamedMatch ,
815
829
repeats : & [ ( usize , usize ) ] ,
816
- sp : & DelimSpan ,
830
+ sp : DelimSpan ,
817
831
) -> PResult < ' dx , usize > {
818
832
// Recursively count the number of matches in `matched` at given depth
819
833
// (or at the top-level of `matched` if no depth is given).
@@ -869,6 +883,7 @@ fn count_repetitions<'dx>(
869
883
}
870
884
871
885
/// Returns a `NamedMatch` item declared on the LHS given an arbitrary [Ident]
886
+ #[ inline( always) ]
872
887
fn matched_from_ident < ' ctx , ' interp , ' rslt > (
873
888
dcx : DiagCtxtHandle < ' ctx > ,
874
889
ident : Ident ,
@@ -900,6 +915,7 @@ fn out_of_bounds_err<'a>(dcx: DiagCtxtHandle<'a>, max: usize, span: Span, ty: &s
900
915
}
901
916
902
917
/// Extracts an metavariable symbol that can be an identifier, a token tree or a literal.
918
+ #[ inline( always) ]
903
919
fn extract_symbol_from_pnr < ' a > (
904
920
dcx : DiagCtxtHandle < ' a > ,
905
921
pnr : & ParseNtResult ,
0 commit comments