Skip to content

Commit

Permalink
Update proc-macro2, syn and quote to 1.0
Browse files Browse the repository at this point in the history
  • Loading branch information
hobofan committed Aug 20, 2019
1 parent 007cc77 commit 005f7bc
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 19 deletions.
6 changes: 3 additions & 3 deletions crates/macro/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,9 @@ proc-macro = true
boolinator = "2.4.0"
lazy_static = "1.3.0"
proc-macro-hack = "0.5"
proc-macro2 = "0.4"
quote = "0.6"
syn = { version = "^0.15.34", features = ["full", "extra-traits"] }
proc-macro2 = "1.0"
quote = "1.0"
syn = { version = "1.0", features = ["full", "extra-traits"] }

[dev-dependencies]
yew = { path = "../.." }
Expand Down
12 changes: 4 additions & 8 deletions crates/macro/src/derive_props/builder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ use super::generics::{to_arguments, with_param_bounds, GenericArguments};
use super::{DerivePropsInput, PropField};
use proc_macro2::{Ident, Span};
use quote::{quote, ToTokens};
use std::iter;

pub struct PropsBuilder<'a> {
builder_name: &'a Ident,
Expand All @@ -36,12 +35,9 @@ impl ToTokens for PropsBuilder<'_> {
..
} = props;

let step_trait_repeat = iter::repeat(step_trait);
let vis_repeat = iter::repeat(&vis);

let build_step = self.build_step();
let impl_steps = self.impl_steps();
let set_fields = self.set_fields();
let impl_steps = self.impl_steps().into_iter();
let set_fields = self.set_fields().into_iter();

let (impl_generics, ty_generics, where_clause) = generics.split_for_impl();
let turbofish_generics = ty_generics.as_turbofish();
Expand All @@ -59,13 +55,13 @@ impl ToTokens for PropsBuilder<'_> {
let builder = quote! {
#(
#[doc(hidden)]
#vis_repeat struct #step_names;
#vis struct #step_names;
)*

#[doc(hidden)]
#vis trait #step_trait {}

#(impl #step_trait_repeat for #step_names {})*
#(impl #step_trait for #step_names {})*

#[doc(hidden)]
#vis struct #builder_name#step_generics {
Expand Down
7 changes: 3 additions & 4 deletions crates/macro/src/derive_props/field.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ use quote::quote;
use std::cmp::{Ord, Ordering, PartialEq, PartialOrd};
use std::convert::TryFrom;
use syn::parse::Result;
use syn::punctuated;
use syn::spanned::Spanned;
use syn::{Error, Field, Meta, MetaList, NestedMeta, Type, Visibility};

Expand Down Expand Up @@ -122,11 +121,11 @@ impl PropField {
};

let word_ident = match first_nested {
punctuated::Pair::End(NestedMeta::Meta(Meta::Word(ident))) => ident,
NestedMeta::Meta(Meta::Path(path)) => path.get_ident(),
_ => return Err(expected_required),
};

if word_ident != "required" {
if word_ident.map(|ident| ident.to_string()) != Some("required".to_owned()) {
return Err(expected_required);
}

Expand All @@ -149,7 +148,7 @@ impl PropField {
_ => None,
})?;

if meta_list.ident == "props" {
if meta_list.path.get_ident().map(|ident| ident.to_string()) == Some("props".to_owned()) {
Some(meta_list)
} else {
None
Expand Down
5 changes: 1 addition & 4 deletions crates/macro/src/html_tree/html_tag/tag_attributes.rs
Original file line number Diff line number Diff line change
Expand Up @@ -144,10 +144,7 @@ impl TagAttributes {
));
}

let var = match inputs.first().unwrap().into_value() {
syn::FnArg::Inferred(pat) => pat,
_ => return Err(syn::Error::new_spanned(or_span, "invalid closure argument")),
};
let var = inputs.first().unwrap();
let handler =
Ident::new(&format!("__yew_{}_handler", name.to_string()), name.span());
let listener =
Expand Down

0 comments on commit 005f7bc

Please sign in to comment.