Fix lookahead with None-delimited group
This commit is contained in:
parent
c18c0ad2bc
commit
eb7b1a150f
2 changed files with 28 additions and 9 deletions
|
@ -929,16 +929,20 @@ impl<'a> Parser<'a> {
|
||||||
return looker(&self.token);
|
return looker(&self.token);
|
||||||
}
|
}
|
||||||
|
|
||||||
let frame = &self.token_cursor.frame;
|
let mut cursor = self.token_cursor.clone();
|
||||||
match frame.tree_cursor.look_ahead(dist - 1) {
|
let mut i = 0;
|
||||||
Some(tree) => match tree {
|
let mut token = Token::dummy();
|
||||||
TokenTree::Token(token) => looker(token),
|
while i < dist {
|
||||||
TokenTree::Delimited(dspan, delim, _) => {
|
token = cursor.next().0;
|
||||||
looker(&Token::new(token::OpenDelim(*delim), dspan.open))
|
if matches!(
|
||||||
}
|
token.kind,
|
||||||
},
|
token::OpenDelim(token::NoDelim) | token::CloseDelim(token::NoDelim)
|
||||||
None => looker(&Token::new(token::CloseDelim(frame.delim), frame.span.close)),
|
) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
i += 1;
|
||||||
}
|
}
|
||||||
|
return looker(&token);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Returns whether any of the given keywords are `dist` tokens ahead of the current one.
|
/// Returns whether any of the given keywords are `dist` tokens ahead of the current one.
|
||||||
|
|
15
src/test/ui/macros/none-delim-lookahead.rs
Normal file
15
src/test/ui/macros/none-delim-lookahead.rs
Normal file
|
@ -0,0 +1,15 @@
|
||||||
|
// check-pass
|
||||||
|
|
||||||
|
macro_rules! make_struct {
|
||||||
|
($name:ident) => {
|
||||||
|
#[derive(Debug)]
|
||||||
|
struct Foo {
|
||||||
|
#[cfg(not(FALSE))]
|
||||||
|
field: fn($name: bool)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
make_struct!(param_name);
|
||||||
|
|
||||||
|
fn main() {}
|
Loading…
Add table
Add a link
Reference in a new issue