librustc: Inline cross-crate tuple struct constructors
This commit is contained in:
parent
c8cdabc32f
commit
76d92c5472
@ -747,7 +747,8 @@ fn encode_info_for_struct_ctor(ecx: &EncodeContext,
|
||||
path: &[ast_map::path_elt],
|
||||
name: ast::Ident,
|
||||
ctor_id: NodeId,
|
||||
index: @mut ~[entry<i64>]) {
|
||||
index: @mut ~[entry<i64>],
|
||||
struct_id: NodeId) {
|
||||
index.push(entry { val: ctor_id as i64, pos: ebml_w.writer.tell() });
|
||||
|
||||
ebml_w.start_tag(tag_items_data_item);
|
||||
@ -756,6 +757,7 @@ fn encode_info_for_struct_ctor(ecx: &EncodeContext,
|
||||
encode_name(ecx, ebml_w, name);
|
||||
encode_type(ecx, ebml_w, node_id_to_type(ecx.tcx, ctor_id));
|
||||
encode_path(ecx, ebml_w, path, ast_map::path_name(name));
|
||||
encode_parent_item(ebml_w, local_def(struct_id));
|
||||
|
||||
if ecx.item_symbols.contains_key(&ctor_id) {
|
||||
encode_symbol(ecx, ebml_w, ctor_id);
|
||||
@ -1032,6 +1034,8 @@ fn encode_info_for_item(ecx: &EncodeContext,
|
||||
needs to know*/
|
||||
encode_struct_fields(ecx, ebml_w, struct_def);
|
||||
|
||||
(ecx.encode_inlined_item)(ecx, ebml_w, path, ii_item(item));
|
||||
|
||||
// Encode inherent implementations for this structure.
|
||||
encode_inherent_implementations(ecx, ebml_w, def_id);
|
||||
|
||||
@ -1054,7 +1058,8 @@ fn encode_info_for_item(ecx: &EncodeContext,
|
||||
path,
|
||||
item.ident,
|
||||
ctor_id,
|
||||
index);
|
||||
index,
|
||||
def_id.node);
|
||||
}
|
||||
}
|
||||
item_impl(_, ref opt_trait, ref ty, ref ast_methods) => {
|
||||
|
@ -99,8 +99,17 @@ pub fn maybe_instantiate_inline(ccx: @mut CrateContext, fn_id: ast::DefId)
|
||||
ccx.external.insert(there.id, Some(here.id.node));
|
||||
}
|
||||
}
|
||||
ast::item_struct(ref struct_def, _) => {
|
||||
match struct_def.ctor_id {
|
||||
None => {}
|
||||
Some(ctor_id) => {
|
||||
let _ = ccx.external.insert(fn_id, Some(ctor_id));
|
||||
my_id = ctor_id;
|
||||
}
|
||||
}
|
||||
}
|
||||
_ => ccx.sess.bug("maybe_instantiate_inline: item has a \
|
||||
non-enum parent")
|
||||
non-enum, non-struct parent")
|
||||
}
|
||||
trans_item(ccx, item);
|
||||
local_def(my_id)
|
||||
|
@ -403,9 +403,9 @@ pub fn map_decoded_item(diag: @mut span_handler,
|
||||
diag: diag,
|
||||
};
|
||||
|
||||
// methods get added to the AST map when their impl is visited. Since we
|
||||
// Methods get added to the AST map when their impl is visited. Since we
|
||||
// don't decode and instantiate the impl, but just the method, we have to
|
||||
// add it to the table now:
|
||||
// add it to the table now. Likewise with foreign items.
|
||||
match *ii {
|
||||
ii_item(*) => {} // fallthrough
|
||||
ii_foreign(i) => {
|
||||
|
@ -590,6 +590,17 @@ impl Visitor<()> for IdVisitor {
|
||||
self.operation.visit_id(struct_field.node.id);
|
||||
visit::walk_struct_field(self, struct_field, env)
|
||||
}
|
||||
|
||||
fn visit_struct_def(&mut self,
|
||||
struct_def: @struct_def,
|
||||
ident: ast::Ident,
|
||||
generics: &ast::Generics,
|
||||
id: NodeId,
|
||||
_: ()) {
|
||||
self.operation.visit_id(id);
|
||||
struct_def.ctor_id.map(|&ctor_id| self.operation.visit_id(ctor_id));
|
||||
visit::walk_struct_def(self, struct_def, ident, generics, id, ());
|
||||
}
|
||||
}
|
||||
|
||||
pub fn visit_ids_for_inlined_item(item: &inlined_item,
|
||||
|
Loading…
x
Reference in New Issue
Block a user