You are an expert in writing code in many different languages. Your goal is to perform code completion for the following code, keeping in mind the rest of the code and the file meta data.
    Metadata details:
    filename: rc_buffer.rs
    path of file: ./repos/rust-clippy/clippy_lints/src/types
    
    the code of the file until where you have to start completion: use clippy_utils::diagnostics::span_lint_and_sugg;
use clippy_utils::source::snippet_with_applicability;
use clippy_utils::{path_def_id, qpath_generic_tys};
use rustc_errors::Applicability;
use rustc_hir::def_id::DefId;
use rustc_hir::{self as hir, QPath, TyKind};
use rustc_lint::LateContext;
use rustc_span::symbol::sym;

use super::RC_BUFFER;

pub(super) fn check(cx: &LateContext<'_>, hir_ty: &hir::Ty<'_>, qpath: &QPath<'_>, def_id: DefId) -> bool {
    let app = Applicability::Unspecified;
    if cx.tcx.is_diagnostic_item(sym::Rc, def_id) {
        if let Some(alternate) = match_buffer_type(cx, qpath) {
            span_lint_and_sugg(
                cx,
                RC_BUFFER,
                hir_ty.span,
                "usage of `Rc<T>` when T is a buffer type",
                "try",
                format!("Rc<{alternate}>"),
                app,
            );
        } else {
            let Some(ty) = qpath_generic_tys(qpath).next() else {
                return false;
            };
            let Some(id) = path_def_id(cx, ty) else { return false };
            if !cx.tcx.is_diagnostic_item(sym::Vec, id) {
                return false;
            }
            let TyKind::Path(qpath) = &ty.kind else { return false };
            let inner_span = match qpath_generic_tys(qpath).next() {
                Some(ty) => ty.span,
                None => return false,
            };
            let mut applicability = app;
            span_lint_and_sugg(
                cx,
                RC_BUFFER,
                hir_ty.span,
                "usage of `Rc<T>` when T is a buffer type",
                "try",
                format!(
                    "Rc<[{}]>",
                    snippet_with_ap
    
pub(super) fn check(cx: &LateContext<'_>, hir_ty: &hir::Ty<'_>, qpath: &QPath<'_>, def_id: DefId) -> bool {
    let app = Applicability::Unspecified;
    if cx.tcx.is_diagnostic_item(sym::Rc, def_id) {
        if let Some(alternate) = match_buffer_type(cx, qpath) {
            span_lint_and_sugg(
                cx,
                RC_BUFFER,
                hir_ty.span,
                "usage of `Rc<T>` when T is a buffer type",
                "try",
                format!("Rc<{alternate}>"),
                app,
            );
        } else {
            let Some(ty) = qpath_generic_tys(qpath).next() else {
                return false;
            };
            let Some(id) = path_def_id(cx, ty) else { return false };
            if !cx.tcx.is_diagnostic_item(sym::Vec, id) {
                return false;
            }
            let TyKind::Path(qpath) = &ty.kind else { return false };
            let inner_span = match qpath_generic_tys(qpath).next() {
                Some(ty) => ty.span,
                None => return false,
            };
            let mut applicability = app;
            span_lint_and_sugg(
                cx,
                RC_BUFFER,
                hir_ty.span,
                "usage of `Rc<T>` when T is a buffer type",
                "try",
                format!(
                    "Rc<[{}]>",
                    snippet_with_applicability(cx, inner_span, "..", &mut applicability)
                ),
                app,
            );
            return true;
        }
    } else if cx.tcx.is_diagnostic_item(sym::Arc, def_id) {
        if let Some(alternate) = match_buffer_type(cx, qpath) {
            span_lint_and_sugg(
                cx,
                RC_BUFFER,
                hir_ty.span,
                "usage of `Arc<T>` when T is a buffer type",
                "try",
                format!("Arc<{alternate}>"),
                app,
            );
        } else if let Some(ty) = qpath_generic_tys(qpath).next() {
            let Some(id) = path_def_id(cx, ty) else { return false };
            if !cx.tcx.is_diagnostic_item(sym::Vec, id) {
                return false;
            }
            let TyKind::Path(qpath) = &ty.kind else { return false };
            let inner_span = match qpath_generic_tys(qpath).next() {
                Some(ty) => ty.span,
                None => return false,
            };
            let mut applicability = app;
            span_lint_and_sugg(
                cx,
                RC_BUFFER,
                hir_ty.span,
                "usage of `Arc<T>` when T is a buffer type",
                "try",
                format!(
                    "Arc<[{}]>",
                    snippet_with_applicability(cx, inner_span, "..", &mut applicability)
                ),
                app,
            );
            return true;
        }
    }

    false
}