Skip to content

Commit 6a5feff

Browse files
committed
rustc: Tolerate def id tags inside module tags. Fixes metadata reading.
1 parent 55fbed3 commit 6a5feff

File tree

1 file changed

+33
-32
lines changed

1 file changed

+33
-32
lines changed

src/comp/front/creader.rs

Lines changed: 33 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -256,42 +256,43 @@ impure fn resolve_path(vec[ast.ident] path, vec[u8] data) -> resolve_result {
256256
auto found = false;
257257
while (ebml.bytes_left(ebml_r) > 0u && !found) {
258258
auto ebml_tag = ebml.peek(ebml_r);
259-
check ((ebml_tag.id == metadata.tag_paths_item) ||
260-
(ebml_tag.id == metadata.tag_paths_mod));
261-
262-
ebml.move_to_first_child(ebml_r);
263-
auto did_opt = none[ast.def_id];
264-
auto name_opt = none[ast.ident];
265-
while (ebml.bytes_left(ebml_r) > 0u) {
266-
auto inner_tag = ebml.peek(ebml_r);
267-
if (inner_tag.id == metadata.tag_paths_name) {
268-
ebml.move_to_first_child(ebml_r);
269-
auto name_data = ebml.read_data(ebml_r);
270-
ebml.move_to_parent(ebml_r);
271-
auto nm = _str.unsafe_from_bytes(name_data);
272-
name_opt = some[ast.ident](nm);
273-
} else if (inner_tag.id == metadata.tag_items_def_id) {
274-
ebml.move_to_first_child(ebml_r);
275-
auto did_data = ebml.read_data(ebml_r);
276-
ebml.move_to_parent(ebml_r);
277-
did_opt = some[ast.def_id](parse_def_id(did_data));
259+
if ((ebml_tag.id == metadata.tag_paths_item) ||
260+
(ebml_tag.id == metadata.tag_paths_mod)) {
261+
ebml.move_to_first_child(ebml_r);
262+
auto did_opt = none[ast.def_id];
263+
auto name_opt = none[ast.ident];
264+
while (ebml.bytes_left(ebml_r) > 0u) {
265+
auto inner_tag = ebml.peek(ebml_r);
266+
if (inner_tag.id == metadata.tag_paths_name) {
267+
ebml.move_to_first_child(ebml_r);
268+
auto name_data = ebml.read_data(ebml_r);
269+
ebml.move_to_parent(ebml_r);
270+
auto nm = _str.unsafe_from_bytes(name_data);
271+
name_opt = some[ast.ident](nm);
272+
} else if (inner_tag.id ==
273+
metadata.tag_items_def_id) {
274+
ebml.move_to_first_child(ebml_r);
275+
auto did_data = ebml.read_data(ebml_r);
276+
ebml.move_to_parent(ebml_r);
277+
auto did = parse_def_id(did_data);
278+
did_opt = some[ast.def_id](did);
279+
}
280+
ebml.move_to_next_sibling(ebml_r);
278281
}
279-
ebml.move_to_next_sibling(ebml_r);
280-
}
281-
ebml.move_to_parent(ebml_r);
282+
ebml.move_to_parent(ebml_r);
282283

283-
if (_str.eq(option.get[ast.ident](name_opt), name)) {
284-
// Matched!
285-
if (last) {
286-
ret rr_ok(option.get[ast.def_id](did_opt));
287-
}
284+
if (_str.eq(option.get[ast.ident](name_opt), name)) {
285+
// Matched!
286+
if (last) {
287+
ret rr_ok(option.get[ast.def_id](did_opt));
288+
}
288289

289-
// Move to the module/item we found for the next iteration
290-
// of the loop...
291-
ebml.move_to_first_child(ebml_r);
292-
found = true;
290+
// Move to the module/item we found for the next
291+
// iteration of the loop...
292+
ebml.move_to_first_child(ebml_r);
293+
found = true;
294+
}
293295
}
294-
295296
ebml.move_to_next_sibling(ebml_r);
296297
}
297298

0 commit comments

Comments
 (0)