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

E0500: Break outside loop

CodeCategoryStability
E0500Control flowPermanent

Explanation

A break expression exits the innermost enclosing loop or while loop. Outside a loop there is no control-flow target to exit, so Rue rejects the expression instead of assigning it a destination.

Likely cause

A break was placed in a function, conditional, or other block that is not nested inside a loop, or it was intended to leave a function. Put the expression inside the loop it should exit; use return when the intended target is the enclosing function.

Examples

Break from a function body

fn main() -> i32 {
    break;
    0
}

Break from an enclosing loop

fn main() -> i32 {
    loop {
        break;
    }
    0
}

References