Skip to content

Commit 8b5a7eb

Browse files
committed
Move things around in collect_tokens_trailing_token.
So that the `capturing` state is adjusted immediately before and after the call to `f`.
1 parent 2342770 commit 8b5a7eb

File tree

1 file changed

+7
-7
lines changed

1 file changed

+7
-7
lines changed

compiler/rustc_parse/src/parser/attr_wrapper.rs

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -218,16 +218,16 @@ impl<'a> Parser<'a> {
218218
let start_token = (self.token.clone(), self.token_spacing);
219219
let cursor_snapshot = self.token_cursor.clone();
220220
let start_pos = self.num_bump_calls;
221-
222221
let has_outer_attrs = !attrs.attrs.is_empty();
223-
let prev_capturing = std::mem::replace(&mut self.capture_state.capturing, Capturing::Yes);
224222
let replace_ranges_start = self.capture_state.replace_ranges.len();
225223

226-
let ret = f(self, attrs.attrs);
227-
228-
self.capture_state.capturing = prev_capturing;
229-
230-
let (mut ret, trailing) = ret?;
224+
let (mut ret, trailing) = {
225+
let prev_capturing =
226+
std::mem::replace(&mut self.capture_state.capturing, Capturing::Yes);
227+
let ret_and_trailing = f(self, attrs.attrs);
228+
self.capture_state.capturing = prev_capturing;
229+
ret_and_trailing?
230+
};
231231

232232
// When we're not in `capture-cfg` mode, then bail out early if:
233233
// 1. Our target doesn't support tokens at all (e.g we're parsing an `NtIdent`)

0 commit comments

Comments
 (0)