about summary refs log tree commit diff
diff options
context:
space:
mode:
authorMatthias Krüger <matthias.krueger@famsik.de>2022-12-09 07:25:47 +0100
committerGitHub <noreply@github.com>2022-12-09 07:25:47 +0100
commit3e7aadc009d4aaa3da7c82b7abd2421e4e497b26 (patch)
tree624acd1e5ce565ec31803829f98cdaf2ef429522
parent04dac4285aefc2fb18ad07b1e40f6771e0763aea (diff)
parent3c29e742d13314365fe0c1887d2e46a9d8a532fb (diff)
downloadrust-3e7aadc009d4aaa3da7c82b7abd2421e4e497b26.tar.gz
rust-3e7aadc009d4aaa3da7c82b7abd2421e4e497b26.zip
Rollup merge of #105470 - flip1995:clippy_backport, r=Manishearth
Clippy: backport ICE fix before beta branch

r? `@Manishearth`

Before beta is branched tomorrow we should backport the fix from https://github.com/rust-lang/rust-clippy/pull/10027 for an ICE. That way we'll get this into stable one release sooner.

This only cherry-picks the fix, not the tests for it. The proper sync of this will be done next week Thursday.
-rw-r--r--src/tools/clippy/clippy_lints/src/methods/unnecessary_to_owned.rs6
1 files changed, 2 insertions, 4 deletions
diff --git a/src/tools/clippy/clippy_lints/src/methods/unnecessary_to_owned.rs b/src/tools/clippy/clippy_lints/src/methods/unnecessary_to_owned.rs
index 17b0507682a..9263f051972 100644
--- a/src/tools/clippy/clippy_lints/src/methods/unnecessary_to_owned.rs
+++ b/src/tools/clippy/clippy_lints/src/methods/unnecessary_to_owned.rs
@@ -386,14 +386,12 @@ fn can_change_type<'a>(cx: &LateContext<'a>, mut expr: &'a Expr<'a>, mut ty: Ty<
             Node::Expr(parent_expr) => {
                 if let Some((callee_def_id, call_substs, recv, call_args)) = get_callee_substs_and_args(cx, parent_expr)
                 {
-                    if Some(callee_def_id) == cx.tcx.lang_items().into_future_fn() {
-                        return false;
-                    }
-
                     let fn_sig = cx.tcx.fn_sig(callee_def_id).skip_binder();
                     if let Some(arg_index) = recv.into_iter().chain(call_args).position(|arg| arg.hir_id == expr.hir_id)
                         && let Some(param_ty) = fn_sig.inputs().get(arg_index)
                         && let ty::Param(ParamTy { index: param_index , ..}) = param_ty.kind()
+                        // https://github.com/rust-lang/rust-clippy/issues/9504 and https://github.com/rust-lang/rust-clippy/issues/10021
+                        && (*param_index as usize) < call_substs.len()
                     {
                         if fn_sig
                             .inputs()