Fix clippy
This commit is contained in:
parent
6a74a0e17b
commit
4488653ec6
@ -386,7 +386,8 @@ fn check_unsafe_derive_deserialize<'tcx>(
|
|||||||
&& cx
|
&& cx
|
||||||
.tcx
|
.tcx
|
||||||
.inherent_impls(def.did())
|
.inherent_impls(def.did())
|
||||||
.iter()
|
.into_iter()
|
||||||
|
.flatten()
|
||||||
.map(|imp_did| cx.tcx.hir().expect_item(imp_did.expect_local()))
|
.map(|imp_did| cx.tcx.hir().expect_item(imp_did.expect_local()))
|
||||||
.any(|imp| has_unsafe(cx, imp))
|
.any(|imp| has_unsafe(cx, imp))
|
||||||
{
|
{
|
||||||
|
@ -53,9 +53,10 @@ impl<'tcx> LateLintPass<'tcx> for MultipleInherentImpl {
|
|||||||
// List of spans to lint. (lint_span, first_span)
|
// List of spans to lint. (lint_span, first_span)
|
||||||
let mut lint_spans = Vec::new();
|
let mut lint_spans = Vec::new();
|
||||||
|
|
||||||
|
let Ok(impls) = cx.tcx.crate_inherent_impls(()) else { return };
|
||||||
let inherent_impls = cx
|
let inherent_impls = cx
|
||||||
.tcx
|
.tcx
|
||||||
.with_stable_hashing_context(|hcx| cx.tcx.crate_inherent_impls(()).inherent_impls.to_sorted(&hcx, true));
|
.with_stable_hashing_context(|hcx| impls.inherent_impls.to_sorted(&hcx, true));
|
||||||
|
|
||||||
for (_, impl_ids) in inherent_impls.into_iter().filter(|(&id, impls)| {
|
for (_, impl_ids) in inherent_impls.into_iter().filter(|(&id, impls)| {
|
||||||
impls.len() > 1
|
impls.len() > 1
|
||||||
|
@ -139,7 +139,7 @@ fn deref_chain<'cx, 'tcx>(cx: &'cx LateContext<'tcx>, ty: Ty<'tcx>) -> impl Iter
|
|||||||
|
|
||||||
fn adt_has_inherent_method(cx: &LateContext<'_>, ty: Ty<'_>, method_name: Symbol) -> bool {
|
fn adt_has_inherent_method(cx: &LateContext<'_>, ty: Ty<'_>, method_name: Symbol) -> bool {
|
||||||
if let Some(ty_did) = ty.ty_adt_def().map(ty::AdtDef::did) {
|
if let Some(ty_did) = ty.ty_adt_def().map(ty::AdtDef::did) {
|
||||||
cx.tcx.inherent_impls(ty_did).iter().any(|&did| {
|
cx.tcx.inherent_impls(ty_did).into_iter().flatten().any(|&did| {
|
||||||
cx.tcx
|
cx.tcx
|
||||||
.associated_items(did)
|
.associated_items(did)
|
||||||
.filter_by_name_unhygienic(method_name)
|
.filter_by_name_unhygienic(method_name)
|
||||||
|
@ -441,7 +441,8 @@ fn check_for_is_empty(
|
|||||||
let is_empty = cx
|
let is_empty = cx
|
||||||
.tcx
|
.tcx
|
||||||
.inherent_impls(impl_ty)
|
.inherent_impls(impl_ty)
|
||||||
.iter()
|
.into_iter()
|
||||||
|
.flatten()
|
||||||
.flat_map(|&id| cx.tcx.associated_items(id).filter_by_name_unhygienic(is_empty))
|
.flat_map(|&id| cx.tcx.associated_items(id).filter_by_name_unhygienic(is_empty))
|
||||||
.find(|item| item.kind == AssocKind::Fn);
|
.find(|item| item.kind == AssocKind::Fn);
|
||||||
|
|
||||||
@ -605,7 +606,7 @@ fn has_is_empty(cx: &LateContext<'_>, expr: &Expr<'_>) -> bool {
|
|||||||
/// Checks the inherent impl's items for an `is_empty(self)` method.
|
/// Checks the inherent impl's items for an `is_empty(self)` method.
|
||||||
fn has_is_empty_impl(cx: &LateContext<'_>, id: DefId) -> bool {
|
fn has_is_empty_impl(cx: &LateContext<'_>, id: DefId) -> bool {
|
||||||
let is_empty = sym!(is_empty);
|
let is_empty = sym!(is_empty);
|
||||||
cx.tcx.inherent_impls(id).iter().any(|imp| {
|
cx.tcx.inherent_impls(id).into_iter().flatten().any(|imp| {
|
||||||
cx.tcx
|
cx.tcx
|
||||||
.associated_items(*imp)
|
.associated_items(*imp)
|
||||||
.filter_by_name_unhygienic(is_empty)
|
.filter_by_name_unhygienic(is_empty)
|
||||||
|
@ -73,7 +73,8 @@ pub(super) fn check<'tcx>(
|
|||||||
let has_suggested_method = receiver_ty.ty_adt_def().is_some_and(|adt_def| {
|
let has_suggested_method = receiver_ty.ty_adt_def().is_some_and(|adt_def| {
|
||||||
cx.tcx
|
cx.tcx
|
||||||
.inherent_impls(adt_def.did())
|
.inherent_impls(adt_def.did())
|
||||||
.iter()
|
.into_iter()
|
||||||
|
.flatten()
|
||||||
.flat_map(|impl_id| cx.tcx.associated_items(impl_id).filter_by_name_unhygienic(sugg))
|
.flat_map(|impl_id| cx.tcx.associated_items(impl_id).filter_by_name_unhygienic(sugg))
|
||||||
.any(|assoc| {
|
.any(|assoc| {
|
||||||
assoc.fn_has_self_parameter
|
assoc.fn_has_self_parameter
|
||||||
|
@ -534,10 +534,11 @@ fn find_primitive_impls<'tcx>(tcx: TyCtxt<'tcx>, name: &str) -> impl Iterator<It
|
|||||||
"u128" => SimplifiedType::Uint(UintTy::U128),
|
"u128" => SimplifiedType::Uint(UintTy::U128),
|
||||||
"f32" => SimplifiedType::Float(FloatTy::F32),
|
"f32" => SimplifiedType::Float(FloatTy::F32),
|
||||||
"f64" => SimplifiedType::Float(FloatTy::F64),
|
"f64" => SimplifiedType::Float(FloatTy::F64),
|
||||||
_ => return [].iter().copied(),
|
#[allow(trivial_casts)]
|
||||||
|
_ => return Result::<_, rustc_errors::ErrorGuaranteed>::Ok(&[] as &[_]).into_iter().flatten().copied(),
|
||||||
};
|
};
|
||||||
|
|
||||||
tcx.incoherent_impls(ty).iter().copied()
|
tcx.incoherent_impls(ty).into_iter().flatten().copied()
|
||||||
}
|
}
|
||||||
|
|
||||||
fn non_local_item_children_by_name(tcx: TyCtxt<'_>, def_id: DefId, name: Symbol) -> Vec<Res> {
|
fn non_local_item_children_by_name(tcx: TyCtxt<'_>, def_id: DefId, name: Symbol) -> Vec<Res> {
|
||||||
@ -663,7 +664,8 @@ pub fn def_path_res(cx: &LateContext<'_>, path: &[&str]) -> Vec<Res> {
|
|||||||
// `impl S { ... }`
|
// `impl S { ... }`
|
||||||
let inherent_impl_children = tcx
|
let inherent_impl_children = tcx
|
||||||
.inherent_impls(def_id)
|
.inherent_impls(def_id)
|
||||||
.iter()
|
.into_iter()
|
||||||
|
.flatten()
|
||||||
.flat_map(|&impl_def_id| item_children_by_name(tcx, impl_def_id, segment));
|
.flat_map(|&impl_def_id| item_children_by_name(tcx, impl_def_id, segment));
|
||||||
|
|
||||||
let direct_children = item_children_by_name(tcx, def_id, segment);
|
let direct_children = item_children_by_name(tcx, def_id, segment);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user