Skip to content

Commit 2ab6be8

Browse files
authored
Rollup merge of #139035 - nnethercote:PatKind-Missing, r=oli-obk
Add new `PatKind::Missing` variants To avoid some ugly uses of `kw::Empty` when handling "missing" patterns, e.g. in bare fn tys. Helps with #137978. Details in the individual commits. r? ``@oli-obk``
2 parents 409c7b8 + 2b3bceb commit 2ab6be8

File tree

2 files changed

+3
-5
lines changed

2 files changed

+3
-5
lines changed

src/items.rs

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2442,11 +2442,7 @@ pub(crate) fn span_hi_for_param(context: &RewriteContext<'_>, param: &ast::Param
24422442
}
24432443

24442444
pub(crate) fn is_named_param(param: &ast::Param) -> bool {
2445-
if let ast::PatKind::Ident(_, ident, _) = param.pat.kind {
2446-
ident.name != symbol::kw::Empty
2447-
} else {
2448-
true
2449-
}
2445+
!matches!(param.pat.kind, ast::PatKind::Missing)
24502446
}
24512447

24522448
#[derive(Copy, Clone, Debug, PartialEq, Eq)]

src/patterns.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@ pub(crate) fn is_short_pattern(
4242

4343
fn is_short_pattern_inner(context: &RewriteContext<'_>, pat: &ast::Pat) -> bool {
4444
match &pat.kind {
45+
ast::PatKind::Missing => unreachable!(),
4546
ast::PatKind::Rest | ast::PatKind::Never | ast::PatKind::Wild | ast::PatKind::Err(_) => {
4647
true
4748
}
@@ -100,6 +101,7 @@ impl Rewrite for Pat {
100101

101102
fn rewrite_result(&self, context: &RewriteContext<'_>, shape: Shape) -> RewriteResult {
102103
match self.kind {
104+
PatKind::Missing => unreachable!(),
103105
PatKind::Or(ref pats) => {
104106
let pat_strs = pats
105107
.iter()

0 commit comments

Comments
 (0)