I’m getting a weird compiler warning from using a macro that I wrote:
warning: unnecessary parentheses around type
--> crates/apub/src/activities/community/announce.rs:43:19
|
43 | #[activity_handler(LemmyContext)]
| ^ ^
|
= note: `#[warn(unused_parens)]` on by default
help: remove these parentheses
|
43 - #[activity_handler(LemmyContext)]
43 + #[activity_handlerLemmyContext]
|
Here is the code that it is warning about:
#[derive(Clone, Debug, Deserialize, Serialize, ActivityHandler, ActivityFields)]
#[serde(untagged)]
#[activity_handler(LemmyContext)]
pub enum AnnouncableActivities {
CreateOrUpdateComment(CreateOrUpdateComment),
CreateOrUpdatePost(Box<CreateOrUpdatePost>),
...
}
The warning is clearly wrong, because the code compiles, but if after applying the suggested fix, it breaks. I also can’t find any info about this problem, or how to fix it. In general there seems to be a real lack of resources for Rust macros.
So does anyone here know how to get rid of the warning, without explicitly ignoring it?
I’ve had this occasionally happen too, clippy lints aren’t perfect. Just disable it on that specific line:
https://stackoverflow.com/questions/39269408/how-to-quiet-a-warning-for-a-single-statement-in-rust