Skip to content

Commit fe1a6e8

Browse files
committed
---
yaml --- r: 16095 b: refs/heads/try c: ccc7651 h: refs/heads/master i: 16093: 299ca3d 16091: 6548e5e 16087: 74fa67c 16079: 8c98f20 16063: 810f4c8 v: v3
1 parent 96d69a1 commit fe1a6e8

File tree

5 files changed

+28
-6
lines changed

5 files changed

+28
-6
lines changed

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,5 +2,5 @@
22
refs/heads/master: 61b1875c16de39c166b0f4d54bba19f9c6777d1a
33
refs/heads/snap-stage1: e33de59e47c5076a89eadeb38f4934f58a3618a6
44
refs/heads/snap-stage3: 4a81779abd786ff22d71434c6d9a5917ea4cdfff
5-
refs/heads/try: 730e8e93103ee657bcaad55f32f0de52e83b19aa
5+
refs/heads/try: ccc7651b482167f61678c8630545a9f0e6b6ea91
66
refs/tags/release-0.1: 1f5c5126e96c79d22cb7862f75304136e204f105

branches/try/src/rustc/middle/trans/base.rs

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@ import link::{mangle_internal_name_by_type_only,
4040
import metadata::{csearch, cstore, encoder};
4141
import metadata::common::link_meta;
4242
import util::ppaux::{ty_to_str, ty_to_short_str};
43+
import syntax::diagnostic::expect;
4344

4445
import common::*;
4546
import build::*;
@@ -2052,7 +2053,10 @@ fn monomorphic_fn(ccx: @crate_ctxt, fn_id: ast::def_id, real_substs: [ty::t],
20522053
let tpt = ty::lookup_item_type(ccx.tcx, fn_id);
20532054
let mut item_ty = tpt.ty;
20542055

2055-
let map_node = ccx.tcx.items.get(fn_id.node);
2056+
let map_node = session::expect(ccx.sess, ccx.tcx.items.find(fn_id.node),
2057+
{|| #fmt("While monomorphizing %?, couldn't find it in the item map \
2058+
(may have attempted to monomorphize an item defined in a different \
2059+
crate?)", fn_id)});
20562060
// Get the path so that we can create a symbol
20572061
let (pt, name, span) = alt map_node {
20582062
ast_map::node_item(i, pt) {

branches/try/src/rustc/middle/trans/impl.rs

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -258,8 +258,13 @@ fn make_impl_vtable(ccx: @crate_ctxt, impl_id: ast::def_id, substs: [ty::t],
258258
if (*im.tps).len() > 0u || ty::type_has_self(fty) {
259259
C_null(T_ptr(T_nil()))
260260
} else {
261-
let m_id = method_with_name(ccx, impl_id, im.ident);
261+
let mut m_id = method_with_name(ccx, impl_id, im.ident);
262262
if has_tps {
263+
// If the method is in another crate, need to make an inlined
264+
// copy first
265+
if m_id.crate != ast::local_crate {
266+
m_id = maybe_instantiate_inline(ccx, m_id);
267+
}
263268
monomorphic_fn(ccx, m_id, substs, some(vtables), none).val
264269
} else if m_id.crate == ast::local_crate {
265270
get_item_val(ccx, m_id.node)

branches/try/src/rustc/middle/trans/reachable.rs

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -98,6 +98,7 @@ fn traverse_public_item(cx: ctx, item: @item) {
9898
for vec::each(ms) {|m|
9999
if tps.len() > 0u || m.tps.len() > 0u ||
100100
attr::find_inline_attr(m.attrs) != attr::ia_none {
101+
cx.rmap.insert(m.id, ());
101102
traverse_inline_body(cx, m.body);
102103
}
103104
}
@@ -141,9 +142,13 @@ fn traverse_inline_body(cx: ctx, body: blk) {
141142
}
142143
visit::visit_expr(e, cx, v);
143144
}
144-
// Ignore nested items
145-
fn traverse_item(_i: @item, _cx: ctx, _v: visit::vt<ctx>) {}
146-
visit::visit_block(body, cx, visit::mk_vt(@{
145+
// Don't ignore nested items: for example if a generic fn contains a
146+
// generic impl (as in deque::create), we need to monomorphize the
147+
// impl as well
148+
fn traverse_item(i: @item, cx: ctx, _v: visit::vt<ctx>) {
149+
traverse_public_item(cx, i);
150+
}
151+
visit::visit_block(body, cx, visit::mk_vt(@{
147152
visit_expr: traverse_expr,
148153
visit_item: traverse_item
149154
with *visit::default_visitor()
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
use std;
2+
import std::deque;
3+
import std::deque::t;
4+
5+
fn main() {
6+
let Q = deque::create();
7+
Q.add_back(10);
8+
}

0 commit comments

Comments
 (0)