Skip to content

Commit 320dedc

Browse files
committed
Auto merge of #111671 - Dylan-DPC:rollup-1jy5r16, r=Dylan-DPC
Rollup of 6 pull requests Successful merges: - #110145 (Share slice of bytes) - #111043 (Stabilize feature `cstr_is_empty`) - #111648 (Remove `LangItems::require`) - #111649 (Add derive for `core::marker::ConstParamTy`) - #111654 (Add a conversion from `&mut T` to `&mut UnsafeCell<T>`) - #111661 (Erase regions of type in `offset_of!`) Failed merges: r? `@ghost` `@rustbot` modify labels: rollup
2 parents 64b34c8 + c4dff09 commit 320dedc

File tree

1 file changed

+5
-4
lines changed

1 file changed

+5
-4
lines changed

clippy_lints/src/matches/redundant_pattern_match.rs

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -289,10 +289,11 @@ fn is_pat_variant(cx: &LateContext<'_>, pat: &Pat<'_>, path: &QPath<'_>, expecte
289289
let Some(id) = cx.typeck_results().qpath_res(path, pat.hir_id).opt_def_id() else { return false };
290290

291291
match expected_item {
292-
Item::Lang(expected_lang_item) => {
293-
let expected_id = cx.tcx.lang_items().require(expected_lang_item).unwrap();
294-
cx.tcx.parent(id) == expected_id
295-
},
292+
Item::Lang(expected_lang_item) => cx
293+
.tcx
294+
.lang_items()
295+
.get(expected_lang_item)
296+
.map_or(false, |expected_id| cx.tcx.parent(id) == expected_id),
296297
Item::Diag(expected_ty, expected_variant) => {
297298
let ty = cx.typeck_results().pat_ty(pat);
298299

0 commit comments

Comments
 (0)