Skip to content

Change how we resolve imports #199

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions src/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -483,6 +483,7 @@ TEST_XFAILS_RUSTC := $(filter-out \
arg-type-mismatch.rs \
import.rs \
import2.rs \
import3.rs \
while-type-error.rs \
), \
$(wildcard test/*/*.rs test/*/*.rc))
Expand Down
4 changes: 2 additions & 2 deletions src/comp/front/ast.rs
Original file line number Diff line number Diff line change
Expand Up @@ -230,7 +230,7 @@ type variant = rec(str name, vec[variant_arg] args, def_id id, ann ann);
type view_item = spanned[view_item_];
tag view_item_ {
view_item_use(ident, vec[@meta_item], def_id);
view_item_import(vec[ident], def_id);
view_item_import(vec[ident], option.t[def], def_id);
}

type item = spanned[item_];
Expand All @@ -248,7 +248,7 @@ fn index_view_item(mod_index index, @view_item it) {
case(ast.view_item_use(?id, _, _)) {
index.insert(id, ast.mie_view_item(it));
}
case(ast.view_item_import(?ids,_)) {
case(ast.view_item_import(?ids,?the_def,_)) {
auto len = _vec.len[ast.ident](ids);
auto last_id = ids.(len - 1u);
index.insert(last_id, ast.mie_view_item(it));
Expand Down
3 changes: 2 additions & 1 deletion src/comp/front/parser.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1670,7 +1670,8 @@ impure fn parse_rest_import_name(parser p, ast.ident id) -> @ast.view_item {
identifiers += i;
}
p.bump();
auto import_decl = ast.view_item_import(identifiers, p.next_def_id());
auto import_decl = ast.view_item_import(identifiers,
none[ast.def], p.next_def_id());
ret @spanned(lo, hi, import_decl);
}

Expand Down
11 changes: 7 additions & 4 deletions src/comp/middle/fold.rs
Original file line number Diff line number Diff line change
Expand Up @@ -211,6 +211,7 @@ type ast_fold[ENV] =
def_id id) -> @view_item) fold_view_item_use,

(fn(&ENV e, &span sp, vec[ident] idents,
option.t[def] the_def,
def_id id) -> @view_item) fold_view_item_import,

// Additional nodes.
Expand Down Expand Up @@ -709,9 +710,10 @@ fn fold_view_item[ENV](&ENV env, ast_fold[ENV] fld, @view_item vi)
ret fld.fold_view_item_use(env_, vi.span, ident, meta_items,
def_id);
}
case (ast.view_item_import(?idents, ?def_id)) {
case (ast.view_item_import(?idents, ?the_def, ?def_id)) {
// FIXME: what other folding should be done in here?
ret fld.fold_view_item_import(env_, vi.span, idents, def_id);
ret fld.fold_view_item_import(env_, vi.span, idents,
the_def, def_id);
}
}

Expand Down Expand Up @@ -1090,8 +1092,9 @@ fn identity_fold_view_item_use[ENV](&ENV e, &span sp, ident i,
}

fn identity_fold_view_item_import[ENV](&ENV e, &span sp, vec[ident] is,
option.t[def] the_def,
def_id id) -> @view_item {
ret @respan(sp, ast.view_item_import(is, id));
ret @respan(sp, ast.view_item_import(is, the_def, id));
}

// Additional identities.
Expand Down Expand Up @@ -1240,7 +1243,7 @@ fn new_identity_fold[ENV]() -> ast_fold[ENV] {
fold_view_item_use =
bind identity_fold_view_item_use[ENV](_,_,_,_,_),
fold_view_item_import =
bind identity_fold_view_item_import[ENV](_,_,_,_),
bind identity_fold_view_item_import[ENV](_,_,_,_,_),

fold_block = bind identity_fold_block[ENV](_,_,_),
fold_fn = bind identity_fold_fn[ENV](_,_,_,_,_),
Expand Down
Loading