Skip to content

Commit

Permalink
don't check visibility when inlining local impls
Browse files Browse the repository at this point in the history
those get handled properly in strip-hidden anyway
  • Loading branch information
QuietMisdreavus committed Sep 20, 2018
1 parent a45d387 commit e79780f
Show file tree
Hide file tree
Showing 2 changed files with 38 additions and 6 deletions.
16 changes: 10 additions & 6 deletions src/librustdoc/clean/inline.rs
Expand Up @@ -309,9 +309,11 @@ pub fn build_impl(cx: &DocContext, did: DefId, ret: &mut Vec<clean::Item>) {

// Only inline impl if the implemented trait is
// reachable in rustdoc generated documentation
if let Some(traitref) = associated_trait {
if !cx.access_levels.borrow().is_doc_reachable(traitref.def_id) {
return
if !did.is_local() {
if let Some(traitref) = associated_trait {
if !cx.access_levels.borrow().is_doc_reachable(traitref.def_id) {
return
}
}
}

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

// Only inline impl if the implementing type is
// reachable in rustdoc generated documentation
if let Some(did) = for_.def_id() {
if !cx.access_levels.borrow().is_doc_reachable(did) {
return
if !did.is_local() {
if let Some(did) = for_.def_id() {
if !cx.access_levels.borrow().is_doc_reachable(did) {
return
}
}
}

Expand Down
28 changes: 28 additions & 0 deletions src/test/rustdoc/inline_local/trait-vis.rs
@@ -0,0 +1,28 @@
// Copyright 2012-2013 The Rust Project Developers. See the COPYRIGHT
// file at the top-level directory of this distribution and at
// http://rust-lang.org/COPYRIGHT.
//
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
// option. This file may not be copied, modified, or distributed
// except according to those terms.

pub trait ThisTrait {}

mod asdf {
use ThisTrait;

pub struct SomeStruct;

impl ThisTrait for SomeStruct {}

trait PrivateTrait {}

impl PrivateTrait for SomeStruct {}
}

// @has trait_vis/struct.SomeStruct.html
// @has - '//code' 'impl ThisTrait for SomeStruct'
// !@has - '//code' 'impl PrivateTrait for SomeStruct'
pub use asdf::SomeStruct;

0 comments on commit e79780f

Please sign in to comment.