Skip to content

Commit dad2db7

Browse files
committed
Change method lookup infrastructure to use the trait methods. Instead
of tracking individual candidates per impl, we just track one candidate for the extension trait itself, and let the trait resolution handle walking the individual impls and so forth. Also change the interface to report back a richer notion of error.
1 parent 1562d8c commit dad2db7

File tree

4 files changed

+640
-661
lines changed

4 files changed

+640
-661
lines changed

src/librustc/middle/ty.rs

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -120,6 +120,13 @@ impl ImplOrTraitItem {
120120
TypeTraitItem(ref associated_type) => associated_type.container,
121121
}
122122
}
123+
124+
pub fn as_opt_method(&self) -> Option<Rc<Method>> {
125+
match *self {
126+
MethodTraitItem(ref m) => Some((*m).clone()),
127+
TypeTraitItem(_) => None
128+
}
129+
}
123130
}
124131

125132
#[deriving(Clone)]
@@ -1240,6 +1247,10 @@ impl Generics {
12401247
}
12411248

12421249
impl TraitRef {
1250+
pub fn new(def_id: ast::DefId, substs: Substs) -> TraitRef {
1251+
TraitRef { def_id: def_id, substs: substs }
1252+
}
1253+
12431254
pub fn self_ty(&self) -> ty::t {
12441255
self.substs.self_ty().unwrap()
12451256
}

0 commit comments

Comments
 (0)