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. --Hello, I am sorry, but I wasn't able to reproduce the bug outside my company's project (proprietary and which I don't have the permission to share), so I can't really help here. Code like this resides in proc-macro transformed function ( from leptos) and inside recursivelly calling macro. Here is how approximately it looks: <!-- 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. --Fails on both nightly and stable, backtrace if from nightly. : <!-- Include a backtrace in the code block by setting in your environment. E.g. . --<details<summary<strongBacktrace</strong</summary<p</p</detailsHope this helps and thank for your work.
Relabeling issues which don't have a runnable reproduction (as opposed to not having a minimized one) to the new label S-needs-repro. label +S-needs-repro -E-needs-mcve
I think I encountered the same bug. A minimal example is below. I think the problem is a lookup, which includes the unimplemented trait without checking the length of the argument list before accessing. : Also fails on nightly. <details<summary<strongnightly ructc-</strong</summary<p</p</details
Maybe inside rollup ? cc
I ran into this ICE and minimized my case to the following reproducer. Its slightly different way to get to the same case as 's code above. Still happens from stable 1.77.2 to nightly 2024-04-19. When doing a bisection I get nightly-2023-05-16.

Discussion:
let Some(arg_ty) = self.node_ty_opt(args[idx].hir_id) else { return false; }; <del> let possible_rcvr_ty = expr_finder.uses.iter().find_map(|binding| { </del> <ins> let possible_rcvr_ty = expr_finder.uses.iter().rev().find_map(|binding| { </ins> let possible_rcvr_ty = self.node_ty_opt(binding.hir_id)?; <ins> if possible_rcvr_ty.is_ty_var() { return None; } </ins> // Fudge the receiver, so we can do new inference on it. let possible_rcvr_ty = possible_rcvr_ty.fold_with(&mut fudger); let method = self

binding, ) .ok()?; <ins> // Make sure we select the same method that we started with... if Some(method.def_id) != self.typeck_results.borrow().type_dependent_def_id(call_expr.hir_id) { return None; } </ins> // Unify the method signature with our incompatible arg, to // do inference in the *opposite* direction and to find out // what our ideal rcvr ty would look like.

) else { continue; }; <ins> // Make sure we select the same method that we started with... if Some(method.def_id) != self.typeck_results.borrow().type_dependent_def_id(parent_expr.hir_id) { continue; } </ins> let ideal_rcvr_ty = rcvr_ty.fold_with(&mut fudger); let ideal_method = self

// blame arg, if possible. Don't do this if we're coming from // arg mismatch code, because we'll possibly suggest a mutually // incompatible fix at the original mismatch site. <ins> // HACK(compiler-errors): We don't actually consider the implications // of our inference guesses in `emit_type_mismatch_suggestions`, so // only suggest things when we know our type error is precisely due to // a type mismatch, and not via some projection or something. See #116155. </ins> if matches!(source, TypeMismatchSource::Ty(_)) && let Some(ideal_method) = ideal_method <del> && let ideal_arg_ty = self.resolve_vars_if_possible(ideal_method.sig.inputs()[idx + 1]) // HACK(compiler-errors): We don't actually consider the implications // of our inference guesses in `emit_type_mismatch_suggestions`, so // only suggest things when we know our type error is precisely due to // a type mismatch, and not via some projection or something. See #116155. </del> <ins> && Some(ideal_method.def_id) == self .typeck_results .borrow() .type_dependent_def_id(parent_expr.hir_id) && let ideal_arg_ty = self.resolve_vars_if_possible(ideal_method.sig.inputs()[idx + 1]) </ins> && !ideal_arg_ty.has_non_region_infer() { self.emit_type_mismatch_suggestions(

<del> //@ known-bug: #118185 fn main() { let target: Target = create_target(); target.get(0); // correct arguments work target.get(10.0); // CRASH HERE } // must be generic fn create_target<T>() -> T { unimplemented!() } // unimplemented trait, but contains function with the same name pub trait RandomTrait { fn get(&mut self); // but less arguments } struct Target; impl Target { // correct function with arguments pub fn get(&self, data: i32) { unimplemented!() } } </del>

<ins> fn main() { let target: Target = create_target(); target.get(0); // correct arguments work target.get(10.0); // (used to crash here) //~^ ERROR mismatched types } // must be generic fn create_target<T>() -> T { unimplemented!() } // unimplemented trait, but contains function with the same name pub trait RandomTrait { fn get(&mut self); // but less arguments } struct Target; impl Target { // correct function with arguments pub fn get(&self, data: i32) { unimplemented!() } } </ins>

<ins> error[E0308]: mismatched types --> $DIR/diagnostic-method-lookup-returns-sig-with-fewer-args.rs:4:16 | LL |     target.get(10.0); // (used to crash here) |            --- ^^^^ expected `i32`, found floating-point number |            | |            arguments to this method are incorrect | note: method defined here --> $DIR/diagnostic-method-lookup-returns-sig-with-fewer-args.rs:22:12 | LL |     pub fn get(&self, data: i32) { |            ^^^        --------- error: aborting due to 1 previous error For more information about this error, try `rustc --explain E0308`. </ins>