Skip to content

Commit d4bf109

Browse files
alexcrichtonthestinger
authored andcommitted
---
yaml --- r: 64162 b: refs/heads/snap-stage3 c: 31114ac h: refs/heads/master v: v3
1 parent 106f294 commit d4bf109

File tree

6 files changed

+28
-16
lines changed

6 files changed

+28
-16
lines changed

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
---
22
refs/heads/master: 2d28d645422c1617be58c8ca7ad9a457264ca850
33
refs/heads/snap-stage1: e33de59e47c5076a89eadeb38f4934f58a3618a6
4-
refs/heads/snap-stage3: b727b9efd7b854ebf099f72894c2d662d2c63977
4+
refs/heads/snap-stage3: 31114acdd7da8f2826558b11adea96d1c561aabd
55
refs/heads/try: 7b78b52e602bb3ea8174f9b2006bff3315f03ef9
66
refs/tags/release-0.1: 1f5c5126e96c79d22cb7862f75304136e204f105
77
refs/heads/ndm: f3868061cd7988080c30d6d5bf352a5a5fe2460b

branches/snap-stage3/src/librustc/middle/typeck/mod.rs

Lines changed: 13 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -319,16 +319,19 @@ fn check_main_fn_ty(ccx: &CrateCtxt,
319319
}
320320
_ => ()
321321
}
322-
let mut ok = ty::type_is_nil(fn_ty.sig.output);
323-
let num_args = fn_ty.sig.inputs.len();
324-
ok &= num_args == 0u;
325-
if !ok {
326-
tcx.sess.span_err(
327-
main_span,
328-
fmt!("Wrong type in main function: found `%s`, \
329-
expected `fn() -> ()`",
330-
ppaux::ty_to_str(tcx, main_t)));
331-
}
322+
let se_ty = ty::mk_bare_fn(tcx, ty::BareFnTy {
323+
purity: ast::impure_fn,
324+
abis: abi::AbiSet::Rust(),
325+
sig: ty::FnSig {
326+
bound_lifetime_names: opt_vec::Empty,
327+
inputs: ~[],
328+
output: ty::mk_nil()
329+
}
330+
});
331+
332+
require_same_types(tcx, None, false, main_span, main_t, se_ty,
333+
|| fmt!("main function expects type: `%s`",
334+
ppaux::ty_to_str(ccx.tcx, se_ty)));
332335
}
333336
_ => {
334337
tcx.sess.span_bug(main_span,

branches/snap-stage3/src/test/compile-fail/bad-main.rs

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,4 @@
88
// option. This file may not be copied, modified, or distributed
99
// except according to those terms.
1010

11-
// error-pattern:expected `fn()
12-
13-
fn main(x: int) { }
11+
fn main(x: int) { } //~ ERROR: main function expects type
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
// Copyright 2013 The Rust Project Developers. See the COPYRIGHT
2+
// file at the top-level directory of this distribution and at
3+
// http://rust-lang.org/COPYRIGHT.
4+
//
5+
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
6+
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
7+
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
8+
// option. This file may not be copied, modified, or distributed
9+
// except according to those terms.
10+
11+
extern fn main() {} //~ ERROR: main function expects type

branches/snap-stage3/src/test/compile-fail/main-wrong-type-2.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,5 +9,5 @@
99
// except according to those terms.
1010

1111
fn main() -> char {
12-
//~^ ERROR Wrong type in main function: found `extern "Rust" fn() -> char`
12+
//~^ ERROR: main function expects type
1313
}

branches/snap-stage3/src/test/compile-fail/main-wrong-type.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,5 +14,5 @@ struct S {
1414
}
1515

1616
fn main(foo: S) {
17-
//~^ ERROR Wrong type in main function: found `extern "Rust" fn(S)`
17+
//~^ ERROR: main function expects type
1818
}

0 commit comments

Comments
 (0)