Skip to content

Commit c7deb27

Browse files
committed
Touch up the unsafe traits parsing
1 parent fdbf3fd commit c7deb27

File tree

1 file changed

+4
-6
lines changed

1 file changed

+4
-6
lines changed

src/parse.rs

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -18,14 +18,12 @@ pub enum Item {
1818
impl Parse for Item {
1919
fn parse(input: ParseStream) -> Result<Self> {
2020
let attrs = input.call(Attribute::parse_outer)?;
21-
let first_lookahead = input.lookahead1();
22-
let lookahead = if first_lookahead.peek(Token![unsafe]) {
21+
let mut lookahead = input.lookahead1();
22+
if lookahead.peek(Token![unsafe]) {
2323
let ahead = input.fork();
2424
ahead.parse::<Token![unsafe]>()?;
25-
ahead.lookahead1()
26-
} else {
27-
first_lookahead
28-
};
25+
lookahead = ahead.lookahead1();
26+
}
2927
if lookahead.peek(Token![pub]) || lookahead.peek(Token![trait]) {
3028
let mut item: ItemTrait = input.parse()?;
3129
item.attrs = attrs;

0 commit comments

Comments
 (0)