Skip to content

Commit e83785c

Browse files
committed
save-analysis: emit a type for enum variants
1 parent ccc4a7c commit e83785c

File tree

2 files changed

+21
-13
lines changed

2 files changed

+21
-13
lines changed

src/librustc_trans/save/mod.rs

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -589,21 +589,21 @@ impl <'l, 'tcx> DxrVisitor<'l, 'tcx> {
589589
item: &ast::Item,
590590
enum_definition: &ast::EnumDef,
591591
ty_params: &ast::Generics) {
592-
let qualname = self.analysis.ty_cx.map.path_to_string(item.id);
592+
let enum_name = self.analysis.ty_cx.map.path_to_string(item.id);
593593
match self.span.sub_span_after_keyword(item.span, keywords::Enum) {
594594
Some(sub_span) => self.fmt.enum_str(item.span,
595595
Some(sub_span),
596596
item.id,
597-
qualname.as_slice(),
597+
enum_name.as_slice(),
598598
self.cur_scope),
599599
None => self.sess.span_bug(item.span,
600600
format!("Could not find subspan for enum {}",
601-
qualname).as_slice()),
601+
enum_name).as_slice()),
602602
}
603603
for variant in enum_definition.variants.iter() {
604604
let name = get_ident(variant.node.name);
605605
let name = name.get();
606-
let mut qualname = qualname.clone();
606+
let mut qualname = enum_name.clone();
607607
qualname.push_str("::");
608608
qualname.push_str(name);
609609
let val = self.span.snippet(variant.span);
@@ -615,6 +615,7 @@ impl <'l, 'tcx> DxrVisitor<'l, 'tcx> {
615615
variant.node.id,
616616
name,
617617
qualname.as_slice(),
618+
enum_name.as_slice(),
618619
val.as_slice(),
619620
item.id);
620621
for arg in args.iter() {
@@ -632,18 +633,19 @@ impl <'l, 'tcx> DxrVisitor<'l, 'tcx> {
632633
variant.node.id,
633634
ctor_id,
634635
qualname.as_slice(),
636+
enum_name.as_slice(),
635637
val.as_slice(),
636638
item.id);
637639

638640
for field in struct_def.fields.iter() {
639-
self.process_struct_field_def(field, qualname.as_slice(), variant.node.id);
641+
self.process_struct_field_def(field, enum_name.as_slice(), variant.node.id);
640642
self.visit_ty(&*field.node.ty);
641643
}
642644
}
643645
}
644646
}
645647

646-
self.process_generic_params(ty_params, item.span, qualname.as_slice(), item.id);
648+
self.process_generic_params(ty_params, item.span, enum_name.as_slice(), item.id);
647649
}
648650

649651
fn process_impl(&mut self,

src/librustc_trans/save/recorder.rs

Lines changed: 13 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -107,10 +107,14 @@ impl<'a> FmtStrs<'a> {
107107
vec!("id","name","qualname","value","type","scopeid"),
108108
true, true),
109109
Enum => ("enum", vec!("id","qualname","scopeid"), true, true),
110-
Variant => ("variant", vec!("id","name","qualname","value","scopeid"), 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),
116120
Struct => ("struct", vec!("id","ctor_id","qualname","scopeid"), true, true),
@@ -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
}
@@ -336,12 +340,13 @@ impl<'a> FmtStrs<'a> {
336340
id: NodeId,
337341
name: &str,
338342
qualname: &str,
343+
typ: &str,
339344
val: &str,
340345
scope_id: NodeId) {
341346
self.check_and_record(Variant,
342347
span,
343348
sub_span,
344-
svec!(id, name, qualname, val, scope_id));
349+
svec!(id, name, qualname, typ, val, scope_id));
345350
}
346351

347352
pub fn struct_variant_str(&mut self,
@@ -350,12 +355,13 @@ impl<'a> FmtStrs<'a> {
350355
id: NodeId,
351356
ctor_id: NodeId,
352357
name: &str,
358+
typ: &str,
353359
val: &str,
354360
scope_id: NodeId) {
355361
self.check_and_record(VariantStruct,
356362
span,
357363
sub_span,
358-
svec!(id, ctor_id, name, val, scope_id));
364+
svec!(id, ctor_id, name, typ, val, scope_id));
359365
}
360366

361367
pub fn fn_str(&mut self,

0 commit comments

Comments
 (0)