Skip to content

Commit 62b5177

Browse files
committed
Fallout: add phantom data to the type inferencer
1 parent 199b992 commit 62b5177

File tree

2 files changed

+8
-6
lines changed

2 files changed

+8
-6
lines changed

src/librustc/middle/infer/type_variable.rs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ use self::UndoEntry::*;
1414

1515
use middle::ty::{self, Ty};
1616
use std::cmp::min;
17+
use std::marker::PhantomData;
1718
use std::mem;
1819
use std::u32;
1920
use util::snapshot_vec as sv;
@@ -42,7 +43,7 @@ enum UndoEntry {
4243
Relate(ty::TyVid, ty::TyVid),
4344
}
4445

45-
struct Delegate<'tcx>;
46+
struct Delegate<'tcx>(PhantomData<&'tcx ()>);
4647

4748
type Relation = (RelationDir, ty::TyVid);
4849

@@ -64,7 +65,7 @@ impl RelationDir {
6465

6566
impl<'tcx> TypeVariableTable<'tcx> {
6667
pub fn new() -> TypeVariableTable<'tcx> {
67-
TypeVariableTable { values: sv::SnapshotVec::new(Delegate) }
68+
TypeVariableTable { values: sv::SnapshotVec::new(Delegate(PhantomData)) }
6869
}
6970

7071
fn relations<'a>(&'a mut self, a: ty::TyVid) -> &'a mut Vec<Relation> {

src/librustc/middle/infer/unify.rs

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ use middle::infer::{uok, ures};
1818
use middle::infer::InferCtxt;
1919
use std::cell::RefCell;
2020
use std::fmt::Debug;
21+
use std::marker::PhantomData;
2122
use syntax::ast;
2223
use util::snapshot_vec as sv;
2324

@@ -79,7 +80,7 @@ pub struct UnificationTable<K:UnifyKey> {
7980
/// made during the snapshot may either be *committed* or *rolled back*.
8081
pub struct Snapshot<K:UnifyKey> {
8182
// Link snapshot to the key type `K` of the table.
82-
marker: marker::CovariantType<K>,
83+
marker: marker::PhantomData<K>,
8384
snapshot: sv::Snapshot,
8485
}
8586

@@ -92,7 +93,7 @@ pub struct Node<K:UnifyKey> {
9293
}
9394

9495
#[derive(Copy)]
95-
pub struct Delegate<K>;
96+
pub struct Delegate<K>(PhantomData<K>);
9697

9798
// We can't use V:LatticeValue, much as I would like to,
9899
// because frequently the pattern is that V=Option<U> for some
@@ -102,14 +103,14 @@ pub struct Delegate<K>;
102103
impl<K:UnifyKey> UnificationTable<K> {
103104
pub fn new() -> UnificationTable<K> {
104105
UnificationTable {
105-
values: sv::SnapshotVec::new(Delegate),
106+
values: sv::SnapshotVec::new(Delegate(PhantomData)),
106107
}
107108
}
108109

109110
/// Starts a new snapshot. Each snapshot must be either
110111
/// rolled back or committed in a "LIFO" (stack) order.
111112
pub fn snapshot(&mut self) -> Snapshot<K> {
112-
Snapshot { marker: marker::CovariantType::<K>,
113+
Snapshot { marker: marker::PhantomData::<K>,
113114
snapshot: self.values.start_snapshot() }
114115
}
115116

0 commit comments

Comments
 (0)