Skip to content

Commit 2279f62

Browse files
author
Alex Burka
committed
add test for deriving Debug on uninhabited enum
1 parent 1cf82fd commit 2279f62

File tree

2 files changed

+41
-0
lines changed

2 files changed

+41
-0
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
// Copyright 2018 The Rust Project Developers. See the COPYRIGHT
2+
// file at the top-level directory of this distribution and at
3+
// http://rust-lang.org/COPYRIGHT.
4+
//
5+
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
6+
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
7+
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
8+
// option. This file may not be copied, modified, or distributed
9+
// except according to those terms.
10+
11+
// compile-pass
12+
// compile-flags: -Wunused
13+
14+
// ensure there are no special warnings about uninhabited types
15+
// when deriving Debug on an empty enum
16+
17+
#[derive(Debug)]
18+
enum Void {} //~ WARN never used
19+
20+
#[derive(Debug)]
21+
enum Foo { //~ WARN never used
22+
Bar(u8),
23+
Void(Void),
24+
}
25+
26+
fn main() {}
27+
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
warning: enum is never used: `Void`
2+
--> $DIR/derive-uninhabited-enum-38885.rs:18:1
3+
|
4+
LL | enum Void {} //~ WARN never used
5+
| ^^^^^^^^^
6+
|
7+
= note: `-W dead-code` implied by `-W unused`
8+
9+
warning: enum is never used: `Foo`
10+
--> $DIR/derive-uninhabited-enum-38885.rs:21:1
11+
|
12+
LL | enum Foo { //~ WARN never used
13+
| ^^^^^^^^
14+

0 commit comments

Comments
 (0)