Skip to content

Commit

Permalink
Parse visibility on impl blocks
Browse files Browse the repository at this point in the history
  • Loading branch information
dtolnay committed Apr 27, 2021
1 parent 7065998 commit 408525d
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion src/item.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2458,6 +2458,7 @@ pub mod parsing {

fn parse_impl(input: ParseStream, allow_verbatim_impl: bool) -> Result<Option<ItemImpl>> {
let mut attrs = input.call(Attribute::parse_outer)?;
let has_visibility = allow_verbatim_impl && input.parse::<Visibility>()?.is_some();
let defaultness: Option<Token![default]> = input.parse()?;
let unsafety: Option<Token![unsafe]> = input.parse()?;
let impl_token: Token![impl] = input.parse()?;
Expand Down Expand Up @@ -2541,7 +2542,7 @@ pub mod parsing {
items.push(content.parse()?);
}

if is_const_impl || is_impl_for && trait_.is_none() {
if has_visibility || is_const_impl || is_impl_for && trait_.is_none() {
Ok(None)
} else {
Ok(Some(ItemImpl {
Expand Down

0 comments on commit 408525d

Please sign in to comment.