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

Function call with attributes on arguments fail to parse #2521

Closed
repnop opened this issue Dec 10, 2019 · 5 comments
Closed

Function call with attributes on arguments fail to parse #2521

repnop opened this issue Dec 10, 2019 · 5 comments

Comments

@repnop
Copy link
Contributor

repnop commented Dec 10, 2019

I just ran into a problem with r-a not parsing the function call when I have something like this

fn foo(a: Foo, #[cfg(debug_assertions)] b: Baz) { ... }

// ...

foo(a, #[cfg(debug_assertions)] b);

(r-a says it expects an expression, not attribute)

#1661 fixed the attributes when put on parameters, but not when calling functions with attributes on the arguments.

I did a test with adding AttrsOwner to Expr in the grammar file and that fixed it, but I'm not sure if that's the way to go or not. I could write up a quick PR if its something simple enough that though :)

@matklad
Copy link
Member

matklad commented Dec 11, 2019

I think this needs some research. The main question is where the arguments are paced: on the expresison, or on the function argument?

Ie, if foo(#[dummy] x) is allowed, is foo((#[dummy] x,)) allowed as well?

The former case should be easy-ish to fix, the latter might be more involved.

@repnop
Copy link
Contributor Author

repnop commented Dec 11, 2019

The second case does seem to be allowed: playground link example, running in debug/release passes different sized tuples to the function

@matklad
Copy link
Member

matklad commented Dec 11, 2019 via email

@EddieIvan01
Copy link

Any progress?

@lnicola
Copy link
Member

lnicola commented Jan 25, 2021

This is working now:

image

@lnicola lnicola closed this as completed Jan 25, 2021
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

No branches or pull requests

4 participants