about summary refs log tree commit diff
diff options
context:
space:
mode:
authorAriel Ben-Yehuda <arielb1@mail.tau.ac.il>2015-07-28 19:21:24 +0300
committerAriel Ben-Yehuda <arielb1@mail.tau.ac.il>2015-07-28 19:21:24 +0300
commitbd0117523448f9cda8a61c048b9f4ce5372ade15 (patch)
tree6575757a1818459426bbc686af63063b9bf87f26
parent4c371bb6de7a1c21b7403b86a66a8ce3318ff003 (diff)
downloadrust-bd0117523448f9cda8a61c048b9f4ce5372ade15.tar.gz
rust-bd0117523448f9cda8a61c048b9f4ce5372ade15.zip
clarify the parenthetical notation stability error message
This also calls the right API, which e.g. prevents a suggestion
for #![feature(unboxed_closures)] on stable.

Fixes #26970
-rw-r--r--src/librustc_typeck/astconv.rs22
-rw-r--r--src/librustc_typeck/diagnostics.rs8
-rw-r--r--src/test/compile-fail/unboxed-closure-feature-gate.rs2
-rw-r--r--src/test/compile-fail/unboxed-closure-sugar-not-used-on-fn.rs4
4 files changed, 17 insertions, 19 deletions
diff --git a/src/librustc_typeck/astconv.rs b/src/librustc_typeck/astconv.rs
index 332b84bfc7b..20e9608bb15 100644
--- a/src/librustc_typeck/astconv.rs
+++ b/src/librustc_typeck/astconv.rs
@@ -69,6 +69,7 @@ use util::nodemap::FnvHashSet;
 use std::slice;
 use syntax::{abi, ast, ast_util};
 use syntax::codemap::{Span, Pos};
+use syntax::feature_gate::emit_feature_err;
 use syntax::parse::token;
 use syntax::print::pprust;
 
@@ -791,12 +792,11 @@ fn create_substs_for_ast_trait_ref<'a,'tcx>(this: &AstConv<'tcx>,
             // For now, require that parenthetical notation be used
             // only with `Fn()` etc.
             if !this.tcx().sess.features.borrow().unboxed_closures && trait_def.paren_sugar {
-                span_err!(this.tcx().sess, span, E0215,
-                                         "angle-bracket notation is not stable when \
-                                         used with the `Fn` family of traits, use parentheses");
-                fileline_help!(this.tcx().sess, span,
-                           "add `#![feature(unboxed_closures)]` to \
-                            the crate attributes to enable");
+                emit_feature_err(&this.tcx().sess.parse_sess.span_diagnostic,
+                                 "unboxed_closures", span,
+                                 "\
+                    the precise format of `Fn`-family traits' type parameters is \
+                    subject to change. Use parenthetical notation (Fn(Foo, Bar) -> Baz) instead");
             }
 
             convert_angle_bracketed_parameters(this, rscope, span, &trait_def.generics, data)
@@ -805,12 +805,10 @@ fn create_substs_for_ast_trait_ref<'a,'tcx>(this: &AstConv<'tcx>,
             // For now, require that parenthetical notation be used
             // only with `Fn()` etc.
             if !this.tcx().sess.features.borrow().unboxed_closures && !trait_def.paren_sugar {
-                span_err!(this.tcx().sess, span, E0216,
-                                         "parenthetical notation is only stable when \
-                                         used with the `Fn` family of traits");
-                fileline_help!(this.tcx().sess, span,
-                           "add `#![feature(unboxed_closures)]` to \
-                            the crate attributes to enable");
+                emit_feature_err(&this.tcx().sess.parse_sess.span_diagnostic,
+                                 "unboxed_closures", span,
+                                 "\
+                    parenthetical notation is only stable when used with `Fn`-family traits");
             }
 
             convert_parenthesized_parameters(this, rscope, span, &trait_def.generics, data)
diff --git a/src/librustc_typeck/diagnostics.rs b/src/librustc_typeck/diagnostics.rs
index 73ee3bbbe5b..21262c53dbb 100644
--- a/src/librustc_typeck/diagnostics.rs
+++ b/src/librustc_typeck/diagnostics.rs
@@ -2319,14 +2319,14 @@ register_diagnostics! {
     E0212, // cannot extract an associated type from a higher-ranked trait bound
     E0213, // associated types are not accepted in this context
     E0214, // parenthesized parameters may only be used with a trait
-    E0215, // angle-bracket notation is not stable with `Fn`
-    E0216, // parenthetical notation is only stable with `Fn`
+//  E0215, // angle-bracket notation is not stable with `Fn`
+//  E0216, // parenthetical notation is only stable with `Fn`
     E0217, // ambiguous associated type, defined in multiple supertraits
     E0218, // no associated type defined
     E0219, // associated type defined in higher-ranked supertrait
     E0221, // ambiguous associated type in bounds
-    //E0222, // Error code E0045 (variadic function must have C calling
-             // convention) duplicate
+//  E0222, // Error code E0045 (variadic function must have C calling
+           // convention) duplicate
     E0224, // at least one non-builtin train is required for an object type
     E0226, // only a single explicit lifetime bound is permitted
     E0227, // ambiguous lifetime bound, explicit lifetime bound required
diff --git a/src/test/compile-fail/unboxed-closure-feature-gate.rs b/src/test/compile-fail/unboxed-closure-feature-gate.rs
index 74a6f869f63..3a3ea058b4e 100644
--- a/src/test/compile-fail/unboxed-closure-feature-gate.rs
+++ b/src/test/compile-fail/unboxed-closure-feature-gate.rs
@@ -21,7 +21,7 @@ trait Foo<A> {
 
 fn main() {
     let x: Box<Foo(isize)>;
-    //~^ ERROR parenthetical notation is only stable when used with the `Fn` family
+    //~^ ERROR parenthetical notation is only stable when used with `Fn`-family
 
     // No errors with these:
     let x: Box<Fn(isize)>;
diff --git a/src/test/compile-fail/unboxed-closure-sugar-not-used-on-fn.rs b/src/test/compile-fail/unboxed-closure-sugar-not-used-on-fn.rs
index 5a821ef1231..ed27a4d0b2a 100644
--- a/src/test/compile-fail/unboxed-closure-sugar-not-used-on-fn.rs
+++ b/src/test/compile-fail/unboxed-closure-sugar-not-used-on-fn.rs
@@ -12,11 +12,11 @@
 // Test that the `Fn` traits require `()` form without a feature gate.
 
 fn bar1(x: &Fn<(), Output=()>) {
-    //~^ ERROR angle-bracket notation is not stable when used with the `Fn` family
+    //~^ ERROR of `Fn`-family traits' type parameters is subject to change
 }
 
 fn bar2<T>(x: &T) where T: Fn<()> {
-    //~^ ERROR angle-bracket notation is not stable when used with the `Fn` family
+    //~^ ERROR of `Fn`-family traits' type parameters is subject to change
 }
 
 fn main() { }