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

E0413: Method call on non struct

CodeCategoryStability
E0413Struct and enumPermanent

Explanation

A method-call expression uses a receiver whose type does not provide a matching method. User-defined methods belong to struct types; compiler-provided built-in receiver operations are resolved separately.

Likely cause

The receiver has an unexpected scalar or other non-struct type, or method syntax was used where an ordinary function or operator was intended. Check the receiver expression's type and choose an operation available for that type.

Examples

Method call on an integer

fn main() -> i32 {
    let value: i32 = 42;
    value.missing()
}

Use an operation defined for the value

fn main() -> i32 {
    let value: i32 = 40;
    value + 2
}

References