diff --git a/src/libsyntax/ast.rs b/src/libsyntax/ast.rs index e9f47e14dbb..75a2081bc14 100644 --- a/src/libsyntax/ast.rs +++ b/src/libsyntax/ast.rs @@ -265,8 +265,8 @@ type crate_ = config: crate_cfg}; enum crate_directive_ { - cdir_src_mod(ident, ~[attribute]), - cdir_dir_mod(ident, ~[@crate_directive], ~[attribute]), + cdir_src_mod(visibility, ident, ~[attribute]), + cdir_dir_mod(visibility, ident, ~[@crate_directive], ~[attribute]), // NB: cdir_view_item is *not* processed by the rest of the compiler, the // attached view_items are sunk into the crate's module during parsing, diff --git a/src/libsyntax/fold.rs b/src/libsyntax/fold.rs index 918b6b28459..f8f481c8f66 100644 --- a/src/libsyntax/fold.rs +++ b/src/libsyntax/fold.rs @@ -162,11 +162,12 @@ fn noop_fold_crate(c: crate_, fld: ast_fold) -> crate_ { fn noop_fold_crate_directive(cd: crate_directive_, fld: ast_fold) -> crate_directive_ { return match cd { - cdir_src_mod(id, attrs) => { - cdir_src_mod(fld.fold_ident(id), /* FIXME (#2543) */ copy attrs) + cdir_src_mod(vis, id, attrs) => { + cdir_src_mod(vis, fld.fold_ident(id), + /* FIXME (#2543) */ copy attrs) } - cdir_dir_mod(id, cds, attrs) => { - cdir_dir_mod(fld.fold_ident(id), + cdir_dir_mod(vis, id, cds, attrs) => { + cdir_dir_mod(vis, fld.fold_ident(id), vec::map(cds, |x| fld.fold_crate_directive(*x)), /* FIXME (#2543) */ copy attrs) } diff --git a/src/libsyntax/parse/eval.rs b/src/libsyntax/parse/eval.rs index c5e64654d7b..7127e2747eb 100644 --- a/src/libsyntax/parse/eval.rs +++ b/src/libsyntax/parse/eval.rs @@ -85,7 +85,7 @@ fn eval_crate_directive(cx: ctx, cdir: @ast::crate_directive, prefix: &Path, &view_items: ~[@ast::view_item], &items: ~[@ast::item]) { match cdir.node { - ast::cdir_src_mod(id, attrs) => { + ast::cdir_src_mod(vis, id, attrs) => { let file_path = Path(cdir_path_opt( cx.sess.interner.get(id) + ~".rs", attrs)); let full_path = if file_path.is_absolute { @@ -103,13 +103,13 @@ fn eval_crate_directive(cx: ctx, cdir: @ast::crate_directive, prefix: &Path, let i = p0.mk_item(cdir.span.lo, cdir.span.hi, /* FIXME (#2543) */ copy id, - ast::item_mod(m0), ast::public, mod_attrs); + ast::item_mod(m0), vis, mod_attrs); // Thread defids, chpos and byte_pos through the parsers cx.sess.chpos = r0.chpos; cx.sess.byte_pos = cx.sess.byte_pos + r0.pos; vec::push(items, i); } - ast::cdir_dir_mod(id, cdirs, attrs) => { + ast::cdir_dir_mod(vis, id, cdirs, attrs) => { let path = Path(cdir_path_opt(*cx.sess.interner.get(id), attrs)); let full_path = if path.is_absolute { copy path @@ -123,7 +123,7 @@ fn eval_crate_directive(cx: ctx, cdir: @ast::crate_directive, prefix: &Path, attrs: vec::append(attrs, a0), id: cx.sess.next_id, node: ast::item_mod(m0), - vis: ast::public, + vis: vis, span: cdir.span}; cx.sess.next_id += 1; vec::push(items, i); diff --git a/src/libsyntax/parse/parser.rs b/src/libsyntax/parse/parser.rs index 2ffe69c8b10..681d6296d4e 100644 --- a/src/libsyntax/parse/parser.rs +++ b/src/libsyntax/parse/parser.rs @@ -3601,6 +3601,7 @@ impl parser { let expect_mod = vec::len(outer_attrs) > 0u; let lo = self.span.lo; + let vis = self.parse_visibility(); if expect_mod || self.is_keyword(~"mod") { self.expect_keyword(~"mod"); @@ -3611,7 +3612,7 @@ impl parser { token::SEMI => { let mut hi = self.span.hi; self.bump(); - return spanned(lo, hi, cdir_src_mod(id, outer_attrs)); + return spanned(lo, hi, cdir_src_mod(vis, id, outer_attrs)); } // mod x = "foo_dir" { ...directives... } token::LBRACE => { @@ -3624,7 +3625,7 @@ impl parser { let mut hi = self.span.hi; self.expect(token::RBRACE); return spanned(lo, hi, - cdir_dir_mod(id, cdirs, mod_attrs)); + cdir_dir_mod(vis, id, cdirs, mod_attrs)); } _ => self.unexpected() } diff --git a/src/libsyntax/visit.rs b/src/libsyntax/visit.rs index efcb5b2bda0..de9caf48b63 100644 --- a/src/libsyntax/visit.rs +++ b/src/libsyntax/visit.rs @@ -96,8 +96,8 @@ fn visit_crate(c: crate, e: E, v: vt) { fn visit_crate_directive(cd: @crate_directive, e: E, v: vt) { match cd.node { - cdir_src_mod(_, _) => (), - cdir_dir_mod(_, cdirs, _) => for cdirs.each |cdir| { + cdir_src_mod(_, _, _) => (), + cdir_dir_mod(_, _, cdirs, _) => for cdirs.each |cdir| { visit_crate_directive(*cdir, e, v); }, cdir_view_item(vi) => v.visit_view_item(vi, e, v),