Skip to content

Commit 6aa3dd1

Browse files
Inline check_method_argument_types to get rid of TupleArgumentsFlag arg
1 parent e650c1d commit 6aa3dd1

File tree

3 files changed

+13
-23
lines changed

3 files changed

+13
-23
lines changed

compiler/rustc_hir_typeck/src/callee.rs

+10-6
Original file line numberDiff line numberDiff line change
@@ -902,19 +902,23 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
902902
call_expr: &'tcx hir::Expr<'tcx>,
903903
arg_exprs: &'tcx [hir::Expr<'tcx>],
904904
expected: Expectation<'tcx>,
905-
method_callee: MethodCallee<'tcx>,
905+
method: MethodCallee<'tcx>,
906906
) -> Ty<'tcx> {
907-
let output_type = self.check_method_argument_types(
907+
self.check_argument_types(
908908
call_expr.span,
909909
call_expr,
910-
Ok(method_callee),
910+
&method.sig.inputs()[1..],
911+
method.sig.output(),
912+
expected,
911913
arg_exprs,
914+
method.sig.c_variadic,
912915
TupleArgumentsFlag::TupleArguments,
913-
expected,
916+
Some(method.def_id),
914917
);
915918

916-
self.write_method_call_and_enforce_effects(call_expr.hir_id, call_expr.span, method_callee);
917-
output_type
919+
self.write_method_call_and_enforce_effects(call_expr.hir_id, call_expr.span, method);
920+
921+
method.sig.output()
918922
}
919923
}
920924

compiler/rustc_hir_typeck/src/expr.rs

+1-9
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,6 @@ use tracing::{debug, instrument, trace};
4040
use {rustc_ast as ast, rustc_hir as hir};
4141

4242
use crate::Expectation::{self, ExpectCastableToType, ExpectHasType, NoExpectation};
43-
use crate::TupleArgumentsFlag::DontTupleArguments;
4443
use crate::coercion::{CoerceMany, DynamicCoerceMany};
4544
use crate::errors::{
4645
AddressOfTemporaryTaken, BaseExpressionDoubleDot, BaseExpressionDoubleDotAddExpr,
@@ -1605,14 +1604,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
16051604
};
16061605

16071606
// Call the generic checker.
1608-
self.check_method_argument_types(
1609-
segment.ident.span,
1610-
expr,
1611-
method,
1612-
args,
1613-
DontTupleArguments,
1614-
expected,
1615-
)
1607+
self.check_method_argument_types(segment.ident.span, expr, method, args, expected)
16161608
}
16171609

16181610
/// Checks use `x.use`.

compiler/rustc_hir_typeck/src/fn_ctxt/checks.rs

+2-8
Original file line numberDiff line numberDiff line change
@@ -133,7 +133,6 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
133133
expr: &'tcx hir::Expr<'tcx>,
134134
method: Result<MethodCallee<'tcx>, ErrorGuaranteed>,
135135
args_no_rcvr: &'tcx [hir::Expr<'tcx>],
136-
tuple_arguments: TupleArgumentsFlag,
137136
expected: Expectation<'tcx>,
138137
) -> Ty<'tcx> {
139138
let has_error = match method {
@@ -147,11 +146,6 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
147146
);
148147
let err_output = Ty::new_error(self.tcx, guar);
149148

150-
let err_inputs = match tuple_arguments {
151-
DontTupleArguments => err_inputs,
152-
TupleArguments => vec![Ty::new_tup(self.tcx, &err_inputs)],
153-
};
154-
155149
self.check_argument_types(
156150
sp,
157151
expr,
@@ -160,7 +154,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
160154
NoExpectation,
161155
args_no_rcvr,
162156
false,
163-
tuple_arguments,
157+
TupleArgumentsFlag::DontTupleArguments,
164158
method.ok().map(|method| method.def_id),
165159
);
166160
return err_output;
@@ -175,7 +169,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
175169
expected,
176170
args_no_rcvr,
177171
method.sig.c_variadic,
178-
tuple_arguments,
172+
TupleArgumentsFlag::DontTupleArguments,
179173
Some(method.def_id),
180174
);
181175

0 commit comments

Comments
 (0)