Skip to content
This repository was archived by the owner on May 28, 2025. It is now read-only.

Commit 642efab

Browse files
Fixed typos and updated to matches! where applicable
1 parent 9194c11 commit 642efab

File tree

2 files changed

+7
-15
lines changed

2 files changed

+7
-15
lines changed

clippy_lints/src/from_str_radix_10.rs

Lines changed: 2 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ impl LateLintPass<'tcx> for FromStrRadix10 {
4646
if let TyKind::Path(ty_qpath) = &ty.kind;
4747
let ty_res = cx.qpath_res(ty_qpath, ty.hir_id);
4848
if let def::Res::PrimTy(prim_ty) = ty_res;
49-
if is_primitive_integer_ty(prim_ty);
49+
if matches!(prim_ty, PrimTy::Int(_) | PrimTy::Uint(_));
5050

5151
// check if the second part of the path indeed calls the associated
5252
// function `from_str_radix`
@@ -63,7 +63,7 @@ impl LateLintPass<'tcx> for FromStrRadix10 {
6363
cx,
6464
FROM_STR_RADIX_10,
6565
exp.span,
66-
"This call to `from_str_radix` can be shortened to a call to str::parse",
66+
"this call to `from_str_radix` can be replaced with a call to `str::parse`",
6767
"try",
6868
format!("({}).parse()", orig_string),
6969
Applicability::MaybeIncorrect
@@ -72,11 +72,3 @@ impl LateLintPass<'tcx> for FromStrRadix10 {
7272
}
7373
}
7474
}
75-
76-
fn is_primitive_integer_ty(ty: PrimTy) -> bool {
77-
match ty {
78-
PrimTy::Int(_) => true,
79-
PrimTy::Uint(_) => true,
80-
_ => false,
81-
}
82-
}

tests/ui/from_str_radix_10.stderr

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,30 +1,30 @@
1-
error: This call to `from_str_radix` can be shortened to a call to str::parse
1+
error: this call to `from_str_radix` can be replaced with a call to `str::parse`
22
--> $DIR/from_str_radix_10.rs:17:5
33
|
44
LL | u32::from_str_radix("30", 10)?;
55
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `("30").parse()`
66
|
77
= note: `-D clippy::from-str-radix-10` implied by `-D warnings`
88

9-
error: This call to `from_str_radix` can be shortened to a call to str::parse
9+
error: this call to `from_str_radix` can be replaced with a call to `str::parse`
1010
--> $DIR/from_str_radix_10.rs:18:5
1111
|
1212
LL | i64::from_str_radix("24", 10)?;
1313
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `("24").parse()`
1414

15-
error: This call to `from_str_radix` can be shortened to a call to str::parse
15+
error: this call to `from_str_radix` can be replaced with a call to `str::parse`
1616
--> $DIR/from_str_radix_10.rs:19:5
1717
|
1818
LL | isize::from_str_radix("100", 10)?;
1919
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `("100").parse()`
2020

21-
error: This call to `from_str_radix` can be shortened to a call to str::parse
21+
error: this call to `from_str_radix` can be replaced with a call to `str::parse`
2222
--> $DIR/from_str_radix_10.rs:20:5
2323
|
2424
LL | u8::from_str_radix("7", 10)?;
2525
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `("7").parse()`
2626

27-
error: This call to `from_str_radix` can be shortened to a call to str::parse
27+
error: this call to `from_str_radix` can be replaced with a call to `str::parse`
2828
--> $DIR/from_str_radix_10.rs:23:5
2929
|
3030
LL | i32::from_str_radix(string, 10)?;

0 commit comments

Comments
 (0)