Rust errors / Types and traits
Rust compiler error · checked with rustc 1.99.0
Rust error E0579: lower bound for range pattern must be less than upper bound
What it meansA lower range wasn't less than the upper range.
What rustc prints
error[E0579]: lower bound for range pattern must be less than upper bound
--> main.rs:7:9
|
7 | 5..5 => {} // error!
| ^^^^Real output of rustc 1.99.0 compiling the official example below (2021 edition). Your names and line numbers will differ; the first line is the part to match.
The compiler team's explanation
A lower range wasn't less than the upper range.
Erroneous code example:
fn main() {
match 5u32 {
// This range is ok, albeit pointless.
1..2 => {}
// This range is empty, and the compiler can tell.
5..5 => {} // error!
}
}
When matching against an exclusive range, the compiler verifies that the range is non-empty. Exclusive range patterns include the start point but not the end point, so this is equivalent to requiring the start of the range to be less than the end of the range.
From rustc --explain E0579 (1.99.0), part of the Rust project, MIT or Apache-2.0. Official page.
Related errors
- E0308mismatched types
- E0277the trait bound is not satisfied
- E0599no method named X found in the current scope
- E0433failed to resolve
- E0575cannot find associated type `Mythology` in trait `Age`
- E0576cannot find associated type `You` in trait `Hello`
- E0580`main` function has wrong type
- E0587type has conflicting packed and align representation hints
Up next
Often hit nextE0308: mismatched typesA related error from the same family.Read it next →Did this answer your question?