rust-lang / rust-lang/rust-clippy

`redundant_field_names` triggered on derived code

Open
#17,525 5 comments 1 reaction 1 assignee View on GitHub

@kiana1kaslana is already working on this.

Since Sep 7, 2026.

C-bug good first issue I-false-positive T-macros
Dominant language
Rust
Stars
13.5k
Forks
2.2k
Avg merge
2d 10h
Merged PRs (30d)
32

Description

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

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.