-
Notifications
You must be signed in to change notification settings - Fork 782
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
Need to be able to create structs via macro_rules #832
Conversation
(The test fails to compile without the patch which is why there's no assertions in it) |
Thanks 👍 |
Encountered this issue myself. One suggestion: maybe there should be an // pseudo-code, probably needs some derefs and other misc. cleanup
fn unwrap_group(expr: &syn::Expr) -> &syn::Expr {
if let syn::Expr::Group(g) = expr {
&*g.expr
}
expr
} that way, the "name" => match unwrap_group(&**right) {
syn::Expr::Path(exp) if exp.path.segments.len() == 1 => {
self.name = Some(exp.clone().into());
}
_ => expected!("type name (e.g., Name)"),
}, |
Btw, I would suggest a |
👍 also my parsing improvements in #1567 might resolve a lot of the problems here. I plan to retest this once that PR is merged. |
(Currently only possible using tt escape type.)
As this branch is very old, I just rebased it and will merge it if tests are green 🤞 |
More of these problems started to appear with Rust 1.53 (at first I thought it was a compiler regression, but actually it’s just the compiler adding a few more groups and pyo3 not handling them correctly). I think we should use |
(Currently only possible using tt escape type which doesn't do any processing.)
There's quite a few places I think we need to update but using
pyclass
as an example to agree the right way to do things. When you pass the argument via macro_rules unless it's the escape sequence type oftt
then the Expr::Path seems to get wrapped in an Expr::Group whatever type I choose for the variable I'm passing in:ident
,path
,expr
.(btw I notice you can't match on box which might make the code a tad nicer.)