@@ -102,11 +102,11 @@ use rustc_hir::hir_id::{HirIdMap, HirIdSet};
102
102
use rustc_hir:: intravisit:: { walk_expr, FnKind , Visitor } ;
103
103
use rustc_hir:: LangItem :: { OptionNone , OptionSome , ResultErr , ResultOk } ;
104
104
use rustc_hir:: {
105
- self as hir, def, Arm , ArrayLen , BindingMode , Block , BlockCheckMode , Body , ByRef , Closure , ConstContext ,
106
- Destination , Expr , ExprField , ExprKind , FnDecl , FnRetTy , GenericArgs , HirId , Impl , ImplItem , ImplItemKind ,
107
- ImplItemRef , Item , ItemKind , LangItem , LetStmt , MatchSource , Mutability , Node , OwnerId , OwnerNode , Param , Pat ,
108
- PatKind , Path , PathSegment , PrimTy , QPath , Stmt , StmtKind , TraitItem , TraitItemKind , TraitItemRef , TraitRef ,
109
- TyKind , UnOp ,
105
+ self as hir, def, Arm , ArrayLen , BindingMode , Block , BlockCheckMode , Body , ByRef , Closure , ConstArgKind ,
106
+ ConstContext , Destination , Expr , ExprField , ExprKind , FnDecl , FnRetTy , GenericArgs , HirId , Impl , ImplItem ,
107
+ ImplItemKind , ImplItemRef , Item , ItemKind , LangItem , LetStmt , MatchSource , Mutability , Node , OwnerId , OwnerNode ,
108
+ Param , Pat , PatKind , Path , PathSegment , PrimTy , QPath , Stmt , StmtKind , TraitItem , TraitItemKind , TraitItemRef ,
109
+ TraitRef , TyKind , UnOp ,
110
110
} ;
111
111
use rustc_lexer:: { tokenize, TokenKind } ;
112
112
use rustc_lint:: { LateContext , Level , Lint , LintContext } ;
@@ -904,7 +904,9 @@ pub fn is_default_equivalent(cx: &LateContext<'_>, e: &Expr<'_>) -> bool {
904
904
} ,
905
905
ExprKind :: Tup ( items) | ExprKind :: Array ( items) => items. iter ( ) . all ( |x| is_default_equivalent ( cx, x) ) ,
906
906
ExprKind :: Repeat ( x, ArrayLen :: Body ( len) ) => {
907
- if let ExprKind :: Lit ( const_lit) = cx. tcx . hir ( ) . body ( len. body ) . value . kind
907
+ #[ allow( irrefutable_let_patterns) ] // FIXME
908
+ if let ConstArgKind :: Anon ( anon_const) = len. kind
909
+ && let ExprKind :: Lit ( const_lit) = cx. tcx . hir ( ) . body ( anon_const. body ) . value . kind
908
910
&& let LitKind :: Int ( v, _) = const_lit. node
909
911
&& v <= 32
910
912
&& is_default_equivalent ( cx, x)
@@ -933,7 +935,9 @@ fn is_default_equivalent_from(cx: &LateContext<'_>, from_func: &Expr<'_>, arg: &
933
935
} ) => return sym. is_empty ( ) && is_path_lang_item ( cx, ty, LangItem :: String ) ,
934
936
ExprKind :: Array ( [ ] ) => return is_path_diagnostic_item ( cx, ty, sym:: Vec ) ,
935
937
ExprKind :: Repeat ( _, ArrayLen :: Body ( len) ) => {
936
- if let ExprKind :: Lit ( const_lit) = cx. tcx . hir ( ) . body ( len. body ) . value . kind
938
+ #[ allow( irrefutable_let_patterns) ] // FIXME
939
+ if let ConstArgKind :: Anon ( anon_const) = len. kind
940
+ && let ExprKind :: Lit ( const_lit) = cx. tcx . hir ( ) . body ( anon_const. body ) . value . kind
937
941
&& let LitKind :: Int ( v, _) = const_lit. node
938
942
{
939
943
return v == 0 && is_path_diagnostic_item ( cx, ty, sym:: Vec ) ;
0 commit comments