Skip to content

Commit

Permalink
Rollup merge of rust-lang#118157 - Nadrieril:never_pat-feature-gate, …
Browse files Browse the repository at this point in the history
…r=compiler-errors

Add `never_patterns` feature gate

This PR adds the feature gate and most basic parsing for the experimental `never_patterns` feature. See the tracking issue (rust-lang#118155) for details on the experiment.

`@scottmcm` has agreed to be my lang-team liaison for this experiment.
  • Loading branch information
matthiaskrgr authored Nov 29, 2023
2 parents d84d8d2 + f2f2431 commit 1ab7fc9
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion src/patterns.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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(..)
Expand Down Expand Up @@ -193,6 +195,7 @@ impl Rewrite for Pat {
None
}
}
PatKind::Never => None,
PatKind::Range(ref lhs, ref rhs, ref end_kind) => {
let infix = match end_kind.node {
RangeEnd::Included(RangeSyntax::DotDotDot) => "...",
Expand Down

0 comments on commit 1ab7fc9

Please sign in to comment.