diff --git a/src/expr.rs b/src/expr.rs index ebceca1f9f..f8eca1d3fb 100644 --- a/src/expr.rs +++ b/src/expr.rs @@ -1684,10 +1684,7 @@ pub(crate) mod parsing { if qself.is_none() && input.peek(Token![!]) && !input.peek(Token![!=]) - && path - .segments - .iter() - .all(|segment| segment.arguments.is_none()) + && path.is_mod_style() { let bang_token: Token![!] = input.parse()?; let (delimiter, tokens) = mac::parse_delimiter(input)?; diff --git a/src/pat.rs b/src/pat.rs index 9338d6fccc..5833eeb332 100644 --- a/src/pat.rs +++ b/src/pat.rs @@ -382,10 +382,7 @@ pub(crate) mod parsing { if qself.is_none() && input.peek(Token![!]) && !input.peek(Token![!=]) - && path - .segments - .iter() - .all(|segment| segment.arguments.is_none()) + && path.is_mod_style() { let bang_token: Token![!] = input.parse()?; let (delimiter, tokens) = mac::parse_delimiter(input)?; diff --git a/src/path.rs b/src/path.rs index 969a9865cb..e99a3f87d0 100644 --- a/src/path.rs +++ b/src/path.rs @@ -584,6 +584,12 @@ pub(crate) mod parsing { } Ok(()) } + + pub(crate) fn is_mod_style(&self) -> bool { + self.segments + .iter() + .all(|segment| segment.arguments.is_none()) + } } pub(crate) fn qpath(input: ParseStream, expr_style: bool) -> Result<(Option, Path)> { diff --git a/src/ty.rs b/src/ty.rs index 37523f480e..69d0deedf0 100644 --- a/src/ty.rs +++ b/src/ty.rs @@ -477,14 +477,7 @@ pub(crate) mod parsing { return Ok(Type::Path(ty)); } - if input.peek(Token![!]) - && !input.peek(Token![!=]) - && ty - .path - .segments - .iter() - .all(|segment| segment.arguments.is_none()) - { + if input.peek(Token![!]) && !input.peek(Token![!=]) && ty.path.is_mod_style() { let bang_token: Token![!] = input.parse()?; let (delimiter, tokens) = mac::parse_delimiter(input)?; return Ok(Type::Macro(TypeMacro {