mirror of
https://github.com/rust-lang/rust.git
synced 2025-06-04 19:29:07 +00:00
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.
This commit is contained in:
parent
02317542eb
commit
29c78cc086
@ -242,14 +242,14 @@ struct TokenCursorFrame {
|
|||||||
}
|
}
|
||||||
|
|
||||||
impl TokenCursorFrame {
|
impl TokenCursorFrame {
|
||||||
fn new(span: DelimSpan, delim: DelimToken, tts: TokenStream) -> Self {
|
fn new(
|
||||||
TokenCursorFrame {
|
span: DelimSpan,
|
||||||
delim,
|
delim: DelimToken,
|
||||||
span,
|
open_delim: bool,
|
||||||
open_delim: false,
|
tts: TokenStream,
|
||||||
tree_cursor: tts.into_trees(),
|
close_delim: bool,
|
||||||
close_delim: false,
|
) -> Self {
|
||||||
}
|
TokenCursorFrame { delim, span, open_delim, tree_cursor: tts.into_trees(), close_delim }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -274,7 +274,7 @@ impl TokenCursor {
|
|||||||
break (token, spacing);
|
break (token, spacing);
|
||||||
}
|
}
|
||||||
TokenTree::Delimited(sp, delim, tts) => {
|
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));
|
self.stack.push(mem::replace(&mut self.frame, frame));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -328,6 +328,7 @@ impl TokenCursor {
|
|||||||
TokenCursorFrame::new(
|
TokenCursorFrame::new(
|
||||||
delim_span,
|
delim_span,
|
||||||
token::NoDelim,
|
token::NoDelim,
|
||||||
|
false,
|
||||||
if attr_style == AttrStyle::Inner {
|
if attr_style == AttrStyle::Inner {
|
||||||
[
|
[
|
||||||
TokenTree::token(token::Pound, span),
|
TokenTree::token(token::Pound, span),
|
||||||
@ -343,6 +344,7 @@ impl TokenCursor {
|
|||||||
.cloned()
|
.cloned()
|
||||||
.collect::<TokenStream>()
|
.collect::<TokenStream>()
|
||||||
},
|
},
|
||||||
|
false,
|
||||||
),
|
),
|
||||||
));
|
));
|
||||||
|
|
||||||
@ -434,9 +436,8 @@ impl<'a> Parser<'a> {
|
|||||||
desugar_doc_comments: bool,
|
desugar_doc_comments: bool,
|
||||||
subparser_name: Option<&'static str>,
|
subparser_name: Option<&'static str>,
|
||||||
) -> Self {
|
) -> Self {
|
||||||
let mut start_frame = TokenCursorFrame::new(DelimSpan::dummy(), token::NoDelim, tokens);
|
let start_frame =
|
||||||
start_frame.open_delim = true;
|
TokenCursorFrame::new(DelimSpan::dummy(), token::NoDelim, true, tokens, true);
|
||||||
start_frame.close_delim = true;
|
|
||||||
|
|
||||||
let mut parser = Parser {
|
let mut parser = Parser {
|
||||||
sess,
|
sess,
|
||||||
|
Loading…
Reference in New Issue
Block a user