diff options
| author | Nicholas Nethercote <n.nethercote@gmail.com> | 2024-07-01 16:12:22 +1000 |
|---|---|---|
| committer | Nicholas Nethercote <n.nethercote@gmail.com> | 2024-07-02 10:46:44 +1000 |
| commit | 8b5a7eb7f4840dcc27e1dcf4a0e102a417ad988f (patch) | |
| tree | 6760868f790c156a7d914cf34c9a44dab45811af /compiler/rustc_parse/src/parser | |
| parent | 2342770f49dcc7e98069efb2db3620d4803c7698 (diff) | |
| download | rust-8b5a7eb7f4840dcc27e1dcf4a0e102a417ad988f.tar.gz rust-8b5a7eb7f4840dcc27e1dcf4a0e102a417ad988f.zip | |
Move things around in `collect_tokens_trailing_token`.
So that the `capturing` state is adjusted immediately before and after the call to `f`.
Diffstat (limited to 'compiler/rustc_parse/src/parser')
| -rw-r--r-- | compiler/rustc_parse/src/parser/attr_wrapper.rs | 14 |
1 files changed, 7 insertions, 7 deletions
diff --git a/compiler/rustc_parse/src/parser/attr_wrapper.rs b/compiler/rustc_parse/src/parser/attr_wrapper.rs index 244a4f26fba..7c22cac350b 100644 --- a/compiler/rustc_parse/src/parser/attr_wrapper.rs +++ b/compiler/rustc_parse/src/parser/attr_wrapper.rs @@ -218,16 +218,16 @@ impl<'a> Parser<'a> { let start_token = (self.token.clone(), self.token_spacing); let cursor_snapshot = self.token_cursor.clone(); let start_pos = self.num_bump_calls; - let has_outer_attrs = !attrs.attrs.is_empty(); - let prev_capturing = std::mem::replace(&mut self.capture_state.capturing, Capturing::Yes); let replace_ranges_start = self.capture_state.replace_ranges.len(); - let ret = f(self, attrs.attrs); - - self.capture_state.capturing = prev_capturing; - - let (mut ret, trailing) = ret?; + let (mut ret, trailing) = { + let prev_capturing = + std::mem::replace(&mut self.capture_state.capturing, Capturing::Yes); + let ret_and_trailing = f(self, attrs.attrs); + self.capture_state.capturing = prev_capturing; + ret_and_trailing? + }; // When we're not in `capture-cfg` mode, then bail out early if: // 1. Our target doesn't support tokens at all (e.g we're parsing an `NtIdent`) |
