fn check_arc_dupe()

in gazebo_lint/src/lib.rs [565:604]


fn check_arc_dupe(cx: &LateContext, ty: &Ty) {
    if let rustc_hir::TyKind::Path(QPath::Resolved(
        _,
        Path {
            res: Res::Def(DefKind::Struct, result),
            segments:
                [
                    PathSegment {
                        args:
                            Some(GenericArgs {
                                args: [GenericArg::Type(inner)],
                                ..
                            }),
                        ..
                    },
                ],
            ..
        },
    )) = &ty.kind
    {
        let lint_name = if clippy::match_def_path(cx, *result, &["alloc", "sync", "Arc"]) {
            GAZEBO_LINT_ARC_ON_DUPE
        } else if clippy::match_def_path(cx, *result, &["alloc", "rc", "Rc"]) {
            GAZEBO_LINT_RC_ON_DUPE
        } else {
            return;
        };

        if let Some(dupe_trait) = clippy::get_trait_def_id(cx, &["gazebo", "dupe", "Dupe"]) {
            let inner = clippy::ty_from_hir_ty(cx, inner);
            if inner.has_escaping_bound_vars() {
                // Otherwise we get a panic in implements_trait
                return;
            }
            if clippy::implements_trait(cx, inner, dupe_trait, &[]) {
                emit_lint(cx, lint_name, ty.span);
            }
        }
    }
}