Skip to content

Commit 21d12c0

Browse files
committed
typeck: Make the supplied parameters to be a tuple
When a type error occurs, check_method_argument_types() tries to provide arguments filled with ty::mk_err(). However, if a function takes the parameters as a tuple, the arguments should be converted to a tuple before being passed to check_argument_types(). Fixes #19521.
1 parent 4c692d3 commit 21d12c0

File tree

2 files changed

+22
-1
lines changed

2 files changed

+22
-1
lines changed

src/librustc_typeck/check/mod.rs

+7-1
Original file line numberDiff line numberDiff line change
@@ -2623,7 +2623,13 @@ fn check_method_argument_types<'a, 'tcx>(fcx: &FnCtxt<'a, 'tcx>,
26232623
tuple_arguments: TupleArgumentsFlag)
26242624
-> ty::FnOutput<'tcx> {
26252625
if ty::type_is_error(method_fn_ty) {
2626-
let err_inputs = err_args(args_no_rcvr.len());
2626+
let err_inputs = err_args(args_no_rcvr.len());
2627+
2628+
let err_inputs = match tuple_arguments {
2629+
DontTupleArguments => err_inputs,
2630+
TupleArguments => vec![ty::mk_tup(fcx.tcx(), err_inputs)],
2631+
};
2632+
26272633
check_argument_types(fcx,
26282634
sp,
26292635
err_inputs.as_slice(),

src/test/compile-fail/issue-19521.rs

+15
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
// Copyright 2014 The Rust Project Developers. See the COPYRIGHT
2+
// file at the top-level directory of this distribution and at
3+
// http://rust-lang.org/COPYRIGHT.
4+
//
5+
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
6+
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
7+
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
8+
// option. This file may not be copied, modified, or distributed
9+
// except according to those terms.
10+
11+
#![feature(unboxed_closures)]
12+
13+
fn main() {
14+
"".homura()(); //~ ERROR does not implement any method
15+
}

0 commit comments

Comments
 (0)