Adjust the handling of trait obligations and defaults to account for
upvar inference. Upvar inference can cause some obligations to be deferred, notably things like `F : Sized` where `F` is a closure type, or `F : FnMut`. Adjust the ordering therefore so that we process all traits and apply fallback, do upvar inference, and only then start reporting errors for outstanding obligations.
This commit is contained in:
parent
f5281e2bb5
commit
92f94765ec
@ -493,8 +493,9 @@ fn check_bare_fn<'a, 'tcx>(ccx: &CrateCtxt<'a, 'tcx>,
|
||||
let fcx = check_fn(ccx, fn_ty.unsafety, id, &fn_sig,
|
||||
decl, id, body, &inh);
|
||||
|
||||
vtable::select_all_fcx_obligations_or_error(&fcx);
|
||||
vtable::select_all_fcx_obligations_and_apply_defaults(&fcx);
|
||||
upvar::closure_analyze_fn(&fcx, id, decl, body);
|
||||
vtable::select_all_fcx_obligations_or_error(&fcx);
|
||||
regionck::regionck_fn(&fcx, id, decl, body);
|
||||
writeback::resolve_type_vars_in_fn(&fcx, decl, body);
|
||||
}
|
||||
|
@ -277,15 +277,20 @@ fn check_object_type_binds_all_associated_types<'tcx>(tcx: &ty::ctxt<'tcx>,
|
||||
}
|
||||
}
|
||||
|
||||
pub fn select_all_fcx_obligations_or_error(fcx: &FnCtxt) {
|
||||
pub fn select_all_fcx_obligations_and_apply_defaults(fcx: &FnCtxt) {
|
||||
debug!("select_all_fcx_obligations_or_error");
|
||||
|
||||
fcx.inh.deferred_resolutions.borrow_mut()
|
||||
.retain(|r| !r.attempt_resolution(fcx));
|
||||
|
||||
select_fcx_obligations_where_possible(fcx);
|
||||
fcx.default_type_parameters();
|
||||
select_fcx_obligations_where_possible(fcx);
|
||||
}
|
||||
|
||||
pub fn select_all_fcx_obligations_or_error(fcx: &FnCtxt) {
|
||||
debug!("select_all_fcx_obligations_or_error");
|
||||
|
||||
select_all_fcx_obligations_and_apply_defaults(fcx);
|
||||
let mut fulfillment_cx = fcx.inh.fulfillment_cx.borrow_mut();
|
||||
let r = fulfillment_cx.select_all_or_error(fcx.infcx(), fcx);
|
||||
match r {
|
||||
|
Loading…
Reference in New Issue
Block a user