Diagnostic codes¶
Every compiler diagnostic carries a four-character prefix plus
a four-digit number: GP for the parser / lexer, GR for
name resolution, GT for the type checker, GM for match
exhaustiveness, GL for lint framework, GK for the package
manager. Use gos explain <code> for the interactive
version. This page is auto-generated from the catalogue in
xtask/src/main.rs; hand edits are overwritten by
cargo xtask docs-diagnostics.
| Code | Phase | Title |
|---|---|---|
GP0001 |
Parser | unexpected token |
GP0002 |
Parser | unexpected end of input |
GP0003 |
Parser | unterminated delimiter |
GP0004 |
Parser | chained comparison without parentheses |
GP0005 |
Parser | chained range operator |
GP0006 |
Parser | struct literal in scrutinee |
GP0007 |
Parser | pipe right-hand side not callable |
GP0008 |
Parser | assignment outside statement position |
GP0009 |
Parser | expected integer literal |
GP0010 |
Parser | expected string literal |
GP0011 |
Parser | invalid tuple index |
GP0012 |
Parser | malformed label |
GP0013 |
Parser | malformed attribute |
GP0014 |
Parser | malformed use declaration |
GP0015 |
Parser | unexpected construct |
GP0016 |
Parser | reserved extern keyword |
GP0017 |
Parser | parser recursion limit |
GP0018 |
Lexer | malformed token |
GP0019 |
Parser | statement outside entry file |
GP0020 |
Parser | mixed entry forms |
GP0021 |
Parser | malformed format placeholder |
GP0022 |
Parser | unserializable derived field |
GP0023 |
Parser | format argument count mismatch |
GP0024 |
Parser | non-literal format template |
GP0026 |
Parser | inclusive range missing upper bound |
GP0027 |
Parser | $ is not part of the language |
GP0029 |
Parser | match arm missing arrow |
GP0030 |
Parser | match arm missing body |
GP0031 |
Parser | match arm missing separator |
GP0032 |
Parser | removed collection literal |
GP0033 |
Parser | text after a triple-quote opener |
GP0034 |
Parser | missing item type |
GP0035 |
Parser | duplicate slice-pattern rest |
GP0036 |
Parser | duplicate struct-literal spread |
GP0037 |
Parser | refutable let without else |
GP0038 |
Parser | unsupported visibility restriction |
GP0039 |
Parser | serde turbofish names an uncovered type |
GP0040 |
Parser | hyphen in a use path |
GP0041 |
Parser | pipe step with arguments is not a closure |
GP0042 |
Parser | targets written as a parenthesised tuple |
GP0043 |
Parser | mod declaration ended in ; |
GP0044 |
Parser | callable type written as something other than Fn |
GP0045 |
Parser | argument label bound with = |
GP0046 |
Parser | unsafe grants nothing |
GP0047 |
Parser | opaque alias written type X = new T |
GP0048 |
Parser | go is retired |
GP0049 |
Parser | compiler-known call written with a ! |
GP0050 |
Parser | enum representation is not an unsigned width |
GP0051 |
Parser | regex! / sql! moved into their modules |
GT0079 |
Types | pointer wrapper written |
GT0080 |
Types | String::parse called |
GT0081 |
Types | enum representation too narrow for its variants |
GT0082 |
Types | reference passed where a value is taken |
GT0083 |
Types | write through a value that is not a reference |
GT0084 |
Types | impl of a trait the language supplies itself |
GT0085 |
Types | ordered container over a type that writes its own cmp |
GT0086 |
Types | spawn outside a cohort block |
GP0052 |
Parser | build-time validated call without a literal |
GP0056 |
Parser | retired cohort isolation spelling |
GP0053 |
Parser | Display rendering declared as to_string |
GP0054 |
Parser | shared reference in parameter position |
GP0055 |
Parser | shared reference on a call argument |
GR0001 |
Resolve | unresolved name |
GR0002 |
Resolve | wrong namespace |
GR0003 |
Resolve | duplicate item |
GR0004 |
Resolve | duplicate import |
GR0005 |
Resolve | unknown module path |
GR0006 |
Resolve | removed stdlib item |
GR0007 |
Resolve | unknown stdlib item |
GR0017 |
Resolver | break or continue with no loop |
GR0018 |
Resolver | compiler-known call named as a value path |
GR0019 |
Resolver | two dependency packages under one module name |
GR0020 |
Resolver | declaration under a compiler-known call name |
GR0021 |
Resolve | std free call written data-last |
GT0001 |
Types | type mismatch |
GT0002 |
Types | unresolved method |
GT0003 |
Types | unresolved operator |
GT0004 |
Match exhaustiveness | non-exhaustive match |
GT0005 |
Types | non-primitive cast |
GT0044 |
Types | generic return type not inferred |
GT0045 |
Types | question mark not supported here |
GP0001 ¶
Parser - unexpected token
The parser saw a token where it expected a different one. Check for missing punctuation, an unmatched delimiter, or an out-of-place keyword.
GP0002 ¶
Parser - unexpected end of input
The parser reached end-of-file in the middle of a construct. Finish the expression, statement, or item - or remove it.
GP0003 ¶
Parser - unterminated delimiter
A balanced construct (block, tuple, array, string literal) was left unterminated. Add the matching closing delimiter.
GP0004 ¶
Parser - chained comparison without parentheses
Comparison operators like == / != / < are not associative. Parenthesise the operands: (a == b) && (b == c).
GP0005 ¶
Parser - chained range operator
Range operators (.., ..=) are not associative. Parenthesise the operands: (a..b)..c.
GP0006 ¶
Parser - struct literal in scrutinee
A braced struct literal in the scrutinee of if/while/match is ambiguous with the block. Wrap the literal in (...).
GP0007 ¶
Parser - pipe right-hand side not callable
The right-hand side of |> must be a callable: a function reference, a method call, or a closure.
GP0008 ¶
Parser - assignment outside statement position
Assignment (=, +=, …) only appears at statement position. If you need an expression, return the right-hand side directly.
GP0009 ¶
Parser - expected integer literal
An integer literal is required at this position.
GP0010 ¶
Parser - expected string literal
A string literal is required at this position.
GP0011 ¶
Parser - invalid tuple index
A tuple index must be a plain decimal integer (p.0, p.1). Hex, binary, or octal indices are not accepted.
GP0012 ¶
Parser - malformed label
A label identifier is required after the leading '.
GP0013 ¶
Parser - malformed attribute
An attribute is malformed. Accepted forms are #[attr], #[attr(args)], and #[attr = value].
GP0014 ¶
Parser - malformed use declaration
A use declaration could not be parsed. Check the path for stray punctuation or an unfinished brace list.
GP0015 ¶
Parser - unexpected construct
Two consecutive tokens formed something the parser does not recognise.
GP0016 ¶
Parser - reserved extern keyword
The extern keyword is reserved but has no source-level item form. Gossamer's FFI surface is the [rust-bindings] section of project.toml plus the gossamer-binding crate.
GP0017 ¶
Parser - parser recursion limit
An expression exceeded the parser's nesting limit. Split it into smaller helpers.
GP0018 ¶
Lexer - malformed token
The lexer rejected a malformed string, comment, escape, or token spelling.
GP0019 ¶
Parser - statement outside entry file
Executable statements belong in the entry file or inside a function, not in a module body.
GP0020 ¶
Parser - mixed entry forms
An entry file cannot combine bare top-level statements with an explicit fn main.
GP0021 ¶
Parser - malformed format placeholder
A format placeholder must be a binding name, format specification, or positional placeholder.
GP0022 ¶
Parser - unserializable derived field
Automatic serialization cannot be generated for a field with an unsupported type.
GP0023 ¶
Parser - format argument count mismatch
The number of positional arguments must equal the number of positional placeholders.
GP0024 ¶
Parser - non-literal format template
Format macros require a literal template so placeholders can be checked at compile time.
GP0026 ¶
Parser - inclusive range missing upper bound
The inclusive range operator ..= requires an upper bound. Use .. for an open upper end.
GP0027 ¶
Parser - $ is not part of the language
$ used to spell the slot a |> step filled. A step that needs the value in a particular slot is a closure, as in x |> |v| f(a, v); a method already chains, as in x.trim(); a callback is a closure or a function named in value position.
GP0029 ¶
Parser - match arm missing arrow
Add => after the match arm pattern and optional guard.
GP0030 ¶
Parser - match arm missing body
Add the expression or block produced by the match arm.
GP0031 ¶
Parser - match arm missing separator
Separate same-line expression arms with a comma, or start the next arm on a new line.
GP0032 ¶
Parser - removed collection literal
A bracket spelling that used to build a container is no longer syntax. Construct the container through its type: Type::new() or Type::from([a, b, c]).
GP0033 ¶
Parser - text after a triple-quote opener
A multi-line """ literal carried text on the same line as its opening delimiter. The body starts on the next line, and the indentation it shares with the closing """ is stripped from every line.
GP0034 ¶
Parser - missing item type
A const or static item was declared without a type annotation. These items are never inferred from their initialiser, so the type is written after the name: const EPS: f64 = 1e-12.
GP0035 ¶
Parser - duplicate slice-pattern rest
A slice pattern wrote more than one ... One rest binding splits the elements into a prefix and a suffix, as in [first, ..rest, last].
GP0036 ¶
Parser - duplicate struct-literal spread
A struct literal wrote more than one ..base functional update. Keep a single base value and list every overridden field explicitly.
GP0037 ¶
Parser - refutable let without else
A let whose pattern can fail to match was written without an else block. Give the failure a diverging path: let Some(x) = opt else { return }.
GP0038 ¶
Parser - unsupported visibility restriction
The three visibilities are private (no annotation), pub(package), and pub.
GP0039 ¶
Parser - serde turbofish names an uncovered type
A codec is synthesized per concrete struct whose fields the synthesizer can classify. Exchange a concrete struct, read the document dynamically with json::parse, or hand-write the function.
GP0040 ¶
Parser - hyphen in a use path
- is subtraction, never part of an identifier. A dependency's module name is its package name with each - replaced by _, so pgsql-gos is imported as use pgsql_gos.
GP0041 ¶
Parser - pipe step with arguments is not a closure
A |> step that writes its own arguments leaves the piped value no slot. Write it as a closure whose parameter is that slot: x |> |v| f(a, v).
GP0042 ¶
Parser - targets written as a parenthesised tuple
A binding and an assignment both list their targets without parentheses: let a, b = value and a, b = x, y. Parentheses group a pattern that sits beside others - a match arm, a for binding, a parameter, or a nested element of the list.
GP0043 ¶
Parser - mod declaration ended in ;
A statement ends at its newline, and a trailing semicolon is invalid everywhere else in the language. Write mod name.
GP0044 ¶
Parser - callable type written as something other than Fn
The language has one callable type, Fn(args) -> ret. There is no raw function-pointer shape and no FnMut / FnOnce distinction to draw.
GP0045 ¶
Parser - argument label bound with =
Every keyed form in the language binds with : - a struct field, a map entry, a cohort header setting. Write name: value.
GP0046 ¶
Parser - unsafe grants nothing
No operation is withheld outside an unsafe block or from a safe fn. The keyword stays reserved for a future raw-FFI story.
GP0047 ¶
Parser - opaque alias written type X = new T
new reads as allocation to a reader arriving from any other language. Write newtype X = T.
GP0048 ¶
Parser - go is retired
Every goroutine is a spawn attached to the cohort { } it is written inside, which every spawn outside main must have (GT0086). go evaluated its operands at the spawn site, so --fix hoists a computed operand into a temporary.
GP0049 ¶
Parser - compiler-known call written with a !
The set of compiler-known names is closed and recognised at the (, so there is nothing a sigil disambiguates. Write println(..), format(..), matches(..).
GP0050 ¶
Parser - enum representation is not an unsigned width
A discriminant is a count, so its store is unsigned. Write enum Name : u8 { .. }, with a width between 1 and 64 bits.
GP0051 ¶
Parser - regex! / sql! moved into their modules
Write regex::compile("…") and sql::statement("…"). A literal argument is still validated while the program is compiled.
GT0079 ¶
Types - pointer wrapper written
Every value is heap-shared and reference-counted already, so Box<T> / Rc<T> / Arc<T> name no choice the writer has to make. Write the inner type.
GT0080 ¶
Types - String::parse called
The parse surface is to_i64, to_f64, and to_bool: each parses the whole string and answers an Option<T>. Add .ok_or(..) where a Result is wanted.
GT0081 ¶
Types - enum representation too narrow for its variants
A declared width is exact - it is what the discriminant is stored in - so it is never widened silently. Write a width that holds every variant, or drop it.
GT0082 ¶
Types - reference passed where a value is taken
A parameter that is not &mut takes the value, and a reference names one rather than being one, so the compiled tiers would hand the callee the address. Write *x.
GT0083 ¶
Types - write through a value that is not a reference
* reaches the place a reference names, and a value has no such place, so the write would reach nothing. Write the binding directly, or make the parameter &mut T and pass &mut at the call site.
GT0084 ¶
Types - impl of a trait the language supplies itself
Hashing, copying, release, marker safety, and the Into / TryInto / IntoIterator directions are the language's, not a per-type choice, so the block would declare a contract nothing dispatches through. The diagnostic names what the language does and what to write in its place - a From impl on the target, a defer, an inherent method - or remove the block.
GT0085 ¶
Types - ordered container over a type that writes its own cmp
A heap, a BTreeSet, or a BTreeMap keeps its elements in the order they went in and reads them back with no comparator to call, so an element or key whose type writes its own cmp would silently not be ordered by it. A sequence orders on demand and does route through the type's cmp: sort a Vec<T>, or key the container on a value that carries the order.
GT0086 ¶
Types - spawn outside a cohort block
A spawn must be written lexically inside a cohort { } in its own function body; main is the one exemption, since the root cohort's extent is main's own. Elsewhere the child attaches to whatever cohort the caller happens to be inside, which neither the callee's signature nor the call site says, and to the root cohort - whose extent is the process - when the program has none. Open a block around the spawns and the code that collects from them.
GP0052 ¶
Parser - build-time validated call without a literal
sql::statement was handed something other than a literal. The statement is checked while the program is compiled, so it has to be there to check; a statement built at run time is an ordinary String and needs no wrapper.
GP0056 ¶
Parser - retired cohort isolation spelling
context::Context is the cancellation type a cohort may one day inherit; this setting decides whether a child gets an OS thread of its own, so it is isolation: Isolation::Shared or isolation: Isolation::Thread. --fix rewrites it.
GP0053 ¶
Parser - Display rendering declared as to_string
Both rendering contracts declare one method that answers a String, so both are written fn fmt; the impl header is what decides which channel a value reaches, {} taking Display and {:?} taking Debug. x.to_string() still renders through Display.
GP0054 ¶
Parser - shared reference in parameter position
An argument is passed without copying whatever its type, and a callee cannot write to the caller's variable unless the parameter says &mut, so f(m: &Map) and f(m: Map) have the same cost and the same guarantee. A sequence view is written [T], and &mut [T] is the form that writes through. --fix drops the &.
GP0055 ¶
Parser - shared reference on a call argument
No parameter is a shared reference, so the sigil changes nothing: an argument is passed without copying either way, and a callee writes to the caller's variable only through a &mut parameter, which is spelled &mut at the call too. --fix drops the &.
GR0001 ¶
Resolve - unresolved name
A name used in source could not be resolved to a declaration. Check the spelling, whether a use brings the name into scope, and whether the item is visible at this location.
GR0002 ¶
Resolve - wrong namespace
A name was resolved to the wrong namespace (value vs. type). Check the declaration and the spelling.
GR0003 ¶
Resolve - duplicate item
Two items in the same module share a name. Rename one of them or move it into a distinct mod.
GR0004 ¶
Resolve - duplicate import
The same path was imported twice in the same use list. Drop the duplicate.
GR0005 ¶
Resolve - unknown module path
The use names a std:: module path that does not exist. Every module has exactly one canonical path (e.g. JSON lives at std::encoding::json); check gos doc or the stdlib reference for the module's path.
GR0006 ¶
Resolve - removed stdlib item
A container spelling that a canonical name replaced. Each container has exactly one name - import and write that one.
GR0007 ¶
Resolve - unknown stdlib item
The use names a module that exists but an item that module does not export. Check the item spelling; gos doc std::<module> lists every name a module exports.
GR0017 ¶
Resolver - break or continue with no loop
A break or continue has no loop to act on: either none encloses it, or the label it names is not carried by any enclosing loop. A closure body is a separate function, so a loop outside it is not a target.
GR0018 ¶
Resolver - compiler-known call named as a value path
A path named one of the compiler-known calls - println, format, panic, and the rest of the fixed set. Each expands where it is written and the runtime binds no callable for it, so the path has nothing to call or pass as a value. Write it as name(..); it needs no import.
GR0019 ¶
Resolver - two dependency packages under one module name
Two dependency packages are reached under one module name. A - is not part of an identifier, so a package name carrying one is reached from source as the same name with _ in its place, which two packages can share. Give one of them a name of its own in [dependencies], or import each through use "id" as name.
GR0020 ¶
Resolver - declaration under a compiler-known call name
A fn or a binding was declared under one of the compiler-known call names - println, format, matches, and the rest of the fixed set. Each expands where it is written, so the declaration could never be reached. Give it a name of its own.
GR0021 ¶
Resolve - std free call written data-last
A std free function was called with its data argument in the slot it occupied before every module took its data first. The call still means what it did, so nothing else in the body is affected; write the data argument first, which is what makes iter::map(xs, f) read as the xs.map(f) it stands for.
GT0001 ¶
Types - type mismatch
The type checker could not reconcile two types it expected to match. The primary label shows the location of the mismatch; the note: line names the conflicting types.
GT0002 ¶
Types - unresolved method
The type checker could not find a method with the supplied name on the receiver type. Check for a typo, a missing use, or a trait impl that lives in an unreachable module.
GT0003 ¶
Types - unresolved operator
The operator is not defined for the operand types. Check the operand types and use the correct operator.
GT0004 ¶
Match exhaustiveness - non-exhaustive match
A match expression does not cover every possible value. Add an arm for the pattern(s) listed under help:.
GT0005 ¶
Types - non-primitive cast
The as cast is restricted to a whitelist: numeric ↔ numeric, bool/char → integer, u8 → char, and same-type no-ops. Struct / enum / String sources are rejected. Use a conversion method when you need serialisation; as does not run code.
GT0044 ¶
Types - generic return type not inferred
A generic return payload cannot be inferred from call arguments alone. Add an explicit generic argument or assign the expression to an expected Result type.
GT0045 ¶
Types - question mark not supported here
The ? operator can only unwrap Result inside a Result-returning function or Option inside an Option-returning function.