Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

or-patterns: Uniformly use PatKind::Or in AST & Fix/Cleanup resolve #64111

Merged
merged 27 commits into from
Sep 6, 2019
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
27 commits
Select commit Hold shift + click to select a range
af06bfb
resolve: extract `resolve_params`.
Centril Aug 28, 2019
f8835ee
resolve: cleanup using `with_rib`, etc.
Centril Aug 28, 2019
6d537d4
resolve: simplify `resolve_arm`.
Centril Aug 28, 2019
219ddde
resolve: extract `try_resolve_as_non_binding`.
Centril Aug 28, 2019
f343e84
resolve: add `type IdentMap<T>` alias.
Centril Aug 28, 2019
fd3b441
resolve: move `fresh_binding`.
Centril Aug 28, 2019
dc91e22
resolve: move `resolve_block` to a better place.
Centril Aug 28, 2019
70cae78
resolve: already-bound-check: account for or-patterns.
Centril Aug 28, 2019
166a558
resolve: revamp already-bound check -- fix some bugs.
Centril Sep 1, 2019
498ec59
resolve: add tests for already-bound check.
Centril Sep 1, 2019
896a1c7
resolve: account for general or-patterns in consistency checking.
Centril Sep 1, 2019
33317c7
resolve: add test for missing bindings in or-patterns.
Centril Sep 1, 2019
aa7a02b
resolve: test binding mode consistency for or-patterns.
Centril Sep 1, 2019
dbe6873
resolve: test consistent or-patterns being allowed.
Centril Sep 3, 2019
ca968a1
or-patterns: syntax: simplify `Arm.pats` and `ExprKind::Let.0`.
Centril Aug 27, 2019
998060b
or-patterns: syntax: adjust `visit` and `mut_visit`.
Centril Aug 27, 2019
ad3db72
or-patterns: syntax: adjust parser removing a hack.
Centril Aug 27, 2019
424492a
or-patterns: syntax: adjust pretty printing.
Centril Aug 27, 2019
76625eb
or-patterns: syntax: adjust derive, format, and building.
Centril Aug 27, 2019
3fccbac
or-patterns: adjust librustc_lint.
Centril Aug 27, 2019
d8ef907
or-patterns: adjust lowering of `ast::Arm` & `ast::ExprKind::Let`.
Centril Aug 28, 2019
a867c5f
resolve: merge `resolve_pats` and `resolve_pattern_top`.
Centril Sep 1, 2019
be95dee
or-patterns: adjust save_analysis wrt. `process_var_decl{_multi}`.
Centril Sep 2, 2019
d70b0c5
or-patterns: fix pprust-expr-roundtrip due to AST change.
Centril Sep 3, 2019
a7db1a4
or-patterns: address review comments.
Centril Sep 4, 2019
0341b78
resolve: bool -> enum PatBoundCtx
Centril Sep 4, 2019
16ba502
or-patterns: fix fallout from #664128.
Centril Sep 5, 2019
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
resolve: add tests for already-bound check.
  • Loading branch information
Centril committed Sep 5, 2019
commit 498ec5952062bac854eae7cb4e5152bb648dfe35
45 changes: 45 additions & 0 deletions src/test/ui/or-patterns/already-bound-name.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
// This test ensures that the "already bound identifier in a product pattern"
// correctly accounts for or-patterns.

#![allow(warnings)]
#![feature(or_patterns)]

enum E<T> { A(T, T), B(T) }

use E::*;

fn main() {
let (a, a) = (0, 1); // Standard duplication without an or-pattern.
//~^ ERROR identifier `a` is bound more than once in the same pattern

let (a, A(a, _) | B(a)) = (0, A(1, 2));
//~^ ERROR identifier `a` is bound more than once in the same pattern
//~| ERROR identifier `a` is bound more than once in the same pattern

let (A(a, _) | B(a), a) = (A(0, 1), 2);
//~^ ERROR identifier `a` is bound more than once in the same pattern

let A(a, a) | B(a) = A(0, 1);
//~^ ERROR identifier `a` is bound more than once in the same pattern

let B(a) | A(a, a) = A(0, 1);
//~^ ERROR identifier `a` is bound more than once in the same pattern

match A(0, 1) {
B(a) | A(a, a) => {} // Let's ensure `match` has no funny business.
//~^ ERROR identifier `a` is bound more than once in the same pattern
}

let B(A(a, _) | B(a)) | A(a, A(a, _) | B(a)) = B(B(1));
//~^ ERROR identifier `a` is bound more than once in the same pattern
//~| ERROR identifier `a` is bound more than once in the same pattern
//~| ERROR mismatched types

let B(_) | A(A(a, _) | B(a), A(a, _) | B(a)) = B(B(1));
//~^ ERROR identifier `a` is bound more than once in the same pattern
//~| ERROR identifier `a` is bound more than once in the same pattern

let B(A(a, _) | B(a)) | A(A(a, _) | B(a), A(a, _) | B(a)) = B(B(1));
//~^ ERROR identifier `a` is bound more than once in the same pattern
//~| ERROR identifier `a` is bound more than once in the same pattern
}
91 changes: 91 additions & 0 deletions src/test/ui/or-patterns/already-bound-name.stderr
Original file line number Diff line number Diff line change
@@ -0,0 +1,91 @@
error[E0416]: identifier `a` is bound more than once in the same pattern
--> $DIR/already-bound-name.rs:12:13
|
LL | let (a, a) = (0, 1); // Standard duplication without an or-pattern.
| ^ used in a pattern more than once

