diff options
| author | Nicholas Nethercote <n.nethercote@gmail.com> | 2022-04-11 09:52:34 +1000 |
|---|---|---|
| committer | Nicholas Nethercote <n.nethercote@gmail.com> | 2022-04-13 11:17:31 +1000 |
| commit | 2657d8f7b3bbdebb7c6428b8d08279504fbfbc3f (patch) | |
| tree | 9839308fa86cbf6571348f96a775e503335d2aa9 | |
| parent | 1a7006482e1bb6cb3498c90e19dbca8b157d5c07 (diff) | |
| download | rust-2657d8f7b3bbdebb7c6428b8d08279504fbfbc3f.tar.gz rust-2657d8f7b3bbdebb7c6428b8d08279504fbfbc3f.zip | |
Pass a slice instead of a `Vec` to `transcribe`.
It avoids some unnecessary allocations.
| -rw-r--r-- | compiler/rustc_expand/src/mbe/macro_rules.rs | 4 | ||||
| -rw-r--r-- | compiler/rustc_expand/src/mbe/transcribe.rs | 2 |
2 files changed, 3 insertions, 3 deletions
diff --git a/compiler/rustc_expand/src/mbe/macro_rules.rs b/compiler/rustc_expand/src/mbe/macro_rules.rs index f5c7186bc4b..c9a06728856 100644 --- a/compiler/rustc_expand/src/mbe/macro_rules.rs +++ b/compiler/rustc_expand/src/mbe/macro_rules.rs @@ -263,14 +263,14 @@ fn generic_extension<'cx, 'tt>( // Ignore the delimiters on the RHS. let rhs = match &rhses[i] { - mbe::TokenTree::Delimited(_, delimited) => delimited.tts.to_vec(), + mbe::TokenTree::Delimited(_, delimited) => &delimited.tts, _ => cx.span_bug(sp, "malformed macro rhs"), }; let arm_span = rhses[i].span(); let rhs_spans = rhs.iter().map(|t| t.span()).collect::<Vec<_>>(); // rhs has holes ( `$id` and `$(...)` that need filled) - let mut tts = match transcribe(cx, &named_matches, rhs, transparency) { + let mut tts = match transcribe(cx, &named_matches, &rhs, transparency) { Ok(tts) => tts, Err(mut err) => { err.emit(); diff --git a/compiler/rustc_expand/src/mbe/transcribe.rs b/compiler/rustc_expand/src/mbe/transcribe.rs index ca2908d7923..d25f044234c 100644 --- a/compiler/rustc_expand/src/mbe/transcribe.rs +++ b/compiler/rustc_expand/src/mbe/transcribe.rs @@ -85,7 +85,7 @@ impl<'a> Iterator for Frame<'a> { pub(super) fn transcribe<'a>( cx: &ExtCtxt<'a>, interp: &FxHashMap<MacroRulesNormalizedIdent, NamedMatch>, - src: Vec<mbe::TokenTree>, + src: &[mbe::TokenTree], transparency: Transparency, ) -> PResult<'a, TokenStream> { // Nothing for us to transcribe... |
