]> git.lizzy.rs Git - rust.git/blobdiff - src/tools/clippy/clippy_lints/src/useless_conversion.rs
Merge commit 'da5a6fb1b65ec6581a67e942a3850f6bc15a552c' into clippyup
[rust.git] / src / tools / clippy / clippy_lints / src / useless_conversion.rs
index a48ad3185e9c2f440de3f95fd5bb0b9eb40e6ae8..1bf37632e326cfa2d7a76be9361983a49fecd731 100644 (file)
@@ -1,6 +1,6 @@
 use crate::utils::{
-    is_type_diagnostic_item, match_def_path, match_trait_method, paths, snippet, snippet_with_macro_callsite,
-    span_lint_and_help, span_lint_and_sugg,
+    get_parent_expr, is_type_diagnostic_item, match_def_path, match_trait_method, paths, snippet,
+    snippet_with_macro_callsite, span_lint_and_help, span_lint_and_sugg,
 };
 use if_chain::if_chain;
 use rustc_errors::Applicability;
@@ -79,6 +79,13 @@ fn check_expr(&mut self, cx: &LateContext<'tcx>, e: &'tcx Expr<'_>) {
                     }
                 }
                 if match_trait_method(cx, e, &paths::INTO_ITERATOR) && &*name.ident.as_str() == "into_iter" {
+                    if let Some(parent_expr) = get_parent_expr(cx, e) {
+                        if let ExprKind::MethodCall(ref parent_name, ..) = parent_expr.kind {
+                            if &*parent_name.ident.as_str() != "into_iter" {
+                                return;
+                            }
+                        }
+                    }
                     let a = cx.typeck_results().expr_ty(e);
                     let b = cx.typeck_results().expr_ty(&args[0]);
                     if TyS::same_type(a, b) {