05.4 Diagnostics you will see
Common name and import errors—and how to fix them without ritual."
Diagnostics you will see
If you only read one page in this chapter, read this. These diagnostics are your daily companions.
Ambiguous import
Section titled “Ambiguous import”Symptom: two imports expose the same name.
Fix: alias at least one (use a.Parser as AParser).
Unresolved name
Section titled “Unresolved name”Symptom: symbol not found in scope.
Checklist:
- Typo in identifier
- Missing
use - Symbol not
pubin defining module - Wrong module path vs file layout
Cannot access private item
Section titled “Cannot access private item”Symptom: using something that exists but is not exported.
Fix: mark pub at the definition (if it should be API) or stop reaching into another module’s internals.
File-scoped module violations
Section titled “File-scoped module violations”Symptom: extra mod in a file-scoped module file.
Fix: move nested modules to another file or drop file-scoped declaration.
Reading the report
Section titled “Reading the report”CLI and LSP share miette-style reports. Read:
- Span — which file/line
- Code — diagnostic id when present (registry: diagnostic code registry)
flowchart TD
D[Diagnostic] --> R[Read span + message]
R --> C{Import or visibility?}
C -->|import| U[Fix use / alias]
C -->|visibility| P[pub or boundary]
C -->|path| M[Fix mod / file layout]