diff options
| author | Camelid <camelidcamel@gmail.com> | 2021-03-23 11:19:42 -0700 |
|---|---|---|
| committer | Camelid <camelidcamel@gmail.com> | 2021-03-23 11:19:42 -0700 |
| commit | a7f902b6934b23504a0716b4f2583d273fd08e2a (patch) | |
| tree | 29dbe3c9fcb2577bc85d8419fb980b0ef5acfb6d | |
| parent | 68244fc521c91b5daba347a4160a884eab268e08 (diff) | |
| download | rust-a7f902b6934b23504a0716b4f2583d273fd08e2a.tar.gz rust-a7f902b6934b23504a0716b4f2583d273fd08e2a.zip | |
Remove another unnecessary `Option`
The previous changes mean that we can now remove this `Option`.
| -rw-r--r-- | src/librustdoc/clean/mod.rs | 2 | ||||
| -rw-r--r-- | src/librustdoc/doctree.rs | 4 | ||||
| -rw-r--r-- | src/librustdoc/visit_ast.rs | 14 |
3 files changed, 7 insertions, 13 deletions
diff --git a/src/librustdoc/clean/mod.rs b/src/librustdoc/clean/mod.rs index 17a961a5f66..ff30632daab 100644 --- a/src/librustdoc/clean/mod.rs +++ b/src/librustdoc/clean/mod.rs @@ -231,7 +231,7 @@ impl Clean<Item> for doctree::Module<'_> { 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, ); diff --git a/src/librustdoc/doctree.rs b/src/librustdoc/doctree.rs index 645b2bb193e..189624c0d80 100644 --- a/src/librustdoc/doctree.rs +++ b/src/librustdoc/doctree.rs @@ -5,7 +5,7 @@ use rustc_span::{self, Span, Symbol}; 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 @@ crate struct Module<'hir> { } 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, diff --git a/src/librustdoc/visit_ast.rs b/src/librustdoc/visit_ast.rs index 11d1bd5f508..17a66d1788e 100644 --- a/src/librustdoc/visit_ast.rs +++ b/src/librustdoc/visit_ast.rs @@ -76,7 +76,7 @@ impl<'a, 'tcx> RustdocVisitor<'a, 'tcx> { &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 @@ impl<'a, 'tcx> RustdocVisitor<'a, 'tcx> { _ => 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 @@ impl<'a, 'tcx> RustdocVisitor<'a, 'tcx> { 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 @@ impl<'a, 'tcx> RustdocVisitor<'a, 'tcx> { 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(..) |
