diff options
Diffstat (limited to 'gcc')
-rw-r--r-- | gcc/rust/resolve/rust-ast-resolve-expr.cc | 12 | ||||
-rw-r--r-- | gcc/testsuite/rust/compile/multiple_bindings2.rs | 14 |
2 files changed, 20 insertions, 6 deletions
diff --git a/gcc/rust/resolve/rust-ast-resolve-expr.cc b/gcc/rust/resolve/rust-ast-resolve-expr.cc index ff9f7ef..a6b16f3 100644 --- a/gcc/rust/resolve/rust-ast-resolve-expr.cc +++ b/gcc/rust/resolve/rust-ast-resolve-expr.cc @@ -207,10 +207,10 @@ ResolveExpr::visit (AST::IfLetExpr &expr) resolver->push_new_type_rib (resolver->get_type_scope ().peek ()); resolver->push_new_label_rib (resolver->get_type_scope ().peek ()); - // FIXME: this declaration should be removed after refactoring - // parse_match_arm_patterns output into an AltPattern + // We know expr.get_patterns () has one pattern at most + // so there's no reason to handle it like an AltPattern. std::vector<PatternBinding> bindings - = {PatternBinding (PatternBoundCtx::Or, std::set<Identifier> ())}; + = {PatternBinding (PatternBoundCtx::Product, std::set<Identifier> ())}; for (auto &pattern : expr.get_patterns ()) { @@ -522,10 +522,10 @@ ResolveExpr::visit (AST::MatchExpr &expr) ResolveExpr::go (arm.get_guard_expr ().get (), prefix, canonical_prefix); - // FIXME: this declaration should be removed after refactoring - // parse_match_arms_patterns output into a single AltPattern + // We know expr.get_patterns () has one pattern at most + // so there's no reason to handle it like an AltPattern. std::vector<PatternBinding> bindings - = {PatternBinding (PatternBoundCtx::Or, std::set<Identifier> ())}; + = {PatternBinding (PatternBoundCtx::Product, std::set<Identifier> ())}; // insert any possible new patterns for (auto &pattern : arm.get_patterns ()) diff --git a/gcc/testsuite/rust/compile/multiple_bindings2.rs b/gcc/testsuite/rust/compile/multiple_bindings2.rs new file mode 100644 index 0000000..e62b18f --- /dev/null +++ b/gcc/testsuite/rust/compile/multiple_bindings2.rs @@ -0,0 +1,14 @@ +fn main() +{ + match (1, 2) { + (a, a) => {}, + } + // { dg-error "identifier .a. is bound more than once in the same pattern .E0416." "" { target *-*-* } .-2 } + + if let (a, a) = (1, 2) {} + // { dg-error "identifier .a. is bound more than once in the same pattern .E0416." "" { target *-*-* } .-1 } + + let (a, a) = (1, 2); + // { dg-error "identifier .a. is bound more than once in the same pattern .E0416." "" { target *-*-* } .-1 } + +} |