@@ -2654,23 +2654,22 @@ impl<'a, 'tcx> Resolver<'a, 'tcx> {
2654
2654
let pat_id = pattern. id ;
2655
2655
walk_pat ( pattern, |pattern| {
2656
2656
match pattern. node {
2657
- PatIdent ( binding_mode, ref path1, _) => {
2658
-
2659
- // The meaning of pat_ident with no type parameters
2657
+ PatIdent ( binding_mode, ref path1, ref at_rhs) => {
2658
+ // The meaning of PatIdent with no type parameters
2660
2659
// depends on whether an enum variant or unit-like struct
2661
2660
// with that name is in scope. The probing lookup has to
2662
2661
// be careful not to emit spurious errors. Only matching
2663
2662
// patterns (match) can match nullary variants or
2664
- // unit-like structs. For binding patterns (let), matching
2665
- // such a value is simply disallowed (since it's rarely
2666
- // what you want).
2663
+ // unit-like structs. For binding patterns (let
2664
+ // and the LHS of @-patterns), matching such a value is
2665
+ // simply disallowed (since it's rarely what you want).
2666
+ let const_ok = mode == RefutableMode && at_rhs. is_none ( ) ;
2667
2667
2668
2668
let ident = path1. node ;
2669
2669
let renamed = mtwt:: resolve ( ident) ;
2670
2670
2671
2671
match self . resolve_bare_identifier_pattern ( ident. name , pattern. span ) {
2672
- FoundStructOrEnumVariant ( def, lp)
2673
- if mode == RefutableMode => {
2672
+ FoundStructOrEnumVariant ( def, lp) if const_ok => {
2674
2673
debug ! ( "(resolving pattern) resolving `{}` to \
2675
2674
struct or enum variant",
2676
2675
renamed) ;
@@ -2693,7 +2692,7 @@ impl<'a, 'tcx> Resolver<'a, 'tcx> {
2693
2692
renamed)
2694
2693
) ;
2695
2694
}
2696
- FoundConst ( def, lp) if mode == RefutableMode => {
2695
+ FoundConst ( def, lp) if const_ok => {
2697
2696
debug ! ( "(resolving pattern) resolving `{}` to \
2698
2697
constant",
2699
2698
renamed) ;
0 commit comments