Skip to content

Commit 34c7664

Browse files
committed
save-analysis: add values for types
1 parent e83785c commit 34c7664

File tree

2 files changed

+22
-13
lines changed

2 files changed

+22
-13
lines changed

src/librustc_trans/save/mod.rs

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -568,13 +568,15 @@ impl <'l, 'tcx> DxrVisitor<'l, 'tcx> {
568568
Some(node_id) => node_id,
569569
None => -1,
570570
};
571+
let val = self.span.snippet(item.span);
571572
let sub_span = self.span.sub_span_after_keyword(item.span, keywords::Struct);
572573
self.fmt.struct_str(item.span,
573574
sub_span,
574575
item.id,
575576
ctor_id,
576577
qualname.as_slice(),
577-
self.cur_scope);
578+
self.cur_scope,
579+
val.as_slice());
578580

579581
// fields
580582
for field in def.fields.iter() {
@@ -590,12 +592,14 @@ impl <'l, 'tcx> DxrVisitor<'l, 'tcx> {
590592
enum_definition: &ast::EnumDef,
591593
ty_params: &ast::Generics) {
592594
let enum_name = self.analysis.ty_cx.map.path_to_string(item.id);
595+
let val = self.span.snippet(item.span);
593596
match self.span.sub_span_after_keyword(item.span, keywords::Enum) {
594597
Some(sub_span) => self.fmt.enum_str(item.span,
595598
Some(sub_span),
596599
item.id,
597600
enum_name.as_slice(),
598-
self.cur_scope),
601+
self.cur_scope,
602+
val.as_slice()),
599603
None => self.sess.span_bug(item.span,
600604
format!("Could not find subspan for enum {}",
601605
enum_name).as_slice()),
@@ -700,13 +704,14 @@ impl <'l, 'tcx> DxrVisitor<'l, 'tcx> {
700704
trait_refs: &OwnedSlice<ast::TyParamBound>,
701705
methods: &Vec<ast::TraitItem>) {
702706
let qualname = self.analysis.ty_cx.map.path_to_string(item.id);
703-
707+
let val = self.span.snippet(item.span);
704708
let sub_span = self.span.sub_span_after_keyword(item.span, keywords::Trait);
705709
self.fmt.trait_str(item.span,
706710
sub_span,
707711
item.id,
708712
qualname.as_slice(),
709-
self.cur_scope);
713+
self.cur_scope,
714+
val.as_slice());
710715

711716
// super-traits
712717
for super_bound in trait_refs.iter() {

src/librustc_trans/save/recorder.rs

Lines changed: 13 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -106,7 +106,7 @@ impl<'a> FmtStrs<'a> {
106106
Variable => ("variable",
107107
vec!("id","name","qualname","value","type","scopeid"),
108108
true, true),
109-
Enum => ("enum", vec!("id","qualname","scopeid"), true, true),
109+
Enum => ("enum", vec!("id","qualname","scopeid","value"), true, true),
110110
Variant => ("variant",
111111
vec!("id","name","qualname","type","value","scopeid"),
112112
true, true),
@@ -117,8 +117,8 @@ impl<'a> FmtStrs<'a> {
117117
vec!("id","qualname","declid","declidcrate","scopeid"),
118118
true, true),
119119
MethodDecl => ("method_decl", vec!("id","qualname","scopeid"), true, true),
120-
Struct => ("struct", vec!("id","ctor_id","qualname","scopeid"), true, true),
121-
Trait => ("trait", vec!("id","qualname","scopeid"), true, true),
120+
Struct => ("struct", vec!("id","ctor_id","qualname","scopeid","value"), true, true),
121+
Trait => ("trait", vec!("id","qualname","scopeid","value"), true, true),
122122
Impl => ("impl", vec!("id","refid","refidcrate","scopeid"), true, true),
123123
Module => ("module", vec!("id","qualname","scopeid","def_file"), true, false),
124124
UseAlias => ("use_alias",
@@ -161,6 +161,7 @@ impl<'a> FmtStrs<'a> {
161161
}
162162

163163
let values = values.iter().map(|s| {
164+
// Never take more than 1020 chars
164165
if s.len() > 1020 {
165166
s.as_slice().slice_to(1020)
166167
} else {
@@ -327,11 +328,12 @@ impl<'a> FmtStrs<'a> {
327328
sub_span: Option<Span>,
328329
id: NodeId,
329330
name: &str,
330-
scope_id: NodeId) {
331+
scope_id: NodeId,
332+
value: &str) {
331333
self.check_and_record(Enum,
332334
span,
333335
sub_span,
334-
svec!(id, name, scope_id));
336+
svec!(id, name, scope_id, value));
335337
}
336338

337339
pub fn tuple_variant_str(&mut self,
@@ -411,23 +413,25 @@ impl<'a> FmtStrs<'a> {
411413
id: NodeId,
412414
ctor_id: NodeId,
413415
name: &str,
414-
scope_id: NodeId) {
416+
scope_id: NodeId,
417+
value: &str) {
415418
self.check_and_record(Struct,
416419
span,
417420
sub_span,
418-
svec!(id, ctor_id, name, scope_id));
421+
svec!(id, ctor_id, name, scope_id, value));
419422
}
420423

421424
pub fn trait_str(&mut self,
422425
span: Span,
423426
sub_span: Option<Span>,
424427
id: NodeId,
425428
name: &str,
426-
scope_id: NodeId) {
429+
scope_id: NodeId,
430+
value: &str) {
427431
self.check_and_record(Trait,
428432
span,
429433
sub_span,
430-
svec!(id, name, scope_id));
434+
svec!(id, name, scope_id, value));
431435
}
432436

433437
pub fn impl_str(&mut self,

0 commit comments

Comments
 (0)