Skip to content

Commit b095522

Browse files
Rollup merge of #44554 - GuillaumeGomez:add-missing-pub, r=QuietMisdreavus
Add pub visibility for methods as well Fixes #44527. r? @QuietMisdreavus
2 parents cc858a7 + 203d71f commit b095522

File tree

2 files changed

+35
-2
lines changed

2 files changed

+35
-2
lines changed

src/librustdoc/html/render.rs

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2621,7 +2621,8 @@ fn render_assoc_item(w: &mut fmt::Formatter,
26212621
href(did).map(|p| format!("{}#{}.{}", p.0, ty, name)).unwrap_or(anchor)
26222622
}
26232623
};
2624-
let mut head_len = format!("{}{}{:#}fn {}{:#}",
2624+
let mut head_len = format!("{}{}{}{:#}fn {}{:#}",
2625+
VisSpace(&meth.visibility),
26252626
ConstnessSpace(constness),
26262627
UnsafetySpace(unsafety),
26272628
AbiSpace(abi),
@@ -2633,8 +2634,9 @@ fn render_assoc_item(w: &mut fmt::Formatter,
26332634
} else {
26342635
(0, true)
26352636
};
2636-
write!(w, "{}{}{}fn <a href='{href}' class='fnname'>{name}</a>\
2637+
write!(w, "{}{}{}{}fn <a href='{href}' class='fnname'>{name}</a>\
26372638
{generics}{decl}{where_clause}",
2639+
VisSpace(&meth.visibility),
26382640
ConstnessSpace(constness),
26392641
UnsafetySpace(unsafety),
26402642
AbiSpace(abi),

src/test/rustdoc/pub-method.rs

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
// Copyright 2017 The Rust Project Developers. See the COPYRIGHT
2+
// file at the top-level directory of this distribution and at
3+
// http://rust-lang.org/COPYRIGHT.
4+
//
5+
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
6+
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
7+
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
8+
// option. This file may not be copied, modified, or distributed
9+
// except according to those terms.
10+
11+
// ignore-tidy-linelength
12+
// compile-flags: --no-defaults --passes collapse-docs --passes unindent-comments --passes strip-priv-imports
13+
14+
#![crate_name = "foo"]
15+
16+
// @has foo/fn.bar.html
17+
// @has - '//*[@class="rust fn"]' 'pub fn bar() -> '
18+
/// foo
19+
pub fn bar() -> usize {
20+
2
21+
}
22+
23+
// @has foo/struct.Foo.html
24+
// @has - '//*[@class="method"]' 'pub fn new()'
25+
// @has - '//*[@class="method"]' 'fn not_pub()'
26+
pub struct Foo(usize);
27+
28+
impl Foo {
29+
pub fn new() -> Foo { Foo(0) }
30+
fn not_pub() {}
31+
}

0 commit comments

Comments
 (0)