@@ -2,7 +2,6 @@ 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 } ;
6
5
use rustc_feature:: { AttributeGate , BuiltinAttribute , Features , GateIssue , BUILTIN_ATTRIBUTE_MAP } ;
7
6
use rustc_session:: parse:: { feature_err, feature_err_issue, feature_warn} ;
8
7
use rustc_session:: Session ;
@@ -374,55 +373,8 @@ impl<'a> Visitor<'a> for PostExpansionVisitor<'a> {
374
373
}
375
374
}
376
375
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
- visit:: walk_stmt ( self , stmt) ;
400
- }
401
-
402
376
fn visit_expr ( & mut self , e : & ' a ast:: Expr ) {
403
377
match e. kind {
404
- 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 {
415
- // And if it isn't, cancel the early-pass warning.
416
- if let Some ( err) = self
417
- . sess
418
- . parse_sess
419
- . span_diagnostic
420
- . steal_diagnostic ( e. span , StashKey :: EarlySyntaxWarning )
421
- {
422
- err. cancel ( )
423
- }
424
- }
425
- }
426
378
ast:: ExprKind :: TryBlock ( _) => {
427
379
gate_feature_post ! ( & self , try_blocks, e. span, "`try` expression is experimental" ) ;
428
380
}
@@ -629,7 +581,6 @@ pub fn check_crate(krate: &ast::Crate, sess: &Session) {
629
581
gate_all ! ( box_patterns, "box pattern syntax is experimental" ) ;
630
582
gate_all ! ( exclusive_range_pattern, "exclusive range pattern syntax is experimental" ) ;
631
583
gate_all ! ( try_blocks, "`try` blocks are unstable" ) ;
632
- gate_all ! ( type_ascription, "type ascription is experimental" ) ;
633
584
634
585
visit:: walk_crate ( & mut visitor, krate) ;
635
586
}
0 commit comments