}
enum TypeVariableValue<'tcx> {
- Known(Ty<'tcx>),
+ Known {
+ value: Ty<'tcx>
+ },
Bounded {
default: Option<Default<'tcx>>
}
// We will use this to store the required information to recapitulate what happened when
// an error occurs.
-#[derive(Clone, Debug, PartialEq, Eq, Hash)]
+#[derive(Copy, Clone, Debug, PartialEq, Eq, Hash)]
pub struct Default<'tcx> {
pub ty: Ty<'tcx>,
/// The span where the default was incurred
pub fn default(&self, vid: ty::TyVid) -> Option<Default<'tcx>> {
match &self.values.get(vid.index as usize).value {
- &Known(_) => None,
- &Bounded { ref default, .. } => default.clone()
+ &Known { .. } => None,
+ &Bounded { default, .. } => default,
}
}
let old_value = {
let vid_data = &mut self.values[vid.index as usize];
- mem::replace(&mut vid_data.value, TypeVariableValue::Known(ty))
+ mem::replace(&mut vid_data.value, TypeVariableValue::Known { value: ty })
};
match old_value {
TypeVariableValue::Bounded { default } => {
self.values.record(Instantiate { vid: vid, default: default });
}
- TypeVariableValue::Known(old_ty) => {
+ TypeVariableValue::Known { value: old_ty } => {
bug!("instantiating type variable `{:?}` twice: new-value = {:?}, old-value={:?}",
vid, ty, old_ty)
}
self.eq_relations.new_key(());
self.sub_relations.new_key(());
let index = self.values.push(TypeVariableData {
- value: Bounded { default: default },
+ value: Bounded { default },
origin,
diverging,
});
debug_assert!(self.root_var(vid) == vid);
match self.values.get(vid.index as usize).value {
Bounded { .. } => None,
- Known(t) => Some(t)
+ Known { value } => Some(value)
}
}
// created since the snapshot started or not.
let escaping_type = match self.values.get(vid.index as usize).value {
Bounded { .. } => bug!(),
- Known(ty) => ty,
+ Known { value } => value,
};
escaping_types.push(escaping_type);
}