Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Rollup of 5 pull requests #41972

Closed
wants to merge 11 commits into from
2 changes: 1 addition & 1 deletion src/librustc_save_analysis/data.rs
Original file line number Diff line number Diff line change
@@ -267,7 +267,7 @@ pub struct ModData {
pub items: Vec<NodeId>,
pub visibility: Visibility,
pub docs: String,
pub sig: Signature,
pub sig: Option<Signature>,
pub attributes: Vec<Attribute>,
}

27 changes: 27 additions & 0 deletions src/librustc_save_analysis/dump_visitor.rs
Original file line number Diff line number Diff line change
@@ -1211,6 +1211,33 @@ impl<'l, 'tcx: 'l, 'll, D: Dump + 'll> DumpVisitor<'l, 'tcx, 'll, D> {
}

impl<'l, 'tcx: 'l, 'll, D: Dump +'ll> Visitor<'l> for DumpVisitor<'l, 'tcx, 'll, D> {
fn visit_mod(&mut self, m: &'l ast::Mod, span: Span, id: NodeId) {
// Since we handle explicit modules ourselves in visit_item, this should
// only get called for the root module of a crate.
assert_eq!(id, ast::CRATE_NODE_ID);

let qualname = format!("::{}", self.tcx.node_path_str(id));

let cm = self.tcx.sess.codemap();
let filename = cm.span_to_filename(span);
self.dumper.mod_data(ModData {
id: id,
name: String::new(),
qualname: qualname,
span: span,
scope: id,
filename: filename,
items: m.items.iter().map(|i| i.id).collect(),
visibility: Visibility::Public,
// TODO Visitor doesn't pass us the attibutes.
docs: String::new(),
sig: None,
// TODO Visitor doesn't pass us the attibutes.
attributes: vec![],
}.lower(self.tcx));
self.nest_scope(id, |v| visit::walk_mod(v, m));
}

fn visit_item(&mut self, item: &'l ast::Item) {
use syntax::ast::ItemKind::*;
self.process_macro_use(item.span, item.id);
4 changes: 2 additions & 2 deletions src/librustc_save_analysis/external_data.rs
Original file line number Diff line number Diff line change
@@ -392,7 +392,7 @@ pub struct ModData {
pub items: Vec<DefId>,
pub visibility: Visibility,
pub docs: String,
pub sig: Signature,
pub sig: Option<Signature>,
pub attributes: Vec<Attribute>,
}

@@ -410,7 +410,7 @@ impl Lower for data::ModData {
items: self.items.into_iter().map(|id| make_def_id(id, &tcx.hir)).collect(),
visibility: self.visibility,
docs: self.docs,
sig: self.sig.lower(tcx),
sig: self.sig.map(|s| s.lower(tcx)),
attributes: self.attributes.lower(tcx),
}
}
2 changes: 1 addition & 1 deletion src/librustc_save_analysis/json_api_dumper.rs
Original file line number Diff line number Diff line change
@@ -293,7 +293,7 @@ impl Into<Option<Def>> for ModData {
parent: None,
decl_id: None,
docs: self.docs,
sig: Some(self.sig.into()),
sig: self.sig.map(|s| s.into()),
attributes: vec![],
}),
_ => None,
2 changes: 1 addition & 1 deletion src/librustc_save_analysis/json_dumper.rs
Original file line number Diff line number Diff line change
@@ -121,7 +121,7 @@ impl<'b, O: DumpOutput + 'b> Dump for JsonDumper<O> {
children: data.items.into_iter().map(|id| id_from_def_id(id)).collect(),
decl_id: None,
docs: data.docs,
sig: Some(data.sig.into()),
sig: data.sig.map(|s| s.into()),
attributes: data.attributes.into_iter().map(|a| a.into()).collect(),
};
if def.span.file_name.to_str().unwrap() != def.value {
2 changes: 1 addition & 1 deletion src/librustc_save_analysis/lib.rs
Original file line number Diff line number Diff line change
@@ -257,7 +257,7 @@ impl<'l, 'tcx: 'l> SaveContext<'l, 'tcx> {
items: m.items.iter().map(|i| i.id).collect(),
visibility: From::from(&item.vis),
docs: docs_for_attrs(&item.attrs),
sig: self.sig_base(item),
sig: Some(self.sig_base(item)),
attributes: item.attrs.clone(),
}))
}