Skip to content

Commit 8c94d8f

Browse files
committed
Allow main to return int
1 parent f26ca02 commit 8c94d8f

File tree

3 files changed

+7
-1
lines changed

3 files changed

+7
-1
lines changed

src/comp/middle/typeck.rs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2672,7 +2672,10 @@ fn check_main_fn_ty(&ty::ctxt tcx, &ast::node_id main_id) {
26722672
alt (ty::struct(tcx, main_t)) {
26732673
case (ty::ty_fn(ast::proto_fn, ?args, ?rs, ast::return, ?constrs)) {
26742674
auto ok = ivec::len(constrs) == 0u;
2675-
ok &= ty::type_is_nil(tcx, rs);
2675+
ok &= ty::type_is_nil(tcx, rs) || alt (ty::struct(tcx, rs)) {
2676+
ty::ty_int { true }
2677+
_ { false }
2678+
};
26762679
auto num_args = ivec::len(args);
26772680
ok &= num_args == 0u || (num_args == 1u &&
26782681
arg_is_argv_ty(tcx, args.(0)));

src/test/run-pass/main-int-synonym.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
type i = int;
2+
fn main() -> i { 0 }

src/test/run-pass/main-int.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
fn main() -> int { 0 }

0 commit comments

Comments
 (0)