Skip to content

warning that uninhabited struct is never constructed #145936

@ijackson

Description

@ijackson

Steps

git clone https://gitlab.torproject.org/Diziet/rust-derive-deftly -b derive-deftly-1.2.0
cd rust-derive-deftly
cargo +beta clippy -p derive-deftly-macros --all-features

The code contains this, where Void is from void:

pub struct MetaUnsupported(Void);

Expected behaviour

It lints without complaint.

Actual behaviour

warning: struct `MetaUnsupported` is never constructed
   --> macros/meta.rs:746:12
    |
746 | pub struct MetaUnsupported(Void);
    |            ^^^^^^^^^^^^^^^
    |
    = note: `#[warn(dead_code)]` on by default

Discussion

I don't think it ever makes sense to warn that an uninhabited type is never constructed. That is normal. Presumably the uninhabited type has some function in the code, or might become inhabited with a different configuration.

Version it worked on

It works on 1.88.0.

Version with regression

rustc --version --verbose:

rustc 1.90.0-beta.3 (630a5f1d3 2025-08-16)
binary: rustc
commit-hash: 630a5f1d3cda0e54d878f3f6bf9be435ee4c68a5
commit-date: 2025-08-16
host: x86_64-unknown-linux-gnu
release: 1.90.0-beta.3
LLVM version: 20.1.8

@rustbot modify labels: +regression-from-stable-to-beta -regression-untriaged
@rustbot modify labels: +A-diagnostics

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-diagnosticsArea: Messages for errors, warnings, and lintsC-bugCategory: This is a bug.E-needs-mcveCall for participation: This issue has a repro, but needs a Minimal Complete and Verifiable ExampleI-prioritizeIssue: Indicates that prioritization has been requested for this issue.S-has-bisectionStatus: A bisection has been found for this issueT-compilerRelevant to the compiler team, which will review and decide on the PR/issue.regression-from-stable-to-betaPerformance or correctness regression from stable to beta.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions