Error codes

E0350: type doesn't fit a shape

In a terminal: auk explain E0350 prints this page.

On this page

A shape (like Show, Ord or your own) asks for certain functions. This type lacks one, so it can't be used where the shape is needed. The note names the missing function.

Wrong#

auk
struct P { x: int }
fn main() { print([P { x: 2 }, P { x: 1 }].sort()) }

Fixed#

auk
struct P { x: int }
fn cmp(a: P, b: P): int = a.x - b.x
fn main() { print([P { x: 2 }, P { x: 1 }].sort()) }

Common causes#

  • Sorting or comparing structs: define cmp (Ord isn't automatic).
  • A generic T interpolated into a string: bound it, fn f<T: Show>(x: T).
  • Printing a closure: closures don't fit Show.

Stuck on a word? Try the glossary. Got a compiler error? Look up its code. Improve this page