Skip to content

Commit

Permalink
Update tests
Browse files Browse the repository at this point in the history
  • Loading branch information
ShE3py committed Apr 12, 2024
1 parent 360de09 commit c82d619
Show file tree
Hide file tree
Showing 7 changed files with 513 additions and 122 deletions.
51 changes: 47 additions & 4 deletions tests/ui/parser/recover/recover-pat-exprs.rs
Original file line number Diff line number Diff line change
@@ -1,14 +1,57 @@
// FieldExpression, TupleIndexingExpression
fn field_access() {
match 0 {
x => (),
x.y => (), //~ error: expected a pattern, found an expression
x.0 => (), //~ error: expected a pattern, found an expression
x._0 => (), //~ error: expected a pattern, found an expression
x.0.1 => (), //~ error: expected a pattern, found an expression
x.4.y.17.__z => (), //~ error: expected a pattern, found an expression
x.0e0 => (), //~ error: expected one of `=>`, `@`, `if`, or `|`, found `.`
}
}

// MethodCallExpression, CallExpression, ErrorPropagationExpression
fn method_call() {
match 0 {
x.f() => (), //~ error: expected a pattern, found an expression
x._f() => (), //~ error: expected a pattern, found an expression
x? => (), //~ error: expected a pattern, found an expression
().f() => (), //~ error: expected a pattern, found an expression
(0, x)?.f() => (), //~ error: expected a pattern, found an expression
x.f().g() => (), //~ error: expected a pattern, found an expression
0.f()?.g()?? => (), //~ error: expected a pattern, found an expression
}
}

// TypeCastExpression
fn type_cast() {
match 0 {
x as usize => (), //~ error: expected a pattern, found an expression
0 as usize => (), //~ error: expected a pattern, found an expression
x.f().0.4 as f32 => (), //~ error: expected a pattern, found an expression
}
}

// ArithmeticOrLogicalExpression
fn operator() {
match 0 {
1 + 1 => (), //~ error: expected a pattern, found an expression
(1 + 2) * 3 => (), //~ error: expected a pattern, found an expression
}
}

fn main() {
match u8::MAX {
u8::MAX.abs() => (),
//~^ error: expected a pattern, found a method call
//~^ error: expected a pattern, found an expression
x.sqrt() @ .. => (),
//~^ error: expected a pattern, found a method call
//~^ error: expected a pattern, found an expression
//~| error: left-hand side of `@` must be a binding
z @ w @ v.u() => (),
//~^ error: expected a pattern, found a method call
//~^ error: expected a pattern, found an expression
y.ilog(3) => (),
//~^ error: expected a pattern, found a method call
//~^ error: expected a pattern, found an expression
n + 1 => (),
//~^ error: expected a pattern, found an expression
("".f() + 14 * 8) => (),
Expand Down
Loading

0 comments on commit c82d619

Please sign in to comment.