Skip to content

Commit 1a515e6

Browse files
committed
rustdoc-json: Add test for #[macro_use] attribute
1 parent e5e79f8 commit 1a515e6

File tree

1 file changed

+40
-0
lines changed

1 file changed

+40
-0
lines changed
Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
//@ compile-flags: --document-private-items
2+
3+
//@ set exported_id = "$.index[?(@.name=='exported')].id"
4+
//@ is "$.index[?(@.name=='exported')].attrs" '[{"other": "#[macro_export]"}]'
5+
//@ is "$.index[?(@.name=='exported')].visibility" '"public"'
6+
7+
#[macro_export]
8+
macro_rules! exported {
9+
() => {};
10+
}
11+
12+
//@ set not_exported_id = "$.index[?(@.name=='not_exported')].id"
13+
//@ is "$.index[?(@.name=='not_exported')].attrs" []
14+
//@ is "$.index[?(@.name=='not_exported')].visibility" '"crate"'
15+
macro_rules! not_exported {
16+
() => {};
17+
}
18+
19+
//@ set module_id = "$.index[?(@.name=='module')].id"
20+
pub mod module {
21+
//@ set exported_from_mod_id = "$.index[?(@.name=='exported_from_mod')].id"
22+
//@ is "$.index[?(@.name=='exported_from_mod')].attrs" '[{"other": "#[macro_export]"}]'
23+
//@ is "$.index[?(@.name=='exported_from_mod')].visibility" '"public"'
24+
#[macro_export]
25+
macro_rules! exported_from_mod {
26+
() => {};
27+
}
28+
29+
//@ set not_exported_from_mod_id = "$.index[?(@.name=='not_exported_from_mod')].id"
30+
//@ is "$.index[?(@.name=='not_exported_from_mod')].attrs" []
31+
//@ is "$.index[?(@.name=='not_exported_from_mod')].visibility" '"crate"'
32+
macro_rules! not_exported_from_mod {
33+
() => {};
34+
}
35+
}
36+
// The non-exported macro's are left in place, but the #[macro_export]'d ones
37+
// are moved to the crate root.
38+
39+
//@ is "$.index[?(@.name=='module')].inner.module.items[*]" $not_exported_from_mod_id
40+
//@ ismany "$.index[?(@.name=='macro_export')].inner.module.items[*]" $exported_id $not_exported_id $module_id $exported_from_mod_id

0 commit comments

Comments
 (0)