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-rangeThe [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
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 therust-versionfield inCargo.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
- arc_with_non_send_syncarc with non send sync
- await_holding_invalid_typeAllows users to configure types which should not be held across await suspension points
- await_holding_lockChecks for calls to await while holding a non-async-aware MutexGuard
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?