]> git.lizzy.rs Git - rust.git/commitdiff
Remove another unnecessary `Option`
authorCamelid <camelidcamel@gmail.com>
Tue, 23 Mar 2021 18:19:42 +0000 (11:19 -0700)
committerCamelid <camelidcamel@gmail.com>
Tue, 23 Mar 2021 18:19:42 +0000 (11:19 -0700)
The previous changes mean that we can now remove this `Option`.

src/librustdoc/clean/mod.rs
src/librustdoc/doctree.rs
src/librustdoc/visit_ast.rs

index 17a961a5f6655efcfee3dee5a6cb84b79eeb4492..ff30632daabfd3e4d6ed4058179b98868c2a6971 100644 (file)
@@ -231,7 +231,7 @@ fn clean(&self, cx: &mut DocContext<'_>) -> Item {
 
         let what_rustc_thinks = Item::from_hir_id_and_parts(
             self.id,
-            self.name,
+            Some(self.name),
             ModuleItem(Module { is_crate: self.is_crate, items }),
             cx,
         );
index 645b2bb193ec258c3da5d58a6dceb0714c908b1a..189624c0d809c35ea7df84971e415271629db459 100644 (file)
@@ -5,7 +5,7 @@
 use rustc_hir as hir;
 
 crate struct Module<'hir> {
-    crate name: Option<Symbol>,
+    crate name: Symbol,
     crate where_outer: Span,
     crate where_inner: Span,
     crate mods: Vec<Module<'hir>>,
@@ -18,7 +18,7 @@
 }
 
 impl Module<'hir> {
-    crate fn new(name: Option<Symbol>) -> Module<'hir> {
+    crate fn new(name: Symbol) -> Module<'hir> {
         Module {
             name,
             id: hir::CRATE_HIR_ID,
index 11d1bd5f508f390af2907e85fb3b585cc8aa126b..17a66d1788e6d23e5ffbedf8a64c9077b5ed38bd 100644 (file)
@@ -76,7 +76,7 @@ fn store_path(&mut self, did: DefId) {
             &Spanned { span: rustc_span::DUMMY_SP, node: hir::VisibilityKind::Public },
             hir::CRATE_HIR_ID,
             &krate.item.module,
-            Some(self.cx.tcx.crate_name),
+            self.cx.tcx.crate_name,
         );
         top_level_module.is_crate = true;
         // Attach the crate's exported macros to the top-level module.
@@ -114,7 +114,7 @@ fn store_path(&mut self, did: DefId) {
                     _ => continue 'exported_macros,
                 };
                 // Descend into the child module that matches this path segment (if any).
-                match cur_mod.mods.iter_mut().find(|child| child.name == Some(path_segment_ty_ns)) {
+                match cur_mod.mods.iter_mut().find(|child| child.name == path_segment_ty_ns) {
                     Some(child_mod) => cur_mod = &mut *child_mod,
                     None => continue 'exported_macros,
                 }
@@ -133,7 +133,7 @@ fn visit_mod_contents(
         vis: &'tcx hir::Visibility<'_>,
         id: hir::HirId,
         m: &'tcx hir::Mod<'tcx>,
-        name: Option<Symbol>,
+        name: Symbol,
     ) -> Module<'tcx> {
         let mut om = Module::new(name);
         om.where_outer = span;
@@ -312,13 +312,7 @@ fn visit_item(
                 om.items.push((item, renamed))
             }
             hir::ItemKind::Mod(ref m) => {
-                om.mods.push(self.visit_mod_contents(
-                    item.span,
-                    &item.vis,
-                    item.hir_id(),
-                    m,
-                    Some(name),
-                ));
+                om.mods.push(self.visit_mod_contents(item.span, &item.vis, item.hir_id(), m, name));
             }
             hir::ItemKind::Fn(..)
             | hir::ItemKind::ExternCrate(..)