@@ -9,18 +9,15 @@ use rustc_hir::Expr;
99use rustc_hir:: QPath ;
1010use rustc_hir:: { def:: Res , ExprKind } ;
1111use rustc_lint:: LateContext ;
12- use rustc_middle:: ty:: { Ty , TyKind } ;
12+ use rustc_middle:: ty:: { self , Ty } ;
1313use rustc_span:: sym;
1414
1515use super :: READ_LINE_WITHOUT_TRIM ;
1616
1717/// Will a `.parse::<ty>()` call fail if the input has a trailing newline?
1818fn parse_fails_on_trailing_newline ( ty : Ty < ' _ > ) -> bool {
1919 // 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 ( _) )
2421}
2522
2623pub 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<
3835 && segment. ident . name == sym ! ( parse)
3936 && let parse_result_ty = cx. typeck_results ( ) . expr_ty ( parent)
4037 && 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 ( )
4239 && let Some ( ok_ty) = substs[ 0 ] . as_type ( )
4340 && parse_fails_on_trailing_newline ( ok_ty)
4441 {
0 commit comments