@@ -47,22 +47,23 @@ impl<'tcx> LateLintPass<'tcx> for FromStrRadix10 {
47
47
fn check_expr ( & mut self , cx : & LateContext < ' tcx > , exp : & Expr < ' tcx > ) {
48
48
if let ExprKind :: Call ( maybe_path, [ src, radix] ) = & exp. kind
49
49
&& let ExprKind :: Path ( QPath :: TypeRelative ( ty, pathseg) ) = & maybe_path. kind
50
- // do not lint in constant context, because the suggestion won't work.
51
- // NB: keep this check until a new `const_trait_impl` is available and stablized.
52
- && !in_constant ( cx, exp. hir_id )
50
+
51
+ // check if the second argument is a primitive `10`
52
+ && is_integer_literal ( radix, 10 )
53
+
54
+ // check if the second part of the path indeed calls the associated
55
+ // function `from_str_radix`
56
+ && pathseg. ident . name . as_str ( ) == "from_str_radix"
53
57
54
58
// check if the first part of the path is some integer primitive
55
59
&& let TyKind :: Path ( ty_qpath) = & ty. kind
56
60
&& let ty_res = cx. qpath_res ( ty_qpath, ty. hir_id )
57
61
&& let def:: Res :: PrimTy ( prim_ty) = ty_res
58
62
&& matches ! ( prim_ty, PrimTy :: Int ( _) | PrimTy :: Uint ( _) )
59
63
60
- // check if the second part of the path indeed calls the associated
61
- // function `from_str_radix`
62
- && pathseg. ident . name . as_str ( ) == "from_str_radix"
63
-
64
- // check if the second argument is a primitive `10`
65
- && is_integer_literal ( radix, 10 )
64
+ // do not lint in constant context, because the suggestion won't work.
65
+ // NB: keep this check until a new `const_trait_impl` is available and stablized.
66
+ && !in_constant ( cx, exp. hir_id )
66
67
{
67
68
let expr = if let ExprKind :: AddrOf ( _, _, expr) = & src. kind {
68
69
let ty = cx. typeck_results ( ) . expr_ty ( expr) ;
0 commit comments