@@ -6,9 +6,9 @@ use crate::errors::{
6
6
InclusiveRangeExtraEquals , InclusiveRangeMatchArrow , InclusiveRangeNoEnd , InvalidMutInPattern ,
7
7
PatternOnWrongSideOfAt , RemoveLet , RepeatedMutInPattern , SwitchRefBoxOrder ,
8
8
TopLevelOrPatternNotAllowed , TopLevelOrPatternNotAllowedSugg , TrailingVertNotAllowed ,
9
- UnexpectedExpressionInPattern , UnexpectedLifetimeInPattern , UnexpectedParenInRangePat ,
10
- UnexpectedParenInRangePatSugg , UnexpectedVertVertBeforeFunctionParam ,
11
- UnexpectedVertVertInPattern ,
9
+ UnexpectedExpressionInPattern , UnexpectedExpressionInPatternConstPatSugg ,
10
+ UnexpectedLifetimeInPattern , UnexpectedParenInRangePat , UnexpectedParenInRangePatSugg ,
11
+ UnexpectedVertVertBeforeFunctionParam , UnexpectedVertVertInPattern ,
12
12
} ;
13
13
use crate :: parser:: expr:: { could_be_unclosed_char_literal, DestructuredFloat } ;
14
14
use crate :: { maybe_recover_from_interpolated_ty_qpath, maybe_whole} ;
@@ -431,14 +431,22 @@ impl<'a> Parser<'a> {
431
431
432
432
let span = expr. span ;
433
433
434
- return Some ( (
435
- self . dcx ( ) . stash_err (
436
- span,
437
- StashKey :: ExprInPat ,
438
- UnexpectedExpressionInPattern { span, is_bound, is_method_call } ,
439
- ) ,
434
+ let mut diag = self . dcx ( ) . create_err ( UnexpectedExpressionInPattern {
440
435
span,
441
- ) ) ;
436
+ is_bound,
437
+ is_method_call,
438
+ } ) ;
439
+ if self . psess . unstable_features . is_nightly_build ( ) {
440
+ diag. subdiagnostic (
441
+ & self . dcx ( ) ,
442
+ UnexpectedExpressionInPatternConstPatSugg {
443
+ start_span : span. shrink_to_lo ( ) ,
444
+ end_span : span. shrink_to_hi ( ) ,
445
+ } ,
446
+ ) ;
447
+ }
448
+
449
+ return Some ( ( diag. stash ( span, StashKey :: ExprInPat ) . unwrap ( ) , span) ) ;
442
450
}
443
451
}
444
452
0 commit comments