Skip to content

Commit fe4e747

Browse files
committed
auto merge of #9560 : pcwalton/rust/xc-tuple-structs, r=pcwalton
r? @thestinger
2 parents 08b510c + 76d92c5 commit fe4e747

File tree

4 files changed

+30
-5
lines changed

4 files changed

+30
-5
lines changed

src/librustc/metadata/encoder.rs

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -747,7 +747,8 @@ fn encode_info_for_struct_ctor(ecx: &EncodeContext,
747747
path: &[ast_map::path_elt],
748748
name: ast::Ident,
749749
ctor_id: NodeId,
750-
index: @mut ~[entry<i64>]) {
750+
index: @mut ~[entry<i64>],
751+
struct_id: NodeId) {
751752
index.push(entry { val: ctor_id as i64, pos: ebml_w.writer.tell() });
752753

753754
ebml_w.start_tag(tag_items_data_item);
@@ -756,6 +757,7 @@ fn encode_info_for_struct_ctor(ecx: &EncodeContext,
756757
encode_name(ecx, ebml_w, name);
757758
encode_type(ecx, ebml_w, node_id_to_type(ecx.tcx, ctor_id));
758759
encode_path(ecx, ebml_w, path, ast_map::path_name(name));
760+
encode_parent_item(ebml_w, local_def(struct_id));
759761

760762
if ecx.item_symbols.contains_key(&ctor_id) {
761763
encode_symbol(ecx, ebml_w, ctor_id);
@@ -1032,6 +1034,8 @@ fn encode_info_for_item(ecx: &EncodeContext,
10321034
needs to know*/
10331035
encode_struct_fields(ecx, ebml_w, struct_def);
10341036

1037+
(ecx.encode_inlined_item)(ecx, ebml_w, path, ii_item(item));
1038+
10351039
// Encode inherent implementations for this structure.
10361040
encode_inherent_implementations(ecx, ebml_w, def_id);
10371041

@@ -1054,7 +1058,8 @@ fn encode_info_for_item(ecx: &EncodeContext,
10541058
path,
10551059
item.ident,
10561060
ctor_id,
1057-
index);
1061+
index,
1062+
def_id.node);
10581063
}
10591064
}
10601065
item_impl(_, ref opt_trait, ref ty, ref ast_methods) => {

src/librustc/middle/trans/inline.rs

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -99,8 +99,17 @@ pub fn maybe_instantiate_inline(ccx: @mut CrateContext, fn_id: ast::DefId)
9999
ccx.external.insert(there.id, Some(here.id.node));
100100
}
101101
}
102+
ast::item_struct(ref struct_def, _) => {
103+
match struct_def.ctor_id {
104+
None => {}
105+
Some(ctor_id) => {
106+
let _ = ccx.external.insert(fn_id, Some(ctor_id));
107+
my_id = ctor_id;
108+
}
109+
}
110+
}
102111
_ => ccx.sess.bug("maybe_instantiate_inline: item has a \
103-
non-enum parent")
112+
non-enum, non-struct parent")
104113
}
105114
trans_item(ccx, item);
106115
local_def(my_id)

src/libsyntax/ast_map.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -403,9 +403,9 @@ pub fn map_decoded_item(diag: @mut span_handler,
403403
diag: diag,
404404
};
405405

406-
// methods get added to the AST map when their impl is visited. Since we
406+
// Methods get added to the AST map when their impl is visited. Since we
407407
// don't decode and instantiate the impl, but just the method, we have to
408-
// add it to the table now:
408+
// add it to the table now. Likewise with foreign items.
409409
match *ii {
410410
ii_item(*) => {} // fallthrough
411411
ii_foreign(i) => {

src/libsyntax/ast_util.rs

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -590,6 +590,17 @@ impl Visitor<()> for IdVisitor {
590590
self.operation.visit_id(struct_field.node.id);
591591
visit::walk_struct_field(self, struct_field, env)
592592
}
593+
594+
fn visit_struct_def(&mut self,
595+
struct_def: @struct_def,
596+
ident: ast::Ident,
597+
generics: &ast::Generics,
598+
id: NodeId,
599+
_: ()) {
600+
self.operation.visit_id(id);
601+
struct_def.ctor_id.map(|&ctor_id| self.operation.visit_id(ctor_id));
602+
visit::walk_struct_def(self, struct_def, ident, generics, id, ());
603+
}
593604
}
594605

595606
pub fn visit_ids_for_inlined_item(item: &inlined_item,

0 commit comments

Comments
 (0)