Skip to content

Commit

Permalink
Use LanguageItems::require
Browse files Browse the repository at this point in the history
  • Loading branch information
Jarcho committed Mar 6, 2021
1 parent f21320f commit e4ffff9
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 5 deletions.
2 changes: 1 addition & 1 deletion clippy_lints/src/lifetimes.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
8 changes: 4 additions & 4 deletions clippy_lints/src/types.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
Expand Down Expand Up @@ -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(
Expand Down Expand Up @@ -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(
Expand Down Expand Up @@ -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(
Expand Down

0 comments on commit e4ffff9

Please sign in to comment.