@@ -50,8 +50,8 @@ use crate::errors::{
50
50
YieldExprOutsideOfCoroutine ,
51
51
} ;
52
52
use crate :: {
53
- BreakableCtxt , CoroutineTypes , Diverges , FnCtxt , Needs , cast , fatally_break_rust ,
54
- report_unexpected_variant_res, type_error_struct,
53
+ BreakableCtxt , CoroutineTypes , Diverges , FnCtxt , Needs , TupleArgumentsFlag , cast ,
54
+ fatally_break_rust , report_unexpected_variant_res, type_error_struct,
55
55
} ;
56
56
57
57
impl < ' a , ' tcx > FnCtxt < ' a , ' tcx > {
@@ -1590,21 +1590,45 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
1590
1590
// no need to check for bot/err -- callee does that
1591
1591
let rcvr_t = self . structurally_resolve_type ( rcvr. span , rcvr_t) ;
1592
1592
1593
- let method = match self . lookup_method ( rcvr_t, segment, segment. ident . span , expr, rcvr, args)
1594
- {
1593
+ match self . lookup_method ( rcvr_t, segment, segment. ident . span , expr, rcvr, args) {
1595
1594
Ok ( method) => {
1596
- // We could add a "consider `foo::<params>`" suggestion here, but I wasn't able to
1597
- // trigger this codepath causing `structurally_resolve_type` to emit an error.
1598
1595
self . write_method_call_and_enforce_effects ( expr. hir_id , expr. span , method) ;
1599
- Ok ( method)
1596
+
1597
+ self . check_argument_types (
1598
+ segment. ident . span ,
1599
+ expr,
1600
+ & method. sig . inputs ( ) [ 1 ..] ,
1601
+ method. sig . output ( ) ,
1602
+ expected,
1603
+ args,
1604
+ method. sig . c_variadic ,
1605
+ TupleArgumentsFlag :: DontTupleArguments ,
1606
+ Some ( method. def_id ) ,
1607
+ ) ;
1608
+
1609
+ method. sig . output ( )
1600
1610
}
1601
1611
Err ( error) => {
1602
- Err ( self . report_method_error ( expr. hir_id , rcvr_t, error, expected, false ) )
1603
- }
1604
- } ;
1612
+ let guar = self . report_method_error ( expr. hir_id , rcvr_t, error, expected, false ) ;
1605
1613
1606
- // Call the generic checker.
1607
- self . check_method_argument_types ( segment. ident . span , expr, method, args, expected)
1614
+ let err_inputs = self . err_args ( args. len ( ) , guar) ;
1615
+ let err_output = Ty :: new_error ( self . tcx , guar) ;
1616
+
1617
+ self . check_argument_types (
1618
+ segment. ident . span ,
1619
+ expr,
1620
+ & err_inputs,
1621
+ err_output,
1622
+ NoExpectation ,
1623
+ args,
1624
+ false ,
1625
+ TupleArgumentsFlag :: DontTupleArguments ,
1626
+ None ,
1627
+ ) ;
1628
+
1629
+ err_output
1630
+ }
1631
+ }
1608
1632
}
1609
1633
1610
1634
/// Checks use `x.use`.
0 commit comments