https://doc.rust-lang.org/book/closures.html
"##,
+E0579: r##"
+The `main` function was incorrectly declared.
+
+Erroneous code example:
+
+```compile_fail,E0579
+fn main() -> i32 { // error: main function has wrong type
+ 0
+}
+```
+
+The `main` function prototype should never take arguments or return type.
+Example:
+
+```
+fn main() {
+ // your code
+}
+```
+
+If you want to get command-line arguments, use `std::env::args`. To exit with a
+specified exit code, use `std::process::exit`.
+"##,
+
}
let mut diag = match trace.cause.code {
ObligationCauseCode::IfExpressionWithNoElse => {
struct_span_err!(self.tcx.sess, span, E0317, "{}", failure_str)
- },
+ }
+ ObligationCauseCode::MainFunctionType => {
+ struct_span_err!(self.tcx.sess, span, E0579, "{}", failure_str)
+ }
_ => {
struct_span_err!(self.tcx.sess, span, E0308, "{}", failure_str)
- },
+ }
};
self.note_type_err(&mut diag, &trace.cause, None, Some(trace.values), terr);
diag
+++ /dev/null
-// Copyright 2016 The Rust Project Developers. See the COPYRIGHT
-// file at the top-level directory of this distribution and at
-// http://rust-lang.org/COPYRIGHT.
-//
-// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
-// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
-// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
-// option. This file may not be copied, modified, or distributed
-// except according to those terms.
-
-fn main() -> i32 { 0 } //~ ERROR E0308
--- /dev/null
+// Copyright 2016 The Rust Project Developers. See the COPYRIGHT
+// file at the top-level directory of this distribution and at
+// http://rust-lang.org/COPYRIGHT.
+//
+// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
+// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
+// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
+// option. This file may not be copied, modified, or distributed
+// except according to those terms.
+
+fn main() -> i32 { 0 } //~ ERROR E0579
// option. This file may not be copied, modified, or distributed
// except according to those terms.
-fn main(x: isize) { } //~ ERROR: main function has wrong type
+fn main(x: isize) { } //~ ERROR: main function has wrong type [E0579]
// option. This file may not be copied, modified, or distributed
// except according to those terms.
-extern fn main() {} //~ ERROR: main function has wrong type
+extern fn main() {} //~ ERROR: main function has wrong type [E0579]
// except according to those terms.
fn main() -> char {
-//~^ ERROR: main function has wrong type
+//~^ ERROR: main function has wrong type [E0579]
' '
}
}
fn main(foo: S) {
-//~^ ERROR: main function has wrong type
+//~^ ERROR: main function has wrong type [E0579]
}