Pretty-print view items in mod items
For mods that aren't defined at the file level we were forgetting to print the view items so, e.g. 'mod { use std; }' would not print correctly.
This commit is contained in:
parent
1e63d5303f
commit
50b1953f9b
|
@ -41,8 +41,7 @@ fn print_crate(session sess, @ast::crate crate, str filename,
|
|||
mutable cur_lit=0u,
|
||||
mutable boxes=boxes,
|
||||
mode=mode);
|
||||
print_inner_attributes(s, crate.node.attrs);
|
||||
print_mod(s, crate.node.module);
|
||||
print_mod(s, crate.node.module, crate.node.attrs);
|
||||
eof(s.s);
|
||||
}
|
||||
|
||||
|
@ -186,7 +185,8 @@ fn commasep_exprs(&ps s, breaks b, vec[@ast::expr] exprs) {
|
|||
commasep_cmnt(s, b, exprs, print_expr, expr_span);
|
||||
}
|
||||
|
||||
fn print_mod(&ps s, ast::_mod _mod) {
|
||||
fn print_mod(&ps s, ast::_mod _mod, &vec[ast::attribute] attrs) {
|
||||
print_inner_attributes(s, attrs);
|
||||
for (@ast::view_item vitem in _mod.view_items) {
|
||||
print_view_item(s, vitem);
|
||||
}
|
||||
|
@ -322,8 +322,7 @@ fn print_item(&ps s, &@ast::item item) {
|
|||
head(s, "mod");
|
||||
word_nbsp(s, item.ident);
|
||||
bopen(s);
|
||||
print_inner_attributes(s, item.attrs);
|
||||
for (@ast::item itm in _mod.items) { print_item(s, itm); }
|
||||
print_mod(s, _mod, item.attrs);
|
||||
bclose(s, item.span);
|
||||
}
|
||||
case (ast::item_native_mod(?nmod)) {
|
||||
|
|
|
@ -0,0 +1,15 @@
|
|||
// Test view items inside non-file-level mods
|
||||
|
||||
// This is a regression test for an issue where we were failing to
|
||||
// pretty-print such view items. If that happens again, this should
|
||||
// begin failing.
|
||||
|
||||
mod m {
|
||||
use std;
|
||||
import std::vec;
|
||||
fn f() -> vec[int] { vec::empty[int]() }
|
||||
}
|
||||
|
||||
fn main() {
|
||||
auto x = m::f();
|
||||
}
|
Loading…
Reference in New Issue