From f2f243109b12cfb0a8207e06df752172c3ecc22e Mon Sep 17 00:00:00 2001 From: Nadrieril Date: Wed, 22 Nov 2023 02:30:43 +0100 Subject: [PATCH] Add `never_patterns` feature gate --- src/patterns.rs | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/patterns.rs b/src/patterns.rs index 33f3b4b8a21..8504999b8ff 100644 --- a/src/patterns.rs +++ b/src/patterns.rs @@ -40,7 +40,9 @@ pub(crate) fn is_short_pattern(pat: &ast::Pat, pat_str: &str) -> bool { fn is_short_pattern_inner(pat: &ast::Pat) -> bool { match pat.kind { - ast::PatKind::Rest | ast::PatKind::Wild | ast::PatKind::Lit(_) => true, + ast::PatKind::Rest | ast::PatKind::Never | ast::PatKind::Wild | ast::PatKind::Lit(_) => { + true + } ast::PatKind::Ident(_, _, ref pat) => pat.is_none(), ast::PatKind::Struct(..) | ast::PatKind::MacCall(..) @@ -193,6 +195,7 @@ fn rewrite(&self, context: &RewriteContext<'_>, shape: Shape) -> Option None } } + PatKind::Never => None, PatKind::Range(ref lhs, ref rhs, ref end_kind) => { let infix = match end_kind.node { RangeEnd::Included(RangeSyntax::DotDotDot) => "...",