Skip to content

Commit

Permalink
Fix dependency bug iface-did-of-impl resolving
Browse files Browse the repository at this point in the history
By simply not resolving that def id until the typeck pass.

Closes #1494
  • Loading branch information
marijnh committed Jan 11, 2012
1 parent 34d7f05 commit 4c9c1cd
Show file tree
Hide file tree
Showing 6 changed files with 12 additions and 30 deletions.
1 change: 0 additions & 1 deletion src/comp/metadata/common.rs
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,6 @@ const tag_mod_impl: uint = 0x30u;

const tag_item_method: uint = 0x31u;
const tag_impl_iface: uint = 0x32u;
const tag_impl_iface_did: uint = 0x33u;

// discriminator value for variants
const tag_disr_val: uint = 0x34u;
Expand Down
13 changes: 1 addition & 12 deletions src/comp/metadata/decoder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -126,16 +126,6 @@ fn item_impl_iface(item: ebml::doc, tcx: ty::ctxt, cdata: cmd)
result
}

fn item_impl_iface_did(item: ebml::doc, cdata: cmd)
-> option::t<ast::def_id> {
let result = none;
ebml::tagged_docs(item, tag_impl_iface_did) {|doc|
let did = translate_def_id(cdata, parse_def_id(ebml::doc_data(doc)));
result = some(did);
}
result
}

fn item_ty_param_bounds(item: ebml::doc, tcx: ty::ctxt, cdata: cmd)
-> @[ty::param_bounds] {
let bounds = [];
Expand Down Expand Up @@ -297,8 +287,7 @@ fn get_impls_for_mod(cdata: cmd, m_id: ast::node_id,
let item = lookup_item(did.node, data), nm = item_name(item);
if alt name { some(n) { n == nm } none. { true } } {
let base_tps = item_ty_param_count(doc);
let i_did = item_impl_iface_did(item, cdata);
result += [@{did: did, iface_did: i_did, ident: nm,
result += [@{did: did, ident: nm,
methods: item_impl_methods(cdata, item, base_tps)}];
}
}
Expand Down
7 changes: 0 additions & 7 deletions src/comp/metadata/encoder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -405,13 +405,6 @@ fn encode_info_for_item(ecx: @encode_ctxt, ebml_w: ebml::writer, item: @item,
ebml::start_tag(ebml_w, tag_impl_iface);
write_type(ecx, ebml_w, i_ty);
ebml::end_tag(ebml_w);
ebml::start_tag(ebml_w, tag_impl_iface_did);
alt ty::struct(tcx, i_ty) {
ty::ty_iface(did, _) {
ebml_w.writer.write(str::bytes(def_to_str(did)));
}
}
ebml::end_tag(ebml_w);
}
_ {}
}
Expand Down
9 changes: 1 addition & 8 deletions src/comp/middle/resolve.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1825,8 +1825,7 @@ fn check_exports(e: @env) {
// Impl resolution

type method_info = {did: def_id, n_tps: uint, ident: ast::ident};
type _impl = {did: def_id, iface_did: option::t<def_id>,
ident: ast::ident, methods: [@method_info]};
type _impl = {did: def_id, ident: ast::ident, methods: [@method_info]};
type iscopes = list<@[@_impl]>;

fn resolve_impls(e: @env, c: @ast::crate) {
Expand Down Expand Up @@ -1893,12 +1892,6 @@ fn find_impls_in_item(e: env, i: @ast::item, &impls: [@_impl],
_ { true }
} {
impls += [@{did: local_def(i.id),
iface_did: alt ifce {
some(@{node: ast::ty_path(_, id), _}) {
some(def_id_of_def(e.def_map.get(id)))
}
_ { none }
},
ident: i.ident,
methods: vec::map(mthds, {|m|
@{did: local_def(m.id),
Expand Down
10 changes: 9 additions & 1 deletion src/comp/middle/typeck.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2947,7 +2947,15 @@ mod dict {
std::list::iter(isc) {|impls|
if option::is_some(found) { ret; }
for im in *impls {
if im.iface_did == some(iface_id) {
let match = alt ty::impl_iface(tcx, im.did) {
some(ity) {
alt ty::struct(tcx, ity) {
ty::ty_iface(id, _) { id == iface_id }
}
}
_ { false }
};
if match {
let {n_tps, ty: self_ty} = impl_self_ty(tcx, im.did);
let {vars, ty: self_ty} = if n_tps > 0u {
bind_params(fcx, self_ty, n_tps)
Expand Down
2 changes: 1 addition & 1 deletion src/libstd/test.rs
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ native mod rustrt {
}

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

0 comments on commit 4c9c1cd

Please sign in to comment.