about summary refs log tree commit diff
path: root/src/librustdoc/html
diff options
context:
space:
mode:
authorMark Rousskov <mark.simulacrum@gmail.com>2019-09-12 22:32:12 -0400
committerMark Rousskov <mark.simulacrum@gmail.com>2019-09-13 19:44:44 -0400
commitec349bef24dc6faf41970bc7de17d22bce6a7cfb (patch)
tree6a86a38c0c67d4f1a56c08af2a93e39f20e0410f /src/librustdoc/html
parent04b27efa00799f984b7ebc50d37a2d571db9235f (diff)
downloadrust-ec349bef24dc6faf41970bc7de17d22bce6a7cfb.tar.gz
rust-ec349bef24dc6faf41970bc7de17d22bce6a7cfb.zip
Unwrap Visibility fields
There's not really any reason to not have the visibility default to
inherited, and this saves us the trouble of checking everywhere for
whether we have a visibility or not.
Diffstat (limited to 'src/librustdoc/html')
-rw-r--r--src/librustdoc/html/format.rs8
-rw-r--r--src/librustdoc/html/render.rs5
2 files changed, 4 insertions, 9 deletions
diff --git a/src/librustdoc/html/format.rs b/src/librustdoc/html/format.rs
index 9baa69d981b..3c62977bd77 100644
--- a/src/librustdoc/html/format.rs
+++ b/src/librustdoc/html/format.rs
@@ -111,7 +111,7 @@ impl Buffer {
 /// Helper to render an optional visibility with a space after it (if the
 /// visibility is preset)
 #[derive(Copy, Clone)]
-pub struct VisSpace<'a>(pub &'a Option<clean::Visibility>);
+pub struct VisSpace<'a>(pub &'a clean::Visibility);
 /// Similarly to VisSpace, this structure is used to render a function style with a
 /// space after it.
 #[derive(Copy, Clone)]
@@ -1034,11 +1034,7 @@ impl Function<'_> {
 
 impl<'a> fmt::Display for VisSpace<'a> {
     fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
-        if let Some(v) = self.0 {
-            fmt::Display::fmt(&v.print_with_space(), f)
-        } else {
-            Ok(())
-        }
+        fmt::Display::fmt(&self.0.print_with_space(), f)
     }
 }
 
diff --git a/src/librustdoc/html/render.rs b/src/librustdoc/html/render.rs
index 7aaf04f34d3..32fa2daa026 100644
--- a/src/librustdoc/html/render.rs
+++ b/src/librustdoc/html/render.rs
@@ -1511,7 +1511,7 @@ impl DocFolder for Cache {
                 self.paths.insert(item.def_id, (stack, ItemType::Enum));
             }
 
-            clean::PrimitiveItem(..) if item.visibility.is_some() => {
+            clean::PrimitiveItem(..) => {
                 self.add_aliases(&item);
                 self.paths.insert(item.def_id, (self.stack.clone(),
                                                 item.type_()));
@@ -4306,8 +4306,7 @@ fn get_methods(
 ) -> Vec<String> {
     i.items.iter().filter_map(|item| {
         match item.name {
-            // Maybe check with clean::Visibility::Public as well?
-            Some(ref name) if !name.is_empty() && item.visibility.is_some() && item.is_method() => {
+            Some(ref name) if !name.is_empty() && item.is_method() => {
                 if !for_deref || should_render_item(item, deref_mut) {
                     Some(format!("<a href=\"#{}\">{}</a>",
                                  get_next_url(used_links, format!("method.{}", name)),