diff --git a/compiler/rustc_errors/src/lib.rs b/compiler/rustc_errors/src/lib.rs index 207aed8c75545..8c0aa7e5bad5b 100644 --- a/compiler/rustc_errors/src/lib.rs +++ b/compiler/rustc_errors/src/lib.rs @@ -833,6 +833,7 @@ impl DiagCtxt { *fulfilled_expectations = Default::default(); } + #[inline] pub fn handle<'a>(&'a self) -> DiagCtxtHandle<'a> { DiagCtxtHandle { dcx: self, tainted_with_errors: None } } diff --git a/compiler/rustc_expand/src/mbe/transcribe.rs b/compiler/rustc_expand/src/mbe/transcribe.rs index 0520be5fbaee5..3b189971cfe05 100644 --- a/compiler/rustc_expand/src/mbe/transcribe.rs +++ b/compiler/rustc_expand/src/mbe/transcribe.rs @@ -70,6 +70,7 @@ struct TranscrCtx<'psess, 'itp> { impl<'psess> TranscrCtx<'psess, '_> { /// Span marked with the correct expansion and transparency. + #[inline(always)] fn visited_dspan(&mut self, dspan: DelimSpan) -> Span { let mut span = dspan.entire(); self.marker.mark_span(&mut span); @@ -86,6 +87,7 @@ struct Marker { impl Marker { /// Mark a span with the stored expansion ID and transparency. + #[inline(always)] fn mark_span(&mut self, span: &mut Span) { // `apply_mark` is a relatively expensive operation, both due to taking hygiene lock, and // by itself. All tokens in a macro body typically have the same syntactic context, unless @@ -113,6 +115,7 @@ enum FrameKind { } impl<'a> Frame<'a> { + #[inline(always)] fn new_delimited(src: &'a mbe::Delimited, span: DelimSpan, spacing: DelimSpacing) -> Frame<'a> { Frame { tts: &src.tts, @@ -121,6 +124,7 @@ impl<'a> Frame<'a> { } } + #[inline(always)] fn new_sequence( src: &'a mbe::SequenceRepetition, sep: Option, @@ -133,6 +137,7 @@ impl<'a> Frame<'a> { impl<'a> Iterator for Frame<'a> { type Item = &'a mbe::TokenTree; + #[inline(always)] fn next(&mut self) -> Option<&'a mbe::TokenTree> { let res = self.tts.get(self.idx); self.idx += 1; @@ -289,6 +294,7 @@ pub(super) fn transcribe<'a>( } /// Turn `$(...)*` sequences into tokens. +#[inline(always)] // called once fn transcribe_sequence<'tx, 'itp>( tscx: &mut TranscrCtx<'tx, 'itp>, seq: &mbe::TokenTree, @@ -357,6 +363,7 @@ fn transcribe_sequence<'tx, 'itp>( /// producing "xyz", which is bad because it effectively merges tokens. /// `Spacing::Alone` is the safer option. Fortunately, `space_between` will avoid /// some of the unnecessary whitespace. +#[inline(always)] // called once fn transcribe_metavar<'tx>( tscx: &mut TranscrCtx<'tx, '_>, mut sp: Span, @@ -492,6 +499,7 @@ fn transcribe_metavar<'tx>( } /// Turn `${expr(...)}` metavariable expressionss into tokens. +#[inline(always)] // called once fn transcribe_metavar_expr<'tx>( tscx: &mut TranscrCtx<'tx, '_>, dspan: DelimSpan, @@ -502,7 +510,7 @@ fn transcribe_metavar_expr<'tx>( MetaVarExpr::Concat(ref elements) => metavar_expr_concat(tscx, dspan, elements)?, MetaVarExpr::Count(original_ident, depth) => { let matched = matched_from_ident(dcx, original_ident, tscx.interp)?; - let count = count_repetitions(dcx, depth, matched, &tscx.repeats, &dspan)?; + let count = count_repetitions(dcx, depth, matched, &tscx.repeats, dspan)?; TokenTree::token_alone( TokenKind::lit(token::Integer, sym::integer(count), None), tscx.visited_dspan(dspan), @@ -537,6 +545,7 @@ fn transcribe_metavar_expr<'tx>( } /// Handle the `${concat(...)}` metavariable expression. +#[inline(always)] // called once fn metavar_expr_concat<'tx>( tscx: &mut TranscrCtx<'tx, '_>, dspan: DelimSpan, @@ -617,6 +626,7 @@ fn metavar_expr_concat<'tx>( /// These are typically used for passing larger amounts of code, and tokens in that code usually /// combine with each other and not with tokens outside of the sequence. /// - The metavariable span comes from a different crate, then we prefer the more local span. +#[inline(always)] // called once fn maybe_use_metavar_location( psess: &ParseSess, stack: &[Frame<'_>], @@ -682,6 +692,7 @@ fn maybe_use_metavar_location( /// See the definition of `repeats` in the `transcribe` function. `repeats` is used to descend /// into the right place in nested matchers. If we attempt to descend too far, the macro writer has /// made a mistake, and we return `None`. +#[inline(always)] fn lookup_cur_matched<'a>( ident: MacroRulesNormalizedIdent, interpolations: &'a FxHashMap, @@ -722,6 +733,7 @@ impl LockstepIterSize { /// - `Unconstrained` is compatible with everything. /// - `Contradiction` is incompatible with everything. /// - `Constraint(len)` is only compatible with other constraints of the same length. + #[inline(always)] fn with(self, other: LockstepIterSize) -> LockstepIterSize { match self { LockstepIterSize::Unconstrained => other, @@ -759,6 +771,7 @@ impl LockstepIterSize { /// declared at depths which weren't equal or there was a compiler bug. For example, if we have 3 repetitions of /// the outer sequence and 4 repetitions of the inner sequence for `x`, we should have the same for /// `y`; otherwise, we can't transcribe them both at the given depth. +#[inline(always)] fn lockstep_iter_size( tree: &mbe::TokenTree, interpolations: &FxHashMap, @@ -808,12 +821,13 @@ fn lockstep_iter_size( /// * `[ $( ${count(foo, 0)} ),* ]` will be the same as `[ $( ${count(foo)} ),* ]` /// * `[ $( ${count(foo, 1)} ),* ]` will return an error because `${count(foo, 1)}` is /// declared inside a single repetition and the index `1` implies two nested repetitions. +#[inline(always)] // called once fn count_repetitions<'dx>( dcx: DiagCtxtHandle<'dx>, depth_user: usize, mut matched: &NamedMatch, repeats: &[(usize, usize)], - sp: &DelimSpan, + sp: DelimSpan, ) -> PResult<'dx, usize> { // Recursively count the number of matches in `matched` at given depth // (or at the top-level of `matched` if no depth is given). @@ -869,6 +883,7 @@ fn count_repetitions<'dx>( } /// Returns a `NamedMatch` item declared on the LHS given an arbitrary [Ident] +#[inline(always)] fn matched_from_ident<'ctx, 'interp, 'rslt>( dcx: DiagCtxtHandle<'ctx>, ident: Ident, @@ -900,6 +915,7 @@ fn out_of_bounds_err<'a>(dcx: DiagCtxtHandle<'a>, max: usize, span: Span, ty: &s } /// Extracts an metavariable symbol that can be an identifier, a token tree or a literal. +#[inline(always)] fn extract_symbol_from_pnr<'a>( dcx: DiagCtxtHandle<'a>, pnr: &ParseNtResult, diff --git a/compiler/rustc_session/src/parse.rs b/compiler/rustc_session/src/parse.rs index 0118cdb1fc274..fe9d23d8f7b30 100644 --- a/compiler/rustc_session/src/parse.rs +++ b/compiler/rustc_session/src/parse.rs @@ -334,6 +334,7 @@ impl ParseSess { self.proc_macro_quoted_spans.iter_enumerated() } + #[inline] pub fn dcx(&self) -> DiagCtxtHandle<'_> { self.dcx.handle() }