Change:
<!-- Thank you for finding an Internal Compiler Error! If possible, try to provide a minimal verifiable example. You can read "Rust Bug Minimization Patterns" for how to create smaller examples. --Found this one while researching for , probably has a related cause (since diagnostics call a second time which confuses the compiler). This is an ICE though so opening a dedicated issue. cc searched nightlies: from nightly-2022-04-10 to nightly-2022-05-09 regressed nightly: nightly-2022-04-17 searched commit range: regressed commit: <details<summarybisected with <a href=''cargo-bisect-rustc</av0.6.3</summaryHost triple: x8664-unknown-linux-gnu Reproduce with: : </details<!-- If you're using the stable version of the compiler, you should also check if the bug also exists in the beta or nightly versions. --: <!-- Include a backtrace in the code block by setting in your environment. E.g. . --<details<summary<strongBacktrace</strong</summary<p</p</details
This does not ICE on stable 1.62.0 but ICEs on Beta version: 1.63.0-beta.3 (2022-07-02 ) and Nightly version: 1.64.0-nightly (2022-07-03 )
label regression-from-stable-to-nightly
I think this should actually be label +regression-from-stable-to-beta
Sorry label -regression-from-stable-to-nightly
WG-prioritization assigning priority (). label -I-prioritize +P-medium

Discussion:
} #[instrument(skip(self, expr), level = "debug")] <del> pub(super) fn check_expr_kind( </del> <ins> fn check_expr_kind( </ins> &self, expr: &'tcx hir::Expr<'tcx>, expected: Expectation<'tcx>,

self.set_tainted_by_errors(); let tcx = self.tcx; <ins> // Precompute the provided types and spans, since that's all we typically need for below let provided_arg_tys: IndexVec<ProvidedIdx, (Ty<'tcx>, Span)> = provided_args .iter() .map(|expr| { let ty = self .typeck_results .borrow() .expr_ty_adjusted_opt(*expr) .unwrap_or_else(|| tcx.ty_error()); (self.resolve_vars_if_possible(ty), expr.span) }) .collect(); </ins> // A "softer" version of the `demand_compatible`, which checks types without persisting them, // and treats error types differently // This will allow us to "probe" for other argument orders that would likely have been correct

return Compatibility::Incompatible(None); } <del> let provided_arg: &hir::Expr<'tcx> = &provided_args[provided_idx]; let expectation = Expectation::rvalue_hint(self, expected_input_ty); // FIXME: check that this is safe; I don't believe this commits any of the obligations, but I can't be sure. // //   I had another method of "soft" type checking before, //   but it was failing to find the type of some expressions (like "") //   so I prodded this method and made it pub(super) so I could call it, and it seems to work well. let checked_ty = self.check_expr_kind(provided_arg, expectation); </del> <ins> let (arg_ty, arg_span) = provided_arg_tys[provided_idx]; let expectation = Expectation::rvalue_hint(self, expected_input_ty); </ins> let coerced_ty = expectation.only_has_type(self).unwrap_or(formal_input_ty); <del> let can_coerce = self.can_coerce(checked_ty, coerced_ty); </del> <ins> let can_coerce = self.can_coerce(arg_ty, coerced_ty); </ins> if !can_coerce { return Compatibility::Incompatible(None); } // Using probe here, since we don't want this subtyping to affect inference. let subtyping_error = self.probe(|_| { <del> self.at(&self.misc(provided_arg.span), self.param_env) .sup(formal_input_ty, coerced_ty) .err() </del> <ins> self.at(&self.misc(arg_span), self.param_env).sup(formal_input_ty, coerced_ty).err() </ins> }); // Same as above: if either the coerce type or the checked type is an error type, // consider them *not* compatible. <del> let references_error = (coerced_ty, checked_ty).references_error(); </del> <ins> let references_error = (coerced_ty, arg_ty).references_error(); </ins> match (references_error, subtyping_error) { (false, None) => Compatibility::Compatible, (_, subtyping_error) => Compatibility::Incompatible(subtyping_error),

ArgMatrix::new(provided_args.len(), formal_and_expected_inputs.len(), check_compatible) .find_errors(); <del> // Precompute the provided types and spans, since that's all we typically need for below let provided_arg_tys: IndexVec<ProvidedIdx, (Ty<'tcx>, Span)> = provided_args .iter() .map(|expr| { let ty = self .typeck_results .borrow() .expr_ty_adjusted_opt(*expr) .unwrap_or_else(|| tcx.ty_error()); (self.resolve_vars_if_possible(ty), expr.span) }) .collect(); </del> // First, check if we just need to wrap some arguments in a tuple. if let Some((mismatch_idx, terr)) = compatibility_diagonal.iter().enumerate().find_map(|(i, c)| {

fn main() { let needlesArr: Vec<char> = vec!['a', 'f']; needlesArr.iter().fold(|x, y| { <ins> //~^ ERROR this function takes 2 arguments but 1 argument was supplied </ins> }); <del> //~^^ ERROR mismatched types //~| ERROR this function takes 2 arguments but 1 argument was supplied </del> }

<del> error[E0308]: mismatched types --> $DIR/issue-3044.rs:3:35 | LL |       needlesArr.iter().fold(|x, y| { |  ____________________________------_^ | |                            | | |                            the expected closure LL | |     }); | |_____^ expected closure, found `()` | = note: expected closure `[closure@$DIR/issue-3044.rs:3:28: 3:34]` found unit type `()` </del> error[E0061]: this function takes 2 arguments but 1 argument was supplied --> $DIR/issue-3044.rs:3:23 | LL |       needlesArr.iter().fold(|x, y| { |  _______________________^^^^- <ins> LL | | </ins> LL | |     }); | |______- an argument is missing |

help: provide the argument | LL ~     needlesArr.iter().fold(|x, y| { <ins> LL + </ins> LL ~     }, /* value */); | <del> error: aborting due to 2 previous errors </del> <ins> error: aborting due to previous error </ins> <del> Some errors have detailed explanations: E0061, E0308. For more information about an error, try `rustc --explain E0061`. </del> <ins> For more information about this error, try `rustc --explain E0061`. </ins>