more consistent handling of inner items
This commit is contained in:
parent
428d5ac5b9
commit
0f847ba74d
@ -2070,12 +2070,12 @@ pub fn trans_item(ccx: &CrateContext, item: &ast::Item) {
|
||||
item.id,
|
||||
item.attrs.as_slice());
|
||||
}
|
||||
} else {
|
||||
// Be sure to travel more than just one layer deep to catch nested
|
||||
// items in blocks and such.
|
||||
let mut v = TransItemVisitor{ ccx: ccx };
|
||||
v.visit_block(&**body, ());
|
||||
}
|
||||
|
||||
// Be sure to travel more than just one layer deep to catch nested
|
||||
// items in blocks and such.
|
||||
let mut v = TransItemVisitor{ ccx: ccx };
|
||||
v.visit_block(&**body, ());
|
||||
}
|
||||
ast::ItemImpl(ref generics, _, _, ref ms) => {
|
||||
meth::trans_impl(ccx, item.ident, ms.as_slice(), generics, item.id);
|
||||
|
@ -69,7 +69,8 @@ pub fn trans_stmt<'a>(cx: &'a Block<'a>,
|
||||
debuginfo::create_local_var_metadata(bcx, &**local);
|
||||
}
|
||||
}
|
||||
ast::DeclItem(ref i) => trans_item(cx.fcx.ccx, &**i)
|
||||
// Inner items are visited by `trans_item`/`trans_meth`.
|
||||
ast::DeclItem(_) => {},
|
||||
}
|
||||
}
|
||||
ast::StmtMac(..) => cx.tcx().sess.bug("unexpanded macro")
|
||||
|
@ -76,10 +76,9 @@ pub fn trans_impl(ccx: &CrateContext,
|
||||
¶m_substs::empty(),
|
||||
method.id,
|
||||
[]);
|
||||
} else {
|
||||
let mut v = TransItemVisitor{ ccx: ccx };
|
||||
visit::walk_method_helper(&mut v, &**method, ());
|
||||
}
|
||||
let mut v = TransItemVisitor{ ccx: ccx };
|
||||
visit::walk_method_helper(&mut v, &**method, ());
|
||||
}
|
||||
}
|
||||
|
||||
|
11
src/test/run-make/issue-7349/Makefile
Normal file
11
src/test/run-make/issue-7349/Makefile
Normal file
@ -0,0 +1,11 @@
|
||||
-include ../tools.mk
|
||||
|
||||
# Test to make sure that inner functions within a polymorphic outer function
|
||||
# don't get re-translated when the outer function is monomorphized. The test
|
||||
# code monomorphizes the outer functions several times, but the magic constants
|
||||
# used in the inner functions should each appear only once in the generated IR.
|
||||
|
||||
all:
|
||||
$(RUSTC) foo.rs --emit=ir
|
||||
[ "$$(grep -c 8675309 "$(TMPDIR)/foo.ll")" -eq "1" ]
|
||||
[ "$$(grep -c 11235813 "$(TMPDIR)/foo.ll")" -eq "1" ]
|
30
src/test/run-make/issue-7349/foo.rs
Normal file
30
src/test/run-make/issue-7349/foo.rs
Normal file
@ -0,0 +1,30 @@
|
||||
// Copyright 2014 The Rust Project Developers. See the COPYRIGHT
|
||||
// file at the top-level directory of this distribution and at
|
||||
// http://rust-lang.org/COPYRIGHT.
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
|
||||
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
|
||||
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
|
||||
// option. This file may not be copied, modified, or distributed
|
||||
// except according to those terms.
|
||||
|
||||
fn outer<T>() {
|
||||
#[allow(dead_code)]
|
||||
fn inner() -> uint {
|
||||
8675309
|
||||
}
|
||||
}
|
||||
|
||||
extern "C" fn outer_foreign<T>() {
|
||||
#[allow(dead_code)]
|
||||
fn inner() -> uint {
|
||||
11235813
|
||||
}
|
||||
}
|
||||
|
||||
fn main() {
|
||||
outer::<int>();
|
||||
outer::<uint>();
|
||||
outer_foreign::<int>();
|
||||
outer_foreign::<uint>();
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user