diff --git a/src/librustdoc/html/render.rs b/src/librustdoc/html/render.rs
index fbd2611acb92d..264b20ddac121 100644
--- a/src/librustdoc/html/render.rs
+++ b/src/librustdoc/html/render.rs
@@ -114,19 +114,19 @@ pub enum ExternalLocation {
/// Metadata about an implementor of a trait.
pub struct Implementor {
- def_id: ast::DefId,
- generics: clean::Generics,
- trait_: clean::Type,
- for_: clean::Type,
- stability: Option,
+ pub def_id: ast::DefId,
+ pub generics: clean::Generics,
+ pub trait_: clean::Type,
+ pub for_: clean::Type,
+ pub stability: Option,
}
/// Metadata about implementations for a type.
#[deriving(Clone)]
pub struct Impl {
- impl_: clean::Impl,
- dox: Option,
- stability: Option,
+ pub impl_: clean::Impl,
+ pub dox: Option,
+ pub stability: Option,
}
/// This cache is used to store information about the `clean::Crate` being
@@ -254,11 +254,6 @@ pub fn run(mut krate: clean::Crate, external_html: &ExternalHtml, dst: Path) ->
try!(mkdir(&cx.dst));
- // Crawl the crate, building a summary of the stability levels. NOTE: this
- // summary *must* be computed with the original `krate`; the folding below
- // removes the impls from their modules.
- let summary = stability_summary::build(&krate);
-
// Crawl the crate attributes looking for attributes which control how we're
// going to emit HTML
let default: &[_] = &[];
@@ -372,6 +367,9 @@ pub fn run(mut krate: clean::Crate, external_html: &ExternalHtml, dst: Path) ->
try!(write_shared(&cx, &krate, &*cache, index));
let krate = try!(render_sources(&mut cx, krate));
+ // Crawl the crate, building a summary of the stability levels.
+ let summary = stability_summary::build(&krate);
+
// And finally render the whole crate's documentation
cx.krate(krate, summary)
}
diff --git a/src/librustdoc/lib.rs b/src/librustdoc/lib.rs
index 5e2f56e00fc0d..9b59a258ce191 100644
--- a/src/librustdoc/lib.rs
+++ b/src/librustdoc/lib.rs
@@ -16,7 +16,7 @@
#![crate_type = "rlib"]
#![allow(unknown_features)]
-#![feature(globs, struct_variant, macro_rules, phase, slicing_syntax)]
+#![feature(globs, struct_variant, macro_rules, phase, slicing_syntax, tuple_indexing)]
extern crate arena;
extern crate getopts;
diff --git a/src/librustdoc/stability_summary.rs b/src/librustdoc/stability_summary.rs
index 5cc5698edfc89..37eb730819109 100644
--- a/src/librustdoc/stability_summary.rs
+++ b/src/librustdoc/stability_summary.rs
@@ -22,7 +22,9 @@ use syntax::ast::Public;
use clean::{Crate, Item, ModuleItem, Module, StructItem, Struct, EnumItem, Enum};
use clean::{ImplItem, Impl, Trait, TraitItem, TraitMethod, ProvidedMethod, RequiredMethod};
-use clean::{TypeTraitItem, ViewItemItem, PrimitiveItem};
+use clean::{TypeTraitItem, ViewItemItem, PrimitiveItem, Stability};
+
+use html::render::cache_key;
#[deriving(Zero, Encodable, Decodable, PartialEq, Eq)]
/// The counts for each stability level.
@@ -88,12 +90,8 @@ fn visible(item: &Item) -> bool {
}
}
-// Produce the summary for an arbitrary item. If the item is a module, include a
-// module summary. The counts for items with nested items (e.g. modules, traits,
-// impls) include all children counts.
-fn summarize_item(item: &Item) -> (Counts, Option) {
- // count this item
- let item_counts = match item.stability {
+fn count_stability(stab: Option<&Stability>) -> Counts {
+ match stab {
None => Counts { unmarked: 1, .. Zero::zero() },
Some(ref stab) => match stab.level {
Deprecated => Counts { deprecated: 1, .. Zero::zero() },
@@ -103,7 +101,31 @@ fn summarize_item(item: &Item) -> (Counts, Option) {
Frozen => Counts { frozen: 1, .. Zero::zero() },
Locked => Counts { locked: 1, .. Zero::zero() },
}
- };
+ }
+}
+
+fn summarize_methods(item: &Item) -> Counts {
+ match cache_key.get().unwrap().impls.get(&item.def_id) {
+ Some(v) => {
+ v.iter().map(|i| {
+ let mut count = count_stability(i.stability.as_ref());
+ if i.impl_.trait_.is_none() {
+ count = count +
+ i.impl_.items.iter().map(|ti| summarize_item(ti).0).sum();
+ }
+ count
+ }).sum()
+ }
+ None => Zero::zero()
+ }
+}
+
+
+// Produce the summary for an arbitrary item. If the item is a module, include a
+// module summary. The counts for items with nested items (e.g. modules, traits,
+// impls) include all children counts.
+fn summarize_item(item: &Item) -> (Counts, Option) {
+ let item_counts = count_stability(item.stability.as_ref()) + summarize_methods(item);
// Count this item's children, if any. Note that a trait impl is
// considered to have no children.