E0593: r##"
You tried to supply an `Fn`-based type with an incorrect number of arguments
-than what was expected. Erroneous code example:
+than what was expected.
+
+Erroneous code example:
```compile_fail,E0593
fn foo<F: Fn()>(x: F) { }
```
"##,
+E0601: r##"
+No `main` function was found in a binary crate. To fix this error, just add a
+`main` function. For example:
+
+```
+fn main() {
+ // Your program will start here.
+ println!("Hello world!");
+}
+```
+
+If you don't know the basics of Rust, you can go look to the Rust Book to get
+started: https://doc.rust-lang.org/book/
+"##,
+
}
this.session.entry_type.set(Some(config::EntryMain));
} else {
// No main function
- let mut err = this.session.struct_err("main function not found");
+ let mut err = struct_err!(this.session, E0601, "main function not found");
if !this.non_main_fns.is_empty() {
// There were some functions named 'main' though. Try to give the user a hint.
err.note("the main function must be defined at the crate level \
pub fn struct_span_warn<'a, S: Into<MultiSpan>>(&'a self,
sp: S,
msg: &str)
- -> DiagnosticBuilder<'a> {
+ -> DiagnosticBuilder<'a> {
self.diagnostic().struct_span_warn(sp, msg)
}
pub fn struct_span_warn_with_code<'a, S: Into<MultiSpan>>(&'a self,
sp: S,
msg: &str,
code: &str)
- -> DiagnosticBuilder<'a> {
+ -> DiagnosticBuilder<'a> {
self.diagnostic().struct_span_warn_with_code(sp, msg, code)
}
pub fn struct_warn<'a>(&'a self, msg: &str) -> DiagnosticBuilder<'a> {
pub fn struct_span_err<'a, S: Into<MultiSpan>>(&'a self,
sp: S,
msg: &str)
- -> DiagnosticBuilder<'a> {
+ -> DiagnosticBuilder<'a> {
self.diagnostic().struct_span_err(sp, msg)
}
pub fn struct_span_err_with_code<'a, S: Into<MultiSpan>>(&'a self,
sp: S,
msg: &str,
code: &str)
- -> DiagnosticBuilder<'a> {
+ -> DiagnosticBuilder<'a> {
self.diagnostic().struct_span_err_with_code(sp, msg, code)
}
- pub fn struct_err<'a>(&'a self, msg: &str) -> DiagnosticBuilder<'a> {
+ // FIXME: This method should be removed (every error should have an associated error code).
+ pub fn struct_err<'a>(&'a self, msg: &str) -> DiagnosticBuilder<'a> {
self.diagnostic().struct_err(msg)
}
+ pub fn struct_err_with_code<'a>(&'a self, msg: &str, code: &str) -> DiagnosticBuilder<'a> {
+ self.diagnostic().struct_err_with_code(msg, code)
+ }
pub fn struct_span_fatal<'a, S: Into<MultiSpan>>(&'a self,
sp: S,
msg: &str)
- -> DiagnosticBuilder<'a> {
+ -> DiagnosticBuilder<'a> {
self.diagnostic().struct_span_fatal(sp, msg)
}
pub fn struct_span_fatal_with_code<'a, S: Into<MultiSpan>>(&'a self,
sp: S,
msg: &str,
code: &str)
- -> DiagnosticBuilder<'a> {
+ -> DiagnosticBuilder<'a> {
self.diagnostic().struct_span_fatal_with_code(sp, msg, code)
}
pub fn struct_fatal<'a>(&'a self, msg: &str) -> DiagnosticBuilder<'a> {
result.code(code.to_owned());
result
}
+ // FIXME: This method should be removed (every error should have an associated error code).
pub fn struct_err<'a>(&'a self, msg: &str) -> DiagnosticBuilder<'a> {
DiagnosticBuilder::new(self, Level::Error, msg)
}
+ pub fn struct_err_with_code<'a>(&'a self, msg: &str, code: &str) -> DiagnosticBuilder<'a> {
+ let mut result = DiagnosticBuilder::new(self, Level::Error, msg);
+ result.code(code.to_owned());
+ result
+ }
pub fn struct_span_fatal<'a, S: Into<MultiSpan>>(&'a self,
sp: S,
msg: &str)
})
}
+#[macro_export]
+macro_rules! struct_err {
+ ($session:expr, $code:ident, $($message:tt)*) => ({
+ __diagnostic_used!($code);
+ $session.struct_err_with_code(&format!($($message)*), stringify!($code))
+ })
+}
+
#[macro_export]
macro_rules! span_err_or_warn {
($is_warning:expr, $session:expr, $span:expr, $code:ident, $($message:tt)*) => ({
-error: main function not found
+error[E0601]: main function not found
error[E0046]: not all trait items implemented, missing: `CONSTANT`, `Type`, `method`
--> $DIR/m2.rs:20:1
133 | bah;
| ^^^ did you mean `Self::bah`?
-error: main function not found
+error[E0601]: main function not found
error: aborting due to previous error(s)
help: possible candidate is found in another module, you can import it into scope
| use foo::bar::T;
-error: main function not found
+error[E0601]: main function not found
error: cannot continue compilation due to previous error
| |
| did you mean `I`?
-error: main function not found
+error[E0601]: main function not found
error: aborting due to previous error(s)
help: possible better candidate is found in another module, you can import it into scope
| use std::ops::Add;
-error: main function not found
+error[E0601]: main function not found
error: cannot continue compilation due to previous error
19 | } //~ ERROR: incorrect close delimiter
| ^
-error: main function not found
+error[E0601]: main function not found
error: aborting due to previous error(s)
11 | impl S {
| ^ not found in this scope
-error: main function not found
+error[E0601]: main function not found
error: aborting due to previous error(s)