File tree Expand file tree Collapse file tree 2 files changed +25
-3
lines changed Expand file tree Collapse file tree 2 files changed +25
-3
lines changed Original file line number Diff line number Diff line change @@ -171,10 +171,15 @@ impl Cfg {
171
171
172
172
/// Renders the configuration for long display, as a long HTML description.
173
173
pub ( crate ) fn render_long_html ( & self ) -> String {
174
- let on = if self . should_use_with_in_description ( ) { "with" } else { "on" } ;
174
+ let on = if self . omit_preposition ( ) {
175
+ ""
176
+ } else if self . should_use_with_in_description ( ) {
177
+ "with "
178
+ } else {
179
+ "on "
180
+ } ;
175
181
176
- let mut msg =
177
- format ! ( "Available {on} <strong>{}</strong>" , Display ( self , Format :: LongHtml ) ) ;
182
+ let mut msg = format ! ( "Available {on}<strong>{}</strong>" , Display ( self , Format :: LongHtml ) ) ;
178
183
if self . should_append_only_to_description ( ) {
179
184
msg. push_str ( " only" ) ;
180
185
}
@@ -244,6 +249,10 @@ impl Cfg {
244
249
Some ( self . clone ( ) )
245
250
}
246
251
}
252
+
253
+ fn omit_preposition ( & self ) -> bool {
254
+ matches ! ( self , Cfg :: True | Cfg :: False )
255
+ }
247
256
}
248
257
249
258
impl ops:: Not for Cfg {
Original file line number Diff line number Diff line change
1
+ #![ feature( doc_cfg) ]
2
+ #![ crate_name = "foo" ]
3
+
4
+ // regression test for https://github.com/rust-lang/rust/issues/138112
5
+
6
+ //@ has 'foo/fn.foo.html' '//div[@class="stab portability"]' 'Available nowhere'
7
+ #[ doc( cfg( false ) ) ]
8
+ pub fn foo ( ) { }
9
+
10
+ // a cfg(true) will simply be ommited, as it is the same as no cfg.
11
+ //@ !has 'foo/fn.bar.html' '//div[@class="stab portability"]' ''
12
+ #[ doc( cfg( true ) ) ]
13
+ pub fn bar ( ) { }
You can’t perform that action at this time.
0 commit comments