@@ -9,18 +9,15 @@ use rustc_hir::Expr;
9
9
use rustc_hir:: QPath ;
10
10
use rustc_hir:: { def:: Res , ExprKind } ;
11
11
use rustc_lint:: LateContext ;
12
- use rustc_middle:: ty:: { Ty , TyKind } ;
12
+ use rustc_middle:: ty:: { self , Ty } ;
13
13
use rustc_span:: sym;
14
14
15
15
use super :: READ_LINE_WITHOUT_TRIM ;
16
16
17
17
/// Will a `.parse::<ty>()` call fail if the input has a trailing newline?
18
18
fn parse_fails_on_trailing_newline ( ty : Ty < ' _ > ) -> bool {
19
19
// only allow a very limited set of types for now, for which we 100% know parsing will fail
20
- matches ! (
21
- ty. kind( ) ,
22
- TyKind :: Float ( _) | TyKind :: Bool | TyKind :: Int ( _) | TyKind :: Uint ( _)
23
- )
20
+ matches ! ( ty. kind( ) , ty:: Float ( _) | ty:: Bool | ty:: Int ( _) | ty:: Uint ( _) )
24
21
}
25
22
26
23
pub fn check ( cx : & LateContext < ' _ > , call : & Expr < ' _ > , recv : & Expr < ' _ > , arg : & Expr < ' _ > ) {
@@ -38,7 +35,7 @@ pub fn check(cx: &LateContext<'_>, call: &Expr<'_>, recv: &Expr<'_>, arg: &Expr<
38
35
&& segment. ident . name == sym ! ( parse)
39
36
&& let parse_result_ty = cx. typeck_results ( ) . expr_ty ( parent)
40
37
&& is_type_diagnostic_item ( cx, parse_result_ty, sym:: Result )
41
- && let TyKind :: Adt ( _, substs) = parse_result_ty. kind ( )
38
+ && let ty :: Adt ( _, substs) = parse_result_ty. kind ( )
42
39
&& let Some ( ok_ty) = substs[ 0 ] . as_type ( )
43
40
&& parse_fails_on_trailing_newline ( ok_ty)
44
41
{
0 commit comments