Skip to content

Commit

Permalink
Support single identifier as unbraced const generic argument
Browse files Browse the repository at this point in the history
  • Loading branch information
dtolnay committed Jul 9, 2023
1 parent e523c36 commit ed8d784
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion src/path.rs
Original file line number Diff line number Diff line change
Expand Up @@ -368,7 +368,6 @@ pub(crate) mod parsing {
return Ok(Expr::Lit(lit));
}

#[cfg(feature = "full")]
if input.peek(Ident) {
let ident: Ident = input.parse()?;
return Ok(Expr::Path(ExprPath {
Expand Down Expand Up @@ -694,6 +693,14 @@ pub(crate) mod printing {
GenericArgument::Const(expr) => match expr {
Expr::Lit(expr) => expr.to_tokens(tokens),

Expr::Path(expr)
if expr.attrs.is_empty()
&& expr.qself.is_none()
&& expr.path.get_ident().is_some() =>
{
expr.to_tokens(tokens);
}

#[cfg(feature = "full")]
Expr::Block(expr) => expr.to_tokens(tokens),

Expand Down

0 comments on commit ed8d784

Please sign in to comment.