Skip to content

Commit 24e921f

Browse files
committed
make anything used in a resource body always reachable
(they appear to be uncond. inlined) Fixes #2170.
1 parent 564d8e0 commit 24e921f

File tree

3 files changed

+20
-1
lines changed

3 files changed

+20
-1
lines changed

src/rustc/middle/trans/reachable.rs

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,11 @@ fn traverse_public_item(cx: ctx, item: @item) {
8484
for vec::each(nm.items) {|item| cx.rmap.insert(item.id, ()); }
8585
}
8686
}
87-
item_res(_, tps, blk, _, _) | item_fn(_, tps, blk) {
87+
item_res(_, tps, blk, _, _) {
88+
// resources seem to be unconditionally inlined
89+
traverse_inline_body(cx, blk);
90+
}
91+
item_fn(_, tps, blk) {
8892
if tps.len() > 0u ||
8993
attr::find_inline_attr(item.attrs) != attr::ia_none {
9094
traverse_inline_body(cx, blk);

src/test/auxiliary/issue2170lib.rs

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
export rsrc;
2+
3+
fn foo(_x: i32) {
4+
}
5+
6+
resource rsrc(x: i32) {
7+
foo(x);
8+
}

src/test/run-pass/issue2170exe.rs

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
// xfail-fast - check-fail fast doesn't under aux-build
2+
// aux-build:issue2170lib.rs
3+
use issue2170lib;
4+
5+
fn main() {
6+
let _ = issue2170lib::rsrc(2i32);
7+
}

0 commit comments

Comments
 (0)