fn check_for_is_empty(
    cx: &LateContext<'_>,
    span: Span,
    self_kind: ImplicitSelfKind,
    output: LenOutput<'_>,
    impl_ty: DefId,
    item_name: Symbol,
    item_kind: &str,
) {
    let is_empty = Symbol::intern("is_empty");
    let is_empty = cx
        .tcx
        .inherent_impls(impl_ty)
        .iter()
        .flat_map(|&id| cx.tcx.associated_items(id).filter_by_name_unhygienic(is_empty))
        .find(|item| item.kind == AssocKind::Fn);

    let (msg, is_empty_span, self_kind) = match is_empty {
        None => (
            format!(
                "{} `{}` has a public `len` method, but no `is_empty` method",
                item_kind,
                item_name.as_str(),
            ),
            None,
            None,
        ),
        Some(is_empty) if !cx.access_levels.is_exported(is_empty.def_id.expect_local()) => (
            format!(
                "{} `{}` has a public `len` method, but a private `is_empty` method",
                item_kind,
                item_name.as_str(),
            ),
            Some(cx.tcx.def_span(is_empty.def_id)),
            None,
        ),
        Some(is_empty)
            if !(is_empty.fn_has_self_parameter
                && check_is_empty_sig(cx.tcx.fn_sig(is_empty.def_id).skip_binder(), self_kind, output)) =>
        {
            (
                format!(
                    "{} `{}` has a public `len` method, but the `is_empty` method has an unexpected signature",
                    item_kind,
                    item_name.as_str(),
                ),
                Some(cx.tcx.def_span(is_empty.def_id)),
                Some(self_kind),
            )
        },
        Some(_) => return,
    };

    span_lint_and_then(cx, LEN_WITHOUT_IS_EMPTY, span, &msg, |db| {
        if let Some(span) = is_empty_span {
            db.span_note(span, "`is_empty` defined here");
        }
        if let Some(self_kind) = self_kind {
            db.note(&output.expected_sig(self_kind));
        }
    });
}
/// Checks if the given type has an `is_empty` method with the appropriate signature.
Checks if the given type has an `is_empty` method with the appropriate signature.
Checks if the given type has an ` is_empty ` method with the appropriate signature .
fn check_for_is_empty(
    cx: &LateContext<'_>,
    span: Span,
    self_kind: ImplicitSelfKind,
    output: LenOutput<'_>,
    impl_ty: DefId,
    item_name: Symbol,
    item_kind: &str,
) {
    let is_empty = Symbol::intern("is_empty");
    let is_empty = cx
        .tcx
        .inherent_impls(impl_ty)
        .iter()
        .flat_map(|&id| cx.tcx.associated_items(id).filter_by_name_unhygienic(is_empty))
        .find(|item| item.kind == AssocKind::Fn);
    let (msg, is_empty_span, self_kind) = match is_empty {
        None => (
            format!(
                "{} `{}` has a public `len` method, but no `is_empty` method",
                item_kind,
                item_name.as_str(),
            ),
            None,
            None,
        ),
        Some(is_empty) if !cx.access_levels.is_exported(is_empty.def_id.expect_local()) => (
            format!(
                "{} `{}` has a public `len` method, but a private `is_empty` method",
                item_kind,
                item_name.as_str(),
            ),
            Some(cx.tcx.def_span(is_empty.def_id)),
            None,
        ),
        Some(is_empty)
            if !(is_empty.fn_has_self_parameter
                && check_is_empty_sig(cx.tcx.fn_sig(is_empty.def_id).skip_binder(), self_kind, output)) =>
        {
            (
                format!(
                    "{} `{}` has a public `len` method, but the `is_empty` method has an unexpected signature",
                    item_kind,
                    item_name.as_str(),
                ),
                Some(cx.tcx.def_span(is_empty.def_id)),
                Some(self_kind),
            )
        },
        Some(_) => return,
    };
    span_lint_and_then(cx, LEN_WITHOUT_IS_EMPTY, span, &msg, |db| {
        if let Some(span) = is_empty_span {
            db.span_note(span, "`is_empty` defined here");
        }
        if let Some(self_kind) = self_kind {
            db.note(&output.expected_sig(self_kind));
        }
    });
}
fn check_for_is_empty ( cx : & LateContext < ' _ > , span : Span , self_kind : ImplicitSelfKind , output : LenOutput < ' _ > , impl_ty : DefId , item_name : Symbol , item_kind : & str , ) { let is_empty = Symbol :: intern ( " " ) ; let is_empty = cx . tcx . inherent_impls ( impl_ty ) . iter ( ) . flat_map ( | & id | cx . tcx . associated_items ( id ) . filter_by_name_unhygienic ( is_empty ) ) . find ( | item | item . kind == AssocKind :: Fn ) ; let ( msg , is_empty_span , self_kind ) = match is_empty { None => ( format ! ( " " item_kind item_name as_str ( ) ) , None , None , ) , Some ( is_empty ) if ! cx . access_levels . is_exported ( is_empty . def_id . expect_local ( ) ) => ( format ! ( " " item_kind item_name as_str ( ) ) , Some ( cx . tcx . def_span ( is_empty . def_id ) ) , None , ) , Some ( is_empty ) if ! ( is_empty . fn_has_self_parameter && check_is_empty_sig ( cx . tcx . fn_sig ( is_empty . def_id ) . skip_binder ( ) , self_kind , output ) ) => { ( format ! ( " " item_kind item_name as_str ( ) ) , Some ( cx . tcx . def_span ( is_empty . def_id ) ) , Some ( self_kind ) , ) } , Some ( _ ) => return , } ; span_lint_and_then ( cx , LEN_WITHOUT_IS_EMPTY , span , & msg , | db | { if let Some ( span ) = is_empty_span { db . span_note ( span , " " ) ; } if let Some ( self_kind ) = self_kind { db . note ( & output . expected_sig ( self_kind ) ) ; } } ) ; }
Checks if the given type has an `is_empty` method with the appropriate signature.
Checks if the given type has an ` is_empty ` method with the appropriate signature .
cx
&LateContext<'_>
span
Span
self_kind
ImplicitSelfKind
output
LenOutput<'_>
impl_ty
DefId
item_name
Symbol
item_kind
&str