diff options
| author | Jason Newcomb <jsnewcomb@pm.me> | 2021-03-02 13:06:30 -0500 |
|---|---|---|
| committer | Jason Newcomb <jsnewcomb@pm.me> | 2021-03-06 13:03:13 -0500 |
| commit | e4ffff9e72f155dfcd1fda6042b725007973835d (patch) | |
| tree | 7028a90740f4b176cc975d2859620d9029f8ec06 | |
| parent | f21320fd74490ba98f1ebca60c85626dd4d9e12d (diff) | |
| download | rust-e4ffff9e72f155dfcd1fda6042b725007973835d.tar.gz rust-e4ffff9e72f155dfcd1fda6042b725007973835d.zip | |
Use `LanguageItems::require`
| -rw-r--r-- | clippy_lints/src/lifetimes.rs | 2 | ||||
| -rw-r--r-- | clippy_lints/src/types.rs | 8 |
2 files changed, 5 insertions, 5 deletions
diff --git a/clippy_lints/src/lifetimes.rs b/clippy_lints/src/lifetimes.rs index 5fed58b8210..3807d346f68 100644 --- a/clippy_lints/src/lifetimes.rs +++ b/clippy_lints/src/lifetimes.rs @@ -360,7 +360,7 @@ impl<'a, 'tcx> Visitor<'tcx> for RefVisitor<'a, 'tcx> { let trait_ref = &poly_tref.trait_ref; if CLOSURE_TRAIT_BOUNDS .iter() - .any(|&item| trait_ref.trait_def_id() == self.cx.tcx.lang_items().items()[item as usize]) + .any(|&item| trait_ref.trait_def_id() == self.cx.tcx.lang_items().require(item).ok()) { let mut sub_visitor = RefVisitor::new(self.cx); sub_visitor.visit_trait_ref(trait_ref); diff --git a/clippy_lints/src/types.rs b/clippy_lints/src/types.rs index d1d9ef7d902..c420be26fc6 100644 --- a/clippy_lints/src/types.rs +++ b/clippy_lints/src/types.rs @@ -294,7 +294,7 @@ fn is_ty_param_lang_item(cx: &LateContext<'_>, qpath: &QPath<'tcx>, item: LangIt if let TyKind::Path(qpath) = &ty.kind { cx.qpath_res(qpath, ty.hir_id) .opt_def_id() - .and_then(|id| (cx.tcx.lang_items().items()[item as usize] == Some(id)).then(|| ty)) + .and_then(|id| (cx.tcx.lang_items().require(item) == Ok(id)).then(|| ty)) } else { None } @@ -431,7 +431,7 @@ impl Types { }; let inner_span = match get_qpath_generic_tys(qpath).next() { Some(ty) => ty.span, - _ => return, + None => return, }; let mut applicability = Applicability::MachineApplicable; span_lint_and_sugg( @@ -467,7 +467,7 @@ impl Types { }; let inner_span = match get_qpath_generic_tys(qpath).next() { Some(ty) => ty.span, - _ => return, + None => return, }; let mut applicability = Applicability::MachineApplicable; span_lint_and_sugg( @@ -517,7 +517,7 @@ impl Types { }; let inner_span = match get_qpath_generic_tys(qpath).next() { Some(ty) => ty.span, - _ => return, + None => return, }; let mut applicability = Applicability::MachineApplicable; span_lint_and_sugg( |
