Skip to content

Commit ca67164

Browse files
Show notice about "never used" for enum
1 parent 0986358 commit ca67164

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed

compiler/rustc_passes/src/dead.rs

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -976,6 +976,16 @@ impl<'tcx> DeadVisitor<'tcx> {
976976
};
977977

978978
let encl_def_id = parent_item.unwrap_or(first_item.def_id);
979+
// If parent of encl_def_id is an enum, use the parent ID intead.
980+
let encl_def_id = if let Some(enum_did) = self.tcx.opt_parent(encl_def_id.to_def_id())
981+
&& let Some(enum_local_id) = enum_did.as_local()
982+
&& let Node::Item(item) = self.tcx.hir_node_by_def_id(enum_local_id)
983+
&& let ItemKind::Enum(_, _) = item.kind
984+
{
985+
enum_local_id
986+
} else {
987+
encl_def_id
988+
};
979989
let ignored_derived_impls =
980990
if let Some(ign_traits) = self.ignored_derived_traits.get(&encl_def_id) {
981991
let trait_list = ign_traits

0 commit comments

Comments
 (0)