Improve parsing error for static and const

Example
---
```rust
static C<i32>: u32 = 0;
```
->
```diff
-error 8: missing type for `const` or `static`
+error 8: `static` may not have generic parameters
```

---

```rust
const C = 0;
```
->
```diff
-error 7: missing type for `const` or `static`
+error 7: missing type for `const`
```

---

```rust
static C = 0;
```
->
```diff
-error 8: missing type for `const` or `static`
+error 8: missing type for `static`
```
This commit is contained in:
A4-Tacks 2025-10-06 12:48:38 +08:00
parent a2e6043bfa
commit 216db6d5b4
No known key found for this signature in database
GPG key ID: DBD861323040663B
8 changed files with 50 additions and 4 deletions

View file

@ -824,10 +824,18 @@ mod err {
run_and_expect_errors("test_data/parser/inline/err/misplaced_label_err.rs");
}
#[test]
fn missing_const_type() {
run_and_expect_errors("test_data/parser/inline/err/missing_const_type.rs");
}
#[test]
fn missing_fn_param_type() {
run_and_expect_errors("test_data/parser/inline/err/missing_fn_param_type.rs");
}
#[test]
fn missing_static_type() {
run_and_expect_errors("test_data/parser/inline/err/missing_static_type.rs");
}
#[test]
fn path_item_without_excl() {
run_and_expect_errors("test_data/parser/inline/err/path_item_without_excl.rs");
}