Skip to content

Commit 5fc61c2

Browse files
committed
Fix bug with defaults not being restored
1 parent d9b1983 commit 5fc61c2

File tree

1 file changed

+13
-10
lines changed

1 file changed

+13
-10
lines changed

src/librustc/middle/infer/type_variable.rs

Lines changed: 13 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -47,9 +47,9 @@ pub struct Snapshot {
4747
snapshot: sv::Snapshot
4848
}
4949

50-
enum UndoEntry {
50+
enum UndoEntry<'tcx> {
5151
// The type of the var was specified.
52-
SpecifyVar(ty::TyVid, Vec<Relation>),
52+
SpecifyVar(ty::TyVid, Vec<Relation>, Option<Default<'tcx>>),
5353
Relate(ty::TyVid, ty::TyVid),
5454
}
5555

@@ -118,8 +118,8 @@ impl<'tcx> TypeVariableTable<'tcx> {
118118
mem::replace(value_ptr, Known(ty))
119119
};
120120

121-
let relations = match old_value {
122-
Bounded { relations, .. } => relations,
121+
let (relations, default) = match old_value {
122+
Bounded { relations, default } => (relations, default),
123123
Known(_) => panic!("Asked to instantiate variable that is \
124124
already instantiated")
125125
};
@@ -128,7 +128,7 @@ impl<'tcx> TypeVariableTable<'tcx> {
128128
stack.push((ty, dir, vid));
129129
}
130130

131-
self.values.record(SpecifyVar(vid, relations));
131+
self.values.record(SpecifyVar(vid, relations, default));
132132
}
133133

134134
pub fn new_var(&mut self,
@@ -198,7 +198,7 @@ impl<'tcx> TypeVariableTable<'tcx> {
198198
debug!("NewElem({}) new_elem_threshold={}", index, new_elem_threshold);
199199
}
200200

201-
sv::UndoLog::Other(SpecifyVar(vid, _)) => {
201+
sv::UndoLog::Other(SpecifyVar(vid, _, _)) => {
202202
if vid.index < new_elem_threshold {
203203
// quick check to see if this variable was
204204
// created since the snapshot started or not.
@@ -229,12 +229,15 @@ impl<'tcx> TypeVariableTable<'tcx> {
229229

230230
impl<'tcx> sv::SnapshotVecDelegate for Delegate<'tcx> {
231231
type Value = TypeVariableData<'tcx>;
232-
type Undo = UndoEntry;
232+
type Undo = UndoEntry<'tcx>;
233233

234-
fn reverse(values: &mut Vec<TypeVariableData<'tcx>>, action: UndoEntry) {
234+
fn reverse(values: &mut Vec<TypeVariableData<'tcx>>, action: UndoEntry<'tcx>) {
235235
match action {
236-
SpecifyVar(vid, relations) => {
237-
values[vid.index as usize].value = Bounded { relations: relations, default: None };
236+
SpecifyVar(vid, relations, default) => {
237+
values[vid.index as usize].value = Bounded {
238+
relations: relations,
239+
default: default
240+
};
238241
}
239242

240243
Relate(a, b) => {

0 commit comments

Comments
 (0)