Skip to content

Commit 1f4a6bb

Browse files
committed
Treat export-globs as import-globs for sake of linking.
1 parent 893bbea commit 1f4a6bb

File tree

1 file changed

+12
-3
lines changed

1 file changed

+12
-3
lines changed

src/comp/middle/resolve.rs

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -225,6 +225,12 @@ fn iter_export_paths(vi: ast::view_item, f: fn(vp: @ast::view_path)) {
225225
}
226226
}
227227

228+
fn iter_all_view_paths(vi: ast::view_item,
229+
f: fn(vp: @ast::view_path)) {
230+
iter_import_paths(vi, f);
231+
iter_export_paths(vi, f);
232+
}
233+
228234
// Locate all modules and imports and index them, so that the next passes can
229235
// resolve through them.
230236
fn map_crate(e: @env, c: @ast::crate) {
@@ -284,9 +290,12 @@ fn map_crate(e: @env, c: @ast::crate) {
284290
}
285291
}
286292

293+
// Note: a glob export works as an implict import, along with a
294+
// re-export of anything that was exported at the glob-target location.
295+
// So we wind up reusing the glob-import machinery when looking at
296+
// glob exports. They just do re-exporting in a later step.
287297
fn link_glob(e: @env, vi: @ast::view_item, sc: scopes, _v: vt<scopes>) {
288-
iter_import_paths(*vi) { |vp|
289-
//if it really is a glob import, that is
298+
iter_all_view_paths(*vi) { |vp|
290299
alt vp.node {
291300
ast::view_path_glob(path, _) {
292301
alt follow_import(*e, sc, *path, vp.span) {
@@ -335,7 +344,7 @@ fn map_crate(e: @env, c: @ast::crate) {
335344
glob_imported_names: new_str_hash(),
336345
path: ""});
337346

338-
// Next, assemble the links for globbed imports.
347+
// Next, assemble the links for globbed imports and exports.
339348
let v_link_glob =
340349
@{visit_view_item: bind link_glob(e, _, _, _),
341350
visit_block: visit_block_with_scope,

0 commit comments

Comments
 (0)