@@ -2666,23 +2666,22 @@ impl<'a, 'tcx> Resolver<'a, 'tcx> {
2666
2666
let pat_id = pattern. id ;
2667
2667
walk_pat ( pattern, |pattern| {
2668
2668
match pattern. node {
2669
- PatIdent ( binding_mode, ref path1, _) => {
2670
-
2671
- // The meaning of pat_ident with no type parameters
2669
+ PatIdent ( binding_mode, ref path1, ref at_rhs) => {
2670
+ // The meaning of PatIdent with no type parameters
2672
2671
// depends on whether an enum variant or unit-like struct
2673
2672
// with that name is in scope. The probing lookup has to
2674
2673
// be careful not to emit spurious errors. Only matching
2675
2674
// patterns (match) can match nullary variants or
2676
- // unit-like structs. For binding patterns (let), matching
2677
- // such a value is simply disallowed (since it's rarely
2678
- // what you want).
2675
+ // unit-like structs. For binding patterns (let
2676
+ // and the LHS of @-patterns), matching such a value is
2677
+ // simply disallowed (since it's rarely what you want).
2678
+ let const_ok = mode == RefutableMode && at_rhs. is_none ( ) ;
2679
2679
2680
2680
let ident = path1. node ;
2681
2681
let renamed = mtwt:: resolve ( ident) ;
2682
2682
2683
2683
match self . resolve_bare_identifier_pattern ( ident. name , pattern. span ) {
2684
- FoundStructOrEnumVariant ( def, lp)
2685
- if mode == RefutableMode => {
2684
+ FoundStructOrEnumVariant ( def, lp) if const_ok => {
2686
2685
debug ! ( "(resolving pattern) resolving `{}` to \
2687
2686
struct or enum variant",
2688
2687
renamed) ;
@@ -2705,7 +2704,7 @@ impl<'a, 'tcx> Resolver<'a, 'tcx> {
2705
2704
renamed)
2706
2705
) ;
2707
2706
}
2708
- FoundConst ( def, lp) if mode == RefutableMode => {
2707
+ FoundConst ( def, lp) if const_ok => {
2709
2708
debug ! ( "(resolving pattern) resolving `{}` to \
2710
2709
constant",
2711
2710
renamed) ;
0 commit comments