frontend: provide contextual source repair advice
This commit is contained in:
1 parent
008867fe48
commit
2c6c7a3dcd
37 files changed
+562
-24
No files matched your search
@@ -112,6 +112,32 @@ Reported in trap records (spec 01 §6), not by the verifier.
|
||||
| T0009 | trap.unsafe_precondition | Unsafe precondition violated (detected) |
|
||||
| T0010 | trap.foreign_iref | An `iref` was used to access a graph it does not belong to |
|
||||
|
||||
## Source repair candidate kinds
|
||||
|
||||
These stable kinds use spec 10 §3. `hint` MUST equal the registered text. Alternatives, when present, MUST use the unit below; hints alone are not replacements. Advice is selected at the rejecting rule, never by parsing diagnostic prose. Existing illustrative/non-source kinds are outside this registry.
|
||||
|
||||
| Kind | Code | Hint | Alternatives unit |
|
||||
|---|---|---|---|
|
||||
| `boolean_negation` | E7001 | Aji boolean negation is `not`; integer complement is not boolean negation. | none |
|
||||
| `annotate_var_type` | E7001 | Write an explicit type: `var name: T = expression;`. `let` may infer its type. | none |
|
||||
| `slice_mut_type` | E7001 | Write `slice_mut<T>` for a mutable slice type. | complete type |
|
||||
| `slice_ref_type` | E7001 | Write `slice<T>` for a shared slice type. | complete type |
|
||||
| `explicit_range_end` | E7001 | Write both slice bounds: `receiver[start..end]`; choose the upper bound explicitly. | none |
|
||||
| `borrow_argument` | E7001 | Write `ref place` or `mut place` for an inline borrow argument. | prefix |
|
||||
| `borrow_binding` | E7001 | Bind a borrow with `ref name = place;` or `mut name = place;`, rather than a let/var initializer. | none |
|
||||
| `zero_storage` | E7001 | `zero` is only a whole var initializer: `var name: T = zero;`; T must be zeroable. | none |
|
||||
| `numeric_cast_modes` | E7005 | Choose `as!` for a checked conversion (T0006 on overflow) or `as%` for a wrapping conversion. | operator |
|
||||
|
||||
Closed applicability:
|
||||
|
||||
- `boolean_negation`: lone `!` rejected at primary-expression start. Excludes `!=`, `as!` and `!` rejected after an expression (such as `panic!()`). It does not assert that the operand is boolean.
|
||||
- `annotate_var_type`: `=` found where a `var` declaration requires its type colon. No advice for `let`, a missing name or other found tokens; no initializer type is guessed.
|
||||
- Slice type kinds: a bare `mut`/`ref` parsed in type position immediately followed by `slice`. Attach at that `slice` token, retaining the caller's expected token. Emit one complete-type alternative only if the following `slice<...>` fragment parses as a single-argument slice type. Keep its token spellings (including nested types), remove comments/whitespace and separate adjacent word/number tokens by one space; replace the outer spelling by `slice_mut`/`slice` respectively. An incomplete/malformed fragment has hint only. Speculative parsing MUST NOT mutate the original tokens, including `>>`.
|
||||
- `explicit_range_end`: `]` immediately after `..` in index syntax. No advice for an omitted start, inclusive `..=`, missing for-loop bound or another malformed expression. No receiver or `.len` alternative is guessed.
|
||||
- Borrow kinds: `&` rejected as the first token of a call argument, excluding enum variant payloads (`borrow_argument`) or let/typed-var initializer (`borrow_binding`). Other expression contexts, including the second `&` in `a && b`, have no borrow advice. For an argument whose following token is an ordinary identifier, emit `["ref"]`; for `&mut` followed by an ordinary identifier, emit `["mut"]`. Other operands have hint only, including `&&x`. These prefixes do not imply that the referent/mode verifies; binding advice has no prefix alternative.
|
||||
- `zero_storage`: keyword `zero` rejected at primary-expression start. Accepted typed-var zero initialization has no advice.
|
||||
- `numeric_cast_modes`: integer `as` rejected by the lossless-widening rule, with unchanged `from`/`to`. Alternatives MUST be `["as!", "as%"]`. Non-integer casts and other E7005 rules have no such candidate.
|
||||
|
||||
## E7006 reasons
|
||||
|
||||
These stable categories are part of the diagnostic API (spec 15 §10), not new rejection rules. One reason is selected at the rejection site; messages remain optional explanation.
|
||||
|
||||
Reference in new issue
Block a user