Skip to content

Commit 5ccf817

Browse files
committed
don't consider use of @fn to be region-param'd
1 parent feca839 commit 5ccf817

File tree

2 files changed

+41
-0
lines changed

2 files changed

+41
-0
lines changed

src/rustc/middle/region.rs

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -655,6 +655,25 @@ fn determine_rp_in_ty(ty: @ast::ty,
655655
_ => {}
656656
}
657657

658+
// temporary hack: right now, fn() is short for &fn(), but @(fn())
659+
// is `@fn()`, so catch this and set anon_implies_rp to none in
660+
// that case
661+
match ty.node {
662+
ast::ty_box(mt) | ast::ty_uniq(mt) => {
663+
match mt.ty.node {
664+
ast::ty_fn(ast::proto_bare, _, _) |
665+
ast::ty_fn(ast::proto_block, _, _) => {
666+
do cx.with(cx.item_id, false) {
667+
visit_mt(mt, cx, visitor);
668+
}
669+
return;
670+
}
671+
_ => {}
672+
}
673+
}
674+
_ => {}
675+
}
676+
658677
match ty.node {
659678
ast::ty_box(mt) | ast::ty_uniq(mt) | ast::ty_vec(mt) |
660679
ast::ty_rptr(_, mt) | ast::ty_ptr(mt) => {
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
struct param1 {
2+
g: &fn();
3+
}
4+
5+
struct param2 {
6+
g: fn();
7+
}
8+
9+
struct not_param1 {
10+
g: @fn();
11+
}
12+
13+
struct not_param2 {
14+
g: @fn();
15+
}
16+
17+
fn take1(p: param1) -> param1 { p } //~ ERROR mismatched types
18+
fn take2(p: param2) -> param2 { p } //~ ERROR mismatched types
19+
fn take3(p: not_param1) -> not_param1 { p }
20+
fn take4(p: not_param2) -> not_param2 { p }
21+
22+
fn main() {}

0 commit comments

Comments
 (0)