Skip to content

Commit 4320f97

Browse files
committed
---
yaml --- r: 151161 b: refs/heads/try2 c: c8a29c4 h: refs/heads/master i: 151159: 5324772 v: v3
1 parent 65354ab commit 4320f97

File tree

4 files changed

+25
-5
lines changed

4 files changed

+25
-5
lines changed

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ refs/heads/snap-stage3: 78a7676898d9f80ab540c6df5d4c9ce35bb50463
55
refs/heads/try: 519addf6277dbafccbb4159db4b710c37eaa2ec5
66
refs/tags/release-0.1: 1f5c5126e96c79d22cb7862f75304136e204f105
77
refs/heads/ndm: f3868061cd7988080c30d6d5bf352a5a5fe2460b
8-
refs/heads/try2: dee21a67b802ba9d8a0fac11369cbcd53552a216
8+
refs/heads/try2: c8a29c4c595e76b71372a2e40d359ac1ddd8aec8
99
refs/heads/dist-snap: ba4081a5a8573875fed17545846f6f6902c8ba8d
1010
refs/tags/release-0.2: c870d2dffb391e14efb05aa27898f1f6333a9596
1111
refs/tags/release-0.3: b5f0d0f648d9a6153664837026ba1be43d3e2503

branches/try2/src/librustdoc/clean.rs

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -223,10 +223,27 @@ impl Clean<Item> for doctree::Module {
223223
self.view_items.clean().move_iter().collect(),
224224
self.macros.clean().move_iter().collect()
225225
);
226+
227+
// determine if we should display the inner contents or
228+
// the outer `mod` item for the source code.
229+
let where = {
230+
let ctxt = local_data::get(super::ctxtkey, |x| *x.unwrap());
231+
let cm = ctxt.sess().codemap();
232+
let outer = cm.lookup_char_pos(self.where_outer.lo);
233+
let inner = cm.lookup_char_pos(self.where_inner.lo);
234+
if outer.file.start_pos == inner.file.start_pos {
235+
// mod foo { ... }
236+
self.where_outer
237+
} else {
238+
// mod foo; (and a separate FileMap for the contents)
239+
self.where_inner
240+
}
241+
};
242+
226243
Item {
227244
name: Some(name),
228245
attrs: self.attrs.clean(),
229-
source: self.where.clean(),
246+
source: where.clean(),
230247
visibility: self.vis.clean(),
231248
id: self.id,
232249
inner: ModuleItem(Module {

branches/try2/src/librustdoc/doctree.rs

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,8 @@ use syntax::ast::{Ident, NodeId};
1919
pub struct Module {
2020
pub name: Option<Ident>,
2121
pub attrs: Vec<ast::Attribute>,
22-
pub where: Span,
22+
pub where_outer: Span,
23+
pub where_inner: Span,
2324
pub structs: Vec<Struct>,
2425
pub enums: Vec<Enum>,
2526
pub fns: Vec<Function>,
@@ -42,7 +43,8 @@ impl Module {
4243
name : name,
4344
id: 0,
4445
vis: ast::Inherited,
45-
where: syntax::codemap::DUMMY_SP,
46+
where_outer: syntax::codemap::DUMMY_SP,
47+
where_inner: syntax::codemap::DUMMY_SP,
4648
attrs : Vec::new(),
4749
structs : Vec::new(),
4850
enums : Vec::new(),

branches/try2/src/librustdoc/visit_ast.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -118,7 +118,8 @@ impl<'a> RustdocVisitor<'a> {
118118
for item in m.view_items.iter() {
119119
self.visit_view_item(item, &mut om);
120120
}
121-
om.where = span;
121+
om.where_outer = span;
122+
om.where_inner = m.inner;
122123
om.attrs = attrs;
123124
om.vis = vis;
124125
om.id = id;

0 commit comments

Comments
 (0)