Skip to content

unnecessary_struct_initialization triggers in proc-macros #12996

Open
@daxpedda

Description

@daxpedda

Summary

unnecessary_struct_initialization triggers in proc-macros of third-party crates.

Lint Name

unnecessary_struct_initialization

Reproducer

I tried this code:

Using bevy_ecs_ldtk v0.9.0.

#[derive(Default, LdtkIntCell)]
struct Test {
    test: i32,
}

I saw this happen:

warning: unnecessary struct building
  --> src/main.rs:45:19
   |
45 | #[derive(Default, LdtkIntCell)]
   |                   ^^^^^^^^^^^
   |
   = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#unnecessary_struct_initialization
   = note: `-W clippy::unnecessary-struct-initialization` implied by `-W clippy::nursery`
   = help: to override `-W clippy::nursery` add `#[allow(clippy::unnecessary_struct_initialization)]`
   = note: this warning originates in the derive macro `LdtkIntCell` (in Nightly builds, run with -Z macro-backtrace for more info)

I expected to see this happen:
The lint not to trigger.

Version

rustc 1.79.0 (129f3b996 2024-06-10)
binary: rustc
commit-hash: 129f3b9964af4d4a709d1383930ade12dfe7c081
commit-date: 2024-06-10
host: x86_64-unknown-linux-gnu
release: 1.79.0
LLVM version: 18.1.7

Additional Labels

@rustbot label +T-macros

Metadata

Metadata

Assignees

No one assigned

    Labels

    C-bugCategory: Clippy is not doing the correct thingI-false-positiveIssue: The lint was triggered on code it shouldn't haveT-macrosType: Issues with macros and macro expansion

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions