* relationship.
*/
pub trait SimplyUnifiable : Clone + PartialEq + Repr {
+ fn to_type(&self) -> ty::t;
fn to_type_err(expected_found<Self>) -> ty::type_err;
}
a_id: K,
b: V)
-> ures;
+ fn probe_var(&self, a_id: K) -> Option<ty::t>;
}
-impl<'tcx,V:SimplyUnifiable,K:UnifyKey<Option<V>>>
- InferCtxtMethodsForSimplyUnifiableTypes<V,K> for InferCtxt<'tcx>
+impl<'a,'tcx,V:SimplyUnifiable,K:UnifyKey<Option<V>>>
+ InferCtxtMethodsForSimplyUnifiableTypes<V,K> for InferCtxt<'a, 'tcx>
{
fn simple_vars(&self,
a_is_expected: bool,
}
}
}
+
+ fn probe_var(&self, a_id: K) -> Option<ty::t> {
+ let tcx = self.tcx;
+ let table = UnifyKey::unification_table(self);
+ let node_a = table.borrow_mut().get(tcx, a_id);
+ match node_a.value {
+ None => None,
+ Some(ref a_t) => Some(a_t.to_type())
+ }
+ }
}
///////////////////////////////////////////////////////////////////////////
}
impl SimplyUnifiable for IntVarValue {
+ fn to_type(&self) -> ty::t {
+ match *self {
+ ty::IntType(i) => ty::mk_mach_int(i),
+ ty::UintType(i) => ty::mk_mach_uint(i),
+ }
+ }
+
fn to_type_err(err: expected_found<IntVarValue>) -> ty::type_err {
return ty::terr_int_mismatch(err);
}
}
impl SimplyUnifiable for ast::FloatTy {
+ fn to_type(&self) -> ty::t {
+ ty::mk_mach_float(*self)
+ }
+
fn to_type_err(err: expected_found<ast::FloatTy>) -> ty::type_err {
return ty::terr_float_mismatch(err);
}