Skip to content

Commit c39de06

Browse files
don't check visibility when inlining local impls
those get handled properly in strip-hidden anyway
1 parent 15dba89 commit c39de06

File tree

2 files changed

+38
-6
lines changed

2 files changed

+38
-6
lines changed

src/librustdoc/clean/inline.rs

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -308,9 +308,11 @@ pub fn build_impl(cx: &DocContext, did: DefId, ret: &mut Vec<clean::Item>) {
308308

309309
// Only inline impl if the implemented trait is
310310
// reachable in rustdoc generated documentation
311-
if let Some(traitref) = associated_trait {
312-
if !cx.access_levels.borrow().is_doc_reachable(traitref.def_id) {
313-
return
311+
if !did.is_local() {
312+
if let Some(traitref) = associated_trait {
313+
if !cx.access_levels.borrow().is_doc_reachable(traitref.def_id) {
314+
return
315+
}
314316
}
315317
}
316318

@@ -327,9 +329,11 @@ pub fn build_impl(cx: &DocContext, did: DefId, ret: &mut Vec<clean::Item>) {
327329

328330
// Only inline impl if the implementing type is
329331
// reachable in rustdoc generated documentation
330-
if let Some(did) = for_.def_id() {
331-
if !cx.access_levels.borrow().is_doc_reachable(did) {
332-
return
332+
if !did.is_local() {
333+
if let Some(did) = for_.def_id() {
334+
if !cx.access_levels.borrow().is_doc_reachable(did) {
335+
return
336+
}
333337
}
334338
}
335339

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
// Copyright 2012-2013 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+
pub trait ThisTrait {}
12+
13+
mod asdf {
14+
use ThisTrait;
15+
16+
pub struct SomeStruct;
17+
18+
impl ThisTrait for SomeStruct {}
19+
20+
trait PrivateTrait {}
21+
22+
impl PrivateTrait for SomeStruct {}
23+
}
24+
25+
// @has trait_vis/struct.SomeStruct.html
26+
// @has - '//code' 'impl ThisTrait for SomeStruct'
27+
// !@has - '//code' 'impl PrivateTrait for SomeStruct'
28+
pub use asdf::SomeStruct;

0 commit comments

Comments
 (0)