Skip to content

redundant_field_names triggered on derived code #17525

Description

@nazar-pc

Summary

This lint should not be triggered on code generated by macros, but right now it is

Lint Name

redundant_field_names

Reproducer

I tried this code:

#[derive(Debug, thiserror::Error)]
pub enum SegmentDownloadingError {
    // ...

    /// Segment reconstruction error
    #[error("Segment reconstruction error: {source}")]
    SegmentReconstruction {
        #[from]
        source: ReconstructorError,
    },
}

Internally it is expanded to things like this:

#[allow(deprecated, unused_qualifications, )]
#[automatically_derived]
impl ::core::convert::From<ReconstructorError> for SegmentDownloadingError {
    fn from(source: ReconstructorError) -> Self {
        SegmentDownloadingError::SegmentReconstruction {
            source: source,
        }
    }
}

I saw this happen:

warning: redundant field names in struct initialization
  --> crates/shared/ab-data-retrieval/src/segment_downloading.rs:48:9
   |
48 | /         #[from]
49 | |         source: ReconstructorError,
   | |______________^ help: replace it with: `source`
   |
   = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#redundant_field_names

I expected to see this happen:
No lint should be triggered since it is outside of developer's control and generated by proc macro.

Version

rustc 1.99.0-nightly (1a98b1e13 2026-08-07)
binary: rustc
commit-hash: 1a98b1e135b254f209c67d447b6d8bcd56a859e0
commit-date: 2026-08-07
host: x86_64-unknown-linux-gnu
release: 1.99.0-nightly
LLVM version: 23.1.0

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 haveT-macrosType: Issues with macros and macro expansiongood first issueThese issues are a good way to get started with Clippy

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions