@@ -2066,9 +2066,9 @@ fn try_index_step<'a, 'tcx>(fcx: &FnCtxt<'a, 'tcx>,
2066
2066
}
2067
2067
2068
2068
fn check_method_argument_types < ' a , ' tcx > ( fcx : & FnCtxt < ' a , ' tcx > ,
2069
- sp : Span ,
2069
+ span : Span ,
2070
+ call_expr : & ' tcx ast:: Expr ,
2070
2071
method_fn_ty : Ty < ' tcx > ,
2071
- callee_expr : & ' tcx ast:: Expr ,
2072
2072
args_no_rcvr : & ' tcx [ P < ast:: Expr > ] ,
2073
2073
tuple_arguments : TupleArgumentsFlag ,
2074
2074
expected : Expectation < ' tcx > )
@@ -2082,7 +2082,8 @@ fn check_method_argument_types<'a, 'tcx>(fcx: &FnCtxt<'a, 'tcx>,
2082
2082
} ;
2083
2083
2084
2084
check_argument_types ( fcx,
2085
- sp,
2085
+ span,
2086
+ ty:: Region :: from_node_id ( call_expr. id ) ,
2086
2087
& err_inputs[ ..] ,
2087
2088
& [ ] ,
2088
2089
args_no_rcvr,
@@ -2094,12 +2095,13 @@ fn check_method_argument_types<'a, 'tcx>(fcx: &FnCtxt<'a, 'tcx>,
2094
2095
ty:: TyBareFn ( _, ref fty) => {
2095
2096
// HACK(eddyb) ignore self in the definition (see above).
2096
2097
let expected_arg_tys = expected_types_for_fn_args ( fcx,
2097
- sp ,
2098
+ span ,
2098
2099
expected,
2099
2100
fty. sig . 0 . output ,
2100
2101
& fty. sig . 0 . inputs [ 1 ..] ) ;
2101
2102
check_argument_types ( fcx,
2102
- sp,
2103
+ span,
2104
+ ty:: Region :: from_node_id ( call_expr. id ) ,
2103
2105
& fty. sig . 0 . inputs [ 1 ..] ,
2104
2106
& expected_arg_tys[ ..] ,
2105
2107
args_no_rcvr,
@@ -2108,8 +2110,7 @@ fn check_method_argument_types<'a, 'tcx>(fcx: &FnCtxt<'a, 'tcx>,
2108
2110
fty. sig . 0 . output
2109
2111
}
2110
2112
_ => {
2111
- fcx. tcx ( ) . sess . span_bug ( callee_expr. span ,
2112
- "method without bare fn type" ) ;
2113
+ fcx. tcx ( ) . sess . span_bug ( span, "method without bare fn type" ) ;
2113
2114
}
2114
2115
}
2115
2116
}
@@ -2119,13 +2120,21 @@ fn check_method_argument_types<'a, 'tcx>(fcx: &FnCtxt<'a, 'tcx>,
2119
2120
/// operators.
2120
2121
fn check_argument_types < ' a , ' tcx > ( fcx : & FnCtxt < ' a , ' tcx > ,
2121
2122
sp : Span ,
2123
+ call_scope : ty:: Region ,
2122
2124
fn_inputs : & [ Ty < ' tcx > ] ,
2123
2125
expected_arg_tys : & [ Ty < ' tcx > ] ,
2124
2126
args : & ' tcx [ P < ast:: Expr > ] ,
2125
2127
variadic : bool ,
2126
2128
tuple_arguments : TupleArgumentsFlag ) {
2127
2129
let tcx = fcx. ccx . tcx ;
2128
2130
2131
+ // All the input types from the fn signature must outlive the call
2132
+ // so as to validate implied bounds.
2133
+ for & fn_input_ty in fn_inputs {
2134
+ let cause = traits:: ObligationCause :: misc ( sp, fcx. body_id ) ;
2135
+ fcx. register_region_obligation ( fn_input_ty, call_scope, cause) ;
2136
+ }
2137
+
2129
2138
// Grab the argument types, supplying fresh type variables
2130
2139
// if the wrong number of arguments were supplied
2131
2140
let supplied_arg_count = if tuple_arguments == DontTupleArguments {
@@ -2551,8 +2560,8 @@ fn check_expr_with_unifier<'a, 'tcx, F>(fcx: &FnCtxt<'a, 'tcx>,
2551
2560
// Call the generic checker.
2552
2561
let ret_ty = check_method_argument_types ( fcx,
2553
2562
method_name. span ,
2554
- fn_ty,
2555
2563
expr,
2564
+ fn_ty,
2556
2565
& args[ 1 ..] ,
2557
2566
DontTupleArguments ,
2558
2567
expected) ;
0 commit comments