Skip to content

Commit 4c947a2

Browse files
committed
Revert "pre-expansion gate type_ascription"
This reverts commit 15a6c09.
1 parent 92df638 commit 4c947a2

File tree

3 files changed

+17
-5
lines changed

3 files changed

+17
-5
lines changed

src/libsyntax/feature_gate/check.rs

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -502,6 +502,21 @@ impl<'a> Visitor<'a> for PostExpansionVisitor<'a> {
502502
}
503503
}
504504

505+
fn visit_expr(&mut self, e: &'a ast::Expr) {
506+
match e.kind {
507+
ast::ExprKind::Type(..) => {
508+
// To avoid noise about type ascription in common syntax errors, only emit if it
509+
// is the *only* error.
510+
if self.parse_sess.span_diagnostic.err_count() == 0 {
511+
gate_feature_post!(&self, type_ascription, e.span,
512+
"type ascription is experimental");
513+
}
514+
}
515+
_ => {}
516+
}
517+
visit::walk_expr(self, e)
518+
}
519+
505520
fn visit_pat(&mut self, pattern: &'a ast::Pat) {
506521
match &pattern.kind {
507522
PatKind::Slice(pats) => {
Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,5 @@
11
// Type ascription is unstable
22

3-
#[cfg(FALSE)]
4-
fn foo() {
3+
fn main() {
54
let a = 10: u8; //~ ERROR type ascription is experimental
65
}
7-
8-
fn main() {}

src/test/ui/feature-gates/feature-gate-type_ascription.stderr

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
error[E0658]: type ascription is experimental
2-
--> $DIR/feature-gate-type_ascription.rs:5:13
2+
--> $DIR/feature-gate-type_ascription.rs:4:13
33
|
44
LL | let a = 10: u8;
55
| ^^^^^^

0 commit comments

Comments
 (0)