diff options
| author | Michael Goulet <michael@errs.io> | 2023-11-12 18:57:24 +0000 |
|---|---|---|
| committer | Michael Goulet <michael@errs.io> | 2024-01-08 20:30:10 +0000 |
| commit | 89f511e4dd4cde330c85f7b596d3f68d381a582e (patch) | |
| tree | afa2c31241e60074257caecd2385e22e7afdcd09 /clippy_lints/src/methods | |
| parent | 122520d80cde154036ed9c0b9a0aacf423b121ed (diff) | |
| download | rust-89f511e4dd4cde330c85f7b596d3f68d381a582e.tar.gz rust-89f511e4dd4cde330c85f7b596d3f68d381a582e.zip | |
Rustdoc and Clippy stop misusing Key for Ty -> (adt) DefId
Diffstat (limited to 'clippy_lints/src/methods')
| -rw-r--r-- | clippy_lints/src/methods/drain_collect.rs | 7 | ||||
| -rw-r--r-- | clippy_lints/src/methods/redundant_as_str.rs | 7 |
2 files changed, 4 insertions, 10 deletions
diff --git a/clippy_lints/src/methods/drain_collect.rs b/clippy_lints/src/methods/drain_collect.rs index 6a82d8f756a..3a8ca37610a 100644 --- a/clippy_lints/src/methods/drain_collect.rs +++ b/clippy_lints/src/methods/drain_collect.rs @@ -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 } diff --git a/clippy_lints/src/methods/redundant_as_str.rs b/clippy_lints/src/methods/redundant_as_str.rs index 98cd6afc2b7..2a2feedd2b4 100644 --- a/clippy_lints/src/methods/redundant_as_str.rs +++ b/clippy_lints/src/methods/redundant_as_str.rs @@ -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( |
