Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion compiler/rustc_passes/src/dead.rs
Original file line number Diff line number Diff line change
Expand Up @@ -670,7 +670,9 @@ fn check_trait_item(
use hir::TraitItemKind::{Const, Fn};
if matches!(tcx.def_kind(id.owner_id), DefKind::AssocConst | DefKind::AssocFn) {
let trait_item = tcx.hir().trait_item(id);
if matches!(trait_item.kind, Const(_, Some(_)) | Fn(_, hir::TraitFn::Provided(_)))
if let Fn(_, hir::TraitFn::Provided(_)) = trait_item.kind {
worklist.push((trait_item.owner_id.def_id, ComesFromAllowExpect::No));
} else if let Const(_, Some(_)) = trait_item.kind
&& let Some(comes_from_allow) =
has_allow_dead_code_or_lang_attr(tcx, trait_item.owner_id.def_id)
{
Expand Down
16 changes: 16 additions & 0 deletions tests/ui/lint/dead-code/issue-118139.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
// run-pass

enum Category {
A,
B,
}

trait Foo {
fn foo(&self) -> Category {
Category::A
}
}

fn main() {
let _c = Category::B;
}