Skip to content

Commit 9dd6916

Browse files
committed
---
yaml --- r: 16292 b: refs/heads/try c: 5e8ef74 h: refs/heads/master v: v3
1 parent f144ba6 commit 9dd6916

File tree

3 files changed

+16
-1
lines changed

3 files changed

+16
-1
lines changed

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,5 +2,5 @@
22
refs/heads/master: 61b1875c16de39c166b0f4d54bba19f9c6777d1a
33
refs/heads/snap-stage1: e33de59e47c5076a89eadeb38f4934f58a3618a6
44
refs/heads/snap-stage3: 4a81779abd786ff22d71434c6d9a5917ea4cdfff
5-
refs/heads/try: a6c92f0a179c4f048aaa5145c438611175b41a0d
5+
refs/heads/try: 5e8ef74e22eaf49518cd93838ec8b2843bc916a9
66
refs/tags/release-0.1: 1f5c5126e96c79d22cb7862f75304136e204f105

branches/try/src/rustc/middle/typeck/check.rs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -387,6 +387,12 @@ fn check_item(ccx: @crate_ctxt, it: @ast::item) {
387387
};
388388
// typecheck the members
389389
for members.each {|m| check_class_member(class_ccx, class_t, m); }
390+
// Check that there's at least one field
391+
let (fields,_) = split_class_items(members);
392+
if fields.len() < 1u {
393+
ccx.tcx.sess.span_err(it.span, "A class must have at least one \
394+
field");
395+
}
390396
// Check that the class is instantiable
391397
check_instantiable(ccx.tcx, it.span, it.id);
392398
}
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
class c { //! ERROR A class must have at least one field
2+
new() { }
3+
}
4+
5+
fn main() {
6+
let a = c();
7+
let x = [a];
8+
let _y = x[0];
9+
}

0 commit comments

Comments
 (0)