Skip to content

Commit 523ee8d

Browse files
committed
Auto merge of #27353 - arielb1:parenthetical-error, r=steveklabnik
This also calls the right API, which e.g. prevents a suggestion for #![feature(unboxed_closures)] on stable. Fixes #26970 r? @steveklabnik
2 parents 090ad6f + bd01175 commit 523ee8d

File tree

4 files changed

+17
-19
lines changed

4 files changed

+17
-19
lines changed

src/librustc_typeck/astconv.rs

+10-12
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,7 @@ use util::nodemap::FnvHashSet;
6969
use std::slice;
7070
use syntax::{abi, ast, ast_util};
7171
use syntax::codemap::{Span, Pos};
72+
use syntax::feature_gate::emit_feature_err;
7273
use syntax::parse::token;
7374
use syntax::print::pprust;
7475

@@ -791,12 +792,11 @@ fn create_substs_for_ast_trait_ref<'a,'tcx>(this: &AstConv<'tcx>,
791792
// For now, require that parenthetical notation be used
792793
// only with `Fn()` etc.
793794
if !this.tcx().sess.features.borrow().unboxed_closures && trait_def.paren_sugar {
794-
span_err!(this.tcx().sess, span, E0215,
795-
"angle-bracket notation is not stable when \
796-
used with the `Fn` family of traits, use parentheses");
797-
fileline_help!(this.tcx().sess, span,
798-
"add `#![feature(unboxed_closures)]` to \
799-
the crate attributes to enable");
795+
emit_feature_err(&this.tcx().sess.parse_sess.span_diagnostic,
796+
"unboxed_closures", span,
797+
"\
798+
the precise format of `Fn`-family traits' type parameters is \
799+
subject to change. Use parenthetical notation (Fn(Foo, Bar) -> Baz) instead");
800800
}
801801

802802
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>,
805805
// For now, require that parenthetical notation be used
806806
// only with `Fn()` etc.
807807
if !this.tcx().sess.features.borrow().unboxed_closures && !trait_def.paren_sugar {
808-
span_err!(this.tcx().sess, span, E0216,
809-
"parenthetical notation is only stable when \
810-
used with the `Fn` family of traits");
811-
fileline_help!(this.tcx().sess, span,
812-
"add `#![feature(unboxed_closures)]` to \
813-
the crate attributes to enable");
808+
emit_feature_err(&this.tcx().sess.parse_sess.span_diagnostic,
809+
"unboxed_closures", span,
810+
"\
811+
parenthetical notation is only stable when used with `Fn`-family traits");
814812
}
815813

816814
convert_parenthesized_parameters(this, rscope, span, &trait_def.generics, data)

src/librustc_typeck/diagnostics.rs

+4-4
Original file line numberDiff line numberDiff line change
@@ -2339,14 +2339,14 @@ register_diagnostics! {
23392339
E0212, // cannot extract an associated type from a higher-ranked trait bound
23402340
E0213, // associated types are not accepted in this context
23412341
E0214, // parenthesized parameters may only be used with a trait
2342-
E0215, // angle-bracket notation is not stable with `Fn`
2343-
E0216, // parenthetical notation is only stable with `Fn`
2342+
// E0215, // angle-bracket notation is not stable with `Fn`
2343+
// E0216, // parenthetical notation is only stable with `Fn`
23442344
E0217, // ambiguous associated type, defined in multiple supertraits
23452345
E0218, // no associated type defined
23462346
E0219, // associated type defined in higher-ranked supertrait
23472347
E0221, // ambiguous associated type in bounds
2348-
//E0222, // Error code E0045 (variadic function must have C calling
2349-
// convention) duplicate
2348+
// E0222, // Error code E0045 (variadic function must have C calling
2349+
// convention) duplicate
23502350
E0224, // at least one non-builtin train is required for an object type
23512351
E0226, // only a single explicit lifetime bound is permitted
23522352
E0227, // ambiguous lifetime bound, explicit lifetime bound required

src/test/compile-fail/unboxed-closure-feature-gate.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ trait Foo<A> {
2121

2222
fn main() {
2323
let x: Box<Foo(isize)>;
24-
//~^ ERROR parenthetical notation is only stable when used with the `Fn` family
24+
//~^ ERROR parenthetical notation is only stable when used with `Fn`-family
2525

2626
// No errors with these:
2727
let x: Box<Fn(isize)>;

src/test/compile-fail/unboxed-closure-sugar-not-used-on-fn.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -12,11 +12,11 @@
1212
// Test that the `Fn` traits require `()` form without a feature gate.
1313

1414
fn bar1(x: &Fn<(), Output=()>) {
15-
//~^ ERROR angle-bracket notation is not stable when used with the `Fn` family
15+
//~^ ERROR of `Fn`-family traits' type parameters is subject to change
1616
}
1717

1818
fn bar2<T>(x: &T) where T: Fn<()> {
19-
//~^ ERROR angle-bracket notation is not stable when used with the `Fn` family
19+
//~^ ERROR of `Fn`-family traits' type parameters is subject to change
2020
}
2121

2222
fn main() { }

0 commit comments

Comments
 (0)