Fixed bounds checking.
Uses type inference results from type comparison. Also, improved the
handling of type parmeters being added etc.
@@ -623,7 +623,16 @@ fn cmp_types<'a, 'tcx>(changes: &mut ChangeSet<'tcx>,
tcx.infer_ctxt().enter(|infcx| {
let new_substs = if new.is_fn() {
- infcx.fresh_substs_for_item(DUMMY_SP, new_def_id)
+ let has_self = tcx.generics_of(new_def_id).has_self;
+ Substs::for_item(infcx.tcx, new_def_id, |def, _| {
+ infcx.region_var_for_def(DUMMY_SP, def)
+ }, |def, substs| {
+ if def.index == 0 && has_self { // `Self` is special
+ tcx.mk_param_from_def(def)
+ } else {
+ infcx.type_var_for_def(DUMMY_SP, def, substs)
+ }
+ })
} else {
Substs::for_item(tcx, new_def_id, |def, _| {
tcx.mk_region(ReEarlyBound(def.to_early_bound_region_data()))
@@ -638,10 +647,9 @@ fn cmp_types<'a, 'tcx>(changes: &mut ChangeSet<'tcx>,
let old_param_env =
translate_param_env(id_mapping, tcx, old_def_id, tcx.param_env(old_def_id));
- let new_param_env = tcx.param_env(new_def_id);
+ let new_param_env = tcx.param_env(new_def_id).subst(infcx.tcx, new_substs);
let cause = ObligationCause::dummy();
-
let mut fulfill_cx = FulfillmentContext::new();
for predicate in new_param_env.caller_bounds.iter() {
@@ -649,12 +657,6 @@ fn cmp_types<'a, 'tcx>(changes: &mut ChangeSet<'tcx>,
fulfill_cx.register_predicate_obligation(&infcx, obligation);
}
- if let Err(error) = fulfill_cx.select_all_or_error(&infcx) {
- // println!("old param env: {:?}", old_param_env);
- // println!("new param env: {:?}", new_param_env);
- // println!("could not fulfill obligation: {:?}", error);
- }
-
let error = infcx
.at(&cause, new_param_env)
.eq(old, new)
@@ -681,5 +683,11 @@ fn cmp_types<'a, 'tcx>(changes: &mut ChangeSet<'tcx>,
old_def_id,
None);
}
+
+ if let Err(error) = fulfill_cx.select_all_or_error(&infcx) {
+ println!("old param env: {:?}", old_param_env);
+ println!("new param env: {:?}", new_param_env);
+ println!("could not fulfill obligation: {:?}", error);
+ }
});
}
