summaryrefslogtreecommitdiffstats
path: root/tests/ui/parser/recover/recover-for-loop-parens-around-head.fixed
diff options
context:
space:
mode:
Diffstat (limited to 'tests/ui/parser/recover/recover-for-loop-parens-around-head.fixed')
-rw-r--r--tests/ui/parser/recover/recover-for-loop-parens-around-head.fixed15
1 files changed, 15 insertions, 0 deletions
diff --git a/tests/ui/parser/recover/recover-for-loop-parens-around-head.fixed b/tests/ui/parser/recover/recover-for-loop-parens-around-head.fixed
new file mode 100644
index 000000000..6afc2d993
--- /dev/null
+++ b/tests/ui/parser/recover/recover-for-loop-parens-around-head.fixed
@@ -0,0 +1,15 @@
+// run-rustfix
+// Here we test that the parser is able to recover in a situation like
+// `for ( $pat in $expr )` since that is familiar syntax in other languages.
+// Instead we suggest that the user writes `for $pat in $expr`.
+
+#![deny(unused)] // Make sure we don't trigger `unused_parens`.
+
+fn main() {
+ let vec = vec![1, 2, 3];
+
+ for _elem in vec {
+ //~^ ERROR unexpected parentheses surrounding `for` loop head
+ const _RECOVERY_WITNESS: u32 = 0u32; //~ ERROR mismatched types
+ }
+}