Skip to content

Commit

Permalink
Provide Expr::Group even with features="full" off
Browse files Browse the repository at this point in the history
  • Loading branch information
dtolnay committed Mar 20, 2023
1 parent cac5cc6 commit 516a5b5
Show file tree
Hide file tree
Showing 9 changed files with 23 additions and 22 deletions.
12 changes: 8 additions & 4 deletions src/expr.rs
Original file line number Diff line number Diff line change
Expand Up @@ -407,7 +407,7 @@ ast_struct! {
/// of expressions and is related to `None`-delimited spans in a
/// `TokenStream`.
#[cfg_attr(doc_cfg, doc(cfg(feature = "full")))]
pub struct ExprGroup #full {
pub struct ExprGroup {
pub attrs: Vec<Attribute>,
pub group_token: token::Group,
pub expr: Box<Expr>,
Expand Down Expand Up @@ -1651,7 +1651,13 @@ pub(crate) mod parsing {

#[cfg(not(feature = "full"))]
fn atom_expr(input: ParseStream, _allow_struct: AllowStruct) -> Result<Expr> {
if input.peek(Lit) {
if input.peek(token::Group)
&& !input.peek2(Token![::])
&& !input.peek2(Token![!])
&& !input.peek2(token::Brace)
{
input.call(expr_group).map(Expr::Group)
} else if input.peek(Lit) {
input.parse().map(Expr::Lit)
} else if input.peek(token::Paren) {
input.call(expr_paren).map(Expr::Paren)
Expand Down Expand Up @@ -1906,7 +1912,6 @@ pub(crate) mod parsing {
}
}

#[cfg(feature = "full")]
fn expr_group(input: ParseStream) -> Result<ExprGroup> {
let group = crate::group::parse_group(input)?;
Ok(ExprGroup {
Expand Down Expand Up @@ -2958,7 +2963,6 @@ pub(crate) mod printing {
}
}

#[cfg(feature = "full")]
#[cfg_attr(doc_cfg, doc(cfg(feature = "printing")))]
impl ToTokens for ExprGroup {
fn to_tokens(&self, tokens: &mut TokenStream) {
Expand Down
3 changes: 1 addition & 2 deletions src/gen/clone.rs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 1 addition & 2 deletions src/gen/debug.rs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 2 additions & 3 deletions src/gen/eq.rs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 3 additions & 3 deletions src/gen/fold.rs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 1 addition & 2 deletions src/gen/hash.rs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 3 additions & 3 deletions src/gen/visit.rs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 3 additions & 3 deletions src/gen/visit_mut.rs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions syn.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 516a5b5

Please sign in to comment.