Skip to content

Commit

Permalink
Touch up the unsafe traits parsing
Browse files Browse the repository at this point in the history
  • Loading branch information
dtolnay committed Oct 13, 2019
1 parent fdbf3fd commit c7deb27
Showing 1 changed file with 4 additions and 6 deletions.
10 changes: 4 additions & 6 deletions src/parse.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,14 +18,12 @@ pub enum Item {
impl Parse for Item {
fn parse(input: ParseStream) -> Result<Self> {
let attrs = input.call(Attribute::parse_outer)?;
let first_lookahead = input.lookahead1();
let lookahead = if first_lookahead.peek(Token![unsafe]) {
let mut lookahead = input.lookahead1();
if lookahead.peek(Token![unsafe]) {
let ahead = input.fork();
ahead.parse::<Token![unsafe]>()?;
ahead.lookahead1()
} else {
first_lookahead
};
lookahead = ahead.lookahead1();
}
if lookahead.peek(Token![pub]) || lookahead.peek(Token![trait]) {
let mut item: ItemTrait = input.parse()?;
item.attrs = attrs;
Expand Down

0 comments on commit c7deb27

Please sign in to comment.