Skip to content

Fix a few nits with save-analysis #19230

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

Merged
merged 2 commits into from
Nov 23, 2014
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 17 additions & 10 deletions src/librustc_trans/save/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -568,13 +568,15 @@ impl <'l, 'tcx> DxrVisitor<'l, 'tcx> {
Some(node_id) => node_id,
None => -1,
};
let val = self.span.snippet(item.span);
let sub_span = self.span.sub_span_after_keyword(item.span, keywords::Struct);
self.fmt.struct_str(item.span,
sub_span,
item.id,
ctor_id,
qualname.as_slice(),
self.cur_scope);
self.cur_scope,
val.as_slice());

// fields
for field in def.fields.iter() {
Expand All @@ -589,21 +591,23 @@ impl <'l, 'tcx> DxrVisitor<'l, 'tcx> {
item: &ast::Item,
enum_definition: &ast::EnumDef,
ty_params: &ast::Generics) {
let qualname = self.analysis.ty_cx.map.path_to_string(item.id);
let enum_name = self.analysis.ty_cx.map.path_to_string(item.id);
let val = self.span.snippet(item.span);
match self.span.sub_span_after_keyword(item.span, keywords::Enum) {
Some(sub_span) => self.fmt.enum_str(item.span,
Some(sub_span),
item.id,
qualname.as_slice(),
self.cur_scope),
enum_name.as_slice(),
self.cur_scope,
val.as_slice()),
None => self.sess.span_bug(item.span,
format!("Could not find subspan for enum {}",
qualname).as_slice()),
enum_name).as_slice()),
}
for variant in enum_definition.variants.iter() {
let name = get_ident(variant.node.name);
let name = name.get();
let mut qualname = qualname.clone();
let mut qualname = enum_name.clone();
qualname.push_str("::");
qualname.push_str(name);
let val = self.span.snippet(variant.span);
Expand All @@ -615,6 +619,7 @@ impl <'l, 'tcx> DxrVisitor<'l, 'tcx> {
variant.node.id,
name,
qualname.as_slice(),
enum_name.as_slice(),
val.as_slice(),
item.id);
for arg in args.iter() {
Expand All @@ -632,18 +637,19 @@ impl <'l, 'tcx> DxrVisitor<'l, 'tcx> {
variant.node.id,
ctor_id,
qualname.as_slice(),
enum_name.as_slice(),
val.as_slice(),
item.id);

for field in struct_def.fields.iter() {
self.process_struct_field_def(field, qualname.as_slice(), variant.node.id);
self.process_struct_field_def(field, enum_name.as_slice(), variant.node.id);
self.visit_ty(&*field.node.ty);
}
}
}
}

self.process_generic_params(ty_params, item.span, qualname.as_slice(), item.id);
self.process_generic_params(ty_params, item.span, enum_name.as_slice(), item.id);
}

