Skip to content

Commit e056ffa

Browse files
committed
Inject the view_items for core in the right place, add comment documenting why the wrong place was wrong.
1 parent 799690b commit e056ffa

File tree

2 files changed

+10
-5
lines changed

2 files changed

+10
-5
lines changed

src/comp/driver/rustc.rs

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -123,12 +123,10 @@ fn inject_libcore_reference(sess: session::session,
123123
let vi1 = spanned(ast::view_item_use("core", [], n1));
124124
let vi2 = spanned(ast::view_item_import_glob(@["core"], n2));
125125

126-
let cd1 = spanned(ast::cdir_view_item(vi1));
127-
let cd2 = spanned(ast::cdir_view_item(vi2));
126+
let vis = [vi1, vi2] + crate.node.module.view_items;
128127

129-
let cdirs = [cd1, cd2] + crate.node.directives;
130-
131-
ret @{node: {directives: cdirs with crate.node} with *crate }
128+
ret @{node: {module: { view_items: vis with crate.node.module }
129+
with crate.node} with *crate }
132130
}
133131

134132

src/comp/syntax/ast.rs

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,14 @@ type crate_ =
6060
tag crate_directive_ {
6161
cdir_src_mod(ident, [attribute]);
6262
cdir_dir_mod(ident, [@crate_directive], [attribute]);
63+
64+
// NB: cdir_view_item is *not* processed by the rest of the compiler; the
65+
// attached view_items are sunk into the crate's module during parsing,
66+
// and processed (resolved, imported, etc.) there. This tag-variant exists
67+
// only to preserve the view items in order in case we decide to
68+
// pretty-print crates in the future.
6369
cdir_view_item(@view_item);
70+
6471
cdir_syntax(@path);
6572
}
6673

0 commit comments

Comments
 (0)