about summary refs log tree commit diff
diff options
context:
space:
mode:
-rw-r--r--src/librustc/middle/entry.rs3
-rw-r--r--src/test/ui/error-codes/E0601.rs11
-rw-r--r--src/test/ui/error-codes/E0601.stderr7
-rw-r--r--src/test/ui/feature-gate/issue-43106-gating-of-bench.stderr2
-rw-r--r--src/test/ui/feature-gate/issue-43106-gating-of-test.stderr2
5 files changed, 25 insertions, 0 deletions
diff --git a/src/librustc/middle/entry.rs b/src/librustc/middle/entry.rs
index 3473923c411..8193aad7627 100644
--- a/src/librustc/middle/entry.rs
+++ b/src/librustc/middle/entry.rs
@@ -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/");
diff --git a/src/test/ui/error-codes/E0601.rs b/src/test/ui/error-codes/E0601.rs
new file mode 100644
index 00000000000..37b3f523475
--- /dev/null
+++ b/src/test/ui/error-codes/E0601.rs
@@ -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.
diff --git a/src/test/ui/error-codes/E0601.stderr b/src/test/ui/error-codes/E0601.stderr
new file mode 100644
index 00000000000..eff0a329902
--- /dev/null
+++ b/src/test/ui/error-codes/E0601.stderr
@@ -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"
diff --git a/src/test/ui/feature-gate/issue-43106-gating-of-bench.stderr b/src/test/ui/feature-gate/issue-43106-gating-of-bench.stderr
index 27bf9c99652..32ee8026197 100644
--- a/src/test/ui/feature-gate/issue-43106-gating-of-bench.stderr
+++ b/src/test/ui/feature-gate/issue-43106-gating-of-bench.stderr
@@ -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
 
diff --git a/src/test/ui/feature-gate/issue-43106-gating-of-test.stderr b/src/test/ui/feature-gate/issue-43106-gating-of-test.stderr
index 0d35be76d92..b86dd834d9a 100644
--- a/src/test/ui/feature-gate/issue-43106-gating-of-test.stderr
+++ b/src/test/ui/feature-gate/issue-43106-gating-of-test.stderr
@@ -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