diff --git a/crates/libanalysis/src/lib.rs b/crates/libanalysis/src/lib.rs index 49c39e1f36..7a34d354ef 100644 --- a/crates/libanalysis/src/lib.rs +++ b/crates/libanalysis/src/lib.rs @@ -130,6 +130,7 @@ impl WorldState { } } +#[derive(Debug)] pub enum QuickFix { CreateFile(PathBuf), } diff --git a/crates/libanalysis/tests/tests.rs b/crates/libanalysis/tests/tests.rs index b3c357b027..7c2950cccb 100644 --- a/crates/libanalysis/tests/tests.rs +++ b/crates/libanalysis/tests/tests.rs @@ -52,7 +52,8 @@ fn test_unresolved_module_diagnostic() { let snap = world.snapshot(|_id, _path| None); let diagnostics = snap.diagnostics(FileId(1)).unwrap(); assert_eq_dbg( - r#"[Diagnostic { range: [4; 7), msg: "unresolved module" }]"#, + r#"[(Diagnostic { range: [4; 7), msg: "unresolved module" }, + Some(CreateFile("../foo.rs")))]"#, &diagnostics, ); } diff --git a/crates/libsyntax2/src/grammar/expressions/atom.rs b/crates/libsyntax2/src/grammar/expressions/atom.rs index e83c82c92d..ab4aa49d2d 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) { let m = p.start(); p.eat(L_CURLY); while !p.at(EOF) && !p.at(R_CURLY) { + if p.at(L_CURLY) { + error_block(p, "expected match arm"); + continue; + } // test match_arms_commas // fn foo() { // match () { diff --git a/crates/libsyntax2/src/grammar/expressions/mod.rs b/crates/libsyntax2/src/grammar/expressions/mod.rs index fb702a3987..9379ed9385 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) { p.bump(); expr(p); } + L_CURLY => error_block(p, "expected a field"), _ => p.err_and_bump("expected identifier"), } if !p.at(R_CURLY) { diff --git a/crates/libsyntax2/src/grammar/items/structs.rs b/crates/libsyntax2/src/grammar/items/structs.rs index 93d3381f8b..180205393a 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) { let m = p.start(); p.bump(); while !p.at(EOF) && !p.at(R_CURLY) { + if p.at(L_CURLY) { + error_block(p, "expected enum variant"); + continue; + } let var = p.start(); attributes::outer_attributes(p); if p.at(IDENT) { diff --git a/crates/libsyntax2/src/grammar/items/traits.rs b/crates/libsyntax2/src/grammar/items/traits.rs index 3853ccaab7..01b79e3c96 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) { let m = p.start(); p.bump(); while !p.at(EOF) && !p.at(R_CURLY) { + if p.at(L_CURLY) { + error_block(p, "expected an item"); + continue; + } item_or_macro(p, true, ItemFlavor::Trait); } p.expect(R_CURLY); @@ -76,6 +80,10 @@ fn impl_item_list(p: &mut Parser) { p.bump(); while !p.at(EOF) && !p.at(R_CURLY) { + if p.at(L_CURLY) { + error_block(p, "expected an item"); + continue; + } item_or_macro(p, true, ItemFlavor::Mod); } p.expect(R_CURLY);