Skip to content

Commit 3861a15

Browse files
author
Ariel Ben-Yehuda
committed
---
yaml --- r: 231691 b: refs/heads/auto c: fcad49e h: refs/heads/master i: 231689: d3342d5 231687: 6f43224 v: v3
1 parent bb24e0a commit 3861a15

File tree

2 files changed

+35
-47
lines changed

2 files changed

+35
-47
lines changed

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ refs/tags/release-0.3: b5f0d0f648d9a6153664837026ba1be43d3e2503
88
refs/tags/release-0.3.1: 495bae036dfe5ec6ceafd3312b4dca48741e845b
99
refs/tags/release-0.4: e828ea2080499553b97dfe33b3f4d472b4562ad7
1010
refs/tags/release-0.5: 7e3bcfbf21278251ee936ad53e92e9b719702d73
11-
refs/heads/auto: 1661947014fc2ecbbb7a30b1604499500dcf767e
11+
refs/heads/auto: fcad49e4161f2083db3ea3c3534d13d10bd130eb
1212
refs/tags/release-0.6: b4ebcfa1812664df5e142f0134a5faea3918544c
1313
refs/tags/0.1: b19db808c2793fe2976759b85a355c3ad8c8b336
1414
refs/tags/0.2: 1754d02027f2924bed83b0160ee340c7f41d5ea1

branches/auto/src/librustc/metadata/encoder.rs

Lines changed: 34 additions & 46 deletions
Original file line numberDiff line numberDiff line change
@@ -287,6 +287,15 @@ fn encode_enum_variant_info(ecx: &EncodeContext,
287287
for variant in &def.variants {
288288
let vid = variant.did;
289289
assert!(vid.is_local());
290+
291+
if let ty::VariantKind::Dict = variant.kind() {
292+
// tuple-like enum variant fields aren't really items so
293+
// don't try to encode them.
294+
for field in &variant.fields {
295+
encode_field(ecx, rbml_w, field, index);
296+
}
297+
}
298+
290299
index.push(entry {
291300
val: vid.node as i64,
292301
pos: rbml_w.mark_stable_position(),
@@ -308,11 +317,6 @@ fn encode_enum_variant_info(ecx: &EncodeContext,
308317
let stab = stability::lookup(ecx.tcx, vid);
309318
encode_stability(rbml_w, stab);
310319

311-
if let ty::VariantKind::Dict = variant.kind() {
312-
let idx = encode_info_for_struct(ecx, rbml_w, variant, index);
313-
encode_index(rbml_w, idx, write_i64);
314-
}
315-
316320
encode_struct_fields(rbml_w, variant, vid);
317321

318322
let specified_disr_val = variant.disr_val;
@@ -618,41 +622,29 @@ fn encode_provided_source(rbml_w: &mut Encoder,
618622
}
619623
}
620624

621-
/* Returns an index of items in this class */
622-
fn encode_info_for_struct<'a, 'tcx>(ecx: &EncodeContext<'a, 'tcx>,
623-
rbml_w: &mut Encoder,
624-
variant: ty::VariantDef<'tcx>,
625-
global_index: &mut Vec<entry<i64>>)
626-
-> Vec<entry<i64>> {
627-
/* Each class has its own index, since different classes
628-
may have fields with the same name */
629-
let mut index = Vec::new();
630-
/* We encode both private and public fields -- need to include
631-
private fields to get the offsets right */
632-
for field in &variant.fields {
633-
let nm = field.name;
634-
let id = field.did.node;
635-
636-
let pos = rbml_w.mark_stable_position();
637-
index.push(entry {val: id as i64, pos: pos});
638-
global_index.push(entry {
639-
val: id as i64,
640-
pos: pos,
641-
});
642-
rbml_w.start_tag(tag_items_data_item);
643-
debug!("encode_info_for_struct: doing {} {}",
644-
nm, id);
645-
encode_struct_field_family(rbml_w, field.vis);
646-
encode_name(rbml_w, nm);
647-
encode_bounds_and_type_for_item(rbml_w, ecx, id);
648-
encode_def_id(rbml_w, DefId::local(id));
649-
650-
let stab = stability::lookup(ecx.tcx, field.did);
651-
encode_stability(rbml_w, stab);
625+
fn encode_field<'a, 'tcx>(ecx: &EncodeContext<'a, 'tcx>,
626+
rbml_w: &mut Encoder,
627+
field: ty::FieldDef<'tcx>,
628+
global_index: &mut Vec<entry<i64>>) {
629+
let nm = field.name;
630+
let id = field.did.node;
652631

653-
rbml_w.end_tag();
654-
}
655-
index
632+
let pos = rbml_w.mark_stable_position();
633+
global_index.push(entry {
634+
val: id as i64,
635+
pos: pos,
636+
});
637+
rbml_w.start_tag(tag_items_data_item);
638+
debug!("encode_field: encoding {} {}", nm, id);
639+
encode_struct_field_family(rbml_w, field.vis);
640+
encode_name(rbml_w, nm);
641+
encode_bounds_and_type_for_item(rbml_w, ecx, id);
642+
encode_def_id(rbml_w, DefId::local(id));
643+
644+
let stab = stability::lookup(ecx.tcx, field.did);
645+
encode_stability(rbml_w, stab);
646+
647+
rbml_w.end_tag();
656648
}
657649

658650
fn encode_info_for_struct_ctor(ecx: &EncodeContext,
@@ -1146,11 +1138,9 @@ fn encode_info_for_item(ecx: &EncodeContext,
11461138
let def = ecx.tcx.lookup_adt_def(def_id);
11471139
let variant = def.struct_variant();
11481140

1149-
/* First, encode the fields
1150-
These come first because we need to write them to make
1151-
the index, and the index needs to be in the item for the
1152-
class itself */
1153-
let idx = encode_info_for_struct(ecx, rbml_w, variant, index);
1141+
for field in &variant.fields {
1142+
encode_field(ecx, rbml_w, field, index);
1143+
}
11541144

11551145
/* Index the class*/
11561146
add_to_index(item, rbml_w, index);
@@ -1179,8 +1169,6 @@ fn encode_info_for_item(ecx: &EncodeContext,
11791169
// Encode inherent implementations for this structure.
11801170
encode_inherent_implementations(ecx, rbml_w, def_id);
11811171

1182-
/* Each class has its own index -- encode it */
1183-
encode_index(rbml_w, idx, write_i64);
11841172
rbml_w.end_tag();
11851173

11861174
// If this is a tuple-like struct, encode the type of the constructor.

0 commit comments

Comments
 (0)