@@ -2,7 +2,7 @@ use rustc_ast as ast;
2
2
use rustc_ast:: visit:: { self , AssocCtxt , FnCtxt , FnKind , Visitor } ;
3
3
use rustc_ast:: { attr, AssocConstraint , AssocConstraintKind , NodeId } ;
4
4
use rustc_ast:: { PatKind , RangeEnd } ;
5
- use rustc_errors:: { Applicability , StashKey } ;
5
+ use rustc_errors:: StashKey ;
6
6
use rustc_feature:: { AttributeGate , BuiltinAttribute , Features , GateIssue , BUILTIN_ATTRIBUTE_MAP } ;
7
7
use rustc_session:: parse:: { feature_err, feature_err_issue, feature_warn} ;
8
8
use rustc_session:: Session ;
@@ -375,43 +375,13 @@ impl<'a> Visitor<'a> for PostExpansionVisitor<'a> {
375
375
}
376
376
377
377
fn visit_stmt ( & mut self , stmt : & ' a ast:: Stmt ) {
378
- if let ast:: StmtKind :: Semi ( expr) = & stmt. kind
379
- && let ast:: ExprKind :: Assign ( lhs, _, _) = & expr. kind
380
- && let ast:: ExprKind :: Type ( ..) = lhs. kind
381
- && self . sess . parse_sess . span_diagnostic . err_count ( ) == 0
382
- && !self . features . type_ascription
383
- && !lhs. span . allows_unstable ( sym:: type_ascription)
384
- {
385
- // When we encounter a statement of the form `foo: Ty = val;`, this will emit a type
386
- // ascription error, but the likely intention was to write a `let` statement. (#78907).
387
- feature_err (
388
- & self . sess . parse_sess ,
389
- sym:: type_ascription,
390
- lhs. span ,
391
- "type ascription is experimental" ,
392
- ) . span_suggestion_verbose (
393
- lhs. span . shrink_to_lo ( ) ,
394
- "you might have meant to introduce a new binding" ,
395
- "let " ,
396
- Applicability :: MachineApplicable ,
397
- ) . emit ( ) ;
398
- }
399
378
visit:: walk_stmt ( self , stmt) ;
400
379
}
401
380
402
381
fn visit_expr ( & mut self , e : & ' a ast:: Expr ) {
403
382
match e. kind {
404
383
ast:: ExprKind :: Type ( ..) => {
405
- if self . sess . parse_sess . span_diagnostic . err_count ( ) == 0 {
406
- // To avoid noise about type ascription in common syntax errors,
407
- // only emit if it is the *only* error.
408
- gate_feature_post ! (
409
- & self ,
410
- type_ascription,
411
- e. span,
412
- "type ascription is experimental"
413
- ) ;
414
- } else {
384
+ if self . sess . parse_sess . span_diagnostic . err_count ( ) > 0 {
415
385
// And if it isn't, cancel the early-pass warning.
416
386
if let Some ( err) = self
417
387
. sess
@@ -629,7 +599,6 @@ pub fn check_crate(krate: &ast::Crate, sess: &Session) {
629
599
gate_all ! ( box_patterns, "box pattern syntax is experimental" ) ;
630
600
gate_all ! ( exclusive_range_pattern, "exclusive range pattern syntax is experimental" ) ;
631
601
gate_all ! ( try_blocks, "`try` blocks are unstable" ) ;
632
- gate_all ! ( type_ascription, "type ascription is experimental" ) ;
633
602
634
603
visit:: walk_crate ( & mut visitor, krate) ;
635
604
}
0 commit comments