@@ -1565,10 +1565,10 @@ pub fn is_ctor_or_promotable_const_function(cx: &LateContext<'_>, expr: &Expr<'_
1565
1565
/// Returns `true` if a pattern is refutable.
1566
1566
// TODO: should be implemented using rustc/mir_build/thir machinery
1567
1567
pub fn is_refutable ( cx : & LateContext < ' _ > , pat : & Pat < ' _ > ) -> bool {
1568
- fn is_enum_variant ( cx : & LateContext < ' _ > , qpath : & QPath < ' _ > , id : HirId ) -> bool {
1569
- matches ! (
1568
+ fn is_qpath_refutable ( cx : & LateContext < ' _ > , qpath : & QPath < ' _ > , id : HirId ) -> bool {
1569
+ ! matches ! (
1570
1570
cx. qpath_res( qpath, id) ,
1571
- Res :: Def ( DefKind :: Variant , ..) | Res :: Def ( DefKind :: Ctor ( def:: CtorOf :: Variant , _) , _)
1571
+ Res :: Def ( DefKind :: Struct , ..) | Res :: Def ( DefKind :: Ctor ( def:: CtorOf :: Struct , _) , _)
1572
1572
)
1573
1573
}
1574
1574
@@ -1585,16 +1585,18 @@ pub fn is_refutable(cx: &LateContext<'_>, pat: &Pat<'_>) -> bool {
1585
1585
kind : PatExprKind :: Path ( qpath) ,
1586
1586
hir_id,
1587
1587
..
1588
- } ) => is_enum_variant ( cx, qpath, * hir_id) ,
1588
+ } ) => is_qpath_refutable ( cx, qpath, * hir_id) ,
1589
1589
PatKind :: Or ( pats) => {
1590
1590
// TODO: should be the honest check, that pats is exhaustive set
1591
1591
are_refutable ( cx, pats)
1592
1592
} ,
1593
1593
PatKind :: Tuple ( pats, _) => are_refutable ( cx, pats) ,
1594
1594
PatKind :: Struct ( ref qpath, fields, _) => {
1595
- is_enum_variant ( cx, qpath, pat. hir_id ) || are_refutable ( cx, fields. iter ( ) . map ( |field| field. pat ) )
1595
+ is_qpath_refutable ( cx, qpath, pat. hir_id ) || are_refutable ( cx, fields. iter ( ) . map ( |field| field. pat ) )
1596
+ } ,
1597
+ PatKind :: TupleStruct ( ref qpath, pats, _) => {
1598
+ is_qpath_refutable ( cx, qpath, pat. hir_id ) || are_refutable ( cx, pats)
1596
1599
} ,
1597
- PatKind :: TupleStruct ( ref qpath, pats, _) => is_enum_variant ( cx, qpath, pat. hir_id ) || are_refutable ( cx, pats) ,
1598
1600
PatKind :: Slice ( head, middle, tail) => {
1599
1601
match & cx. typeck_results ( ) . node_type ( pat. hir_id ) . kind ( ) {
1600
1602
rustc_ty:: Slice ( ..) => {
0 commit comments