diff --git a/src/librustc/middle/typeck/check/mod.rs b/src/librustc/middle/typeck/check/mod.rs index 8c37567bcd7..953ae0b9bd9 100644 --- a/src/librustc/middle/typeck/check/mod.rs +++ b/src/librustc/middle/typeck/check/mod.rs @@ -2523,8 +2523,10 @@ fn check_argument_types<'a>(fcx: &FnCtxt, "this function takes 0 parameters but {} parameter{} supplied", args.len(), if args.len() == 1 {" was"} else {"s were"}); + err_args(args.len()) + } else { + vec![] } - Vec::new() } _ => { span_err!(tcx.sess, sp, E0059, diff --git a/src/test/compile-fail/issue-16939.rs b/src/test/compile-fail/issue-16939.rs new file mode 100644 index 00000000000..8e7a2a9db3d --- /dev/null +++ b/src/test/compile-fail/issue-16939.rs @@ -0,0 +1,20 @@ +// Copyright 2014 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +#![feature(overloaded_calls)] + +// Make sure we don't ICE when making an overloaded call with the +// wrong arity. + +fn _foo (f: F) { + |t| f(t); //~ ERROR E0058 +} + +fn main() {}