Skip to content

Commit cbd7e8e

Browse files
committed
rustdoc: Prune unconfigured items from AST
1 parent 1b839a6 commit cbd7e8e

File tree

1 file changed

+14
-0
lines changed

1 file changed

+14
-0
lines changed

src/rustdoc/astsrv.rs

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,12 +41,26 @@ fn mk_srv_from_file(file: str) -> srv {
4141
}
4242

4343
fn build_ctxt(ast: @ast::crate) -> ctxt {
44+
45+
import rustc::front::config;
46+
47+
let ast = config::strip_unconfigured_items(ast);
48+
4449
{
4550
ast: ast,
4651
map: ast_map::map_crate(*ast)
4752
}
4853
}
4954

55+
#[test]
56+
fn should_prune_unconfigured_items() {
57+
let source = "#[cfg(shut_up_and_leave_me_alone)]fn a() { }";
58+
let srv = mk_srv_from_str(source);
59+
exec(srv) {|ctxt|
60+
assert vec::is_empty(ctxt.ast.node.module.items);
61+
}
62+
}
63+
5064
fn exec<T>(
5165
srv: srv,
5266
f: fn~(ctxt: ctxt) -> T

0 commit comments

Comments
 (0)