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 {
171171
172172 /// Renders the configuration for long display, as a long HTML description.
173173 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+ } ;
175181
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 ) ) ;
178183 if self . should_append_only_to_description ( ) {
179184 msg. push_str ( " only" ) ;
180185 }
@@ -244,6 +249,10 @@ impl Cfg {
244249 Some ( self . clone ( ) )
245250 }
246251 }
252+
253+ fn omit_preposition ( & self ) -> bool {
254+ matches ! ( self , Cfg :: True | Cfg :: False )
255+ }
247256}
248257
249258impl 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