Skip to content

Commit 19b854d

Browse files
alexcrichtonthestinger
authored andcommitted
---
yaml --- r: 142570 b: refs/heads/try2 c: 31114ac h: refs/heads/master v: v3
1 parent 0262253 commit 19b854d

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
@@ -5,7 +5,7 @@ refs/heads/snap-stage3: 78a7676898d9f80ab540c6df5d4c9ce35bb50463
55
refs/heads/try: 519addf6277dbafccbb4159db4b710c37eaa2ec5
66
refs/tags/release-0.1: 1f5c5126e96c79d22cb7862f75304136e204f105
77
refs/heads/ndm: f3868061cd7988080c30d6d5bf352a5a5fe2460b
8-
refs/heads/try2: b727b9efd7b854ebf099f72894c2d662d2c63977
8+
refs/heads/try2: 31114acdd7da8f2826558b11adea96d1c561aabd
99
refs/heads/dist-snap: ba4081a5a8573875fed17545846f6f6902c8ba8d
1010
refs/tags/release-0.2: c870d2dffb391e14efb05aa27898f1f6333a9596
1111
refs/tags/release-0.3: b5f0d0f648d9a6153664837026ba1be43d3e2503

branches/try2/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/try2/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/try2/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/try2/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)