Skip to content

Commit 6e6564c

Browse files
committed
---
yaml --- r: 12901 b: refs/heads/master c: 8e73bb6 h: refs/heads/master i: 12899: 2c6a033 v: v3
1 parent 06a8b57 commit 6e6564c

File tree

3 files changed

+27
-21
lines changed

3 files changed

+27
-21
lines changed

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
---
2-
refs/heads/master: 1ad5f7d2c144117d9bb45eb657fb378d386788bf
2+
refs/heads/master: 8e73bb6ea06cf52b52cb403c84106873519f1220
33
refs/heads/snap-stage1: e33de59e47c5076a89eadeb38f4934f58a3618a6
44
refs/heads/snap-stage3: 4a81779abd786ff22d71434c6d9a5917ea4cdfff
55
refs/heads/try: 2898dcc5d97da9427ac367542382b6239d9c0bbf

trunk/src/rustc/middle/resolve.rs

Lines changed: 21 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -681,28 +681,29 @@ fn visit_arm_with_scope(a: ast::arm, sc: scopes, v: vt<scopes>) {
681681

682682
// This is only for irrefutable patterns (e.g. ones that appear in a let)
683683
// 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+
}
702702
_ {}
703+
}
703704
}
704-
}
705-
_ {}
705+
_ {}
706+
}
706707
}
707708
visit::visit_local(loc, sc, v);
708709
}
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
enum foo = uint;
2+
3+
fn main() {
4+
let (foo, _) = (2, 3); //! ERROR declaration of `foo` shadows an enum that's in scope
5+
}

0 commit comments

Comments
 (0)