rust-lang / rust-lang/rust

warning that uninhabited struct is never constructed

Open
#145,936 12 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

A-diagnostics C-bug E-needs-mcve regression-from-stable-to-stable S-has-bisection T-compiler
Dominant language
Rust
Stars
119k
Forks
16.1k
PR merge metrics
PR metrics pending

Description

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

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.

Research direction

Run cargo +beta clippy -p derive-deftly-macros --all-features in the reported rust-derive-deftly checkout and compare the behavior with Rust 1.88.0. Read macros/meta.rs around the MetaUnsupported(Void) definition, then trace the compiler's dead-code diagnostic entry point to determine why the warning changed. Done means the uninhabited struct no longer produces this warning without regressing ordinary dead-code diagnostics.

Written by the indexing model from the issue text.

Assessment

Tech stack
rust
Domain
compilers
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
48/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.