Skip to content

Commit 4cad58c

Browse files
committed
Fix broken assertion in regionck for code like (a[])()
1 parent 39d33a6 commit 4cad58c

File tree

2 files changed

+12
-4
lines changed

2 files changed

+12
-4
lines changed

src/rustc/middle/typeck/check/regionck.rs

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -183,16 +183,15 @@ fn visit_expr(expr: @ast::expr, &&rcx: @rcx, v: rvt) {
183183
// `constrain_auto_ref()` on all exprs. But that causes a
184184
// lot of spurious errors because of how the region
185185
// hierarchy is setup.
186-
let tcx = rcx.fcx.tcx();
187186
if rcx.fcx.ccx.method_map.contains_key(callee.id) {
188187
match callee.node {
189188
ast::expr_field(base, _, _) => {
190189
constrain_auto_ref(rcx, base);
191190
}
192191
_ => {
193-
tcx.sess.span_bug(
194-
callee.span,
195-
~"call of method that is not a field");
192+
// This can happen if you have code like
193+
// (x[0])() where `x[0]` is overloaded. Just
194+
// ignore it.
196195
}
197196
}
198197
} else {
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
use dvec::DVec;
2+
3+
fn foo() -> int { 22 }
4+
5+
fn main() {
6+
let x = DVec::<@fn() -> int>();
7+
x.push(foo);
8+
assert (x[0])() == 22;
9+
}

0 commit comments

Comments
 (0)