File tree 3 files changed +59
-1
lines changed
doc/rustdoc/src/write-documentation
3 files changed +59
-1
lines changed Original file line number Diff line number Diff line change @@ -170,3 +170,32 @@ There are a few attributes which are not inlined though:
170
170
171
171
All other attributes are inherited when inlined, so that the documentation matches the behavior if
172
172
the inlined item was directly defined at the spot where it's shown.
173
+
174
+ These rules also apply if the item is inlined with a glob re-export:
175
+
176
+ ``` rust,ignore (inline)
177
+ mod private_mod {
178
+ /// First
179
+ #[cfg(a)]
180
+ pub struct InPrivate;
181
+ }
182
+
183
+ #[cfg(c)]
184
+ pub use self::private_mod::*;
185
+ ```
186
+
187
+ Otherwise, the attributes displayed will be from the re-exported item and the attributes on the
188
+ re-export itself will be ignored:
189
+
190
+ ``` rust,ignore (inline)
191
+ mod private_mod {
192
+ /// First
193
+ #[cfg(a)]
194
+ pub struct InPrivate;
195
+ }
196
+
197
+ #[cfg(c)]
198
+ pub use self::private_mod::InPrivate;
199
+ ```
200
+
201
+ In the above case, ` cfg(c) ` will not be displayed in the docs.
Original file line number Diff line number Diff line change @@ -2736,7 +2736,7 @@ fn add_without_unwanted_attributes<'hir>(
2736
2736
if ident == sym:: doc {
2737
2737
filter_doc_attr ( normal, is_inline) ;
2738
2738
attrs. push ( ( Cow :: Owned ( attr) , import_parent) ) ;
2739
- } else if ident != sym:: cfg {
2739
+ } else if is_inline || ident != sym:: cfg {
2740
2740
// If it's not a `cfg()` attribute, we keep it.
2741
2741
attrs. push ( ( Cow :: Owned ( attr) , import_parent) ) ;
2742
2742
}
Original file line number Diff line number Diff line change
1
+ // This test ensures that non-glob reexports don't get their attributes merge with
2
+ // the reexported item whereas glob reexports do with the `doc_auto_cfg` feature.
3
+
4
+ #![ crate_name = "foo" ]
5
+ #![ feature( doc_auto_cfg) ]
6
+
7
+ // @has 'foo/index.html'
8
+ // There are two items.
9
+ // @count - '//*[@class="item-table"]//div[@class="item-name"]' 2
10
+ // Only one of them should have an attribute.
11
+ // @count - '//*[@class="item-table"]//div[@class="item-name"]/*[@class="stab portability"]' 1
12
+
13
+ mod a {
14
+ #[ cfg( not( feature = "a" ) ) ]
15
+ pub struct Test1 ;
16
+ }
17
+
18
+ mod b {
19
+ #[ cfg( not( feature = "a" ) ) ]
20
+ pub struct Test2 ;
21
+ }
22
+
23
+ // @has 'foo/struct.Test1.html'
24
+ // @count - '//*[@id="main-content"]/*[@class="item-info"]' 1
25
+ // @has - '//*[@id="main-content"]/*[@class="item-info"]' 'Available on non-crate feature a only.'
26
+ pub use a:: * ;
27
+ // @has 'foo/struct.Test2.html'
28
+ // @count - '//*[@id="main-content"]/*[@class="item-info"]' 0
29
+ pub use b:: Test2 ;
You can’t perform that action at this time.
0 commit comments