aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAleksey Kladov <[email protected]>2018-08-27 19:10:02 +0100
committerAleksey Kladov <[email protected]>2018-08-27 19:10:02 +0100
commitb79c8b6d8a3b38c94de992a54ffb9055c1ad6f31 (patch)
tree4979b92b8f4e41bf55e4e1404a8cb183c034d6d7
parent7f4b07a9076a38b2bd0fa0518ba090311dcaf880 (diff)
Fix error blocks
-rw-r--r--crates/libanalysis/src/lib.rs1
-rw-r--r--crates/libanalysis/tests/tests.rs3
-rw-r--r--crates/libsyntax2/src/grammar/expressions/atom.rs4
-rw-r--r--crates/libsyntax2/src/grammar/expressions/mod.rs1
-rw-r--r--crates/libsyntax2/src/grammar/items/structs.rs4
-rw-r--r--crates/libsyntax2/src/grammar/items/traits.rs8
6 files changed, 20 insertions, 1 deletions
diff --git a/crates/libanalysis/src/lib.rs b/crates/libanalysis/src/lib.rs
index 49c39e1f3..7a34d354e 100644
--- a/crates/libanalysis/src/lib.rs
+++ b/crates/libanalysis/src/lib.rs
@@ -130,6 +130,7 @@ impl WorldState {
130 } 130 }
131} 131}
132 132
133#[derive(Debug)]
133pub enum QuickFix { 134pub enum QuickFix {
134 CreateFile(PathBuf), 135 CreateFile(PathBuf),
135} 136}
diff --git a/crates/libanalysis/tests/tests.rs b/crates/libanalysis/tests/tests.rs
index b3c357b02..7c2950ccc 100644
--- a/crates/libanalysis/tests/tests.rs
+++ b/crates/libanalysis/tests/tests.rs
@@ -52,7 +52,8 @@ fn test_unresolved_module_diagnostic() {
52 let snap = world.snapshot(|_id, _path| None); 52 let snap = world.snapshot(|_id, _path| None);
53 let diagnostics = snap.diagnostics(FileId(1)).unwrap(); 53 let diagnostics = snap.diagnostics(FileId(1)).unwrap();
54 assert_eq_dbg( 54 assert_eq_dbg(
55 r#"[Diagnostic { range: [4; 7), msg: "unresolved module" }]"#, 55 r#"[(Diagnostic { range: [4; 7), msg: "unresolved module" },
56 Some(CreateFile("../foo.rs")))]"#,
56 &diagnostics, 57 &diagnostics,
57 ); 58 );
58} 59}
diff --git a/crates/libsyntax2/src/grammar/expressions/atom.rs b/crates/libsyntax2/src/grammar/expressions/atom.rs
index e83c82c92..ab4aa49d2 100644
--- a/crates/libsyntax2/src/grammar/expressions/atom.rs
+++ b/crates/libsyntax2/src/grammar/expressions/atom.rs
@@ -269,6 +269,10 @@ fn match_arm_list(p: &mut Parser) {
269 let m = p.start(); 269 let m = p.start();
270 p.eat(L_CURLY); 270 p.eat(L_CURLY);
271 while !p.at(EOF) && !p.at(R_CURLY) { 271 while !p.at(EOF) && !p.at(R_CURLY) {
272 if p.at(L_CURLY) {
273 error_block(p, "expected match arm");
274 continue;
275 }
272 // test match_arms_commas 276 // test match_arms_commas
273 // fn foo() { 277 // fn foo() {
274 // match () { 278 // match () {
diff --git a/crates/libsyntax2/src/grammar/expressions/mod.rs b/crates/libsyntax2/src/grammar/expressions/mod.rs
index fb702a398..9379ed938 100644
--- a/crates/libsyntax2/src/grammar/expressions/mod.rs
+++ b/crates/libsyntax2/src/grammar/expressions/mod.rs
@@ -433,6 +433,7 @@ fn named_field_list(p: &mut Parser) {
433 p.bump(); 433 p.bump();
434 expr(p); 434 expr(p);
435 } 435 }
436 L_CURLY => error_block(p, "expected a field"),
436 _ => p.err_and_bump("expected identifier"), 437 _ => p.err_and_bump("expected identifier"),
437 } 438 }
438 if !p.at(R_CURLY) { 439 if !p.at(R_CURLY) {
diff --git a/crates/libsyntax2/src/grammar/items/structs.rs b/crates/libsyntax2/src/grammar/items/structs.rs
index 93d3381f8..180205393 100644
--- a/crates/libsyntax2/src/grammar/items/structs.rs
+++ b/crates/libsyntax2/src/grammar/items/structs.rs
@@ -56,6 +56,10 @@ fn enum_variant_list(p: &mut Parser) {
56 let m = p.start(); 56 let m = p.start();
57 p.bump(); 57 p.bump();
58 while !p.at(EOF) && !p.at(R_CURLY) { 58 while !p.at(EOF) && !p.at(R_CURLY) {
59 if p.at(L_CURLY) {
60 error_block(p, "expected enum variant");
61 continue;
62 }
59 let var = p.start(); 63 let var = p.start();
60 attributes::outer_attributes(p); 64 attributes::outer_attributes(p);
61 if p.at(IDENT) { 65 if p.at(IDENT) {
diff --git a/crates/libsyntax2/src/grammar/items/traits.rs b/crates/libsyntax2/src/grammar/items/traits.rs
index 3853ccaab..01b79e3c9 100644
--- a/crates/libsyntax2/src/grammar/items/traits.rs
+++ b/crates/libsyntax2/src/grammar/items/traits.rs
@@ -30,6 +30,10 @@ fn trait_item_list(p: &mut Parser) {
30 let m = p.start(); 30 let m = p.start();
31 p.bump(); 31 p.bump();
32 while !p.at(EOF) && !p.at(R_CURLY) { 32 while !p.at(EOF) && !p.at(R_CURLY) {
33 if p.at(L_CURLY) {
34 error_block(p, "expected an item");
35 continue;
36 }
33 item_or_macro(p, true, ItemFlavor::Trait); 37 item_or_macro(p, true, ItemFlavor::Trait);
34 } 38 }
35 p.expect(R_CURLY); 39 p.expect(R_CURLY);
@@ -76,6 +80,10 @@ fn impl_item_list(p: &mut Parser) {
76 p.bump(); 80 p.bump();
77 81
78 while !p.at(EOF) && !p.at(R_CURLY) { 82 while !p.at(EOF) && !p.at(R_CURLY) {
83 if p.at(L_CURLY) {
84 error_block(p, "expected an item");
85 continue;
86 }
79 item_or_macro(p, true, ItemFlavor::Mod); 87 item_or_macro(p, true, ItemFlavor::Mod);
80 } 88 }
81 p.expect(R_CURLY); 89 p.expect(R_CURLY);