@@ -421,18 +421,18 @@ impl<'a> Parser<'a> {
421
421
. span_label ( rhs. span , "binding on the right, should be to the left" )
422
422
. span_suggestion ( sp, "switch the order" , pprust:: pat_to_string ( & rhs) , applicability)
423
423
. emit ( ) ;
424
-
425
- rhs. span = sp;
426
- return Ok ( rhs) ;
424
+ } else {
425
+ // The special case above doesn't apply so we may have e.g. `A(x) @ B(y)`.
426
+ rhs. kind = PatKind :: Wild ;
427
+ self . struct_span_err ( sp, "left-hand side of `@` must be a binding pattern" )
428
+ . span_label ( lhs. span , "interpreted as a pattern, not a binding" )
429
+ . span_label ( rhs. span , "also a pattern" )
430
+ . note ( "bindings are `x`, `mut x`, `ref x`, and `ref mut x`" )
431
+ . emit ( ) ;
427
432
}
428
433
429
- // The special case above doesn't apply so we may have e.g. `A(x) @ B(y)`.
430
- let mut err = self . struct_span_err ( sp, "left-hand side of `@` must be a binding pattern" ) ;
431
- err. span_label ( lhs. span , "interpreted as a pattern, not a binding" )
432
- . span_label ( rhs. span , "also a pattern" )
433
- . note ( "bindings are `x`, `mut x`, `ref x`, and `ref mut x`" ) ;
434
- // FIXME(Centril): Introduce `PatKind::Err` and use that instead.
435
- Err ( err)
434
+ rhs. span = sp;
435
+ Ok ( rhs)
436
436
}
437
437
438
438
/// Ban a range pattern if it has an ambiguous interpretation.
0 commit comments