Skip to content

Commit 34ab154

Browse files
author
Jakub Bukaj
committed
rollup merge of #19230: nick29581/dxr-values
r?
2 parents 11700cb + 34c7664 commit 34ab154

File tree

2 files changed

+43
-26
lines changed

2 files changed

+43
-26
lines changed

src/librustc_trans/save/mod.rs

Lines changed: 17 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -560,13 +560,15 @@ impl <'l, 'tcx> DxrVisitor<'l, 'tcx> {
560560
Some(node_id) => node_id,
561561
None => -1,
562562
};
563+
let val = self.span.snippet(item.span);
563564
let sub_span = self.span.sub_span_after_keyword(item.span, keywords::Struct);
564565
self.fmt.struct_str(item.span,
565566
sub_span,
566567
item.id,
567568
ctor_id,
568569
qualname.as_slice(),
569-
self.cur_scope);
570+
self.cur_scope,
571+
val.as_slice());
570572

571573
// fields
572574
for field in def.fields.iter() {
@@ -581,21 +583,23 @@ impl <'l, 'tcx> DxrVisitor<'l, 'tcx> {
581583
item: &ast::Item,
582584
enum_definition: &ast::EnumDef,
583585
ty_params: &ast::Generics) {
584-
let qualname = self.analysis.ty_cx.map.path_to_string(item.id);
586+
let enum_name = self.analysis.ty_cx.map.path_to_string(item.id);
587+
let val = self.span.snippet(item.span);
585588
match self.span.sub_span_after_keyword(item.span, keywords::Enum) {
586589
Some(sub_span) => self.fmt.enum_str(item.span,
587590
Some(sub_span),
588591
item.id,
589-
qualname.as_slice(),
590-
self.cur_scope),
592+
enum_name.as_slice(),
593+
self.cur_scope,
594+
val.as_slice()),
591595
None => self.sess.span_bug(item.span,
592596
format!("Could not find subspan for enum {}",
593-
qualname).as_slice()),
597+
enum_name).as_slice()),
594598
}
595599
for variant in enum_definition.variants.iter() {
596600
let name = get_ident(variant.node.name);
597601
let name = name.get();
598-
let mut qualname = qualname.clone();
602+
let mut qualname = enum_name.clone();
599603
qualname.push_str("::");
600604
qualname.push_str(name);
601605
let val = self.span.snippet(variant.span);
@@ -607,6 +611,7 @@ impl <'l, 'tcx> DxrVisitor<'l, 'tcx> {
607611
variant.node.id,
608612
name,
609613
qualname.as_slice(),
614+
enum_name.as_slice(),
610615
val.as_slice(),
611616
item.id);
612617
for arg in args.iter() {
@@ -624,18 +629,19 @@ impl <'l, 'tcx> DxrVisitor<'l, 'tcx> {
624629
variant.node.id,
625630
ctor_id,
626631
qualname.as_slice(),
632+
enum_name.as_slice(),
627633
val.as_slice(),
628634
item.id);
629635

630636
for field in struct_def.fields.iter() {
631-
self.process_struct_field_def(field, qualname.as_slice(), variant.node.id);
637+
self.process_struct_field_def(field, enum_name.as_slice(), variant.node.id);
632638
self.visit_ty(&*field.node.ty);
633639
}
634640
}
635641
}
636642
}
637643

638-
self.process_generic_params(ty_params, item.span, qualname.as_slice(), item.id);
644+
self.process_generic_params(ty_params, item.span, enum_name.as_slice(), item.id);
639645
}
640646

