-
Notifications
You must be signed in to change notification settings - Fork 12.9k
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
unused_parens
triggers on macro by example code.
#66295
Comments
My head can't come up with an example that requires parentheses. Can you give me a counter example? |
@hellow554 A real world example is the diesel |
So somehing like this: macro_rules! foo {
($($foo:expr),+) => {
($($foo),*)
}
}
fn main() {
let _a = foo!(3, 4);
let _b = foo!(3);
} You're right. The question is: should we remove the lint for all macros? Only for macros that contain repetitive expansions? (Is that even possible to detect?) |
This comment has been minimized.
This comment has been minimized.
Would be great to get that fixed till it is part of the next stable release. |
This seems to occur first on nightly-2019-11-02 |
nominating for discussing at T-compiler + T-lang meeting, namely to take peoples' temperature with respect to the idea of just not linting this case when the flagged code appears as part of a macro definition. |
also, marking as P-high w.r.t. answer the question(s) posed here. (I personally don't think the severity of the actual impact is likely to be worth a P-high rating; the priority is likely just temporary until the discussion happens.) |
unused_parens
triggerts on macro by example code.unused_parens
triggers on macro by example code.
The language team discussed this last week. The general consensus was that we can stop linting when the redundant parens are inside the macro (as opposed to e.g. |
I've played a bit around with this issue today. Seems like those conditions need to be adjusted to also check if we are in macro expanded code. I've tried something like |
I think the questions have been basically answered in terms of what path we see best going forward. Self-assigning, removing I-nominated. |
…bank Fix `unused_parens` triggers on macro by example code Fix rust-lang#66295 Unfortunately this does also break [an existing test](https://github.com/rust-lang/rust/blob/4787e97475de6be9487e3d9255a9c2d3c0bf9252/src/test/ui/lint/issue-47775-nested-macro-unnecessary-parens-arg.rs#L22). I'm not sure how to handle that, because that seems to be quite similar to the allowed cases If this gets accepted it would be great to backport this fix to beta.
The latest beta contains a new? l
unused_parens
lint that triggers on macro by example code. This does not necessarily make sense because macros could be used to construct nearly arbitrary custom syntax for example something requiring to wrap a single element into a parenthesis.The strange thing here is that seems to only happen on beta, not on nightly, not on current stable.
Found via the diesel CI
Error message:
rustc version:
rustc 1.40.0-beta.1 (76b40532a 2019-11-05)
The text was updated successfully, but these errors were encountered: