Remove duplicate type_diagnostic_name
function
This commit is contained in:
parent
4f661302c6
commit
ed46141081
@ -1,7 +1,7 @@
|
|||||||
use clippy_utils::diagnostics::{span_lint_and_sugg, span_lint_and_then};
|
use clippy_utils::diagnostics::{span_lint_and_sugg, span_lint_and_then};
|
||||||
use clippy_utils::higher::VecArgs;
|
use clippy_utils::higher::VecArgs;
|
||||||
use clippy_utils::source::snippet_opt;
|
use clippy_utils::source::snippet_opt;
|
||||||
use clippy_utils::ty::type_diagnostic_name;
|
use clippy_utils::ty::get_type_diagnostic_name;
|
||||||
use clippy_utils::usage::{local_used_after_expr, local_used_in};
|
use clippy_utils::usage::{local_used_after_expr, local_used_in};
|
||||||
use clippy_utils::{get_path_from_caller_to_method_type, is_adjusted, path_to_local, path_to_local_id};
|
use clippy_utils::{get_path_from_caller_to_method_type, is_adjusted, path_to_local, path_to_local_id};
|
||||||
use rustc_errors::Applicability;
|
use rustc_errors::Applicability;
|
||||||
@ -139,7 +139,7 @@ fn check_clousure<'tcx>(cx: &LateContext<'tcx>, outer_receiver: Option<&Expr<'tc
|
|||||||
{
|
{
|
||||||
let callee_ty_raw = typeck.expr_ty(callee);
|
let callee_ty_raw = typeck.expr_ty(callee);
|
||||||
let callee_ty = callee_ty_raw.peel_refs();
|
let callee_ty = callee_ty_raw.peel_refs();
|
||||||
if matches!(type_diagnostic_name(cx, callee_ty), Some(sym::Arc | sym::Rc))
|
if matches!(get_type_diagnostic_name(cx, callee_ty), Some(sym::Arc | sym::Rc))
|
||||||
|| !check_inputs(typeck, body.params, None, args)
|
|| !check_inputs(typeck, body.params, None, args)
|
||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
|
@ -455,11 +455,6 @@ pub fn is_type_lang_item(cx: &LateContext<'_>, ty: Ty<'_>, lang_item: LangItem)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Gets the diagnostic name of the type, if it has one
|
|
||||||
pub fn type_diagnostic_name(cx: &LateContext<'_>, ty: Ty<'_>) -> Option<Symbol> {
|
|
||||||
ty.ty_adt_def().and_then(|adt| cx.tcx.get_diagnostic_name(adt.did()))
|
|
||||||
}
|
|
||||||
|
|
||||||
/// Return `true` if the passed `typ` is `isize` or `usize`.
|
/// Return `true` if the passed `typ` is `isize` or `usize`.
|
||||||
pub fn is_isize_or_usize(typ: Ty<'_>) -> bool {
|
pub fn is_isize_or_usize(typ: Ty<'_>) -> bool {
|
||||||
matches!(typ.kind(), ty::Int(IntTy::Isize) | ty::Uint(UintTy::Usize))
|
matches!(typ.kind(), ty::Int(IntTy::Isize) | ty::Uint(UintTy::Usize))
|
||||||
|
Loading…
Reference in New Issue
Block a user