Skip to content

Commit 4c9c1cd

Browse files
committed
Fix dependency bug iface-did-of-impl resolving
By simply not resolving that def id until the typeck pass. Closes #1494
1 parent 34d7f05 commit 4c9c1cd

File tree

6 files changed

+12
-30
lines changed

6 files changed

+12
-30
lines changed

src/comp/metadata/common.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,6 @@ const tag_mod_impl: uint = 0x30u;
6868

6969
const tag_item_method: uint = 0x31u;
7070
const tag_impl_iface: uint = 0x32u;
71-
const tag_impl_iface_did: uint = 0x33u;
7271

7372
// discriminator value for variants
7473
const tag_disr_val: uint = 0x34u;

src/comp/metadata/decoder.rs

Lines changed: 1 addition & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -126,16 +126,6 @@ fn item_impl_iface(item: ebml::doc, tcx: ty::ctxt, cdata: cmd)
126126
result
127127
}
128128

129-
fn item_impl_iface_did(item: ebml::doc, cdata: cmd)
130-
-> option::t<ast::def_id> {
131-
let result = none;
132-
ebml::tagged_docs(item, tag_impl_iface_did) {|doc|
133-
let did = translate_def_id(cdata, parse_def_id(ebml::doc_data(doc)));
134-
result = some(did);
135-
}
136-
result
137-
}
138-
139129
fn item_ty_param_bounds(item: ebml::doc, tcx: ty::ctxt, cdata: cmd)
140130
-> @[ty::param_bounds] {
141131
let bounds = [];
@@ -297,8 +287,7 @@ fn get_impls_for_mod(cdata: cmd, m_id: ast::node_id,
297287
let item = lookup_item(did.node, data), nm = item_name(item);
298288
if alt name { some(n) { n == nm } none. { true } } {
299289
let base_tps = item_ty_param_count(doc);
300-
let i_did = item_impl_iface_did(item, cdata);
301-
result += [@{did: did, iface_did: i_did, ident: nm,
290+
result += [@{did: did, ident: nm,
302291
methods: item_impl_methods(cdata, item, base_tps)}];
303292
}
304293
}

src/comp/metadata/encoder.rs

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -405,13 +405,6 @@ fn encode_info_for_item(ecx: @encode_ctxt, ebml_w: ebml::writer, item: @item,
405405
ebml::start_tag(ebml_w, tag_impl_iface);
406406
write_type(ecx, ebml_w, i_ty);
407407
ebml::end_tag(ebml_w);
408-
ebml::start_tag(ebml_w, tag_impl_iface_did);
409-
alt ty::struct(tcx, i_ty) {
410-
ty::ty_iface(did, _) {
411-
ebml_w.writer.write(str::bytes(def_to_str(did)));
412-
}
413-
}
414-
ebml::end_tag(ebml_w);
415408
}
416409
_ {}
417410
}

src/comp/middle/resolve.rs

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1825,8 +1825,7 @@ fn check_exports(e: @env) {
18251825
// Impl resolution
18261826

18271827
type method_info = {did: def_id, n_tps: uint, ident: ast::ident};
1828-
type _impl = {did: def_id, iface_did: option::t<def_id>,
1829-
ident: ast::ident, methods: [@method_info]};
1828+
type _impl = {did: def_id, ident: ast::ident, methods: [@method_info]};
18301829
type iscopes = list<@[@_impl]>;
18311830

18321831
fn resolve_impls(e: @env, c: @ast::crate) {
@@ -1893,12 +1892,6 @@ fn find_impls_in_item(e: env, i: @ast::item, &impls: [@_impl],
18931892
_ { true }
18941893
} {
18951894
impls += [@{did: local_def(i.id),
1896-
iface_did: alt ifce {
1897-
some(@{node: ast::ty_path(_, id), _}) {
1898-
some(def_id_of_def(e.def_map.get(id)))
1899-
}
1900-
_ { none }
1901-
},
19021895
ident: i.ident,
19031896
methods: vec::map(mthds, {|m|
19041897
@{did: local_def(m.id),

src/comp/middle/typeck.rs

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2947,7 +2947,15 @@ mod dict {
29472947
std::list::iter(isc) {|impls|
29482948
if option::is_some(found) { ret; }
29492949
for im in *impls {
2950-
if im.iface_did == some(iface_id) {
2950+
let match = alt ty::impl_iface(tcx, im.did) {
2951+
some(ity) {
2952+
alt ty::struct(tcx, ity) {
2953+
ty::ty_iface(id, _) { id == iface_id }
2954+
}
2955+
}
2956+
_ { false }
2957+
};
2958+
if match {
29512959
let {n_tps, ty: self_ty} = impl_self_ty(tcx, im.did);
29522960
let {vars, ty: self_ty} = if n_tps > 0u {
29532961
bind_params(fcx, self_ty, n_tps)

src/libstd/test.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ native mod rustrt {
3131
}
3232

3333
// FIXME Kludge to work around issue #1494 . Simply import io::writer_util
34-
// when that is fixed.
34+
// after the next snapshot.
3535
impl writer_util for io::writer {
3636
fn write_str(s: str) { self.write(str::bytes(s)); }
3737
fn write_line(s: str) { self.write(str::bytes(s + "\n")); }

0 commit comments

Comments
 (0)