Skip to content

no_effect_underscore_binding: FP on field inside derive macros #12045

Closed
@xFrednet

Description

@xFrednet

Summary

clippy::no_effect_underscore_binding can trigger on fields starting with an underscore inside proc-macros. I looked at the code and it seems like the lint only checks

Lint Name

no_effect_underscore_binding

Reproducer

I tried this code:

#![warn(clippy::no_effect_underscore_binding)]

use core::marker::PhantomData;

#[derive(typed_builder::TypedBuilder)]
pub(crate) struct CommonTyData<'ast> {
    #[builder(default)]
    _lifetime: PhantomData<&'ast ()>,
}

This example code, sadly, uses a dependency:

typed-builder      = "0.18"

I saw this happen:

warning: binding to `_` prefixed variable with no side-effect
  --> marker_api/src/ast/stmt.rs:62:43
   |
62 | #[derive(typed_builder::TypedBuilder)]
   |          ^^^^^^^^^^^^^^^^^^^^^^^^^^^
   |
   = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#no_effect_underscore_binding

I expected to see this happen:

Nothing

Version

rustc 1.77.0-nightly (89e2160c4 2023-12-27)
binary: rustc
commit-hash: 89e2160c4ca5808657ed55392620ed1dbbce78d1
commit-date: 2023-12-27
host: x86_64-unknown-linux-gnu
release: 1.77.0-nightly
LLVM version: 17.0.6

Additional Labels

See:

Metadata

Metadata

Assignees

Labels

C-bugCategory: Clippy is not doing the correct thingI-false-positiveIssue: The lint was triggered on code it shouldn't have

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions