@@ -681,28 +681,29 @@ fn visit_arm_with_scope(a: ast::arm, sc: scopes, v: vt<scopes>) {
681
681
682
682
// This is only for irrefutable patterns (e.g. ones that appear in a let)
683
683
// So if x occurs, and x is already known to be a enum, that's always an error
684
- fn visit_local_with_scope( e: @env, loc: @local, sc: scopes, v: vt < scopes > ) {
685
- // Check whether the given local has the same name as a enum that's
686
- // in scope
687
- // We disallow this, in order to make alt patterns consisting of
688
- // a single identifier unambiguous (does the pattern "foo" refer
689
- // to enum foo, or is it binding a new name foo?)
690
- alt loc . node . pat . node {
691
- pat_ident( an_ident , _) {
692
- alt lookup_in_scope( * e, sc, loc. span, path_to_ident( an_ident ) ,
693
- ns_val, false ) {
694
- some( ast:: def_variant( enum_id, variant_id) ) {
695
- // Declaration shadows an enum that's in scope.
696
- // That's an error.
697
- e. sess. span_err( loc. span,
698
- #fmt( "declaration of `%s` shadows an \
699
- enum that's in scope",
700
- path_to_ident( an_ident ) ) ) ;
701
- }
684
+ fn visit_local_with_scope( e: @env, loc: @local, & & sc: scopes, v: vt < scopes > ) {
685
+ // Check whether the given local has the same name as a enum that's in
686
+ // scope. We disallow this, in order to make alt patterns consisting of a
687
+ // single identifier unambiguous (does the pattern "foo" refer to enum
688
+ // foo, or is it binding a new name foo?)
689
+ pat_util :: walk_pat ( loc . node . pat ) { |p|
690
+ alt p . node {
691
+ pat_ident( path , _) {
692
+ alt lookup_in_scope( * e, sc, loc. span, path_to_ident( path ) ,
693
+ ns_val, false ) {
694
+ some( ast:: def_variant( enum_id, variant_id) ) {
695
+ // Declaration shadows an enum that's in scope.
696
+ // That's an error.
697
+ e. sess. span_err( loc. span,
698
+ #fmt( "declaration of `%s` shadows an \
699
+ enum that's in scope",
700
+ path_to_ident( path ) ) ) ;
701
+ }
702
702
_ { }
703
+ }
703
704
}
704
- }
705
- _ { }
705
+ _ { }
706
+ }
706
707
}
707
708
visit:: visit_local( loc, sc, v) ;
708
709
}
0 commit comments