Skip to content

Commit e79780f

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

File tree

2 files changed

+38
-6
lines changed

2 files changed

+38
-6
lines changed

src/librustdoc/clean/inline.rs

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

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

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

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

+28
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)