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.
This commit is contained in:
parent
16fd2a83d7
commit
bde939058b
8 changed files with 69 additions and 7 deletions
|
|
@ -9,3 +9,20 @@ fn main() {
|
|||
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
|
||||
}
|
||||
|
|
|
|||
|
|
@ -9,3 +9,20 @@ fn main() {
|
|||
let _ = char::to_digit(c, 8).is_some();
|
||||
//~^ to_digit_is_some
|
||||
}
|
||||
|
||||
#[clippy::msrv = "1.86"]
|
||||
mod cannot_lint_in_const_context {
|
||||
fn without_const(c: char) -> bool {
|
||||
c.to_digit(8).is_some()
|
||||
//~^ 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.to_digit(8).is_some()
|
||||
//~^ to_digit_is_some
|
||||
}
|
||||
|
|
|
|||
|
|
@ -13,5 +13,17 @@ error: use of `.to_digit(..).is_some()`
|
|||
LL | let _ = char::to_digit(c, 8).is_some();
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `char::is_digit(c, 8)`
|
||||
|
||||
error: aborting due to 2 previous errors
|
||||
error: use of `.to_digit(..).is_some()`
|
||||
--> tests/ui/to_digit_is_some.rs:16:9
|
||||
|
|
||||
LL | c.to_digit(8).is_some()
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^ help: try: `c.is_digit(8)`
|
||||
|
||||
error: use of `.to_digit(..).is_some()`
|
||||
--> tests/ui/to_digit_is_some.rs:26:5
|
||||
|
|
||||
LL | c.to_digit(8).is_some()
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^ help: try: `c.is_digit(8)`
|
||||
|
||||
error: aborting due to 4 previous errors
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue