Skip to content

Commit e4ffff9

Browse files
committed
Use LanguageItems::require
1 parent f21320f commit e4ffff9

File tree

2 files changed

+5
-5
lines changed

2 files changed

+5
-5
lines changed

clippy_lints/src/lifetimes.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -360,7 +360,7 @@ impl<'a, 'tcx> Visitor<'tcx> for RefVisitor<'a, 'tcx> {
360360
let trait_ref = &poly_tref.trait_ref;
361361
if CLOSURE_TRAIT_BOUNDS
362362
.iter()
363-
.any(|&item| trait_ref.trait_def_id() == self.cx.tcx.lang_items().items()[item as usize])
363+
.any(|&item| trait_ref.trait_def_id() == self.cx.tcx.lang_items().require(item).ok())
364364
{
365365
let mut sub_visitor = RefVisitor::new(self.cx);
366366
sub_visitor.visit_trait_ref(trait_ref);

clippy_lints/src/types.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -294,7 +294,7 @@ fn is_ty_param_lang_item(cx: &LateContext<'_>, qpath: &QPath<'tcx>, item: LangIt
294294
if let TyKind::Path(qpath) = &ty.kind {
295295
cx.qpath_res(qpath, ty.hir_id)
296296
.opt_def_id()
297-
.and_then(|id| (cx.tcx.lang_items().items()[item as usize] == Some(id)).then(|| ty))
297+
.and_then(|id| (cx.tcx.lang_items().require(item) == Ok(id)).then(|| ty))
298298
} else {
299299
None
300300
}
@@ -431,7 +431,7 @@ impl Types {
431431
};
432432
let inner_span = match get_qpath_generic_tys(qpath).next() {
433433
Some(ty) => ty.span,
434-
_ => return,
434+
None => return,
435435
};
436436
let mut applicability = Applicability::MachineApplicable;
437437
span_lint_and_sugg(
@@ -467,7 +467,7 @@ impl Types {
467467
};
468468
let inner_span = match get_qpath_generic_tys(qpath).next() {
469469
Some(ty) => ty.span,
470-
_ => return,
470+
None => return,
471471
};
472472
let mut applicability = Applicability::MachineApplicable;
473473
span_lint_and_sugg(
@@ -517,7 +517,7 @@ impl Types {
517517
};
518518
let inner_span = match get_qpath_generic_tys(qpath).next() {
519519
Some(ty) => ty.span,
520-
_ => return,
520+
None => return,
521521
};
522522
let mut applicability = Applicability::MachineApplicable;
523523
span_lint_and_sugg(

0 commit comments

Comments
 (0)