@@ -25,10 +25,10 @@ use crate::errors::{
25
25
GenericArgsInPatRequireTurbofishSyntax , InclusiveRangeExtraEquals , InclusiveRangeMatchArrow ,
26
26
InclusiveRangeNoEnd , InvalidMutInPattern , ParenRangeSuggestion , PatternOnWrongSideOfAt ,
27
27
RemoveLet , RepeatedMutInPattern , SwitchRefBoxOrder , TopLevelOrPatternNotAllowed ,
28
- TopLevelOrPatternNotAllowedSugg , TrailingVertNotAllowed , UnexpectedExpressionInPattern ,
29
- UnexpectedExpressionInPatternSugg , UnexpectedLifetimeInPattern , UnexpectedParenInRangePat ,
30
- UnexpectedParenInRangePatSugg , UnexpectedVertVertBeforeFunctionParam ,
31
- UnexpectedVertVertInPattern , WrapInParens ,
28
+ TopLevelOrPatternNotAllowedSugg , TrailingVertNotAllowed , TrailingVertSuggestion ,
29
+ UnexpectedExpressionInPattern , UnexpectedExpressionInPatternSugg , UnexpectedLifetimeInPattern ,
30
+ UnexpectedParenInRangePat , UnexpectedParenInRangePatSugg ,
31
+ UnexpectedVertVertBeforeFunctionParam , UnexpectedVertVertInPattern , WrapInParens ,
32
32
} ;
33
33
use crate :: parser:: expr:: { DestructuredFloat , could_be_unclosed_char_literal} ;
34
34
use crate :: { exp, maybe_recover_from_interpolated_ty_qpath} ;
@@ -268,10 +268,9 @@ impl<'a> Parser<'a> {
268
268
269
269
if let PatKind :: Or ( pats) = & pat. kind {
270
270
let span = pat. span ;
271
- let sub = if pats. len ( ) == 1 {
272
- Some ( TopLevelOrPatternNotAllowedSugg :: RemoveLeadingVert {
273
- span : span. with_hi ( span. lo ( ) + BytePos ( 1 ) ) ,
274
- } )
271
+ let sub = if let [ _] = & pats[ ..] {
272
+ let span = span. with_hi ( span. lo ( ) + BytePos ( 1 ) ) ;
273
+ Some ( TopLevelOrPatternNotAllowedSugg :: RemoveLeadingVert { span } )
275
274
} else {
276
275
Some ( TopLevelOrPatternNotAllowedSugg :: WrapInParens {
277
276
span,
@@ -363,6 +362,9 @@ impl<'a> Parser<'a> {
363
362
self . dcx ( ) . emit_err ( TrailingVertNotAllowed {
364
363
span : self . token . span ,
365
364
start : lo,
365
+ suggestion : TrailingVertSuggestion {
366
+ span : self . prev_token . span . shrink_to_hi ( ) . with_hi ( self . token . span . hi ( ) ) ,
367
+ } ,
366
368
token : self . token ,
367
369
note_double_vert : self . token . kind == token:: OrOr ,
368
370
} ) ;
0 commit comments