From bff0be37845a96010fa2161bbf137fadfe763ae5 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Esteban=20K=C3=BCber?= Date: Mon, 29 Apr 2019 14:35:09 -0700 Subject: [PATCH] Add test case for #47287 --- src/test/ui/parser/expr-as-stmt.fixed | 6 ++++++ src/test/ui/parser/expr-as-stmt.rs | 6 ++++++ src/test/ui/parser/expr-as-stmt.stderr | 14 +++++++++++++- 3 files changed, 25 insertions(+), 1 deletion(-) diff --git a/src/test/ui/parser/expr-as-stmt.fixed b/src/test/ui/parser/expr-as-stmt.fixed index a0abd00a15c..123f06e7707 100644 --- a/src/test/ui/parser/expr-as-stmt.fixed +++ b/src/test/ui/parser/expr-as-stmt.fixed @@ -31,4 +31,10 @@ fn qux(a: Option, b: Option) -> bool { if let Some(y) = a { true } else { false } } +fn moo(x: u32) -> bool { + (match x { + _ => 1, + }) > 0 //~ ERROR ambiguous parse +} + fn main() {} diff --git a/src/test/ui/parser/expr-as-stmt.rs b/src/test/ui/parser/expr-as-stmt.rs index cf2e7266a4a..6f713c08940 100644 --- a/src/test/ui/parser/expr-as-stmt.rs +++ b/src/test/ui/parser/expr-as-stmt.rs @@ -31,4 +31,10 @@ fn qux(a: Option, b: Option) -> bool { if let Some(y) = a { true } else { false } } +fn moo(x: u32) -> bool { + match x { + _ => 1, + } > 0 //~ ERROR ambiguous parse +} + fn main() {} diff --git a/src/test/ui/parser/expr-as-stmt.stderr b/src/test/ui/parser/expr-as-stmt.stderr index 03119605432..be577b8f36f 100644 --- a/src/test/ui/parser/expr-as-stmt.stderr +++ b/src/test/ui/parser/expr-as-stmt.stderr @@ -30,6 +30,18 @@ LL | if let Some(x) = a { true } else { false } LL | && | ^^ +error: ambiguous parse + --> $DIR/expr-as-stmt.rs:37:7 + | +LL | } > 0 + | ^ +help: parenthesis are required to parse this as an expression + | +LL | (match x { +LL | _ => 1, +LL | }) > 0 + | + error[E0308]: mismatched types --> $DIR/expr-as-stmt.rs:7:6 | @@ -74,7 +86,7 @@ LL | { 3 } * 3 | | | help: parenthesis are required to parse this as an expression: `({ 3 })` -error: aborting due to 9 previous errors +error: aborting due to 10 previous errors Some errors have detailed explanations: E0308, E0614. For more information about an error, try `rustc --explain E0308`. -- 2.44.0