about summary refs log tree commit diff
path: root/clippy_utils
diff options
context:
space:
mode:
authorflip1995 <philipp.krones@embecosm.com>2021-07-16 10:45:28 +0200
committerflip1995 <philipp.krones@embecosm.com>2021-07-16 10:45:28 +0200
commitb98e2ec527fb13b2eaf4f70fd9c290fd0552e16a (patch)
tree10dce4ca38d9a4109aa5355a236171501e5d55c6 /clippy_utils
parent78ffcd9959cc81d1328fcafb996dcc7cd9b5f1ac (diff)
downloadrust-b98e2ec527fb13b2eaf4f70fd9c290fd0552e16a.tar.gz
rust-b98e2ec527fb13b2eaf4f70fd9c290fd0552e16a.zip
Fix ICE in redundant_pattern_matching
Diffstat (limited to 'clippy_utils')
-rw-r--r--clippy_utils/src/ty.rs6
1 files changed, 4 insertions, 2 deletions
diff --git a/clippy_utils/src/ty.rs b/clippy_utils/src/ty.rs
index 3f5c5604d43..523d55219ab 100644
--- a/clippy_utils/src/ty.rs
+++ b/clippy_utils/src/ty.rs
@@ -257,10 +257,12 @@ pub fn is_type_diagnostic_item(cx: &LateContext<'_>, ty: Ty<'_>, diag_item: Symb
     }
 }
 
-/// Checks if the type is equal to a lang item
+/// Checks if the type is equal to a lang item.
+///
+/// Returns `false` if the `LangItem` is not defined.
 pub fn is_type_lang_item(cx: &LateContext<'_>, ty: Ty<'_>, lang_item: hir::LangItem) -> bool {
     match ty.kind() {
-        ty::Adt(adt, _) => cx.tcx.lang_items().require(lang_item).unwrap() == adt.did,
+        ty::Adt(adt, _) => cx.tcx.lang_items().require(lang_item).map_or(false, |li| li == adt.did),
         _ => false,
     }
 }