From 2bebdf0b372b23c3766fc08b345012870ae768c9 Mon Sep 17 00:00:00 2001
From: bravomikekilo <bmk1221@126.com>
Date: Wed, 14 Aug 2019 11:55:21 +0800
Subject: fix error of RangeFrom in for-loop

---
 crates/ra_parser/src/grammar/expressions/atom.rs | 18 +++++++++++++++++-
 1 file changed, 17 insertions(+), 1 deletion(-)

(limited to 'crates/ra_parser/src')

diff --git a/crates/ra_parser/src/grammar/expressions/atom.rs b/crates/ra_parser/src/grammar/expressions/atom.rs
index d98953a7e..6e25e3cb4 100644
--- a/crates/ra_parser/src/grammar/expressions/atom.rs
+++ b/crates/ra_parser/src/grammar/expressions/atom.rs
@@ -110,7 +110,13 @@ pub(super) fn atom_expr(p: &mut Parser, r: Restrictions) -> Option<(CompletedMar
             p.bump();
             block_expr(p, Some(m))
         }
-        T!['{'] => block_expr(p, None),
+        T!['{'] => {
+            if r.forbid_structs {
+                return None;
+            } else {
+                block_expr(p, None)
+            }
+        }
         T![return] => return_expr(p),
         T![continue] => continue_expr(p),
         T![break] => break_expr(p, r),
@@ -307,6 +313,16 @@ fn while_expr(p: &mut Parser, m: Option<Marker>) -> CompletedMarker {
 // fn foo() {
 //     for x in [] {};
 // }
+
+// test for_range_block
+// fn foo() {
+//    for x in 0 .. {
+//        break;
+//    }
+//    for _x in 0 .. (0 .. {1 + 2}).sum::<u32>() {
+//        break;
+//    }
+// }
 fn for_expr(p: &mut Parser, m: Option<Marker>) -> CompletedMarker {
     assert!(p.at(T![for]));
     let m = m.unwrap_or_else(|| p.start());
-- 
cgit v1.2.3


From 4f31fed362e1bb08f748b188eedc0bdc5a070bee Mon Sep 17 00:00:00 2001
From: bravomikekilo <bmk1221@126.com>
Date: Wed, 14 Aug 2019 21:20:04 +0800
Subject: fix test position

---
 crates/ra_parser/src/grammar/expressions/atom.rs | 16 ++++++----------
 1 file changed, 6 insertions(+), 10 deletions(-)

(limited to 'crates/ra_parser/src')

diff --git a/crates/ra_parser/src/grammar/expressions/atom.rs b/crates/ra_parser/src/grammar/expressions/atom.rs
index 6e25e3cb4..50c70b3b3 100644
--- a/crates/ra_parser/src/grammar/expressions/atom.rs
+++ b/crates/ra_parser/src/grammar/expressions/atom.rs
@@ -111,6 +111,12 @@ pub(super) fn atom_expr(p: &mut Parser, r: Restrictions) -> Option<(CompletedMar
             block_expr(p, Some(m))
         }
         T!['{'] => {
+            // test for_range_from
+            // fn foo() {
+            //    for x in 0 .. {
+            //        break;
+            //    }
+            // }
             if r.forbid_structs {
                 return None;
             } else {
@@ -313,16 +319,6 @@ fn while_expr(p: &mut Parser, m: Option<Marker>) -> CompletedMarker {
 // fn foo() {
 //     for x in [] {};
 // }
-
-// test for_range_block
-// fn foo() {
-//    for x in 0 .. {
-//        break;
-//    }
-//    for _x in 0 .. (0 .. {1 + 2}).sum::<u32>() {
-//        break;
-//    }
-// }
 fn for_expr(p: &mut Parser, m: Option<Marker>) -> CompletedMarker {
     assert!(p.at(T![for]));
     let m = m.unwrap_or_else(|| p.start());
-- 
cgit v1.2.3