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 MethodTurbofish in favor of AngleBracketedGenericArguments #1321

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
56 changes: 2 additions & 54 deletions src/expr.rs
Original file line number Diff line number Diff line change
Expand Up @@ -526,7 +526,7 @@ ast_struct! {
pub receiver: Box<Expr>,
pub dot_token: Token![.],
pub method: Ident,
pub turbofish: Option<MethodTurbofish>,
pub turbofish: Option<AngleBracketedGenericArguments>,
pub paren_token: token::Paren,
pub args: Punctuated<Expr, Token![,]>,
}
Expand Down Expand Up @@ -858,19 +858,6 @@ impl IdentFragment for Index {
}
}

#[cfg(feature = "full")]
ast_struct! {
/// The `::<>` explicit type parameters passed to a method call:
/// `parse::<u64>()`.
#[cfg_attr(doc_cfg, doc(cfg(feature = "full")))]
pub struct MethodTurbofish {
pub colon2_token: Token![::],
pub lt_token: Token![<],
pub args: Punctuated<GenericArgument, Token![,]>,
pub gt_token: Token![>],
}
}

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

let member: Member = input.parse()?;
let turbofish = if member.is_named() && input.peek(Token![::]) {
Some(input.parse::<MethodTurbofish>()?)
Some(AngleBracketedGenericArguments::parse_turbofish(input)?)
} else {
None
};
Expand Down Expand Up @@ -1946,34 +1933,6 @@ pub(crate) mod parsing {
})
}

#[cfg(feature = "full")]
#[cfg_attr(doc_cfg, doc(cfg(feature = "parsing")))]
impl Parse for MethodTurbofish {
fn parse(input: ParseStream) -> Result<Self> {
Ok(MethodTurbofish {
colon2_token: input.parse()?,
lt_token: input.parse()?,
args: {
let mut args = Punctuated::new();
loop {
if input.peek(Token![>]) {
break;
}
let value: GenericArgument = input.parse()?;
args.push_value(value);
if input.peek(Token![>]) {
break;
}
let punct = input.parse()?;
args.push_punct(punct);
}
args
},
gt_token: input.parse()?,
})
}
}

#[cfg(feature = "full")]
#[cfg_attr(doc_cfg, doc(cfg(feature = "parsing")))]
impl Parse for ExprLet {
Expand Down Expand Up @@ -2855,17 +2814,6 @@ pub(crate) mod printing {
}
}

#[cfg(feature = "full")]
#[cfg_attr(doc_cfg, doc(cfg(feature = "printing")))]
impl ToTokens for MethodTurbofish {
fn to_tokens(&self, tokens: &mut TokenStream) {
self.colon2_token.to_tokens(tokens);
self.lt_token.to_tokens(tokens);
self.args.to_tokens(tokens);
self.gt_token.to_tokens(tokens);
}
}

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

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

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

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

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

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

19 changes: 2 additions & 17 deletions src/gen/fold.rs

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

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

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

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

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

22 changes: 1 addition & 21 deletions src/gen/visit_mut.rs

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

2 changes: 1 addition & 1 deletion src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -345,7 +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, Label, MethodTurbofish, RangeLimits};
pub use crate::expr::{Arm, FieldValue, Label, RangeLimits};
#[cfg(any(feature = "full", feature = "derive"))]
pub use crate::expr::{
Expr, ExprArray, ExprAssign, ExprAssignOp, ExprAsync, ExprAwait, ExprBinary, ExprBlock,
Expand Down
30 changes: 24 additions & 6 deletions src/path.rs
Original file line number Diff line number Diff line change
Expand Up @@ -328,24 +328,34 @@ pub mod parsing {
Err(lookahead.error())
}

#[cfg_attr(doc_cfg, doc(cfg(feature = "parsing")))]
impl Parse for AngleBracketedGenericArguments {
fn parse(input: ParseStream) -> Result<Self> {
impl AngleBracketedGenericArguments {
/// Parse `::<…>` with mandatory leading `::`.
///
/// The ordinary [`Parse`] impl for `AngleBracketedGenericArguments`
/// parses optional leading `::`.
#[cfg(feature = "full")]
#[cfg_attr(doc_cfg, doc(cfg(all(feature = "parsing", feature = "full"))))]
pub fn parse_turbofish(input: ParseStream) -> Result<Self> {
let colon2_token: Token![::] = input.parse()?;
Self::do_parse(Some(colon2_token), input)
}

fn do_parse(colon2_token: Option<Token![::]>, input: ParseStream) -> Result<Self> {
Ok(AngleBracketedGenericArguments {
colon2_token: input.parse()?,
colon2_token,
lt_token: input.parse()?,
args: {
let mut args = Punctuated::new();
loop {
if input.peek(Token![>]) {
break;
}
let value = input.parse()?;
let value: GenericArgument = input.parse()?;
args.push_value(value);
if input.peek(Token![>]) {
break;
}
let punct = input.parse()?;
let punct: Token![,] = input.parse()?;
args.push_punct(punct);
}
args
Expand All @@ -355,6 +365,14 @@ pub mod parsing {
}
}

#[cfg_attr(doc_cfg, doc(cfg(feature = "parsing")))]
impl Parse for AngleBracketedGenericArguments {
fn parse(input: ParseStream) -> Result<Self> {
let colon2_token: Option<Token![::]> = input.parse()?;
Self::do_parse(colon2_token, input)
}
}

#[cfg_attr(doc_cfg, doc(cfg(feature = "parsing")))]
impl Parse for ParenthesizedGenericArguments {
fn parse(input: ParseStream) -> Result<Self> {
Expand Down
29 changes: 1 addition & 28 deletions syn.json

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

Loading