Skip to content

Commit

Permalink
Factor out Path::is_mod_style private method
Browse files Browse the repository at this point in the history
  • Loading branch information
dtolnay committed Mar 22, 2023
1 parent 736d479 commit 99de683
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 16 deletions.
5 changes: 1 addition & 4 deletions src/expr.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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)?;
Expand Down
5 changes: 1 addition & 4 deletions src/pat.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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)?;
Expand Down
6 changes: 6 additions & 0 deletions src/path.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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<QSelf>, Path)> {
Expand Down
9 changes: 1 addition & 8 deletions src/ty.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down

0 comments on commit 99de683

Please sign in to comment.