Closed georgemp closed 4 years ago
This looks like a strange compiler bug, related to https://github.com/rust-lang/rust/issues/43081. Inserting a println!("{:#?}", input)
at the beginning of the implementation of async_trait, the tokens being passed as input to the async_trait macro by rustc are:
Notice in particular this part:
Ident {
ident: "self",
span: #0 bytes(0..0),
},
Punct {
ch: '.',
spacing: Alone,
span: #0 bytes(0..0),
},
Ident {
ident: "action",
span: #0 bytes(0..0),
},
Punct {
ch: '=',
spacing: Alone,
span: #0 bytes(0..0),
},
Group {
delimiter: Parenthesis,
stream: TokenStream [
Punct {
ch: '|',
spacing: Alone,
span: #0 bytes(0..0),
},
Ident {
ident: "str",
span: #0 bytes(0..0),
},
Punct {
ch: '|',
spacing: Alone,
span: #0 bytes(0..0),
},
Ident {
ident: "str",
span: #0 bytes(0..0),
},
],
span: #0 bytes(0..0),
},
Rustc inserted unnecessary parentheses around the closure before even calling async_trait, passing the statement as self.action = (|str| str);
. At the same time, it lost all the location information on the source tokens (#0 bytes(0..0)
) so it blames the user for handwriting those parentheses.
I released 0.1.37 which just suppresses the lint as a workaround.
Now that https://github.com/rust-lang/rust/issues/75734 has been fixed, the lint should no longer fire.
Hi,
I'm running into an issue wherein I get unused_parens warnings. A reproducible version on the rust playground can be found here.
The code is
If i uncomment the println! on line 24 (on the playground), the warning goes away. Do let me know if you would need any more details with this (or, would like me to try something else). Thanks