Bug fixes for stability tracking
This commit adds correct stability tracking for struct fields and corrects some places where rustdoc was not pulling the stability data.
This commit is contained in:
parent
4d16de01d0
commit
0487e6387b
@ -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
|
||||
|
@ -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 @@ impl Visitor<Option<Stability>> for Annotator {
|
||||
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<Stability>) {
|
||||
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 @@ impl 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
|
||||
}
|
||||
}
|
||||
|
@ -1461,12 +1461,15 @@ impl Clean<Item> for ty::VariantInfo {
|
||||
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 @@ impl Clean<Item> for ty::VariantInfo {
|
||||
visibility: Some(ast::Public),
|
||||
def_id: self.id,
|
||||
inner: VariantItem(Variant { kind: kind }),
|
||||
stability: None,
|
||||
stability: get_stability(self.id),
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -1890,7 +1893,7 @@ impl Clean<Item> for ast::ForeignItem {
|
||||
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,
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user