TedDriggs / darling

A Rust proc-macro attribute parser
MIT License
983 stars 66 forks source link

Feature/parse attr #279

Closed cathaysia closed 6 months ago

cathaysia commented 6 months ago

continue of #277

NOTE: I add the permission, so you can push commits to cathaysia:feature/parse_attr, then it will autoupdate to this pr.

cathaysia commented 6 months ago

In the previous pr, you add a comment: https://github.com/TedDriggs/darling/pull/277#issuecomment-1988424260, I don't quite understand what you mean. What function do you want to achieve, or what is wrong with the current implementation?

TedDriggs commented 6 months ago

I expect this to pass: let x: NegatableIdentList = parse_meta!(inner(example::flag, my_feature)); - it didn't, which seems to be an issue with the macro construction where commas end the tt.

cathaysia commented 6 months ago

Can you give a more detailed, working example? (Can be used to test parse_meta)

TedDriggs commented 6 months ago

If I could give you a working example, then the PR wouldn't need amendment. Try using the macro with anything that contains a comma, and you get an error because the tt stops consuming at that point.

cathaysia commented 6 months ago

I don't quite understand the purpose of this way of writing. What is inner(example::flag, my_feature)? Is it a function that returns a TokenStream?

TedDriggs commented 6 months ago

Oh, wow, I'm sorry - this is entirely on me. I was mistakenly thinking of this as parse_quote! and was trying to write a fragment of a Meta that I expected to work here. Sorry about that. Let me have another look at this today, I think it's working properly and I'm the one who was off-base.

cathaysia commented 6 months ago

This feature merging cycle far exceeded my expectations. On the one hand, considering that no obvious progress has been seen yet, on the other hand, this function has been completed. So I closed this pr. If you are still interested in this macro. You can implement it on your own branch.