Skip to content

Commit 8d0754d

Browse files
committed
Inline and remove parse_token_tree_non_delim_non_eof.
It has a single call site.
1 parent ce76768 commit 8d0754d

File tree

1 file changed

+14
-16
lines changed

1 file changed

+14
-16
lines changed

compiler/rustc_parse/src/lexer/tokentrees.rs

+14-16
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,20 @@ impl<'a> TokenTreesReader<'a> {
6464
}
6565
return Ok(buf.into_token_stream());
6666
}
67-
_ => buf.push(self.parse_token_tree_non_delim_non_eof()),
67+
_ => {
68+
// `this_spacing` for the returned token refers to whether the token is
69+
// immediately followed by another op token. It is determined by the
70+
// next token: its kind and its `preceded_by_whitespace` status.
71+
let (next_tok, is_next_tok_preceded_by_whitespace) =
72+
self.string_reader.next_token();
73+
let this_spacing = if is_next_tok_preceded_by_whitespace || !next_tok.is_op() {
74+
Spacing::Alone
75+
} else {
76+
Spacing::Joint
77+
};
78+
let this_tok = std::mem::replace(&mut self.token, next_tok);
79+
buf.push(TokenTree::Token(this_tok, this_spacing))
80+
}
6881
}
6982
}
7083
}
@@ -235,21 +248,6 @@ impl<'a> TokenTreesReader<'a> {
235248
err.span_label(self.token.span, "unexpected closing delimiter");
236249
err
237250
}
238-
239-
#[inline]
240-
fn parse_token_tree_non_delim_non_eof(&mut self) -> TokenTree {
241-
// `this_spacing` for the returned token refers to whether the token is
242-
// immediately followed by another op token. It is determined by the
243-
// next token: its kind and its `preceded_by_whitespace` status.
244-
let (next_tok, is_next_tok_preceded_by_whitespace) = self.string_reader.next_token();
245-
let this_spacing = if is_next_tok_preceded_by_whitespace || !next_tok.is_op() {
246-
Spacing::Alone
247-
} else {
248-
Spacing::Joint
249-
};
250-
let this_tok = std::mem::replace(&mut self.token, next_tok);
251-
TokenTree::Token(this_tok, this_spacing)
252-
}
253251
}
254252

255253
#[derive(Default)]

0 commit comments

Comments
 (0)