Skip to content

Commit 29b5ebf

Browse files
committed
Use a match guard to avoid code repetition
1 parent 5b88fba commit 29b5ebf

File tree

1 file changed

+5
-8
lines changed

1 file changed

+5
-8
lines changed

src/librustc/middle/reachable.rs

+5-8
Original file line numberDiff line numberDiff line change
@@ -32,15 +32,12 @@ fn item_might_be_inlined(tcx: TyCtxt<'tcx>, item: &hir::Item, attrs: CodegenFnAt
3232
return true
3333
}
3434

35-
match item.node {
36-
hir::ItemKind::Fn(_, header, ..) => {
37-
if header.constness == hir::Constness::Const {
38-
return true;
39-
}
40-
let generics = tcx.generics_of(tcx.hir().local_def_id(item.hir_id));
41-
generics.requires_monomorphization(tcx)
35+
match item.node {
36+
hir::ItemKind::Fn(_, header, ..) if header.constness == hir::Constness::Const => {
37+
return true;
4238
}
43-
hir::ItemKind::Impl(..) => {
39+
hir::ItemKind::Impl(..) |
40+
hir::ItemKind::Fn(..) => {
4441
let generics = tcx.generics_of(tcx.hir().local_def_id(item.hir_id));
4542
generics.requires_monomorphization(tcx)
4643
}

0 commit comments

Comments
 (0)