Skip to content

Commit 53dbde6

Browse files
committed
rustc: Make 'attempted access of field' error non-fatal
1 parent 3321880 commit 53dbde6

File tree

2 files changed

+9
-1
lines changed

2 files changed

+9
-1
lines changed

src/comp/middle/typeck.rs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2297,7 +2297,9 @@ fn check_expr_with_unifier(fcx: @fn_ctxt, expr: @ast::expr, unify: unifier,
22972297
let msg = #fmt["attempted access of field %s on type %s, but \
22982298
no method implementation was found",
22992299
field, ty_to_str(tcx, t_err)];
2300-
tcx.sess.span_fatal(expr.span, msg);
2300+
tcx.sess.span_err(expr.span, msg);
2301+
// NB: Adding a bogus type to allow typechecking to continue
2302+
write::ty_only_fixup(fcx, id, ty::mk_nil(tcx));
23012303
}
23022304
}
23032305
}
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
// Check that bogus field access is non-fatal
2+
fn main() {
3+
let x = 0;
4+
log(debug, x.foo); //! ERROR attempted access of field
5+
log(debug, x.bar); //! ERROR attempted access of field
6+
}

0 commit comments

Comments
 (0)