Skip to content

Deriving Clone and PartialEq on a type containing ! creates warnings #154900

@WaffleLapkin

Description

@WaffleLapkin

Given the following code:

#![feature(never_type)]

#[derive(Clone, PartialEq)]
pub struct X(!);

I would expect no warnings to be emitted. Instead, both Clone and PartialEq macros emit unreachable code warnings:

warning: unreachable call
 --> src/lib.rs:3:10
  |
3 | #[derive(Clone, PartialEq)]
  |          ^^^^^ unreachable call
4 | pub struct X(!);
  |              - any code following this expression is unreachable
  |
  = note: `#[warn(unreachable_code)]` (part of `#[warn(unused)]`) on by default

warning: unreachable expression
 --> src/lib.rs:4:14
  |
3 | #[derive(Clone, PartialEq)]
  |                 --------- in this derive macro expansion
4 | pub struct X(!);
  |              ^
  |              |
  |              unreachable expression
  |              any code following this expression is unreachable

Metadata

Metadata

Assignees

Labels

A-lintsArea: Lints (warnings about flaws in source code) such as unused_mut.A-macrosArea: All kinds of macros (custom derive, macro_rules!, proc macros, ..)F-never_type`#![feature(never_type)]`L-dead_codeLint: dead_codeL-unreachable_codeLint: unreachable_codeS-has-mcveStatus: A Minimal Complete and Verifiable Example has been found for this issue

Type

No fields configured for Bug.

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions