Rust

Inclusive Range With No End E0586 Fix

E0586 is one missing expression: an inclusive range - written with `..=` - was used with no end after the equals sign. An inclusive end is the whole point of the operator, so the compiler rejects the range wherever it appears: in a slice index, as a value, in a `for` loop, or as a pattern with a start. The repair is a choice between the two meanings you could have wanted - give the range the end it asks for (`1..=3`), or drop the equals sign and take everything from the start onward (`1..`). This guide shows both repairs running, and the nearby range shapes that never draw this error.

Written December 1, 2026 · Tested with Rust 1.99.0 · 13 min read

By the end of this guide
  • The rule underneath: ..= promises a last value
  • How to read the diagnostic
  • The first failure: an inclusive range with no end in a slice index
  • The position does not matter: expression, argument, loop, array

Written December 1, 2026

Tested with Rust 1.99.0

What this guide is

Error E0586 means an inclusive range was used with no end. The error codes index states it in one line - an inclusive range was used with no end - and its erroneous example is a slice index: let x = &tmp[1..=];, commented "error: inclusive range was used with no end". The index gives the reason in one sentence: an inclusive range needs an end in order to include it. Its two repairs are to use a non-inclusive range instead - &tmp[1..] - or to put an end to the inclusive range - &tmp[1..=3].

The slice index is only the shape the index chose to show. The same missing end draws the same error as a bare expression, with a start written before the operator, as a function argument, as the range a for loop iterates, on an array index as well as a vector slice, and in a pattern that has a start. Every one of those shapes is shown failing below, and both of the index's repairs are shown running.

Build every program in this guide with rustc --edition 2021. In the compiler transcripts below, the file names are the bare names shown on the command line.

The rule underneath: ..= promises a last value

Each range operator makes a different promise about its end. .. with no end at all is the full range, and 3.. is a range-from: both are open-ended on purpose, and both compile. ..5 ends before 5, and ..=5 ends at 5, included. The = in ..= is exactly that promise - there is a last value, and it is part of the range.

Writing ..= and then writing nothing after it breaks the promise in the writing itself. There is no value to include, so there is nothing the range could mean: it is not an open-ended range (that is what .. already says) and it is not an inclusive range (that needs the end). The compiler therefore rejects the range as written, in every position where a range can appear as an expression, before any indexing, iteration, or matching happens.

How to read the diagnostic

Every E0586 diagnostic has the same header: "inclusive range with no end", with the whole ..= span - plus its start, when one is written - underlined by carets. Under the span sits one note, word for word the same in every case shown here: "inclusive ranges must be bounded at the end (..=b or a..=b)". Then comes one help block, "use .. instead", which rewrites your exact line with the equals sign removed - the slice index &tmp[1..=] becomes &tmp[1..], the pattern 3..= becomes 3.., and so on.

Read the help as one of two options, not as the fix. The compiler offers .. because it is the smallest edit that compiles, but it changes the meaning: an open-ended range takes everything from the start onward. If you actually wanted a last value included, the repair is the note's shape instead - keep ..= and write the end. Choosing between those two is the whole decision this error asks for, and it is yours, because only you know whether the range was meant to stop.

The first failure: an inclusive range with no end in a slice index

The index's own example shape - an inclusive range starting at 1, used to index a vector, with nothing after the equals sign:

Rust
fn main() {
    let tmp = vec![0, 1, 2, 3, 4];
    let x = &tmp[1..=];
    println!("{:?}", x);
}
Output
error[E0586]: inclusive range with no end
 --> fail_slice_start_no_end.rs:3:19
  |
3 |     let x = &tmp[1..=];
  |                   ^^^
  |
  = note: inclusive ranges must be bounded at the end (`..=b` or `a..=b`)
help: use `..` instead
  |
3 -     let x = &tmp[1..=];
3 +     let x = &tmp[1..];
  |

error: aborting due to 1 previous error

For more information about this error, try `rustc --explain E0586`.

Nothing is wrong with the vector, the start, or the indexing itself. The one defect is the range: 1..= names a start and promises an included end that never arrives. Both repairs for this exact line are shown running at the end of this guide.

Dropping the start does not help. An inclusive range with neither a start nor an end in the same position - &tmp[..=] - draws the identical header, note, and help, with the carets under the ..= alone:

Rust
fn main() {
    let tmp = vec![0, 1, 2, 3, 4];
    let x = &tmp[..=];
    println!("{:?}", x);
}
Output
error[E0586]: inclusive range with no end
 --> fail_slice_no_start_no_end.rs:3:18
  |
3 |     let x = &tmp[..=];
  |                  ^^^
  |
  = note: inclusive ranges must be bounded at the end (`..=b` or `a..=b`)
help: use `..` instead
  |
3 -     let x = &tmp[..=];
3 +     let x = &tmp[..];
  |

error: aborting due to 1 previous error

For more information about this error, try `rustc --explain E0586`.

The position does not matter: expression, argument, loop, array

A bare inclusive range as a value - bound to a variable, with no start and no end - is the same error:

Rust
fn main() {
    let r = ..=;
    println!("{:?}", r);
}
Output
error[E0586]: inclusive range with no end
 --> fail_expr_bare.rs:2:13
  |
2 |     let r = ..=;
  |             ^^^
  |
  = note: inclusive ranges must be bounded at the end (`..=b` or `a..=b`)
help: use `..` instead
  |
2 -     let r = ..=;
2 +     let r = ..;
  |

error: aborting due to 1 previous error

For more information about this error, try `rustc --explain E0586`.

Writing a start before the operator changes nothing. 3..= looks like a range-from, but the equals sign still promises an end, so it draws E0586 - it is not a range-from-inclusive, because there is no such shape: a range that starts at 3 and never ends is written 3.., without the equals sign.

Rust
fn main() {
    let r = 3..=;
    println!("{:?}", r);
}
Output
error[E0586]: inclusive range with no end
 --> fail_expr_range_from_inclusive.rs:2:14
  |
2 |     let r = 3..=;
  |              ^^^
  |
  = note: inclusive ranges must be bounded at the end (`..=b` or `a..=b`)
help: use `..` instead
  |
2 -     let r = 3..=;
2 +     let r = 3..;
  |

error: aborting due to 1 previous error

For more information about this error, try `rustc --explain E0586`.

The remaining expression positions behave identically - the same header, the same note, and a help block that rewrites that line with ..:

  • take(..=) - an inclusive range with no end passed as a function argument, where the parameter type is a range-to-inclusive: E0586.
  • for i in 1..= { ... } - an inclusive range with no end as the value a for loop iterates: E0586.
  • &a[1..=] on an array a of three elements - an inclusive range with no end as an array index, not just a vector slice: E0586.

In each case the defect is in the range alone, not in the position: the argument's declared type, the loop, and the array are all fine once the range is repaired.

Patterns: a started pattern is this error, a bare one is a parse error

A range pattern that has a start and the equals sign but no end - 3..= as a match arm pattern - draws E0586, with the same note and a help block offering 3..:

Rust
fn main() {
    match 5 {
        3..= => println!("matched"),
        _ => println!("other"),
    }
}
Output
error[E0586]: inclusive range with no end
 --> fail_pattern_range_from_inclusive.rs:3:10
  |
3 |         3..= => println!("matched"),
  |          ^^^
  |
  = note: inclusive ranges must be bounded at the end (`..=b` or `a..=b`)
help: use `..` instead
  |
3 -         3..= => println!("matched"),
3 +         3.. => println!("matched"),
  |

error: aborting due to 1 previous error

For more information about this error, try `rustc --explain E0586`.

That help is a real repair here, not just a smaller edit: a range pattern with a start and no end is a working pattern shape in its own right - 3.. as an arm pattern compiles and matches, as shown below - so dropping the equals sign in a pattern keeps a start-bounded test.

The bare pattern is the one position where this guide's error does not appear. A match arm written as just ..=, with no start and no end, never reaches the E0586 check: the parser rejects it first, with an uncoded error naming the token that follows it:

Rust
fn main() {
    match 5 {
        ..= => println!("matched"),
        _ => println!("other"),
    }
}
Output
error: unexpected token: `=>`
 --> fail_pattern_bare.rs:3:13
  |
3 |         ..= => println!("matched"),
  |             ^^

error: aborting due to 1 previous error

The same happens in a let pattern: let ..= = 5; draws "unexpected token: =", again with no error code. So the pattern boundary is exact: a started inclusive pattern with no end is E0586; a bare ..= pattern is a parse error, and the repair for both is the same choice - write an end (..=5, 3..=5), or write the range shape that needs none (.. matches anything, 3.. matches from the start onward).

The boundary: ranges that need no end, and inclusive ranges that have one

Four open-ended shapes compile because their operators never promised an end. The full range .. compiles as a value and as a slice index - &tmp[..] is the whole vector. A range-from 3.. compiles as a value (an iterator starting at 3) and as a slice index (&tmp[3..]). A range-to ..5 compiles as a slice index, ending before 5. And in patterns, 3.. compiles as an arm pattern and matches 5.

An inclusive range with its end written compiles everywhere the end-less version failed. As a value, ..=5 compiles, and used as a slice index it takes the elements up to and including index 5. In a for loop, 0..=5 iterates six values, printing 0 1 2 3 4 5. In slices, &v[..=2] takes the first three elements and &v[1..=3] takes the three elements starting at index 1, the last one included. In patterns, both 0..=5 and ..=5 compile as arm patterns and match 3. The end is the only difference between every one of these programs and the failures above it.

