|
1 | 1 | use clippy_utils::diagnostics::span_lint_and_then;
|
2 |
| -use clippy_utils::{expr_or_init, fn_def_id_with_node_args, get_trait_def_id, path_def_id}; |
3 |
| -use itertools::Itertools; |
| 2 | +use clippy_utils::{expr_or_init, fn_def_id_with_node_args, path_def_id}; |
4 | 3 | use rustc_ast::BinOpKind;
|
5 | 4 | use rustc_data_structures::fx::FxHashMap;
|
6 | 5 | use rustc_hir as hir;
|
@@ -311,10 +310,9 @@ where
|
311 | 310 | }
|
312 | 311 |
|
313 | 312 | impl UnconditionalRecursion {
|
314 |
| - #[allow(clippy::unnecessary_def_path)] |
315 | 313 | fn init_default_impl_for_type_if_needed(&mut self, cx: &LateContext<'_>) {
|
316 | 314 | if self.default_impl_for_type.is_empty()
|
317 |
| - && let Some(default_trait_id) = get_trait_def_id(cx, &["core", "default", "Default"]) |
| 315 | + && let Some(default_trait_id) = cx.tcx.get_diagnostic_item(sym::Default) |
318 | 316 | {
|
319 | 317 | let impls = cx.tcx.trait_impls_of(default_trait_id);
|
320 | 318 | for (ty, impl_def_ids) in impls.non_blanket_impls() {
|
@@ -409,7 +407,8 @@ fn check_from(cx: &LateContext<'_>, method_span: Span, method_def_id: LocalDefId
|
409 | 407 | // which calls back into our `From::from` again (`Into` is not specializable).
|
410 | 408 | // rustc's unconditional_recursion already catches calling `From::from` directly
|
411 | 409 | if let Some((fn_def_id, node_args)) = fn_def_id_with_node_args(cx, expr)
|
412 |
| - && let Some((s1, s2)) = node_args.iter().filter_map(ty::GenericArg::as_type).collect_tuple() |
| 410 | + && let [s1, s2] = **node_args |
| 411 | + && let (Some(s1), Some(s2)) = (s1.as_type(), s2.as_type()) |
413 | 412 | && let Some(trait_def_id) = cx.tcx.trait_of_item(fn_def_id)
|
414 | 413 | && cx.tcx.is_diagnostic_item(sym::Into, trait_def_id)
|
415 | 414 | && get_impl_trait_def_id(cx, method_def_id) == cx.tcx.get_diagnostic_item(sym::From)
|
|
0 commit comments