Ruta graveolens  ·  notes from a language experiment  ·  cultivated since 2025

E0404: Reserved type name

CodeCategoryStability
E0404Struct and enumPermanent

Explanation

A user-defined struct or enum has a name reserved for a compiler-provided type. Rue reserves exactly one type-name spelling: str, the built-in view over borrowed UTF-8 bytes. It is injected into every module's scope rather than declared in source, so a user declaration cannot take its name. Every other type name — StrBuf among them, an ordinary declaration in std — participates in ordinary lexical and module lookup and may be reused freely.

Likely cause

A struct or enum was named str. Rename it; a name such as Str, StrView, or a domain name distinct from the built-in view is available.

Examples

Define a type named str

struct str { value: i32 }
fn main() -> i32 { 0 }

Other built-in spellings are ordinary type names

struct StrBuf { value: i32 }
fn main() -> i32 {
    StrBuf { value: 42 }.value
}

References