fn process_impl(&mut self,
Expand Down Expand Up @@ -698,13 +704,14 @@ impl <'l, 'tcx> DxrVisitor<'l, 'tcx> {
trait_refs: &OwnedSlice<ast::TyParamBound>,
methods: &Vec<ast::TraitItem>) {
let qualname = self.analysis.ty_cx.map.path_to_string(item.id);

let val = self.span.snippet(item.span);
let sub_span = self.span.sub_span_after_keyword(item.span, keywords::Trait);
self.fmt.trait_str(item.span,
sub_span,
item.id,
qualname.as_slice(),
self.cur_scope);
self.cur_scope,
val.as_slice());

// super-traits
for super_bound in trait_refs.iter() {
Expand Down
42 changes: 26 additions & 16 deletions src/librustc_trans/save/recorder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -106,15 +106,19 @@ impl<'a> FmtStrs<'a> {
Variable => ("variable",
vec!("id","name","qualname","value","type","scopeid"),
true, true),
Enum => ("enum", vec!("id","qualname","scopeid"), true, true),
Variant => ("variant", vec!("id","name","qualname","value","scopeid"), true, true),
Enum => ("enum", vec!("id","qualname","scopeid","value"), true, true),
Variant => ("variant",
vec!("id","name","qualname","type","value","scopeid"),
true, true),
VariantStruct => ("variant_struct",
vec!("id","ctor_id","qualname","value","scopeid"), true, true),
Function => ("function", vec!("id","qualname","declid","declidcrate","scopeid"),
vec!("id","ctor_id","qualname","type","value","scopeid"),
true, true),
Function => ("function",
vec!("id","qualname","declid","declidcrate","scopeid"),
true, true),
MethodDecl => ("method_decl", vec!("id","qualname","scopeid"), true, true),
Struct => ("struct", vec!("id","ctor_id","qualname","scopeid"), true, true),
Trait => ("trait", vec!("id","qualname","scopeid"), true, true),
Struct => ("struct", vec!("id","ctor_id","qualname","scopeid","value"), true, true),
Trait => ("trait", vec!("id","qualname","scopeid","value"), true, true),
Impl => ("impl", vec!("id","refid","refidcrate","scopeid"), true, true),
Module => ("module", vec!("id","qualname","scopeid","def_file"), true, false),
UseAlias => ("use_alias",
Expand All @@ -128,7 +132,7 @@ impl<'a> FmtStrs<'a> {
true, false),
MethodCall => ("method_call",
vec!("refid","refidcrate","declid","declidcrate","scopeid"),
true, true),
true, true),
Typedef => ("typedef", vec!("id","qualname","value"), true, true),
ExternalCrate => ("external_crate", vec!("name","crate","file_name"), false, false),
Crate => ("crate", vec!("name"), true, false),
Expand All @@ -140,7 +144,7 @@ impl<'a> FmtStrs<'a> {
true, true),
StructRef => ("struct_ref",
vec!("refid","refidcrate","qualname","scopeid"),
true, true),
true, true),
FnRef => ("fn_ref", vec!("refid","refidcrate","qualname","scopeid"), true, true)
}
}
Expand All @@ -157,6 +161,7 @@ impl<'a> FmtStrs<'a> {
}

let values = values.iter().map(|s| {
// Never take more than 1020 chars
if s.len() > 1020 {
s.as_slice().slice_to(1020)
} else {
Expand Down Expand Up @@ -323,11 +328,12 @@ impl<'a> FmtStrs<'a> {
sub_span: Option<Span>,
id: NodeId,
name: &str,
scope_id: NodeId) {
scope_id: NodeId,
value: &str) {
self.check_and_record(Enum,
span,
sub_span,
svec!(id, name, scope_id));
svec!(id, name, scope_id, value));
}

pub fn tuple_variant_str(&mut self,
Expand All @@ -336,12 +342,13 @@ impl<'a> FmtStrs<'a> {
id: NodeId,
name: &str,
qualname: &str,
typ: &str,
val: &str,
scope_id: NodeId) {
self.check_and_record(Variant,
span,
sub_span,
svec!(id, name, qualname, val, scope_id));
svec!(id, name, qualname, typ, val, scope_id));
}

pub fn struct_variant_str(&mut self,
Expand All @@ -350,12 +357,13 @@ impl<'a> FmtStrs<'a> {
id: NodeId,
ctor_id: NodeId,
name: &str,
typ: &str,
val: &str,
scope_id: NodeId) {
self.check_and_record(VariantStruct,
span,
sub_span,
svec!(id, ctor_id, name, val, scope_id));
svec!(id, ctor_id, name, typ, val, scope_id));
}

pub fn fn_str(&mut self,
Expand Down Expand Up @@ -405,23 +413,25 @@ impl<'a> FmtStrs<'a> {
id: NodeId,
ctor_id: NodeId,
name: &str,
scope_id: NodeId) {
scope_id: NodeId,
value: &str) {
self.check_and_record(Struct,
span,
sub_span,
svec!(id, ctor_id, name, scope_id));
svec!(id, ctor_id, name, scope_id, value));
}

pub fn trait_str(&mut self,
span: Span,
sub_span: Option<Span>,
id: NodeId,
name: &str,
scope_id: NodeId) {
scope_id: NodeId,
value: &str) {
self.check_and_record(Trait,
span,
sub_span,
svec!(id, name, scope_id));
svec!(id, name, scope_id, value));
}

pub fn impl_str(&mut self,
Expand Down