diff options
| author | Nicholas Nethercote <n.nethercote@gmail.com> | 2022-04-19 13:51:12 +1000 |
|---|---|---|
| committer | Nicholas Nethercote <n.nethercote@gmail.com> | 2022-04-19 17:02:48 +1000 |
| commit | 29c78cc086d55b46401f3ba9ca89ad6e95c57c8d (patch) | |
| tree | 9ded09e1327a2e125e80c086f432325bec9cddcc /compiler/rustc_parse/src/parser | |
| parent | 02317542ebceef780ddac660d751cbe268f56105 (diff) | |
| download | rust-29c78cc086d55b46401f3ba9ca89ad6e95c57c8d.tar.gz rust-29c78cc086d55b46401f3ba9ca89ad6e95c57c8d.zip | |
Add {open,close}_delim arguments to `TokenCursorFrame::new()`.
This will facilitate the change in the next commit. `boolean` arguments aren't great, but the function is only used in three places within this one file.
Diffstat (limited to 'compiler/rustc_parse/src/parser')
| -rw-r--r-- | compiler/rustc_parse/src/parser/mod.rs | 25 |
1 files changed, 13 insertions, 12 deletions
diff --git a/compiler/rustc_parse/src/parser/mod.rs b/compiler/rustc_parse/src/parser/mod.rs index 513a95234ab..2e2fc6694a5 100644 --- a/compiler/rustc_parse/src/parser/mod.rs +++ b/compiler/rustc_parse/src/parser/mod.rs @@ -242,14 +242,14 @@ struct TokenCursorFrame { } impl TokenCursorFrame { - fn new(span: DelimSpan, delim: DelimToken, tts: TokenStream) -> Self { - TokenCursorFrame { - delim, - span, - open_delim: false, - tree_cursor: tts.into_trees(), - close_delim: false, - } + fn new( + span: DelimSpan, + delim: DelimToken, + open_delim: bool, + tts: TokenStream, + close_delim: bool, + ) -> Self { + TokenCursorFrame { delim, span, open_delim, tree_cursor: tts.into_trees(), close_delim } } } @@ -274,7 +274,7 @@ impl TokenCursor { break (token, spacing); } TokenTree::Delimited(sp, delim, tts) => { - let frame = TokenCursorFrame::new(sp, delim, tts); + let frame = TokenCursorFrame::new(sp, delim, false, tts, false); self.stack.push(mem::replace(&mut self.frame, frame)); } } @@ -328,6 +328,7 @@ impl TokenCursor { TokenCursorFrame::new( delim_span, token::NoDelim, + false, if attr_style == AttrStyle::Inner { [ TokenTree::token(token::Pound, span), @@ -343,6 +344,7 @@ impl TokenCursor { .cloned() .collect::<TokenStream>() }, + false, ), )); @@ -434,9 +436,8 @@ impl<'a> Parser<'a> { desugar_doc_comments: bool, subparser_name: Option<&'static str>, ) -> Self { - let mut start_frame = TokenCursorFrame::new(DelimSpan::dummy(), token::NoDelim, tokens); - start_frame.open_delim = true; - start_frame.close_delim = true; + let start_frame = + TokenCursorFrame::new(DelimSpan::dummy(), token::NoDelim, true, tokens, true); let mut parser = Parser { sess, |
