diff options
| author | Nicholas Nethercote <n.nethercote@gmail.com> | 2024-03-20 07:08:22 +1100 |
|---|---|---|
| committer | Nicholas Nethercote <n.nethercote@gmail.com> | 2024-03-21 10:18:28 +1100 |
| commit | d4ad322b5d38dbdb4aeddbead04dd3e592b374fb (patch) | |
| tree | cdb683b09d9e40016b092fb8fdb472782a499157 /compiler/rustc_parse/src/parser/mod.rs | |
| parent | 8ac16c6193f6b694e5b05ff2209caafac792e760 (diff) | |
| download | rust-d4ad322b5d38dbdb4aeddbead04dd3e592b374fb.tar.gz rust-d4ad322b5d38dbdb4aeddbead04dd3e592b374fb.zip | |
Use `maybe_whole!` to streamline `parse_item_common`.
This requires changing `maybe_whole!` so it allows the value to be modified.
Diffstat (limited to 'compiler/rustc_parse/src/parser/mod.rs')
| -rw-r--r-- | compiler/rustc_parse/src/parser/mod.rs | 13 |
1 files changed, 7 insertions, 6 deletions
diff --git a/compiler/rustc_parse/src/parser/mod.rs b/compiler/rustc_parse/src/parser/mod.rs index 125e77d8ee7..78233e0f8b5 100644 --- a/compiler/rustc_parse/src/parser/mod.rs +++ b/compiler/rustc_parse/src/parser/mod.rs @@ -93,12 +93,13 @@ pub enum TrailingToken { #[macro_export] macro_rules! maybe_whole { ($p:expr, $constructor:ident, |$x:ident| $e:expr) => { - if let token::Interpolated(nt) = &$p.token.kind { - if let token::$constructor(x) = &nt.0 { - let $x = x.clone(); - $p.bump(); - return Ok($e); - } + if let token::Interpolated(nt) = &$p.token.kind + && let token::$constructor(x) = &nt.0 + { + #[allow(unused_mut)] + let mut $x = x.clone(); + $p.bump(); + return Ok($e); } }; } |