The repair: drop the equals sign, or add the end

The index's first repair drops the equals sign. The range becomes open-ended - everything from the start onward - and the index's own corrected example runs:

Rust
fn main() {
    let tmp = vec![0, 1, 2, 3, 4, 4, 3, 3, 2, 1];
    let x = &tmp[1..];
    println!("{:?}", x);
}
Config
[1, 2, 3, 4, 4, 3, 3, 2, 1]

The output is every element from index 1 to the end of the vector. Choose this repair when "from here onward" is what the code meant - it is also the repair the compiler's help block offers, in expressions and in patterns alike.

The index's second repair keeps the equals sign and writes the end:

Rust
fn main() {
    let tmp = vec![0, 1, 2, 3, 4, 4, 3, 3, 2, 1];
    let x = &tmp[1..=3];
    println!("{:?}", x);
}
Config
[1, 2, 3]

The output is the elements at indices 1, 2, and 3 - the end, 3, included, which is what the = was for. The same choice repairs the other positions: an end-less argument becomes ..=5 (which, used as an index, takes the elements up to and including index 5), and an end-less loop range becomes 1..=3:

Rust
fn main() {
    let r = ..=5;
    let v = vec![0, 1, 2, 3, 4, 5, 6];
    println!("{:?}", &v[r]);
    for i in 1..=3 {
        print!("{} ", i);
    }
    println!();
}
Output
[0, 1, 2, 3, 4, 5]
1 2 3

The output is the six elements up to and including index 5, then the loop values 1, 2, and 3, the last one included. Pattern repairs follow the same split, both shown compiling above: ..=5 keeps an included end with no start, and 3.. keeps a start with no end.

Fixes in reach order

First, decide what the range was meant to cover. If it was meant to run from a start to the end of the value, drop the equals sign: 1..= becomes 1.., in a slice, an expression, a loop, or a pattern. That is the compiler's offered help, and it is correct exactly when nothing was meant to stop the range.

Second, if the range was meant to stop at a last value and include it, keep ..= and write that value: 1..=3, ..=5, 0..=5. The note in the diagnostic gives the two bounded shapes - ..=b with no start, a..=b with one.

Third, do not try to keep both an open end and the equals sign by moving the start around. 3..= fails for the same reason 1..= and ..= do: there is no range-from-inclusive shape. A start with no end is 3..; a start with an included end is 3..=5; the equals sign with nothing after it is never a third option.

Last, if the diagnostic has no error code and says "unexpected token", the ..= was in pattern position with no start - a bare ..= arm or let pattern. It is the same missing end, caught earlier by the parser; repair it the same way, with an end or with ...

Decision summary

E0586 fired for an inclusive range with no end in every expression position tried: a slice index with a start (1..=) and without one (..=), a bare expression (..=), an expression with a start (3..=), a function argument (..=), a for loop's range (1..=), and an array index (1..=) - and for a range pattern with a start (3..=). It did not fire for the bare pattern ..= in a match arm or a let pattern, which drew an uncoded parse error ("unexpected token") instead, nor for any range whose operator needs no end - the full range .., a range-from 3.. as a value, an index, and a pattern, and a range-to ..5 as an index - nor for an inclusive range with its end written, as a value and index (..=5), in a for loop (0..=5), in slices (..=2, 1..=3), and in patterns (0..=5, ..=5). Compiling and running were: the index's non-inclusive repair (1..), its add-an-end repair (1..=3), and a combined repair using ..=5 as an index and 1..=3 as a loop range.

Checklist

  • The defect is the range alone: ..= with nothing after the equals sign, in any expression position or in a started pattern.
  • Choose the meaning first: open-ended from a start is ..; stopping at an included last value is ..= plus the end.
  • The compiler's help always offers .. - take it only when an open-ended range is what you meant.
  • There is no range-from-inclusive: 3..= is E0586, 3.. is a range-from, and 3..=5 is an inclusive range.
  • A start does not rescue the error, and removing the start does not either - only an end, or dropping the equals sign, does.
  • A bare ..= pattern is a parse error with no error code, not E0586 - a started pattern (3..=) is E0586.
  • An inclusive range with its end written compiles in expressions, slices, for loops, and patterns alike.

Sources

  • Rust error codes index, E0586 - an inclusive range was used with no end; the erroneous example is the slice index &tmp[1..=], the explanation is that an inclusive range needs an end in order to include it, and the two repairs are to use a non-inclusive range (&tmp[1..]) or to put an end to the inclusive range (&tmp[1..=3]).

Keep Exploring