Skip to content

Commit 2e2e45a

Browse files
authored
Rollup merge of rust-lang#108484 - Nilstrieb:˂DiagnosticItem˂FromFn˃ as From˂˂LangItemFromFn˃˃˃꞉꞉from, r=cjgillot
Remove `from` 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.
2 parents 9fd0a41 + 0f3446b commit 2e2e45a

File tree

3 files changed

+6
-5
lines changed

3 files changed

+6
-5
lines changed

clippy_lints/src/operators/cmp_owned.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -49,10 +49,10 @@ fn check_op(cx: &LateContext<'_>, expr: &Expr<'_>, other: &Expr<'_>, left: bool)
4949
(arg, arg.span)
5050
},
5151
ExprKind::Call(path, [arg])
52-
if path_def_id(cx, path).map_or(false, |id| {
53-
if match_def_path(cx, id, &paths::FROM_STR_METHOD) {
52+
if path_def_id(cx, path).map_or(false, |did| {
53+
if match_def_path(cx, did, &paths::FROM_STR_METHOD) {
5454
true
55-
} else if cx.tcx.lang_items().from_fn() == Some(id) {
55+
} else if cx.tcx.is_diagnostic_item(sym::from_fn, did) {
5656
!is_copy(cx, typeck.expr_ty(expr))
5757
} else {
5858
false

clippy_lints/src/unnecessary_owned_empty_strings.rs

+2-1
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ use rustc_hir::{BorrowKind, Expr, ExprKind, LangItem, Mutability};
77
use rustc_lint::{LateContext, LateLintPass};
88
use rustc_middle::ty;
99
use rustc_session::{declare_lint_pass, declare_tool_lint};
10+
use rustc_span::symbol::sym;
1011

1112
declare_clippy_lint! {
1213
/// ### What it does
@@ -54,7 +55,7 @@ impl<'tcx> LateLintPass<'tcx> for UnnecessaryOwnedEmptyStrings {
5455
);
5556
} else {
5657
if_chain! {
57-
if Some(fun_def_id) == cx.tcx.lang_items().from_fn();
58+
if cx.tcx.is_diagnostic_item(sym::from_fn, fun_def_id);
5859
if let [.., last_arg] = args;
5960
if let ExprKind::Lit(spanned) = &last_arg.kind;
6061
if let LitKind::Str(symbol, _) = spanned.node;

clippy_lints/src/useless_conversion.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -161,7 +161,7 @@ impl<'tcx> LateLintPass<'tcx> for UselessConversion {
161161
}
162162

163163
if_chain! {
164-
if Some(def_id) == cx.tcx.lang_items().from_fn();
164+
if cx.tcx.is_diagnostic_item(sym::from_fn, def_id);
165165
if same_type_and_consts(a, b);
166166

167167
then {

0 commit comments

Comments
 (0)