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

Update proc-macro2, syn and quote to 1.0 #608

Merged
merged 1 commit into from
Aug 21, 2019

Conversation

hobofan
Copy link
Contributor

@hobofan hobofan commented Aug 20, 2019

CLOSES #590

I also tried to lift the recursion limits in the examples, but it looks like they are still required (maybe due to macros from stdweb?).

Copy link
Member

@jstarry jstarry left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great, thanks for jumping on this! That's a bummer that the recursion limit didn't go down :/

syn::FnArg::Inferred(pat) => pat,
_ => return Err(syn::Error::new_spanned(or_span, "invalid closure argument")),
};
let var = inputs.first().unwrap();
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We actually can't handle all Pat types. I think we only want to cover Pat::Ident and Pat::Wild. Here's a code snippet only handling Ident:

let var = match inputs.first().unwrap() {
  Pat::Ident(ident) => Ok(ident),
   _ => Err(syn::Error::new_spanned(or_span, "unsupported closure argument")),
}?;

@@ -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()) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

How about trying to avoid the to_owned allocation and use a helper fn like this:

fn match_path(path: &Path, id_str: &str) -> bool {
    if let Some(ident) = path.get_ident() {
        ident == id_str
    } else {
        false
    }
}

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I just found Path::is_ident(), which does that

crates/macro/src/derive_props/builder.rs Outdated Show resolved Hide resolved
crates/macro/src/derive_props/builder.rs Outdated Show resolved Hide resolved
@jstarry
Copy link
Member

jstarry commented Aug 21, 2019

In order to fix the macro tests you will have to follow these steps:

  1. Remove *.stderr files for the failing tets
  2. Run cargo test --test macro_test
  3. Copy the new generated *.stderr files from the wip dir into the test dir

@hobofan
Copy link
Contributor Author

hobofan commented Aug 21, 2019

@jstarry Thanks for the feedback! Ready for review again.

Copy link
Member

@jstarry jstarry left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks great! Good find with is_ident :)

@jstarry
Copy link
Member

jstarry commented Aug 21, 2019

bors r+

bors bot added a commit that referenced this pull request Aug 21, 2019
608: Update proc-macro2, syn and quote to 1.0 r=jstarry a=hobofan

CLOSES #590

I also tried to lift the recursion limits in the examples, but it looks like they are still required (maybe due to macros from stdweb?).

Co-authored-by: Maximilian Goisser <goisser94@gmail.com>
@bors
Copy link
Contributor

bors bot commented Aug 21, 2019

Build succeeded

  • continuous-integration/travis-ci/push

@bors bors bot merged commit c97d23c into yewstack:master Aug 21, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Update proc macros to use quote 1.0
2 participants