Skip to content

Commit 3f4af33

Browse files
committed
Fix ICE when function argument mismatches.
1 parent 51ebe10 commit 3f4af33

File tree

2 files changed

+7
-2
lines changed

2 files changed

+7
-2
lines changed

compiler/rustc_hir_typeck/src/fn_ctxt/checks.rs

+4-1
Original file line numberDiff line numberDiff line change
@@ -126,7 +126,10 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
126126
Err(guar) => Err(guar),
127127
};
128128
if let Err(guar) = has_error {
129-
let err_inputs = self.err_args(args_no_rcvr.len(), guar);
129+
let err_inputs = self.err_args(
130+
method.map_or(args_no_rcvr.len(), |method| method.sig.inputs().len() - 1),
131+
guar,
132+
);
130133
let err_output = Ty::new_error(self.tcx, guar);
131134

132135
let err_inputs = match tuple_arguments {

tests/crashes/135124.rs renamed to tests/ui/fn/issue-135124.rs

+3-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
1-
//@ known-bug: #135124
1+
//! Used to ICE due to a size mismatch between the actual fake signature of `fold` and the
2+
//! generated signature used for error reporting.
3+
24
trait A {
35
fn y(&self)
46
{

0 commit comments

Comments
 (0)