Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Delete GenericMethodArgument in favor of GenericArgument #1320

Merged
merged 1 commit into from
Jan 23, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
48 changes: 2 additions & 46 deletions src/expr.rs
Original file line number Diff line number Diff line change
Expand Up @@ -866,26 +866,11 @@ ast_struct! {
pub struct MethodTurbofish {
pub colon2_token: Token![::],
pub lt_token: Token![<],
pub args: Punctuated<GenericMethodArgument, Token![,]>,
pub args: Punctuated<GenericArgument, Token![,]>,
pub gt_token: Token![>],
}
}

#[cfg(feature = "full")]
ast_enum! {
/// An individual generic argument to a method, like `T`.
#[cfg_attr(doc_cfg, doc(cfg(feature = "full")))]
pub enum GenericMethodArgument {
/// A type argument.
Type(Type),
/// A const expression. Must be inside of a block.
///
/// NOTE: Identity expressions are represented as Type arguments, as
/// they are indistinguishable syntactically.
Const(Expr),
}
}

#[cfg(feature = "full")]
ast_struct! {
/// A field-value pair in a struct literal.
Expand Down Expand Up @@ -1961,24 +1946,6 @@ pub(crate) mod parsing {
})
}

#[cfg(feature = "full")]
#[cfg_attr(doc_cfg, doc(cfg(feature = "parsing")))]
impl Parse for GenericMethodArgument {
fn parse(input: ParseStream) -> Result<Self> {
if input.peek(Lit) {
let lit = input.parse()?;
return Ok(GenericMethodArgument::Const(Expr::Lit(lit)));
}

if input.peek(token::Brace) {
let block: ExprBlock = input.parse()?;
return Ok(GenericMethodArgument::Const(Expr::Block(block)));
}

input.parse().map(GenericMethodArgument::Type)
}
}

#[cfg(feature = "full")]
#[cfg_attr(doc_cfg, doc(cfg(feature = "parsing")))]
impl Parse for MethodTurbofish {
Expand All @@ -1992,7 +1959,7 @@ pub(crate) mod parsing {
if input.peek(Token![>]) {
break;
}
let value: GenericMethodArgument = input.parse()?;
let value: GenericArgument = input.parse()?;
args.push_value(value);
if input.peek(Token![>]) {
break;
Expand Down Expand Up @@ -2899,17 +2866,6 @@ pub(crate) mod printing {
}
}

#[cfg(feature = "full")]
#[cfg_attr(doc_cfg, doc(cfg(feature = "printing")))]
impl ToTokens for GenericMethodArgument {
fn to_tokens(&self, tokens: &mut TokenStream) {
match self {
GenericMethodArgument::Type(t) => t.to_tokens(tokens),
GenericMethodArgument::Const(c) => c.to_tokens(tokens),
}
}
}

#[cfg(feature = "full")]
#[cfg_attr(doc_cfg, doc(cfg(feature = "printing")))]
impl ToTokens for ExprTuple {
Expand Down
10 changes: 0 additions & 10 deletions src/gen/clone.rs

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

18 changes: 0 additions & 18 deletions src/gen/debug.rs

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

19 changes: 0 additions & 19 deletions src/gen/eq.rs

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

26 changes: 1 addition & 25 deletions src/gen/fold.rs

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

19 changes: 0 additions & 19 deletions src/gen/hash.rs

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

23 changes: 1 addition & 22 deletions src/gen/visit.rs

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

20 changes: 1 addition & 19 deletions src/gen/visit_mut.rs

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

4 changes: 1 addition & 3 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -345,9 +345,7 @@ pub use crate::error::{Error, Result};
#[cfg(any(feature = "full", feature = "derive"))]
mod expr;
#[cfg(feature = "full")]
pub use crate::expr::{
Arm, FieldValue, GenericMethodArgument, Label, MethodTurbofish, RangeLimits,
};
pub use crate::expr::{Arm, FieldValue, Label, MethodTurbofish, RangeLimits};
#[cfg(any(feature = "full", feature = "derive"))]
pub use crate::expr::{
Expr, ExprArray, ExprAssign, ExprAssignOp, ExprAsync, ExprAwait, ExprBinary, ExprBlock,
Expand Down
22 changes: 1 addition & 21 deletions syn.json

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

21 changes: 0 additions & 21 deletions tests/debug/gen.rs

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

Loading