gate_feature_post!(&self, box_syntax, e.span, EXPLAIN_BOX_SYNTAX);
}
ast::ExprKind::Type(..) => {
- gate_feature_post!(&self, type_ascription, e.span,
- "type ascription is experimental");
+ // To avoid noise about type ascription in common syntax errors, only emit if it
+ // is the *only* error.
+ if self.context.parse_sess.span_diagnostic.err_count() == 0 {
+ gate_feature_post!(&self, type_ascription, e.span,
+ "type ascription is experimental");
+ }
}
ast::ExprKind::ObsoleteInPlace(..) => {
// these get a hard error in ast-validation
let closure_annotated = |value: i32| -> i32 {
temp: i32 = fun(5i32);
//~^ ERROR cannot find value `temp` in this scope
- //~| ERROR type ascription is experimental
temp + value + 1
//~^ ERROR cannot find value `temp` in this scope
};
| help: maybe you meant to write an assignment here: `let temp`
error[E0425]: cannot find value `temp` in this scope
- --> $DIR/type-ascription-instead-of-let.rs:8:9
+ --> $DIR/type-ascription-instead-of-let.rs:7:9
|
LL | temp + value + 1
| ^^^^ not found in this scope
-error[E0658]: type ascription is experimental (see issue #23416)
- --> $DIR/type-ascription-instead-of-let.rs:5:9
- |
-LL | temp: i32 = fun(5i32);
- | ^^^^^^^^^
- |
- = help: add #![feature(type_ascription)] to the crate attributes to enable
-
-error: aborting due to 3 previous errors
+error: aborting due to 2 previous errors
-Some errors occurred: E0425, E0658.
-For more information about an error, try `rustc --explain E0425`.
+For more information about this error, try `rustc --explain E0425`.
std:io::stdin();
//~^ ERROR failed to resolve: use of undeclared type or module `io`
//~| ERROR expected value, found module
- //~| ERROR type ascription is experimental
}
| |
| not a value
-error[E0658]: type ascription is experimental (see issue #23416)
- --> $DIR/type-ascription-instead-of-path.rs:2:5
- |
-LL | std:io::stdin();
- | ^^^^^^^^^^^^^^^
- |
- = help: add #![feature(type_ascription)] to the crate attributes to enable
-
-error: aborting due to 3 previous errors
+error: aborting due to 2 previous errors
-Some errors occurred: E0423, E0433, E0658.
+Some errors occurred: E0423, E0433.
For more information about an error, try `rustc --explain E0423`.