error[E0416]: identifier `a` is bound more than once in the same pattern
--> $DIR/already-bound-name.rs:15:15
|
LL | let (a, A(a, _) | B(a)) = (0, A(1, 2));
| ^ used in a pattern more than once

error[E0416]: identifier `a` is bound more than once in the same pattern
--> $DIR/already-bound-name.rs:15:25
|
LL | let (a, A(a, _) | B(a)) = (0, A(1, 2));
| ^ used in a pattern more than once

error[E0416]: identifier `a` is bound more than once in the same pattern
--> $DIR/already-bound-name.rs:19:26
|
LL | let (A(a, _) | B(a), a) = (A(0, 1), 2);
| ^ used in a pattern more than once

error[E0416]: identifier `a` is bound more than once in the same pattern
--> $DIR/already-bound-name.rs:22:14
|
LL | let A(a, a) | B(a) = A(0, 1);
| ^ used in a pattern more than once

error[E0416]: identifier `a` is bound more than once in the same pattern
--> $DIR/already-bound-name.rs:25:21
|
LL | let B(a) | A(a, a) = A(0, 1);
| ^ used in a pattern more than once

error[E0416]: identifier `a` is bound more than once in the same pattern
--> $DIR/already-bound-name.rs:29:21
|
LL | B(a) | A(a, a) => {} // Let's ensure `match` has no funny business.
| ^ used in a pattern more than once

error[E0416]: identifier `a` is bound more than once in the same pattern
--> $DIR/already-bound-name.rs:33:36
|
LL | let B(A(a, _) | B(a)) | A(a, A(a, _) | B(a)) = B(B(1));
| ^ used in a pattern more than once

error[E0416]: identifier `a` is bound more than once in the same pattern
--> $DIR/already-bound-name.rs:33:46
|
LL | let B(A(a, _) | B(a)) | A(a, A(a, _) | B(a)) = B(B(1));
| ^ used in a pattern more than once

error[E0416]: identifier `a` is bound more than once in the same pattern
--> $DIR/already-bound-name.rs:38:36
|
LL | let B(_) | A(A(a, _) | B(a), A(a, _) | B(a)) = B(B(1));
| ^ used in a pattern more than once

error[E0416]: identifier `a` is bound more than once in the same pattern
--> $DIR/already-bound-name.rs:38:46
|
LL | let B(_) | A(A(a, _) | B(a), A(a, _) | B(a)) = B(B(1));
| ^ used in a pattern more than once

error[E0416]: identifier `a` is bound more than once in the same pattern
--> $DIR/already-bound-name.rs:42:49
|
LL | let B(A(a, _) | B(a)) | A(A(a, _) | B(a), A(a, _) | B(a)) = B(B(1));
| ^ used in a pattern more than once

error[E0416]: identifier `a` is bound more than once in the same pattern
--> $DIR/already-bound-name.rs:42:59
|
LL | let B(A(a, _) | B(a)) | A(A(a, _) | B(a), A(a, _) | B(a)) = B(B(1));
| ^ used in a pattern more than once

error[E0308]: mismatched types
--> $DIR/already-bound-name.rs:33:31
|
LL | let B(A(a, _) | B(a)) | A(a, A(a, _) | B(a)) = B(B(1));
| ^ expected integer, found enum `E`
|
= note: expected type `{integer}`
found type `E<{integer}>`

error: aborting due to 14 previous errors

Some errors have detailed explanations: E0308, E0416.
For more information about an error, try `rustc --explain E0308`.