Skip to content

Commit 0afee6f

Browse files
Revert "Rollup merge of rust-lang#124460 - long-long-float:show-notice-about-enum-with-debug, r=pnkfelix"
This reverts commit 00e5f58, reversing changes made to 5a3e2a4.
1 parent 99cf574 commit 0afee6f

File tree

3 files changed

+1
-55
lines changed

3 files changed

+1
-55
lines changed

compiler/rustc_passes/src/dead.rs

-19
Original file line numberDiff line numberDiff line change
@@ -1011,22 +1011,6 @@ impl<'tcx> DeadVisitor<'tcx> {
10111011
parent_item: Option<LocalDefId>,
10121012
report_on: ReportOn,
10131013
) {
1014-
fn get_parent_if_enum_variant<'tcx>(
1015-
tcx: TyCtxt<'tcx>,
1016-
may_variant: LocalDefId,
1017-
) -> LocalDefId {
1018-
if let Node::Variant(_) = tcx.hir_node_by_def_id(may_variant)
1019-
&& let Some(enum_did) = tcx.opt_parent(may_variant.to_def_id())
1020-
&& let Some(enum_local_id) = enum_did.as_local()
1021-
&& let Node::Item(item) = tcx.hir_node_by_def_id(enum_local_id)
1022-
&& let ItemKind::Enum(_, _) = item.kind
1023-
{
1024-
enum_local_id
1025-
} else {
1026-
may_variant
1027-
}
1028-
}
1029-
10301014
let Some(&first_item) = dead_codes.first() else {
10311015
return;
10321016
};
@@ -1070,9 +1054,6 @@ impl<'tcx> DeadVisitor<'tcx> {
10701054
};
10711055

10721056
let encl_def_id = parent_item.unwrap_or(first_item.def_id);
1073-
// If parent of encl_def_id is an enum, use the parent ID intead.
1074-
let encl_def_id = get_parent_if_enum_variant(tcx, encl_def_id);
1075-
10761057
let ignored_derived_impls =
10771058
if let Some(ign_traits) = self.ignored_derived_traits.get(&encl_def_id) {
10781059
let trait_list = ign_traits

tests/ui/lint/dead-code/unused-variant.rs

-15
Original file line numberDiff line numberDiff line change
@@ -6,22 +6,7 @@ enum Enum {
66
Variant2,
77
}
88

9-
#[derive(Debug)]
10-
enum TupleVariant {
11-
Variant1(i32), //~ ERROR: variant `Variant1` is never constructed
12-
Variant2,
13-
}
14-
15-
#[derive(Debug)]
16-
enum StructVariant {
17-
Variant1 { id: i32 }, //~ ERROR: variant `Variant1` is never constructed
18-
Variant2,
19-
}
20-
219
fn main() {
2210
let e = Enum::Variant2;
2311
e.clone();
24-
25-
let _ = TupleVariant::Variant2;
26-
let _ = StructVariant::Variant2;
2712
}

tests/ui/lint/dead-code/unused-variant.stderr

+1-21
Original file line numberDiff line numberDiff line change
@@ -13,25 +13,5 @@ note: the lint level is defined here
1313
LL | #![deny(dead_code)]
1414
| ^^^^^^^^^
1515

16-
error: variant `Variant1` is never constructed
17-
--> $DIR/unused-variant.rs:11:5
18-
|
19-
LL | enum TupleVariant {
20-
| ------------ variant in this enum
21-
LL | Variant1(i32),
22-
| ^^^^^^^^
23-
|
24-
= note: `TupleVariant` has a derived impl for the trait `Debug`, but this is intentionally ignored during dead code analysis
25-
26-
error: variant `Variant1` is never constructed
27-
--> $DIR/unused-variant.rs:17:5
28-
|
29-
LL | enum StructVariant {
30-
| ------------- variant in this enum
31-
LL | Variant1 { id: i32 },
32-
| ^^^^^^^^
33-
|
34-
= note: `StructVariant` has a derived impl for the trait `Debug`, but this is intentionally ignored during dead code analysis
35-
36-
error: aborting due to 3 previous errors
16+
error: aborting due to 1 previous error
3717

0 commit comments

Comments
 (0)