diff --git a/src/librustc/metadata/encoder.rs b/src/librustc/metadata/encoder.rs index fbf0288418ab8f8e83865255fd3959fe88097f3f..425db5e4dc07b02cda6a4a0320eace2deae94d00 100644 --- a/src/librustc/metadata/encoder.rs +++ b/src/librustc/metadata/encoder.rs @@ -693,6 +693,10 @@ fn encode_info_for_struct(ecx: &EncodeContext, encode_name(ebml_w, nm); encode_type(ecx, ebml_w, node_id_to_type(tcx, id)); encode_def_id(ebml_w, local_def(id)); + + let stab = stability::lookup(ecx.tcx, field.id); + encode_stability(ebml_w, stab); + ebml_w.end_tag(); } index diff --git a/src/librustc/middle/stability.rs b/src/librustc/middle/stability.rs index ac17bd07503521212b46b40f71055095d86649e3..a3fa5a5f85ba4cd5237d3d43d37ebb49bffbd148 100644 --- a/src/librustc/middle/stability.rs +++ b/src/librustc/middle/stability.rs @@ -14,9 +14,10 @@ use util::nodemap::{NodeMap, DefIdMap}; use syntax::codemap::Span; use syntax::{attr, visit}; +use syntax::ast; use syntax::ast::{Attribute, Block, Crate, DefId, FnDecl, NodeId, Variant}; use syntax::ast::{Item, Required, Provided, TraitMethod, TypeMethod, Method}; -use syntax::ast::{Generics, StructDef, Ident}; +use syntax::ast::{Generics, StructDef, StructField, Ident}; use syntax::ast_util::is_local; use syntax::attr::Stability; use syntax::visit::{FnKind, FkMethod, Visitor}; @@ -91,6 +92,11 @@ fn visit_struct_def(&mut self, s: &StructDef, _: Ident, _: &Generics, s.ctor_id.map(|id| self.annotate(id, &[], parent.clone())); visit::walk_struct_def(self, s, parent) } + + fn visit_struct_field(&mut self, s: &StructField, parent: Option) { + let stab = self.annotate(s.node.id, s.node.attrs.as_slice(), parent); + visit::walk_struct_field(self, s, stab) + } } impl Index { @@ -102,8 +108,8 @@ pub fn build(krate: &Crate) -> Index { extern_cache: DefIdMap::new() } }; - visit::walk_crate(&mut annotator, krate, - attr::find_stability(krate.attrs.as_slice())); + let stab = annotator.annotate(ast::CRATE_NODE_ID, krate.attrs.as_slice(), None); + visit::walk_crate(&mut annotator, krate, stab); annotator.index } } diff --git a/src/librustdoc/clean/mod.rs b/src/librustdoc/clean/mod.rs index af0b6a1cb21d104d496de178bd696f1db0c8920d..24f23761286f024f295809942c6d00321fa1e580 100644 --- a/src/librustdoc/clean/mod.rs +++ b/src/librustdoc/clean/mod.rs @@ -1461,12 +1461,15 @@ fn clean(&self) -> Item { name: Some(name.clean()), attrs: Vec::new(), visibility: Some(ast::Public), - stability: get_stability(self.id), // FIXME: this is not accurate, we need an id for // the specific field but we're using the id - // for the whole variant. Nothing currently - // uses this so we should be good for now. + // for the whole variant. Thus we read the + // stability from the whole variant as well. + // Struct variants are experimental and need + // more infrastructure work before we can get + // at the needed information here. def_id: self.id, + stability: get_stability(self.id), inner: StructFieldItem( TypedStructField(ty.clean()) ) @@ -1482,7 +1485,7 @@ fn clean(&self) -> Item { visibility: Some(ast::Public), def_id: self.id, inner: VariantItem(Variant { kind: kind }), - stability: None, + stability: get_stability(self.id), } } } @@ -1890,7 +1893,7 @@ fn clean(&self) -> Item { source: self.span.clean(), def_id: ast_util::local_def(self.id), visibility: self.vis.clean(), - stability: None, + stability: get_stability(ast_util::local_def(self.id)), inner: inner, } }