]> git.lizzy.rs Git - rust.git/commitdiff
don't check visibility when inlining local impls
authorQuietMisdreavus <grey@quietmisdreavus.net>
Tue, 21 Aug 2018 21:22:20 +0000 (16:22 -0500)
committerQuietMisdreavus <grey@quietmisdreavus.net>
Thu, 20 Sep 2018 10:42:33 +0000 (05:42 -0500)
those get handled properly in strip-hidden anyway

src/librustdoc/clean/inline.rs
src/test/rustdoc/inline_local/trait-vis.rs [new file with mode: 0644]

index 12a33228cb2131f3558de2f3d33e6eb4c742584c..6ef0a3f3da550055d83a05f28b42fbb91abec1e6 100644 (file)
@@ -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
+            }
         }
     }
 
@@ -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
+            }
         }
     }
 
diff --git a/src/test/rustdoc/inline_local/trait-vis.rs b/src/test/rustdoc/inline_local/trait-vis.rs
new file mode 100644 (file)
index 0000000..1035e35
--- /dev/null
@@ -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;