rust/tests/ui/to_digit_is_some.fixed
Samuel Tardieu bde939058b
char::is_digit() is const-stable only since Rust 1.87
The `to_digit_is_some()` lint suggests using `char::is_digit()`. It
should not trigger in const contexts before Rust 1.87.
2025-05-10 00:20:55 +02:00

28 lines
550 B
Rust

#![warn(clippy::to_digit_is_some)]
fn main() {
let c = 'x';
let d = &c;
let _ = d.is_digit(8);
//~^ to_digit_is_some
let _ = char::is_digit(c, 8);
//~^ to_digit_is_some
}
#[clippy::msrv = "1.86"]
mod cannot_lint_in_const_context {
fn without_const(c: char) -> bool {
c.is_digit(8)
//~^ to_digit_is_some
}
const fn with_const(c: char) -> bool {
c.to_digit(8).is_some()
}
}
#[clippy::msrv = "1.87"]
const fn with_const(c: char) -> bool {
c.is_digit(8)
//~^ to_digit_is_some
}