diff options
author | bravomikekilo <[email protected]> | 2019-08-14 04:55:21 +0100 |
---|---|---|
committer | bravomikekilo <[email protected]> | 2019-08-14 04:55:21 +0100 |
commit | 2bebdf0b372b23c3766fc08b345012870ae768c9 (patch) | |
tree | 7d242e820b9757e8c9b49f81a0d8ae2d2ae0d5f1 /crates/ra_parser/src/grammar | |
parent | 978e3e384b045ea72ba952e7f94a2a4c82297e66 (diff) |
fix error of RangeFrom in for-loop
Diffstat (limited to 'crates/ra_parser/src/grammar')
-rw-r--r-- | crates/ra_parser/src/grammar/expressions/atom.rs | 18 |
1 files changed, 17 insertions, 1 deletions
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 | |||
110 | p.bump(); | 110 | p.bump(); |
111 | block_expr(p, Some(m)) | 111 | block_expr(p, Some(m)) |
112 | } | 112 | } |
113 | T!['{'] => block_expr(p, None), | 113 | T!['{'] => { |
114 | if r.forbid_structs { | ||
115 | return None; | ||
116 | } else { | ||
117 | block_expr(p, None) | ||
118 | } | ||
119 | } | ||
114 | T![return] => return_expr(p), | 120 | T![return] => return_expr(p), |
115 | T![continue] => continue_expr(p), | 121 | T![continue] => continue_expr(p), |
116 | T![break] => break_expr(p, r), | 122 | T![break] => break_expr(p, r), |
@@ -307,6 +313,16 @@ fn while_expr(p: &mut Parser, m: Option<Marker>) -> CompletedMarker { | |||
307 | // fn foo() { | 313 | // fn foo() { |
308 | // for x in [] {}; | 314 | // for x in [] {}; |
309 | // } | 315 | // } |
316 | |||
317 | // test for_range_block | ||
318 | // fn foo() { | ||
319 | // for x in 0 .. { | ||
320 | // break; | ||
321 | // } | ||
322 | // for _x in 0 .. (0 .. {1 + 2}).sum::<u32>() { | ||
323 | // break; | ||
324 | // } | ||
325 | // } | ||
310 | fn for_expr(p: &mut Parser, m: Option<Marker>) -> CompletedMarker { | 326 | fn for_expr(p: &mut Parser, m: Option<Marker>) -> CompletedMarker { |
311 | assert!(p.at(T![for])); | 327 | assert!(p.at(T![for])); |
312 | let m = m.unwrap_or_else(|| p.start()); | 328 | let m = m.unwrap_or_else(|| p.start()); |