Skip to content

Commit 8f57383

Browse files
committed
---
yaml --- r: 150942 b: refs/heads/try2 c: d46c737 h: refs/heads/master v: v3
1 parent b873a0d commit 8f57383

38 files changed

+294
-882
lines changed

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ refs/heads/snap-stage3: 78a7676898d9f80ab540c6df5d4c9ce35bb50463
55
refs/heads/try: 519addf6277dbafccbb4159db4b710c37eaa2ec5
66
refs/tags/release-0.1: 1f5c5126e96c79d22cb7862f75304136e204f105
77
refs/heads/ndm: f3868061cd7988080c30d6d5bf352a5a5fe2460b
8-
refs/heads/try2: 412a18f12ef2c1004b55d0580ab81eee76abcb48
8+
refs/heads/try2: d46c737d3bab0f99fb6b28107725531b18ef081b
99
refs/heads/dist-snap: ba4081a5a8573875fed17545846f6f6902c8ba8d
1010
refs/tags/release-0.2: c870d2dffb391e14efb05aa27898f1f6333a9596
1111
refs/tags/release-0.3: b5f0d0f648d9a6153664837026ba1be43d3e2503

branches/try2/src/doc/rust.md

Lines changed: 0 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1214,22 +1214,6 @@ struct Cookie;
12141214
let c = [Cookie, Cookie, Cookie, Cookie];
12151215
~~~~
12161216

1217-
By using the `struct_inherit` feature gate, structures may use single inheritance. A Structure may only
1218-
inherit from a single other structure, called the _super-struct_. The inheriting structure (sub-struct)
1219-
acts as if all fields in the super-struct were present in the sub-struct. Fields declared in a sub-struct
1220-
must not have the same name as any field in any (transitive) super-struct. All fields (both declared
1221-
and inherited) must be specified in any initializers. Inheritance between structures does not give
1222-
subtyping or coercion. The super-struct and sub-struct must be defined in the same crate. The super-struct
1223-
must be declared using the `virtual` keyword.
1224-
For example:
1225-
1226-
~~~~ {.ignore}
1227-
virtual struct Sup { x: int }
1228-
struct Sub : Sup { y: int }
1229-
let s = Sub {x: 10, y: 11};
1230-
let sx = s.x;
1231-
~~~~
1232-
12331217
### Enumerations
12341218

12351219
An _enumeration_ is a simultaneous definition of a nominal [enumerated type](#enumerated-types) as well as a set of *constructors*,

branches/try2/src/librustc/front/config.rs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -151,8 +151,6 @@ fn fold_struct(cx: &Context, def: &ast::StructDef) -> @ast::StructDef {
151151
@ast::StructDef {
152152
fields: fields.collect(),
153153
ctor_id: def.ctor_id,
154-
super_struct: def.super_struct.clone(),
155-
is_virtual: def.is_virtual,
156154
}
157155
}
158156

branches/try2/src/librustc/front/feature_gate.rs

Lines changed: 1 addition & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,6 @@ static KNOWN_FEATURES: &'static [(&'static str, Status)] = &[
5555
("default_type_params", Active),
5656
("quote", Active),
5757
("linkage", Active),
58-
("struct_inherit", Active),
5958

6059
// These are used to test this portion of the compiler, they don't actually
6160
// mean anything
@@ -191,22 +190,11 @@ impl<'a> Visitor<()> for Context<'a> {
191190
}
192191
}
193192

