Add suggestion where to add main function.

This commit is contained in:
Eric Huss 2018-03-12 13:23:12 -07:00
parent 6aa4dcb9cf
commit b08e6d305f
5 changed files with 25 additions and 0 deletions

View File

@ -178,6 +178,9 @@ fn configure_main(this: &mut EntryContext, crate_name: &str) {
err.emit();
this.session.abort_if_errors();
} else {
if let Some(ref filename) = this.session.local_crate_source_file {
err.note(&format!("consider adding a main function to {}", filename.display()));
}
if this.session.teach(&err.get_code().unwrap()) {
err.note("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/");

View File

@ -0,0 +1,11 @@
// Copyright 2018 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.
// Test for main function not found.

View File

@ -0,0 +1,7 @@
error[E0601]: main function not found in crate E0601
|
= note: consider adding a main function to $DIR/E0601.rs
error: aborting due to previous error
If you want more information on this error, try using "rustc --explain E0601"

View File

@ -1,4 +1,6 @@
error[E0601]: main function not found in crate issue_43106_gating_of_bench
|
= note: consider adding a main function to $DIR/issue-43106-gating-of-bench.rs
error: aborting due to previous error

View File

@ -1,4 +1,6 @@
error[E0601]: main function not found in crate issue_43106_gating_of_test
|
= note: consider adding a main function to $DIR/issue-43106-gating-of-test.rs
error: aborting due to previous error