Email me

Clippy lints / Suspicious

Clippy lint · Suspicious · checked with Clippy 0.1.99

clippy::almost_complete_range: almost complete ascii range

What it meansChecks for ranges which almost include the entire range of letters from ‘a’ to ‘z’ or digits from ‘0’ to ‘9’, but don’t because they’re a half open range. It is in the suspicious group and warns by default.

What you see

warning: almost complete ascii range
 --> main.rs:3:9
  |
3 | let _ = 'a'..'z';
  |         ^^^--^^^
  |            |
  |            help: use an inclusive range: `..=`
  |
  = help: for further information visit https://rust-lang.github.io/rust-clippy/stable/index.html#almost_complete_range
  = note: `#[warn(clippy::almost_complete_range)]` on by default

Real output of Clippy 0.1.99 (Rust 1.99) on the example below. Names and line numbers in yours will differ.

Does it matter?

This ('a'..'z') is almost certainly a typo meant to include all letters.

Code that is most likely wrong or useless. Warns by default.

How to fix it

Clippy does not fix this one automatically (its suggestion may change behaviour, so it only shows it). Change the code by hand:

Flagged

let _ = 'a'..'z';

Write this instead

let _ = 'a'..='z';

Turn it off, or on

Allow it where it does not fit your code, as narrowly as you can:

On one item

#[allow(clippy::almost_complete_range)]
fn my_function() { /* ... */ }

Whole crate (Cargo.toml)

[lints.clippy]
almost_complete_range = "allow"

One run

cargo clippy -- -A clippy::almost-complete-range

The [lints] table needs Rust 1.74 or newer. In a workspace, put it under [workspace.lints.clippy] and add [lints] workspace = true to each member.

Settings in clippy.toml

  • msrv: The minimum rust version that the project supports. Defaults to the rust-version field in Cargo.toml
Suspiciousgroup
warndefault level
nofixed by cargo clippy --fix
1.68.0added in Rust

Clippy's own documentation

What it does

Checks for ranges which almost include the entire range of letters from ‘a’ to ‘z’ or digits from ‘0’ to ‘9’, but don’t because they’re a half open range.

Why is this bad?

This ('a'..'z') is almost certainly a typo meant to include all letters.

Example

let _ = 'a'..'z';

Use instead:

let _ = 'a'..='z';

Past names

  • almost_complete_letter_range

Configuration

  • msrv: The minimum rust version that the project supports. Defaults to the rust-version field in Cargo.toml

    (default: current version)

From the Clippy lint list (0.1.99), part of the Rust project, MIT or Apache-2.0. Official entry.

Related lints

All 847 Clippy lints · Rust compiler errors · Cargo.toml checker

Up next

Related lintclippy::arc_with_non_send_syncarc with non send syncRead it next →

Did this answer your question?

Get the receipts by email.

What my AI agents tried this week, with the real numbers: what worked, what flopped, what made money. One email when there is something worth reading.

No spam, never sold. Every email has a one-click unsubscribe.

Popular in the shop

All 124 tools →

Browse: Bundles and kitsHome, family and schoolMoney and businessAI toolsSports and fitnessMaking and hobbiesFood and drinkIndie dev and launchTrading and quant

Free: Landing page teardown iPhone app cost calculator LLM API cost calculator Paid online: $49 Launch Check App builds Articles FAQ