Rollup merge of #129061 - compiler-errors:lang-item, r=Urgau
Use `is_lang_item` more Few places that I missed since introducing `TyCtxt::is_lang_item`.
This commit is contained in:
commit
cd6852b9ea
12 changed files with 26 additions and 24 deletions
|
@ -1,5 +1,5 @@
|
|||
use hir::{Expr, Pat};
|
||||
use rustc_hir as hir;
|
||||
use rustc_hir::{self as hir, LangItem};
|
||||
use rustc_infer::infer::TyCtxtInferExt;
|
||||
use rustc_infer::traits::ObligationCause;
|
||||
use rustc_middle::ty;
|
||||
|
@ -126,7 +126,10 @@ fn extract_iterator_next_call<'tcx>(
|
|||
) -> Option<&'tcx Expr<'tcx>> {
|
||||
// This won't work for `Iterator::next(iter)`, is this an issue?
|
||||
if let hir::ExprKind::MethodCall(_, recv, _, _) = expr.kind
|
||||
&& cx.typeck_results().type_dependent_def_id(expr.hir_id) == cx.tcx.lang_items().next_fn()
|
||||
&& cx
|
||||
.typeck_results()
|
||||
.type_dependent_def_id(expr.hir_id)
|
||||
.is_some_and(|def_id| cx.tcx.is_lang_item(def_id, LangItem::IteratorNext))
|
||||
{
|
||||
Some(recv)
|
||||
} else {
|
||||
|
|
|
@ -114,7 +114,7 @@ impl<'tcx> LateLintPass<'tcx> for DropTraitConstraints {
|
|||
let hir::TyKind::TraitObject(bounds, _lifetime, _syntax) = &ty.kind else { return };
|
||||
for (bound, modifier) in &bounds[..] {
|
||||
let def_id = bound.trait_ref.trait_def_id();
|
||||
if cx.tcx.lang_items().drop_trait() == def_id
|
||||
if def_id.is_some_and(|def_id| cx.tcx.is_lang_item(def_id, LangItem::Drop))
|
||||
&& *modifier != hir::TraitBoundModifier::Maybe
|
||||
{
|
||||
let Some(def_id) = cx.tcx.get_diagnostic_item(sym::needs_drop) else { return };
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue