about summary refs log tree commit diff
diff options
context:
space:
mode:
authorAlex Crichton <alex@alexcrichton.com>2014-10-30 08:57:36 -0700
committerAlex Crichton <alex@alexcrichton.com>2014-10-30 09:29:24 -0700
commitce63fbc7bdc08d313c569bd3b5ba04dd97dd44ca (patch)
treee8a58a7fd1cec3c289ff16149bb0edd07c4997c7
parent1e919c93c7b643bf81fd065c2be947138621143d (diff)
parentcb5f9799421c7ae9289295acdf15546a1e68da91 (diff)
downloadrust-ce63fbc7bdc08d313c569bd3b5ba04dd97dd44ca.tar.gz
rust-ce63fbc7bdc08d313c569bd3b5ba04dd97dd44ca.zip
rollup merge of #18409 : gamazeps/issue15273
-rw-r--r--src/librustc/middle/typeck/check/writeback.rs6
-rw-r--r--src/libsyntax/diagnostics/macros.rs7
-rw-r--r--src/test/compile-fail/coerce-bare-fn-to-closure-and-proc.rs6
3 files changed, 15 insertions, 4 deletions
diff --git a/src/librustc/middle/typeck/check/writeback.rs b/src/librustc/middle/typeck/check/writeback.rs
index 56dec61d410..b53318861b8 100644
--- a/src/librustc/middle/typeck/check/writeback.rs
+++ b/src/librustc/middle/typeck/check/writeback.rs
@@ -1,4 +1,4 @@
-// Copyright 2012 The Rust Project Developers. See the COPYRIGHT
+// Copyright 2014 The Rust Project Developers. See the COPYRIGHT
 // file at the top-level directory of this distribution and at
 // http://rust-lang.org/COPYRIGHT.
 //
@@ -282,7 +282,9 @@ impl<'cx, 'tcx> WritebackCx<'cx, 'tcx> {
                             }
                             _ => {
                                 span_err!(self.tcx().sess, reason.span(self.tcx()), E0100,
-                                    "cannot coerce non-statically resolved bare fn");
+                                    "cannot coerce non-statically resolved bare fn to closure");
+                                span_help!(self.tcx().sess, reason.span(self.tcx()),
+                                    "consider embedding the function in a closure");
                             }
                         }
 
diff --git a/src/libsyntax/diagnostics/macros.rs b/src/libsyntax/diagnostics/macros.rs
index c344168b62a..b4bf793d4e1 100644
--- a/src/libsyntax/diagnostics/macros.rs
+++ b/src/libsyntax/diagnostics/macros.rs
@@ -40,6 +40,13 @@ macro_rules! span_note(
 )
 
 #[macro_export]
+macro_rules! span_help(
+    ($session:expr, $span:expr, $($message:tt)*) => ({
+        ($session).span_help($span, format!($($message)*).as_slice())
+    })
+)
+
+#[macro_export]
 macro_rules! register_diagnostics(
     ($($code:tt),*) => (
         $(register_diagnostic!($code))*
diff --git a/src/test/compile-fail/coerce-bare-fn-to-closure-and-proc.rs b/src/test/compile-fail/coerce-bare-fn-to-closure-and-proc.rs
index c165802d61f..087ebf4e28c 100644
--- a/src/test/compile-fail/coerce-bare-fn-to-closure-and-proc.rs
+++ b/src/test/compile-fail/coerce-bare-fn-to-closure-and-proc.rs
@@ -13,7 +13,9 @@ fn foo() {}
 fn main() {
     let f = foo;
     let f_closure: || = f;
-    //~^ ERROR: cannot coerce non-statically resolved bare fn
+    //~^ ERROR: cannot coerce non-statically resolved bare fn to closure
+    //~^ HELP: consider embedding the function in a closure
     let f_proc: proc() = f;
-    //~^ ERROR: cannot coerce non-statically resolved bare fn
+    //~^ ERROR: cannot coerce non-statically resolved bare fn to closure
+    //~^ HELP: consider embedding the function in a closure
 }