Skip to content

Commit 54566e9

Browse files
committed
rustc: Convert field access on invalid types from an ICE to a fatal error
Closes #367
1 parent d9f452a commit 54566e9

File tree

3 files changed

+15
-6
lines changed

3 files changed

+15
-6
lines changed

src/comp/middle/typeck.rs

+4-5
Original file line numberDiff line numberDiff line change
@@ -1994,11 +1994,10 @@ fn check_expr(&@fn_ctxt fcx, &@ast::expr expr) {
19941994
write::ty_only_fixup(fcx, id, t);
19951995
}
19961996
case (_) {
1997-
fcx.ccx.tcx.sess.span_unimpl(expr.span,
1998-
"base type for expr_field \
1999-
in typeck::check_expr: "
2000-
+ ty_to_str(fcx.ccx.tcx,
2001-
base_t));
1997+
auto t_err = resolve_type_vars_if_possible(fcx, base_t);
1998+
auto msg = #fmt("attempted field access on type %s",
1999+
ty_to_str(fcx.ccx.tcx, t_err));
2000+
fcx.ccx.tcx.sess.span_fatal(expr.span, msg);
20022001
}
20032002
}
20042003
}

src/test/compile-fail/direct-obj-fn-call.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// error-pattern: base type for expr_field
1+
// error-pattern: attempted field access
22

33
obj x() {
44
fn hello() {

src/test/compile-fail/vec-field.rs

+10
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
// xfail-stage0
2+
// error-pattern:attempted field access on type vec\[int\]
3+
// issue #367
4+
5+
fn f() {
6+
auto v = [1];
7+
log v.some_field_name; //type error
8+
}
9+
10+
fn main() {}

0 commit comments

Comments
 (0)