@@ -2,7 +2,7 @@ use crate::ast::{
2
2
self , Param , BinOpKind , BindingMode , BlockCheckMode , Expr , ExprKind , Ident , Item , ItemKind ,
3
3
Mutability , Pat , PatKind , PathSegment , QSelf , Ty , TyKind , VariantData ,
4
4
} ;
5
- use crate :: feature_gate:: { feature_err, UnstableFeatures } ;
5
+ use crate :: feature_gate:: feature_err;
6
6
use crate :: parse:: { SeqSep , PResult , Parser , ParseSess } ;
7
7
use crate :: parse:: parser:: { BlockMode , PathStyle , SemiColonMode , TokenType , TokenExpectType } ;
8
8
use crate :: parse:: token:: { self , TokenKind } ;
@@ -387,14 +387,17 @@ impl<'a> Parser<'a> {
387
387
let next_pos = sm. lookup_char_pos ( self . token . span . lo ( ) ) ;
388
388
let op_pos = sm. lookup_char_pos ( sp. hi ( ) ) ;
389
389
390
+ let allow_unstable = self . sess . unstable_features . is_nightly_build ( ) ;
391
+
390
392
if likely_path {
391
393
err. span_suggestion (
392
394
sp,
393
395
"maybe write a path separator here" ,
394
396
"::" . to_string ( ) ,
395
- match self . sess . unstable_features {
396
- UnstableFeatures :: Disallow => Applicability :: MachineApplicable ,
397
- _ => Applicability :: MaybeIncorrect ,
397
+ if allow_unstable {
398
+ Applicability :: MaybeIncorrect
399
+ } else {
400
+ Applicability :: MachineApplicable
398
401
} ,
399
402
) ;
400
403
} else if op_pos. line != next_pos. line && maybe_expected_semicolon {
@@ -404,14 +407,13 @@ impl<'a> Parser<'a> {
404
407
";" . to_string ( ) ,
405
408
Applicability :: MaybeIncorrect ,
406
409
) ;
407
- } else if let UnstableFeatures :: Disallow = self . sess . unstable_features {
408
- err. span_label ( sp, "tried to parse a type due to this" ) ;
409
- } else {
410
+ } else if allow_unstable {
410
411
err. span_label ( sp, "tried to parse a type due to this type ascription" ) ;
412
+ } else {
413
+ err. span_label ( sp, "tried to parse a type due to this" ) ;
411
414
}
412
- if let UnstableFeatures :: Disallow = self . sess . unstable_features {
415
+ if allow_unstable {
413
416
// Give extra information about type ascription only if it's a nightly compiler.
414
- } else {
415
417
err. note ( "`#![feature(type_ascription)]` lets you annotate an expression with a \
416
418
type: `<expr>: <type>`") ;
417
419
err. note ( "for more information, see \
0 commit comments