Skip to content
This repository was archived by the owner on May 28, 2025. It is now read-only.

Commit 29c78cc

Browse files
committed
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.
1 parent 0231754 commit 29c78cc

File tree

1 file changed

+13
-12
lines changed
  • compiler/rustc_parse/src/parser

1 file changed

+13
-12
lines changed

compiler/rustc_parse/src/parser/mod.rs

Lines changed: 13 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -242,14 +242,14 @@ struct TokenCursorFrame {
242242
}
243243

244244
impl TokenCursorFrame {
245-
fn new(span: DelimSpan, delim: DelimToken, tts: TokenStream) -> Self {
246-
TokenCursorFrame {
247-
delim,
248-
span,
249-
open_delim: false,
250-
tree_cursor: tts.into_trees(),
251-
close_delim: false,
252-
}
245+
fn new(
246+
span: DelimSpan,
247+
delim: DelimToken,
248+
open_delim: bool,
249+
tts: TokenStream,
250+
close_delim: bool,
251+
) -> Self {
252+
TokenCursorFrame { delim, span, open_delim, tree_cursor: tts.into_trees(), close_delim }
253253
}
254254
}
255255

@@ -274,7 +274,7 @@ impl TokenCursor {
274274
break (token, spacing);
275275
}
276276
TokenTree::Delimited(sp, delim, tts) => {
277-
let frame = TokenCursorFrame::new(sp, delim, tts);
277+
let frame = TokenCursorFrame::new(sp, delim, false, tts, false);
278278
self.stack.push(mem::replace(&mut self.frame, frame));
279279
}
280280
}
@@ -328,6 +328,7 @@ impl TokenCursor {
328328
TokenCursorFrame::new(
329329
delim_span,
330330
token::NoDelim,
331+
false,
331332
if attr_style == AttrStyle::Inner {
332333
[
333334
TokenTree::token(token::Pound, span),
@@ -343,6 +344,7 @@ impl TokenCursor {
343344
.cloned()
344345
.collect::<TokenStream>()
345346
},
347+
false,
346348
),
347349
));
348350

@@ -434,9 +436,8 @@ impl<'a> Parser<'a> {
434436
desugar_doc_comments: bool,
435437
subparser_name: Option<&'static str>,
436438
) -> Self {
437-
let mut start_frame = TokenCursorFrame::new(DelimSpan::dummy(), token::NoDelim, tokens);
438-
start_frame.open_delim = true;
439-
start_frame.close_delim = true;
439+
let start_frame =
440+
TokenCursorFrame::new(DelimSpan::dummy(), token::NoDelim, true, tokens, true);
440441

441442
let mut parser = Parser {
442443
sess,

0 commit comments

Comments
 (0)