Skip to content

Commit

Permalink
Use parse_quote_spanned macro from syn
Browse files Browse the repository at this point in the history
  • Loading branch information
taiki-e committed Dec 26, 2021
1 parent 27dce27 commit ba7d5fd
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 14 deletions.
2 changes: 1 addition & 1 deletion pin-project-internal/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ proc-macro = true
[dependencies]
proc-macro2 = "1"
quote = "1"
syn = { version = "1.0.56", features = ["full", "visit-mut"] }
syn = { version = "1.0.84", features = ["full", "visit-mut"] }

[dev-dependencies]
pin-project = { path = ".." }
7 changes: 4 additions & 3 deletions pin-project-internal/src/pin_project/derive.rs
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
use proc_macro2::{Delimiter, Group, Span, TokenStream};
use quote::{format_ident, quote, quote_spanned, ToTokens};
use syn::{
parse_quote, token, visit_mut::VisitMut, Attribute, Data, DataEnum, DeriveInput, Error, Field,
Fields, FieldsNamed, FieldsUnnamed, Generics, Ident, Index, Lifetime, LifetimeDef, Meta,
MetaList, MetaNameValue, NestedMeta, Result, Token, Type, Variant, Visibility, WhereClause,
parse_quote, parse_quote_spanned, token, visit_mut::VisitMut, Attribute, Data, DataEnum,
DeriveInput, Error, Field, Fields, FieldsNamed, FieldsUnnamed, Generics, Ident, Index,
Lifetime, LifetimeDef, Meta, MetaList, MetaNameValue, NestedMeta, Result, Token, Type, Variant,
Visibility, WhereClause,
};

use super::{
Expand Down
6 changes: 3 additions & 3 deletions pin-project-internal/src/pinned_drop.rs
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
use proc_macro2::TokenStream;
use quote::{format_ident, quote, ToTokens};
use syn::{
parse_quote, spanned::Spanned, visit_mut::VisitMut, Error, FnArg, GenericArgument, ImplItem,
ItemImpl, Pat, PatIdent, Path, PathArguments, Result, ReturnType, Signature, Token, Type,
TypePath, TypeReference,
parse_quote, parse_quote_spanned, spanned::Spanned, visit_mut::VisitMut, Error, FnArg,
GenericArgument, ImplItem, ItemImpl, Pat, PatIdent, Path, PathArguments, Result, ReturnType,
Signature, Token, Type, TypePath, TypeReference,
};

use crate::utils::{parse_as_empty, prepend_underscore_to_self, ReplaceReceiver, SliceExt};
Expand Down
8 changes: 1 addition & 7 deletions pin-project-internal/src/utils.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ use proc_macro2::{Group, Spacing, Span, TokenStream, TokenTree};
use quote::{quote, quote_spanned, ToTokens};
use syn::{
parse::{Parse, ParseBuffer, ParseStream},
parse_quote,
parse_quote, parse_quote_spanned,
punctuated::Punctuated,
token,
visit_mut::{self, VisitMut},
Expand All @@ -30,12 +30,6 @@ macro_rules! bail {
};
}

macro_rules! parse_quote_spanned {
($span:expr => $($tt:tt)*) => {
syn::parse2(quote::quote_spanned!($span => $($tt)*)).unwrap_or_else(|e| panic!("{}", e))
};
}

/// Determines the lifetime names. Ensure it doesn't overlap with any existing
/// lifetime names.
pub(crate) fn determine_lifetime_name(lifetime_name: &mut String, generics: &mut Generics) {
Expand Down

0 comments on commit ba7d5fd

Please sign in to comment.