[Clippy] Swap unnecessary_owned_empty_strings
to use diagnostic item instead of path
This commit is contained in:
parent
1b76ae683c
commit
f1fc9c07c4
@ -1,6 +1,5 @@
|
|||||||
use clippy_utils::diagnostics::span_lint_and_sugg;
|
use clippy_utils::diagnostics::span_lint_and_sugg;
|
||||||
use clippy_utils::ty::is_type_lang_item;
|
use clippy_utils::ty::is_type_lang_item;
|
||||||
use clippy_utils::{match_def_path, paths};
|
|
||||||
use rustc_ast::ast::LitKind;
|
use rustc_ast::ast::LitKind;
|
||||||
use rustc_errors::Applicability;
|
use rustc_errors::Applicability;
|
||||||
use rustc_hir::{BorrowKind, Expr, ExprKind, LangItem, Mutability};
|
use rustc_hir::{BorrowKind, Expr, ExprKind, LangItem, Mutability};
|
||||||
@ -42,7 +41,7 @@ impl<'tcx> LateLintPass<'tcx> for UnnecessaryOwnedEmptyStrings {
|
|||||||
&& let ty::Ref(_, inner_str, _) = cx.typeck_results().expr_ty_adjusted(expr).kind()
|
&& let ty::Ref(_, inner_str, _) = cx.typeck_results().expr_ty_adjusted(expr).kind()
|
||||||
&& inner_str.is_str()
|
&& inner_str.is_str()
|
||||||
{
|
{
|
||||||
if match_def_path(cx, fun_def_id, &paths::STRING_NEW) {
|
if cx.tcx.is_diagnostic_item(sym::string_new, fun_def_id) {
|
||||||
span_lint_and_sugg(
|
span_lint_and_sugg(
|
||||||
cx,
|
cx,
|
||||||
UNNECESSARY_OWNED_EMPTY_STRINGS,
|
UNNECESSARY_OWNED_EMPTY_STRINGS,
|
||||||
|
@ -51,7 +51,6 @@ pub const SERDE_DESERIALIZE: [&str; 3] = ["serde", "de", "Deserialize"];
|
|||||||
pub const SERDE_DE_VISITOR: [&str; 3] = ["serde", "de", "Visitor"];
|
pub const SERDE_DE_VISITOR: [&str; 3] = ["serde", "de", "Visitor"];
|
||||||
pub const STD_IO_SEEK_FROM_CURRENT: [&str; 4] = ["std", "io", "SeekFrom", "Current"];
|
pub const STD_IO_SEEK_FROM_CURRENT: [&str; 4] = ["std", "io", "SeekFrom", "Current"];
|
||||||
pub const STD_IO_SEEKFROM_START: [&str; 4] = ["std", "io", "SeekFrom", "Start"];
|
pub const STD_IO_SEEKFROM_START: [&str; 4] = ["std", "io", "SeekFrom", "Start"];
|
||||||
pub const STRING_NEW: [&str; 4] = ["alloc", "string", "String", "new"];
|
|
||||||
pub const SYMBOL: [&str; 3] = ["rustc_span", "symbol", "Symbol"];
|
pub const SYMBOL: [&str; 3] = ["rustc_span", "symbol", "Symbol"];
|
||||||
pub const SYMBOL_AS_STR: [&str; 4] = ["rustc_span", "symbol", "Symbol", "as_str"];
|
pub const SYMBOL_AS_STR: [&str; 4] = ["rustc_span", "symbol", "Symbol", "as_str"];
|
||||||
pub const SYMBOL_INTERN: [&str; 4] = ["rustc_span", "symbol", "Symbol", "intern"];
|
pub const SYMBOL_INTERN: [&str; 4] = ["rustc_span", "symbol", "Symbol", "intern"];
|
||||||
|
Loading…
x
Reference in New Issue
Block a user