641647
fn process_impl(&mut self,
@@ -690,13 +696,14 @@ impl <'l, 'tcx> DxrVisitor<'l, 'tcx> {
690696
trait_refs: &OwnedSlice<ast::TyParamBound>,
691697
methods: &Vec<ast::TraitItem>) {
692698
let qualname = self.analysis.ty_cx.map.path_to_string(item.id);
693-
699+
let val = self.span.snippet(item.span);
694700
let sub_span = self.span.sub_span_after_keyword(item.span, keywords::Trait);
695701
self.fmt.trait_str(item.span,
696702
sub_span,
697703
item.id,
698704
qualname.as_slice(),
699-
self.cur_scope);
705+
self.cur_scope,
706+
val.as_slice());
700707

701708
// super-traits
702709
for super_bound in trait_refs.iter() {

src/librustc_trans/save/recorder.rs

Lines changed: 26 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -106,15 +106,19 @@ 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),
110-
Variant => ("variant", vec!("id","name","qualname","value","scopeid"), true, true),
109+
Enum => ("enum", vec!("id","qualname","scopeid","value"), true, true),
110+
Variant => ("variant",
111+
vec!("id","name","qualname","type","value","scopeid"),
112+
true, true),
111113
VariantStruct => ("variant_struct",
112-
vec!("id","ctor_id","qualname","value","scopeid"), true, true),
113-
Function => ("function", vec!("id","qualname","declid","declidcrate","scopeid"),
114+
vec!("id","ctor_id","qualname","type","value","scopeid"),
115+
true, true),
116+
Function => ("function",
117+
vec!("id","qualname","declid","declidcrate","scopeid"),
114118
true, true),
115119
MethodDecl => ("method_decl", vec!("id","qualname","scopeid"), true, true),
116-
Struct => ("struct", vec!("id","ctor_id","qualname","scopeid"), true, true),
117-
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),
118122
Impl => ("impl", vec!("id","refid","refidcrate","scopeid"), true, true),
119123
Module => ("module", vec!("id","qualname","scopeid","def_file"), true, false),
120124
UseAlias => ("use_alias",
@@ -128,7 +132,7 @@ impl<'a> FmtStrs<'a> {
128132
true, false),
129133
MethodCall => ("method_call",
130134
vec!("refid","refidcrate","declid","declidcrate","scopeid"),
131-
true, true),
135+
true, true),
132136
Typedef => ("typedef", vec!("id","qualname","value"), true, true),
133137
ExternalCrate => ("external_crate", vec!("name","crate","file_name"), false, false),
134138
Crate => ("crate", vec!("name"), true, false),
@@ -140,7 +144,7 @@ impl<'a> FmtStrs<'a> {
140144
true, true),
141145
StructRef => ("struct_ref",
142146
vec!("refid","refidcrate","qualname","scopeid"),
143-
true, true),
147+
true, true),
144148
FnRef => ("fn_ref", vec!("refid","refidcrate","qualname","scopeid"), true, true)
145149
}
146150
}
@@ -157,6 +161,7 @@ impl<'a> FmtStrs<'a> {
157161
}
158162

159163
let values = values.iter().map(|s| {
164+
// Never take more than 1020 chars
160165
if s.len() > 1020 {
161166
s.as_slice().slice_to(1020)
162167
} else {
@@ -323,11 +328,12 @@ impl<'a> FmtStrs<'a> {
323328
sub_span: Option<Span>,
324329
id: NodeId,
325330
name: &str,
326-
scope_id: NodeId) {
331+
scope_id: NodeId,
332+
value: &str) {
327333
self.check_and_record(Enum,
328334
span,
329335
sub_span,
330-
svec!(id, name, scope_id));
336+
svec!(id, name, scope_id, value));
331337
}
332338

333339
pub fn tuple_variant_str(&mut self,
@@ -336,12 +342,13 @@ impl<'a> FmtStrs<'a> {
336342
id: NodeId,
337343
name: &str,
338344
qualname: &str,
345+
typ: &str,
339346
val: &str,
340347
scope_id: NodeId) {
341348
self.check_and_record(Variant,
342349
span,
343350
sub_span,
344-
svec!(id, name, qualname, val, scope_id));
351+
svec!(id, name, qualname, typ, val, scope_id));
345352
}
346353

347354
pub fn struct_variant_str(&mut self,
@@ -350,12 +357,13 @@ impl<'a> FmtStrs<'a> {
350357
id: NodeId,
351358
ctor_id: NodeId,
352359
name: &str,
360+
typ: &str,
353361
val: &str,
354362
scope_id: NodeId) {
355363
self.check_and_record(VariantStruct,
356364
span,
357365
sub_span,
358-
svec!(id, ctor_id, name, val, scope_id));
366+
svec!(id, ctor_id, name, typ, val, scope_id));
359367
}
360368

361369
pub fn fn_str(&mut self,
@@ -405,23 +413,25 @@ impl<'a> FmtStrs<'a> {
405413
id: NodeId,
406414
ctor_id: NodeId,
407415
name: &str,
408-
scope_id: NodeId) {
416+
scope_id: NodeId,
417+
value: &str) {
409418
self.check_and_record(Struct,
410419
span,
411420
sub_span,
412-
svec!(id, ctor_id, name, scope_id));
421+
svec!(id, ctor_id, name, scope_id, value));
413422
}
414423

415424
pub fn trait_str(&mut self,
416425
span: Span,
417426
sub_span: Option<Span>,
418427
id: NodeId,
419428
name: &str,
420-
scope_id: NodeId) {
429+
scope_id: NodeId,
430+
value: &str) {
421431
self.check_and_record(Trait,
422432
span,
423433
sub_span,
424-
svec!(id, name, scope_id));
434+
svec!(id, name, scope_id, value));
425435
}
426436

427437
pub fn impl_str(&mut self,

0 commit comments

Comments
 (0)