Skip to content

Commit

Permalink
Merge pull request #1571 from dtolnay/exprstruct
Browse files Browse the repository at this point in the history
Make Expr::Struct available in non-"full" mode
  • Loading branch information
dtolnay authored Jan 1, 2024
2 parents dc40229 + 3b947f3 commit 1b7119c
Show file tree
Hide file tree
Showing 10 changed files with 48 additions and 55 deletions.
15 changes: 5 additions & 10 deletions src/expr.rs
Original file line number Diff line number Diff line change
Expand Up @@ -590,8 +590,8 @@ ast_struct! {
///
/// The `rest` provides the value of the remaining fields as in `S { a:
/// 1, b: 1, ..rest }`.
#[cfg_attr(doc_cfg, doc(cfg(feature = "full")))]
pub struct ExprStruct #full {
#[cfg_attr(doc_cfg, doc(cfg(any(feature = "full", feature = "derive"))))]
pub struct ExprStruct {
pub attrs: Vec<Attribute>,
pub qself: Option<QSelf>,
pub path: Path,
Expand Down Expand Up @@ -843,10 +843,9 @@ impl IdentFragment for Index {
}
}

#[cfg(feature = "full")]
ast_struct! {
/// A field-value pair in a struct literal.
#[cfg_attr(doc_cfg, doc(cfg(feature = "full")))]
#[cfg_attr(doc_cfg, doc(cfg(any(feature = "full", feature = "derive"))))]
pub struct FieldValue {
pub attrs: Vec<Attribute>,
pub member: Member,
Expand Down Expand Up @@ -1803,7 +1802,8 @@ pub(crate) mod parsing {
}));
}

#[cfg(feature = "full")]
#[cfg(not(feature = "full"))]
let allow_struct = (true,);
if allow_struct.0 && input.peek(token::Brace) {
return expr_struct_helper(input, qself, path).map(Expr::Struct);
}
Expand Down Expand Up @@ -2612,7 +2612,6 @@ pub(crate) mod parsing {
})
}

#[cfg(feature = "full")]
#[cfg_attr(doc_cfg, doc(cfg(feature = "parsing")))]
impl Parse for FieldValue {
fn parse(input: ParseStream) -> Result<Self> {
Expand Down Expand Up @@ -2642,7 +2641,6 @@ pub(crate) mod parsing {
}
}

#[cfg(feature = "full")]
#[cfg_attr(doc_cfg, doc(cfg(feature = "parsing")))]
impl Parse for ExprStruct {
fn parse(input: ParseStream) -> Result<Self> {
Expand All @@ -2651,7 +2649,6 @@ pub(crate) mod parsing {
}
}

#[cfg(feature = "full")]
fn expr_struct_helper(
input: ParseStream,
qself: Option<QSelf>,
Expand Down Expand Up @@ -3333,7 +3330,6 @@ pub(crate) mod printing {
}
}

#[cfg(feature = "full")]
#[cfg_attr(doc_cfg, doc(cfg(feature = "printing")))]
impl ToTokens for ExprStruct {
fn to_tokens(&self, tokens: &mut TokenStream) {
Expand Down Expand Up @@ -3450,7 +3446,6 @@ pub(crate) mod printing {
}
}

#[cfg(feature = "full")]
#[cfg_attr(doc_cfg, doc(cfg(feature = "printing")))]
impl ToTokens for FieldValue {
fn to_tokens(&self, tokens: &mut TokenStream) {
Expand Down
5 changes: 2 additions & 3 deletions src/gen/clone.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/debug.rs

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

9 changes: 4 additions & 5 deletions src/gen/eq.rs

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

18 changes: 9 additions & 9 deletions src/gen/fold.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/hash.rs

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

18 changes: 9 additions & 9 deletions src/gen/visit.rs

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

18 changes: 9 additions & 9 deletions src/gen/visit_mut.rs

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

8 changes: 4 additions & 4 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -349,20 +349,20 @@ pub use crate::error::{Error, Result};
mod expr;
#[cfg(feature = "full")]
#[cfg_attr(doc_cfg, doc(cfg(feature = "full")))]
pub use crate::expr::{Arm, FieldValue, Label, RangeLimits};
pub use crate::expr::{Arm, Label, RangeLimits};
#[cfg(any(feature = "full", feature = "derive"))]
#[cfg_attr(doc_cfg, doc(cfg(any(feature = "full", feature = "derive"))))]
pub use crate::expr::{
Expr, ExprBinary, ExprCall, ExprCast, ExprField, ExprIndex, ExprLit, ExprMacro, ExprMethodCall,
ExprParen, ExprPath, ExprReference, ExprUnary, Index, Member,
ExprParen, ExprPath, ExprReference, ExprStruct, ExprUnary, FieldValue, Index, Member,
};
#[cfg(any(feature = "full", feature = "derive"))]
#[cfg_attr(doc_cfg, doc(cfg(feature = "full")))]
pub use crate::expr::{
ExprArray, ExprAssign, ExprAsync, ExprAwait, ExprBlock, ExprBreak, ExprClosure, ExprConst,
ExprContinue, ExprForLoop, ExprGroup, ExprIf, ExprInfer, ExprLet, ExprLoop, ExprMatch,
ExprRange, ExprRepeat, ExprReturn, ExprStruct, ExprTry, ExprTryBlock, ExprTuple, ExprUnsafe,
ExprWhile, ExprYield,
ExprRange, ExprRepeat, ExprReturn, ExprTry, ExprTryBlock, ExprTuple, ExprUnsafe, ExprWhile,
ExprYield,
};

#[cfg(feature = "parsing")]
Expand Down
2 changes: 2 additions & 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 1b7119c

Please sign in to comment.