Skip to content

unsafe_derive_deserialize fires on generated code #13062

Open
@alexkazik

Description

@alexkazik

Summary

The lint is fired also on code generated by a proc_macro.

Maybe it should not report an unsafe in generated code or if it would be possible to mark the unsafe call in the proc_macro to be safe - though the unsafe block already marks that the writer thought about it and decided that it is safe.

Or for this case: never warn on enums without fields.

Lint Name

unsafe_derive_deserialize

Reproducer

Minimal Example:

#[derive(Clone, Copy, serde::Deserialize, enum_tools::EnumTools)]
#[enum_tools(iter)]
#[repr(usize)]
pub enum Test {
    One,
}

Version

rustc 1.79.0 (129f3b996 2024-06-10)
binary: rustc
commit-hash: 129f3b9964af4d4a709d1383930ade12dfe7c081
commit-date: 2024-06-10
host: aarch64-apple-darwin
release: 1.79.0
LLVM version: 18.1.7

Additional Labels

No response

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 have

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions