mirror of
https://github.com/rust-lang/rust-clippy
synced 2024-11-30 16:39:26 +00:00
Remove from_fn
lang item
It was probably a leftover from the old `?` desugaring but anyways, it's unused now except for clippy, which can just use a diagnostics item.
This commit is contained in:
parent
ab69a2a57b
commit
0f3446b371
3 changed files with 6 additions and 5 deletions
|
@ -49,10 +49,10 @@ fn check_op(cx: &LateContext<'_>, expr: &Expr<'_>, other: &Expr<'_>, left: bool)
|
||||||
(arg, arg.span)
|
(arg, arg.span)
|
||||||
},
|
},
|
||||||
ExprKind::Call(path, [arg])
|
ExprKind::Call(path, [arg])
|
||||||
if path_def_id(cx, path).map_or(false, |id| {
|
if path_def_id(cx, path).map_or(false, |did| {
|
||||||
if match_def_path(cx, id, &paths::FROM_STR_METHOD) {
|
if match_def_path(cx, did, &paths::FROM_STR_METHOD) {
|
||||||
true
|
true
|
||||||
} else if cx.tcx.lang_items().from_fn() == Some(id) {
|
} else if cx.tcx.is_diagnostic_item(sym::from_fn, did) {
|
||||||
!is_copy(cx, typeck.expr_ty(expr))
|
!is_copy(cx, typeck.expr_ty(expr))
|
||||||
} else {
|
} else {
|
||||||
false
|
false
|
||||||
|
|
|
@ -7,6 +7,7 @@ use rustc_hir::{BorrowKind, Expr, ExprKind, LangItem, Mutability};
|
||||||
use rustc_lint::{LateContext, LateLintPass};
|
use rustc_lint::{LateContext, LateLintPass};
|
||||||
use rustc_middle::ty;
|
use rustc_middle::ty;
|
||||||
use rustc_session::{declare_lint_pass, declare_tool_lint};
|
use rustc_session::{declare_lint_pass, declare_tool_lint};
|
||||||
|
use rustc_span::symbol::sym;
|
||||||
|
|
||||||
declare_clippy_lint! {
|
declare_clippy_lint! {
|
||||||
/// ### What it does
|
/// ### What it does
|
||||||
|
@ -54,7 +55,7 @@ impl<'tcx> LateLintPass<'tcx> for UnnecessaryOwnedEmptyStrings {
|
||||||
);
|
);
|
||||||
} else {
|
} else {
|
||||||
if_chain! {
|
if_chain! {
|
||||||
if Some(fun_def_id) == cx.tcx.lang_items().from_fn();
|
if cx.tcx.is_diagnostic_item(sym::from_fn, fun_def_id);
|
||||||
if let [.., last_arg] = args;
|
if let [.., last_arg] = args;
|
||||||
if let ExprKind::Lit(spanned) = &last_arg.kind;
|
if let ExprKind::Lit(spanned) = &last_arg.kind;
|
||||||
if let LitKind::Str(symbol, _) = spanned.node;
|
if let LitKind::Str(symbol, _) = spanned.node;
|
||||||
|
|
|
@ -161,7 +161,7 @@ impl<'tcx> LateLintPass<'tcx> for UselessConversion {
|
||||||
}
|
}
|
||||||
|
|
||||||
if_chain! {
|
if_chain! {
|
||||||
if Some(def_id) == cx.tcx.lang_items().from_fn();
|
if cx.tcx.is_diagnostic_item(sym::from_fn, def_id);
|
||||||
if same_type_and_consts(a, b);
|
if same_type_and_consts(a, b);
|
||||||
|
|
||||||
then {
|
then {
|
||||||
|
|
Loading…
Reference in a new issue