aboutsummaryrefslogtreecommitdiff
path: root/crates/ra_parser/src/grammar
diff options
context:
space:
mode:
authorbors[bot] <26634292+bors[bot]@users.noreply.github.com>2020-06-23 15:55:03 +0100
committerGitHub <[email protected]>2020-06-23 15:55:03 +0100
commitc0b9ae55034fd29a86f52822634fcb1c1303e7f9 (patch)
tree4a97c8939ae27fa3c3f30fa46729383a71b810e7 /crates/ra_parser/src/grammar
parent3e09dbba94de103d4d7a211ec578b049d0adc3c7 (diff)
parent76ddface089886c88b8b29e3893119f38ef26aab (diff)
Merge #5004
5004: Fix panic in split/merge import assists r=matklad a=lnicola Fixes #4368 #4905 Not sure if this is the best solution here. Maybe the `make` functions should be fallible? We generally seem to be playing whack-a-mole with panics in assists, although most of them are `unwrap`s in the assist code. Co-authored-by: LaurenČ›iu Nicola <[email protected]>
Diffstat (limited to 'crates/ra_parser/src/grammar')
-rw-r--r--crates/ra_parser/src/grammar/paths.rs8
1 files changed, 8 insertions, 0 deletions
diff --git a/crates/ra_parser/src/grammar/paths.rs b/crates/ra_parser/src/grammar/paths.rs
index 428aa711e..fd51189d5 100644
--- a/crates/ra_parser/src/grammar/paths.rs
+++ b/crates/ra_parser/src/grammar/paths.rs
@@ -73,8 +73,10 @@ fn path_segment(p: &mut Parser, mode: Mode, first: bool) {
73 } 73 }
74 p.expect(T![>]); 74 p.expect(T![>]);
75 } else { 75 } else {
76 let mut empty = true;
76 if first { 77 if first {
77 p.eat(T![::]); 78 p.eat(T![::]);
79 empty = false;
78 } 80 }
79 match p.current() { 81 match p.current() {
80 IDENT => { 82 IDENT => {
@@ -86,6 +88,12 @@ fn path_segment(p: &mut Parser, mode: Mode, first: bool) {
86 T![self] | T![super] | T![crate] => p.bump_any(), 88 T![self] | T![super] | T![crate] => p.bump_any(),
87 _ => { 89 _ => {
88 p.err_recover("expected identifier", items::ITEM_RECOVERY_SET); 90 p.err_recover("expected identifier", items::ITEM_RECOVERY_SET);
91 if empty {
92 // test_err empty_segment
93 // use crate::;
94 m.abandon(p);
95 return;
96 }
89 } 97 }
90 }; 98 };
91 } 99 }