File tree Expand file tree Collapse file tree 1 file changed +5
-8
lines changed Expand file tree Collapse file tree 1 file changed +5
-8
lines changed Original file line number Diff line number Diff line change @@ -52,18 +52,20 @@ impl LateLintPass<'tcx> for FromStrRadix10 {
52
52
// function `from_str_radix`
53
53
if pathseg. ident. name. as_str( ) == "from_str_radix" ;
54
54
55
- // check if the second argument resolves to a constant `10`
55
+ // check if the second argument is a primitive `10`
56
56
if arguments. len( ) == 2 ;
57
- if is_constant_10( & arguments[ 1 ] ) ;
57
+ if let ExprKind :: Lit ( lit) = & arguments[ 1 ] . kind;
58
+ if let rustc_ast:: ast:: LitKind :: Int ( 10 , _) = lit. node;
58
59
59
60
then {
61
+ let orig_string = crate :: utils:: snippet( cx, arguments[ 0 ] . span, "string" ) ;
60
62
span_lint_and_sugg(
61
63
cx,
62
64
FROM_STR_RADIX_10 ,
63
65
exp. span,
64
66
"This call to `from_str_radix` can be shortened to a call to str::parse" ,
65
67
"try" ,
66
- format!( "TODO" ) ,
68
+ format!( "({}).parse()" , orig_string ) ,
67
69
Applicability :: MachineApplicable
68
70
) ;
69
71
}
@@ -77,9 +79,4 @@ fn is_primitive_integer_ty(ty: PrimTy) -> bool {
77
79
PrimTy :: Uint ( _) => true ,
78
80
_ => false
79
81
}
80
- }
81
-
82
- fn is_constant_10 < ' tcx > ( expr : & Expr < ' tcx > ) -> bool {
83
- // TODO
84
- true
85
82
}
You can’t perform that action at this time.
0 commit comments