Rustdoc and Clippy stop misusing Key for Ty -> (adt) DefId
This commit is contained in:
parent
122520d80c
commit
89f511e4dd
6 changed files with 9 additions and 19 deletions
|
|
@ -6,7 +6,6 @@ use clippy_utils::ty::is_type_lang_item;
|
|||
use rustc_errors::Applicability;
|
||||
use rustc_hir::{Expr, ExprKind, LangItem, Path, QPath};
|
||||
use rustc_lint::LateContext;
|
||||
use rustc_middle::query::Key;
|
||||
use rustc_middle::ty;
|
||||
use rustc_middle::ty::Ty;
|
||||
use rustc_span::{sym, Symbol};
|
||||
|
|
@ -18,10 +17,10 @@ use rustc_span::{sym, Symbol};
|
|||
/// `vec![1,2].drain(..).collect::<HashSet<_>>()`
|
||||
/// ^^^^^^^^^ ^^^^^^^^^^ false
|
||||
fn types_match_diagnostic_item(cx: &LateContext<'_>, expr: Ty<'_>, recv: Ty<'_>, sym: Symbol) -> bool {
|
||||
if let Some(expr_adt_did) = expr.ty_adt_id()
|
||||
&& let Some(recv_adt_did) = recv.ty_adt_id()
|
||||
if let Some(expr_adt) = expr.ty_adt_def()
|
||||
&& let Some(recv_adt) = recv.ty_adt_def()
|
||||
{
|
||||
cx.tcx.is_diagnostic_item(sym, expr_adt_did) && cx.tcx.is_diagnostic_item(sym, recv_adt_did)
|
||||
cx.tcx.is_diagnostic_item(sym, expr_adt.did()) && cx.tcx.is_diagnostic_item(sym, recv_adt.did())
|
||||
} else {
|
||||
false
|
||||
}
|
||||
|
|
|
|||
|
|
@ -4,7 +4,6 @@ use clippy_utils::source::snippet_with_applicability;
|
|||
use rustc_errors::Applicability;
|
||||
use rustc_hir::Expr;
|
||||
use rustc_lint::LateContext;
|
||||
use rustc_middle::query::Key;
|
||||
use rustc_span::Span;
|
||||
|
||||
pub(super) fn check(
|
||||
|
|
@ -14,11 +13,7 @@ pub(super) fn check(
|
|||
as_str_span: Span,
|
||||
other_method_span: Span,
|
||||
) {
|
||||
if cx
|
||||
.tcx
|
||||
.lang_items()
|
||||
.string()
|
||||
.is_some_and(|id| Some(id) == cx.typeck_results().expr_ty(recv).ty_adt_id())
|
||||
if cx.typeck_results().expr_ty(recv).ty_adt_def().is_some_and(|adt| Some(adt.did()) == cx.tcx.lang_items().string())
|
||||
{
|
||||
let mut applicability = Applicability::MachineApplicable;
|
||||
span_lint_and_sugg(
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue