about summary refs log tree commit diff
path: root/src/librustdoc/doctree.rs
diff options
context:
space:
mode:
authorTimothée Delabrouille <timothee.delabrouille@musicworldmedia.com>2021-05-01 15:33:49 +0200
committerTimothée Delabrouille <timothee.delabrouille@musicworldmedia.com>2021-05-01 15:33:49 +0200
commit649bf22df56c18b28d41978990071b513094345d (patch)
tree239b393bbd3937a7098d7dc41e8a6547cb66d005 /src/librustdoc/doctree.rs
parent855c2d130fb70da1643cf8f696c7aad7537aef34 (diff)
downloadrust-649bf22df56c18b28d41978990071b513094345d.tar.gz
rust-649bf22df56c18b28d41978990071b513094345d.zip
compute where_outer on demand, remove it from Module
Diffstat (limited to 'src/librustdoc/doctree.rs')
-rw-r--r--src/librustdoc/doctree.rs13
1 files changed, 8 insertions, 5 deletions
diff --git a/src/librustdoc/doctree.rs b/src/librustdoc/doctree.rs
index d3f4353a58b..eadac89f79e 100644
--- a/src/librustdoc/doctree.rs
+++ b/src/librustdoc/doctree.rs
@@ -1,12 +1,12 @@
 //! This module is used to store stuff from Rust's AST in a more convenient
 //! manner (and with prettier names) before cleaning.
+use rustc_middle::ty::TyCtxt;
 use rustc_span::{self, Span, Symbol};
 
 use rustc_hir as hir;
 
 crate struct Module<'hir> {
     crate name: Symbol,
-    crate where_outer: Span,
     crate where_inner: Span,
     crate mods: Vec<Module<'hir>>,
     crate id: hir::HirId,
@@ -17,16 +17,19 @@ crate struct Module<'hir> {
 }
 
 impl Module<'hir> {
-    crate fn new(name: Symbol) -> Module<'hir> {
+    crate fn new(name: Symbol, id: hir::HirId, where_inner: Span) -> Module<'hir> {
         Module {
             name,
-            id: hir::CRATE_HIR_ID,
-            where_outer: rustc_span::DUMMY_SP,
-            where_inner: rustc_span::DUMMY_SP,
+            id,
+            where_inner,
             mods: Vec::new(),
             items: Vec::new(),
             foreigns: Vec::new(),
             macros: Vec::new(),
         }
     }
+
+    crate fn where_outer(&self, tcx: TyCtxt<'_>) -> Span {
+        tcx.hir().span(self.id)
+    }
 }