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

E0416: Duplicate destructor

CodeCategoryStability
E0416Struct and enumPermanent

Explanation

More than one user-defined destructor is declared for the same struct type. Rue permits at most one destructor because dropping a value has one canonical user cleanup action.

Likely cause

A drop fn declaration was duplicated, or cleanup for one type was split across multiple destructor declarations. Combine the cleanup into a single destructor for that struct.

Examples

Two destructors for one struct

struct Resource { value: i32 }
drop fn Resource(self) {}
drop fn Resource(self) {}
fn main() -> i32 { 0 }

Keep one destructor per struct

struct Resource { value: i32 }
drop fn Resource(self) {}
fn main() -> i32 { 0 }

References