diff options
| author | Nicholas Nethercote <n.nethercote@gmail.com> | 2022-09-30 16:50:02 +1000 |
|---|---|---|
| committer | Nicholas Nethercote <n.nethercote@gmail.com> | 2022-10-03 11:42:29 +1100 |
| commit | 8d0754d602d8d6fd2b357d98ee0bdaf2382b937a (patch) | |
| tree | fa6de9aa9501467e309c89648e728bc960bdf924 /compiler/rustc_parse/src | |
| parent | ce7676829e4786a44e8199e5df6e0cf9035a6d0f (diff) | |
| download | rust-8d0754d602d8d6fd2b357d98ee0bdaf2382b937a.tar.gz rust-8d0754d602d8d6fd2b357d98ee0bdaf2382b937a.zip | |
Inline and remove `parse_token_tree_non_delim_non_eof`.
It has a single call site.
Diffstat (limited to 'compiler/rustc_parse/src')
| -rw-r--r-- | compiler/rustc_parse/src/lexer/tokentrees.rs | 30 |
1 files changed, 14 insertions, 16 deletions
diff --git a/compiler/rustc_parse/src/lexer/tokentrees.rs b/compiler/rustc_parse/src/lexer/tokentrees.rs index b06f23d7c7b..e3ccfc65462 100644 --- a/compiler/rustc_parse/src/lexer/tokentrees.rs +++ b/compiler/rustc_parse/src/lexer/tokentrees.rs @@ -64,7 +64,20 @@ impl<'a> TokenTreesReader<'a> { } return Ok(buf.into_token_stream()); } - _ => buf.push(self.parse_token_tree_non_delim_non_eof()), + _ => { + // `this_spacing` for the returned token refers to whether the token is + // immediately followed by another op token. It is determined by the + // next token: its kind and its `preceded_by_whitespace` status. + let (next_tok, is_next_tok_preceded_by_whitespace) = + self.string_reader.next_token(); + let this_spacing = if is_next_tok_preceded_by_whitespace || !next_tok.is_op() { + Spacing::Alone + } else { + Spacing::Joint + }; + let this_tok = std::mem::replace(&mut self.token, next_tok); + buf.push(TokenTree::Token(this_tok, this_spacing)) + } } } } @@ -235,21 +248,6 @@ impl<'a> TokenTreesReader<'a> { err.span_label(self.token.span, "unexpected closing delimiter"); err } - - #[inline] - fn parse_token_tree_non_delim_non_eof(&mut self) -> TokenTree { - // `this_spacing` for the returned token refers to whether the token is - // immediately followed by another op token. It is determined by the - // next token: its kind and its `preceded_by_whitespace` status. - let (next_tok, is_next_tok_preceded_by_whitespace) = self.string_reader.next_token(); - let this_spacing = if is_next_tok_preceded_by_whitespace || !next_tok.is_op() { - Spacing::Alone - } else { - Spacing::Joint - }; - let this_tok = std::mem::replace(&mut self.token, next_tok); - TokenTree::Token(this_tok, this_spacing) - } } #[derive(Default)] |