194-
ast::ItemStruct(struct_definition, _) => {
193+
ast::ItemStruct(..) => {
195194
if attr::contains_name(i.attrs.as_slice(), "simd") {
196195
self.gate_feature("simd", i.span,
197196
"SIMD types are experimental and possibly buggy");
198197
}
199-
match struct_definition.super_struct {
200-
Some(ref path) => self.gate_feature("struct_inherit", path.span,
201-
"struct inheritance is experimental \
202-
and possibly buggy"),
203-
None => {}
204-
}
205-
if struct_definition.is_virtual {
206-
self.gate_feature("struct_inherit", i.span,
207-
"struct inheritance (`virtual` keyword) is \
208-
experimental and possibly buggy");
209-
}
210198
}
211199

212200
_ => {}

branches/try2/src/librustc/lib/llvm.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -709,7 +709,6 @@ pub mod llvm {
709709
pub fn LLVMSetGC(Fn: ValueRef, Name: *c_char);
710710
pub fn LLVMAddFunctionAttr(Fn: ValueRef, PA: c_uint);
711711
pub fn LLVMAddFunctionAttrString(Fn: ValueRef, Name: *c_char);
712-
pub fn LLVMRemoveFunctionAttrString(Fn: ValueRef, Name: *c_char);
713712
pub fn LLVMGetFunctionAttr(Fn: ValueRef) -> c_ulonglong;
714713

715714
pub fn LLVMAddReturnAttribute(Fn: ValueRef, PA: c_uint);

branches/try2/src/librustc/metadata/common.rs

Lines changed: 58 additions & 59 deletions
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,6 @@ pub static tag_path_len: uint = 0x25;
9292
pub static tag_path_elem_mod: uint = 0x26;
9393
pub static tag_path_elem_name: uint = 0x27;
9494
pub static tag_item_field: uint = 0x28;
95-
pub static tag_item_field_origin: uint = 0x29;
9695

9796
pub static tag_item_variances: uint = 0x2a;
9897
/*
@@ -103,43 +102,43 @@ pub static tag_item_variances: uint = 0x2a;
103102
both, tag_item_trait_method and tag_item_impl_method have to be two
104103
different tags.
105104
*/
106-
pub static tag_item_impl_method: uint = 0x30;
107-
pub static tag_item_trait_method_explicit_self: uint = 0x31;
105+
pub static tag_item_impl_method: uint = 0x2c;
106+
pub static tag_item_trait_method_explicit_self: uint = 0x2d;
108107

109108

110109
// Reexports are found within module tags. Each reexport contains def_ids
111110
// and names.
112-
pub static tag_items_data_item_reexport: uint = 0x38;
113-
pub static tag_items_data_item_reexport_def_id: uint = 0x39;
114-
pub static tag_items_data_item_reexport_name: uint = 0x3a;
111+
pub static tag_items_data_item_reexport: uint = 0x2f;
112+
pub static tag_items_data_item_reexport_def_id: uint = 0x30;
113+
pub static tag_items_data_item_reexport_name: uint = 0x31;
115114

116115
// used to encode crate_ctxt side tables
117116
#[deriving(Eq)]
118117
#[repr(uint)]
119-
pub enum astencode_tag { // Reserves 0x40 -- 0x5f
120-
tag_ast = 0x40,
121-
122-
tag_tree = 0x41,
123-
124-
tag_id_range = 0x42,
125-
126-
tag_table = 0x43,
127-
tag_table_id = 0x44,
128-
tag_table_val = 0x45,
129-
tag_table_def = 0x46,
130-
tag_table_node_type = 0x47,
131-
tag_table_node_type_subst = 0x48,
132-
tag_table_freevars = 0x49,
133-
tag_table_tcache = 0x4a,
134-
tag_table_param_defs = 0x4b,
135-
tag_table_mutbl = 0x4c,
136-
tag_table_last_use = 0x4d,
137-
tag_table_spill = 0x4e,
138-
tag_table_method_map = 0x4f,
139-
tag_table_vtable_map = 0x50,
140-
tag_table_adjustments = 0x51,
141-
tag_table_moves_map = 0x52,
142-
tag_table_capture_map = 0x53
118+
pub enum astencode_tag { // Reserves 0x32 -- 0x45
119+
tag_ast = 0x32,
120+
121+
tag_tree = 0x33,
122+
123+
tag_id_range = 0x34,
124+
125+
tag_table = 0x35,
126+
tag_table_id = 0x36,
127+
tag_table_val = 0x37,
128+
tag_table_def = 0x38,
129+
tag_table_node_type = 0x39,
130+
tag_table_node_type_subst = 0x3a,
131+
tag_table_freevars = 0x3b,
132+
tag_table_tcache = 0x3c,
133+
tag_table_param_defs = 0x3d,
134+
tag_table_mutbl = 0x3e,
135+
tag_table_last_use = 0x3f,
136+
tag_table_spill = 0x40,
137+
tag_table_method_map = 0x41,
138+
tag_table_vtable_map = 0x42,
139+
tag_table_adjustments = 0x43,
140+
tag_table_moves_map = 0x44,
141+
tag_table_capture_map = 0x45
143142
}
144143
static first_astencode_tag: uint = tag_ast as uint;
145144
static last_astencode_tag: uint = tag_table_capture_map as uint;
@@ -152,9 +151,9 @@ impl astencode_tag {
152151
}
153152
}
154153

155-
pub static tag_item_trait_method_sort: uint = 0x60;
154+
pub static tag_item_trait_method_sort: uint = 0x46;
156155

157-
pub static tag_item_impl_type_basename: uint = 0x61;
156+
pub static tag_item_impl_type_basename: uint = 0x47;
158157

159158
// Language items are a top-level directory (for speed). Hierarchy:
160159
//
@@ -163,42 +162,42 @@ pub static tag_item_impl_type_basename: uint = 0x61;
163162
// - tag_lang_items_item_id: u32
164163
// - tag_lang_items_item_node_id: u32
165164

166-
pub static tag_lang_items: uint = 0x70;
167-
pub static tag_lang_items_item: uint = 0x71;
168-
pub static tag_lang_items_item_id: uint = 0x72;
169-
pub static tag_lang_items_item_node_id: uint = 0x73;
165+
pub static tag_lang_items: uint = 0x48;
166+
pub static tag_lang_items_item: uint = 0x49;
167+
pub static tag_lang_items_item_id: uint = 0x4a;
168+
pub static tag_lang_items_item_node_id: uint = 0x4b;
170169

171-
pub static tag_item_unnamed_field: uint = 0x74;
172-
pub static tag_items_data_item_visibility: uint = 0x76;
170+
pub static tag_item_unnamed_field: uint = 0x4c;
171+
pub static tag_items_data_item_visibility: uint = 0x4e;
173172

174-
pub static tag_item_method_tps: uint = 0x79;
175-
pub static tag_item_method_fty: uint = 0x7a;
173+
pub static tag_item_method_tps: uint = 0x51;
174+
pub static tag_item_method_fty: uint = 0x52;
176175

177-
pub static tag_mod_child: uint = 0x7b;
178-
pub static tag_misc_info: uint = 0x7c;
179-
pub static tag_misc_info_crate_items: uint = 0x7d;
176+
pub static tag_mod_child: uint = 0x53;
177+
pub static tag_misc_info: uint = 0x54;
178+
pub static tag_misc_info_crate_items: uint = 0x55;
180179

181-
pub static tag_item_method_provided_source: uint = 0x7e;
182-
pub static tag_item_impl_vtables: uint = 0x7f;
180+
pub static tag_item_method_provided_source: uint = 0x56;
181+
pub static tag_item_impl_vtables: uint = 0x57;
183182

184-
pub static tag_impls: uint = 0x80;
185-
pub static tag_impls_impl: uint = 0x81;
183+
pub static tag_impls: uint = 0x58;
184+
pub static tag_impls_impl: uint = 0x59;
186185

187-
pub static tag_items_data_item_inherent_impl: uint = 0x82;
188-
pub static tag_items_data_item_extension_impl: uint = 0x83;
186+
pub static tag_items_data_item_inherent_impl: uint = 0x5a;
187+
pub static tag_items_data_item_extension_impl: uint = 0x5b;
189188

190-
pub static tag_region_param_def: uint = 0x84;
191-
pub static tag_region_param_def_ident: uint = 0x85;
192-
pub static tag_region_param_def_def_id: uint = 0x86;
189+
pub static tag_region_param_def: uint = 0x5c;
190+
pub static tag_region_param_def_ident: uint = 0x5d;
191+
pub static tag_region_param_def_def_id: uint = 0x5e;
193192

194-
pub static tag_native_libraries: uint = 0x87;
195-
pub static tag_native_libraries_lib: uint = 0x88;
196-
pub static tag_native_libraries_name: uint = 0x89;
197-
pub static tag_native_libraries_kind: uint = 0x8a;
193+
pub static tag_native_libraries: uint = 0x5f;
194+
pub static tag_native_libraries_lib: uint = 0x60;
195+
pub static tag_native_libraries_name: uint = 0x61;
196+
pub static tag_native_libraries_kind: uint = 0x62;
198197

199-
pub static tag_macro_registrar_fn: uint = 0x8b;
200-
pub static tag_exported_macros: uint = 0x8c;
201-
pub static tag_macro_def: uint = 0x8d;
198+
pub static tag_macro_registrar_fn: uint = 0x63;
199+
pub static tag_exported_macros: uint = 0x64;
200+
pub static tag_macro_def: uint = 0x65;
202201

203202
#[deriving(Clone, Show)]
204203
pub struct LinkMeta {

branches/try2/src/librustc/metadata/decoder.rs

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -975,27 +975,21 @@ pub fn get_struct_fields(intr: Rc<IdentInterner>, cdata: Cmd, id: ast::NodeId)
975975
// FIXME #6993: name should be of type Name, not Ident
976976
let name = item_name(&*intr, an_item);
977977
let did = item_def_id(an_item, cdata);
978-
let tagdoc = reader::get_doc(an_item, tag_item_field_origin);
979-
let origin_id = translate_def_id(cdata, reader::with_doc_data(tagdoc, parse_def_id));
980978
result.push(ty::field_ty {
981979
name: name.name,
982-
id: did,
983-
vis: struct_field_family_to_visibility(f),
984-
origin: origin_id,
980+
id: did, vis:
981+
struct_field_family_to_visibility(f),
985982
});
986983
}
987984
true
988985
});
989986
reader::tagged_docs(item, tag_item_unnamed_field, |an_item| {
990987
let did = item_def_id(an_item, cdata);
991-
let tagdoc = reader::get_doc(an_item, tag_item_field_origin);
992988
let f = item_family(an_item);
993-
let origin_id = translate_def_id(cdata, reader::with_doc_data(tagdoc, parse_def_id));
994989
result.push(ty::field_ty {
995990
name: special_idents::unnamed_field.name,
996991
id: did,
997992
vis: struct_field_family_to_visibility(f),
998-
origin: origin_id,
999993
});
1000994
true
1001995
});

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

Lines changed: 31 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -290,22 +290,23 @@ fn encode_parent_item(ebml_w: &mut Encoder, id: DefId) {
290290
}
291291

292292
fn encode_struct_fields(ebml_w: &mut Encoder,
293-
fields: &Vec<ty::field_ty>,
294-
origin: DefId) {
295-
for f in fields.iter() {
296-
if f.name == special_idents::unnamed_field.name {
297-
ebml_w.start_tag(tag_item_unnamed_field);
298-
} else {
299-
ebml_w.start_tag(tag_item_field);
300-
encode_name(ebml_w, f.name);
293+
def: @StructDef) {
294+
for f in def.fields.iter() {
295+
match f.node.kind {
296+
NamedField(ident, vis) => {
297+
ebml_w.start_tag(tag_item_field);
298+
encode_struct_field_family(ebml_w, vis);
299+
encode_name(ebml_w, ident.name);
300+
encode_def_id(ebml_w, local_def(f.node.id));
301+
ebml_w.end_tag();
302+
}
303+
UnnamedField(vis) => {
304+
ebml_w.start_tag(tag_item_unnamed_field);
305+
encode_struct_field_family(ebml_w, vis);
306+
encode_def_id(ebml_w, local_def(f.node.id));
307+
ebml_w.end_tag();
308+
}
301309
}
302-
encode_struct_field_family(ebml_w, f.vis);
303-
encode_def_id(ebml_w, f.id);
304-
ebml_w.start_tag(tag_item_field_origin);
305-
let s = def_to_str(origin);
306-
ebml_w.writer.write(s.as_bytes());
307-
ebml_w.end_tag();
308-
ebml_w.end_tag();
309310
}
310311
}
311312

@@ -343,13 +344,12 @@ fn encode_enum_variant_info(ecx: &EncodeContext,
343344
encode_symbol(ecx, ebml_w, variant.node.id);
344345
}
345346
ast::TupleVariantKind(_) => {},
346-
ast::StructVariantKind(_) => {
347-
let fields = ty::lookup_struct_fields(ecx.tcx, def_id);
347+
ast::StructVariantKind(def) => {
348348
let idx = encode_info_for_struct(ecx,
349349
ebml_w,
350-
&fields,
350+
def.fields.as_slice(),
351351
index);
352-
encode_struct_fields(ebml_w, &fields, def_id);
352+
encode_struct_fields(ebml_w, def);
353353
let bkts = create_index(idx);
354354
encode_index(ebml_w, bkts, write_i64);
355355
}
@@ -666,7 +666,7 @@ fn encode_provided_source(ebml_w: &mut Encoder,
666666
/* Returns an index of items in this class */
667667
fn encode_info_for_struct(ecx: &EncodeContext,
668668
ebml_w: &mut Encoder,
669-
fields: &Vec<ty::field_ty>,
669+
fields: &[StructField],
670670
global_index: @RefCell<Vec<entry<i64>> >)
671671
-> Vec<entry<i64>> {
672672
/* Each class has its own index, since different classes
@@ -676,19 +676,22 @@ fn encode_info_for_struct(ecx: &EncodeContext,
676676
/* We encode both private and public fields -- need to include
677677
private fields to get the offsets right */
678678
for field in fields.iter() {
679-
let nm = field.name;
680-
let id = field.id.node;
679+
let (nm, vis) = match field.node.kind {
680+
NamedField(nm, vis) => (nm, vis),
681+
UnnamedField(vis) => (special_idents::unnamed_field, vis)
682+
};
681683

684+
let id = field.node.id;
682685
index.push(entry {val: id as i64, pos: ebml_w.writer.tell().unwrap()});
683686
global_index.borrow_mut().push(entry {
684687
val: id as i64,
685688
pos: ebml_w.writer.tell().unwrap(),
686689
});
687690
ebml_w.start_tag(tag_items_data_item);
688691
debug!("encode_info_for_struct: doing {} {}",
689-
token::get_name(nm), id);
690-
encode_struct_field_family(ebml_w, field.vis);
691-
encode_name(ebml_w, nm);
692+
token::get_ident(nm), id);
693+
encode_struct_field_family(ebml_w, vis);
694+
encode_name(ebml_w, nm.name);
692695
encode_type(ecx, ebml_w, node_id_to_type(tcx, id));
693696
encode_def_id(ebml_w, local_def(id));
694697
ebml_w.end_tag();
@@ -980,16 +983,12 @@ fn encode_info_for_item(ecx: &EncodeContext,
980983
generics);
981984
}
982985
ItemStruct(struct_def, _) => {
983-
let fields = ty::lookup_struct_fields(tcx, def_id);
984-
985986
/* First, encode the fields
986987
These come first because we need to write them to make
987988
the index, and the index needs to be in the item for the
988989
class itself */
989-
let idx = encode_info_for_struct(ecx,
990-
ebml_w,
991-
&fields,
992-
index);
990+
let idx = encode_info_for_struct(ecx, ebml_w,
991+
struct_def.fields.as_slice(), index);
993992

994993
/* Index the class*/
995994
add_to_index(item, ebml_w, index);
@@ -1009,7 +1008,7 @@ fn encode_info_for_item(ecx: &EncodeContext,
10091008
/* Encode def_ids for each field and method
10101009
for methods, write all the stuff get_trait_method
10111010
needs to know*/
1012-
encode_struct_fields(ebml_w, &fields, def_id);
1011+
encode_struct_fields(ebml_w, struct_def);
10131012

10141013
(ecx.encode_inlined_item)(ecx, ebml_w, IIItemRef(item));
10151014

0 commit comments

Comments
 (0)