@@ -6,9 +6,9 @@ use crate::errors::{
66 InclusiveRangeExtraEquals , InclusiveRangeMatchArrow , InclusiveRangeNoEnd , InvalidMutInPattern ,
77 PatternOnWrongSideOfAt , RemoveLet , RepeatedMutInPattern , SwitchRefBoxOrder ,
88 TopLevelOrPatternNotAllowed , TopLevelOrPatternNotAllowedSugg , TrailingVertNotAllowed ,
9- UnexpectedExpressionInPattern , UnexpectedLifetimeInPattern , UnexpectedParenInRangePat ,
10- UnexpectedParenInRangePatSugg , UnexpectedVertVertBeforeFunctionParam ,
11- UnexpectedVertVertInPattern ,
9+ UnexpectedExpressionInPattern , UnexpectedExpressionInPatternConstPatSugg ,
10+ UnexpectedLifetimeInPattern , UnexpectedParenInRangePat , UnexpectedParenInRangePatSugg ,
11+ UnexpectedVertVertBeforeFunctionParam , UnexpectedVertVertInPattern ,
1212} ;
1313use crate :: parser:: expr:: { could_be_unclosed_char_literal, DestructuredFloat } ;
1414use crate :: { maybe_recover_from_interpolated_ty_qpath, maybe_whole} ;
@@ -431,14 +431,22 @@ impl<'a> Parser<'a> {
431431
432432 let span = expr. span ;
433433
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 {
440435 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) ) ;
442450 }
443451 }
444452
0 commit comments