Skip to content

Commit 9f089e0

Browse files
committed
Add {ast,hir,thir}::PatKind::Missing variants.
"Missing" patterns are possible in bare fn types (`fn f(u32)`) and similar places. Currently these are represented in the AST with `ast::PatKind::Ident` with no `by_ref`, no `mut`, an empty ident, and no sub-pattern. This flows through to `{hir,thir}::PatKind::Binding` for HIR and THIR. This is a bit nasty. It's very non-obvious, and easy to forget to check for the exceptional empty identifier case. This commit adds a new variant, `PatKind::Missing`, to do it properly. The process I followed: - Add a `Missing` variant to `{ast,hir,thir}::PatKind`. - Chang `parse_param_general` to produce `ast::PatKind::Missing` instead of `ast::PatKind::Missing`. - Look through `kw::Empty` occurrences to find functions where an existing empty ident check needs replacing with a `PatKind::Missing` check: `print_param`, `check_trait_item`, `is_named_param`. - Add a `PatKind::Missing => unreachable!(),` arm to every exhaustive match identified by the compiler. - Find which arms are actually reachable by running the test suite, changing them to something appropriate, usually by looking at what would happen to a `PatKind::Ident`/`PatKind::Binding` with no ref, no `mut`, an empty ident, and no subpattern. Quite a few of the `unreachable!()` arms were never reached. This makes sense because `PatKind::Missing` can't happen in every pattern, only in places like bare fn tys and trait fn decls. I also tried an alternative approach: modifying `ast::Param::pat` to hold an `Option<P<Pat>>` instead of a `P<Pat>`, but that quickly turned into a very large and painful change. Adding `PatKind::Missing` is much easier.
1 parent 217693a commit 9f089e0

File tree

40 files changed

+86
-46
lines changed

40 files changed

+86
-46
lines changed

Diff for: compiler/rustc_ast/src/ast.rs

+7-1
Original file line numberDiff line numberDiff line change
@@ -563,6 +563,7 @@ impl Pat {
563563
/// This is intended for use by diagnostics.
564564
pub fn to_ty(&self) -> Option<P<Ty>> {
565565
let kind = match &self.kind {
566+
PatKind::Missing => unreachable!(),
566567
// In a type expression `_` is an inference variable.
567568
PatKind::Wild => TyKind::Infer,
568569
// An IDENT pattern with no binding mode would be valid as path to a type. E.g. `u32`.
@@ -625,7 +626,8 @@ impl Pat {
625626
| PatKind::Guard(s, _) => s.walk(it),
626627

627628
// These patterns do not contain subpatterns, skip.
628-
PatKind::Wild
629+
PatKind::Missing
630+
| PatKind::Wild
629631
| PatKind::Rest
630632
| PatKind::Never
631633
| PatKind::Expr(_)
@@ -676,6 +678,7 @@ impl Pat {
676678
/// Return a name suitable for diagnostics.
677679
pub fn descr(&self) -> Option<String> {
678680
match &self.kind {
681+
PatKind::Missing => unreachable!(),
679682
PatKind::Wild => Some("_".to_string()),
680683
PatKind::Ident(BindingMode::NONE, ident, None) => Some(format!("{ident}")),
681684
PatKind::Ref(pat, mutbl) => pat.descr().map(|d| format!("&{}{d}", mutbl.prefix_str())),
@@ -769,6 +772,9 @@ pub enum RangeSyntax {
769772
// Adding a new variant? Please update `test_pat` in `tests/ui/macros/stringify.rs`.
770773
#[derive(Clone, Encodable, Decodable, Debug)]
771774
pub enum PatKind {
775+
/// A missing pattern, e.g. for an anonymous param in a bare fn like `fn f(u32)`.
776+
Missing,
777+
772778
/// Represents a wildcard pattern (`_`).
773779
Wild,
774780

Diff for: compiler/rustc_ast/src/mut_visit.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1572,7 +1572,7 @@ pub fn walk_pat<T: MutVisitor>(vis: &mut T, pat: &mut P<Pat>) {
15721572
vis.visit_id(id);
15731573
match kind {
15741574
PatKind::Err(_guar) => {}
1575-
PatKind::Wild | PatKind::Rest | PatKind::Never => {}
1575+
PatKind::Missing | PatKind::Wild | PatKind::Rest | PatKind::Never => {}
15761576
PatKind::Ident(_binding_mode, ident, sub) => {
15771577
vis.visit_ident(ident);
15781578
visit_opt(sub, |sub| vis.visit_pat(sub));

Diff for: compiler/rustc_ast/src/visit.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -727,7 +727,7 @@ pub fn walk_pat<'a, V: Visitor<'a>>(visitor: &mut V, pattern: &'a Pat) -> V::Res
727727
try_visit!(visitor.visit_pat(subpattern));
728728
try_visit!(visitor.visit_expr(guard_condition));
729729
}
730-
PatKind::Wild | PatKind::Rest | PatKind::Never => {}
730+
PatKind::Missing | PatKind::Wild | PatKind::Rest | PatKind::Never => {}
731731
PatKind::Err(_guar) => {}
732732
PatKind::Tuple(elems) | PatKind::Slice(elems) | PatKind::Or(elems) => {
733733
walk_list!(visitor, visit_pat, elems);

Diff for: compiler/rustc_ast_lowering/src/lib.rs

+2-1
Original file line numberDiff line numberDiff line change
@@ -1495,6 +1495,7 @@ impl<'a, 'hir> LoweringContext<'a, 'hir> {
14951495

14961496
fn lower_fn_params_to_names(&mut self, decl: &FnDecl) -> &'hir [Option<Ident>] {
14971497
self.arena.alloc_from_iter(decl.inputs.iter().map(|param| match param.pat.kind {
1498+
PatKind::Missing => None,
14981499
PatKind::Ident(_, ident, _) => {
14991500
if ident.name != kw::Empty {
15001501
Some(self.lower_ident(ident))
@@ -1506,7 +1507,7 @@ impl<'a, 'hir> LoweringContext<'a, 'hir> {
15061507
_ => {
15071508
self.dcx().span_delayed_bug(
15081509
param.pat.span,
1509-
"non-ident/wild param pat must trigger an error",
1510+
"non-missing/ident/wild param pat must trigger an error",
15101511
);
15111512
None
15121513
}

Diff for: compiler/rustc_ast_lowering/src/pat.rs

+1
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ impl<'a, 'hir> LoweringContext<'a, 'hir> {
2626
let pat_hir_id = self.lower_node_id(pattern.id);
2727
let node = loop {
2828
match &pattern.kind {
29+
PatKind::Missing => break hir::PatKind::Missing,
2930
PatKind::Wild => break hir::PatKind::Wild,
3031
PatKind::Never => break hir::PatKind::Never,
3132
PatKind::Ident(binding_mode, ident, sub) => {

Diff for: compiler/rustc_ast_passes/src/ast_validation.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -239,7 +239,7 @@ impl<'a> AstValidator<'a> {
239239
fn check_decl_no_pat(decl: &FnDecl, mut report_err: impl FnMut(Span, Option<Ident>, bool)) {
240240
for Param { pat, .. } in &decl.inputs {
241241
match pat.kind {
242-
PatKind::Ident(BindingMode::NONE, _, None) | PatKind::Wild => {}
242+
PatKind::Missing | PatKind::Ident(BindingMode::NONE, _, None) | PatKind::Wild => {}
243243
PatKind::Ident(BindingMode::MUT, ident, None) => {
244244
report_err(pat.span, Some(ident), true)
245245
}

Diff for: compiler/rustc_ast_pretty/src/pprust/state.rs

+3-8
Original file line numberDiff line numberDiff line change
@@ -1622,9 +1622,9 @@ impl<'a> State<'a> {
16221622
fn print_pat(&mut self, pat: &ast::Pat) {
16231623
self.maybe_print_comment(pat.span.lo());
16241624
self.ann.pre(self, AnnNode::Pat(pat));
1625-
/* Pat isn't normalized, but the beauty of it
1626-
is that it doesn't matter */
1625+
/* Pat isn't normalized, but the beauty of it is that it doesn't matter */
16271626
match &pat.kind {
1627+
PatKind::Missing => unreachable!(),
16281628
PatKind::Wild => self.word("_"),
16291629
PatKind::Never => self.word("!"),
16301630
PatKind::Ident(BindingMode(by_ref, mutbl), ident, sub) => {
@@ -1946,12 +1946,7 @@ impl<'a> State<'a> {
19461946
if let Some(eself) = input.to_self() {
19471947
self.print_explicit_self(&eself);
19481948
} else {
1949-
let invalid = if let PatKind::Ident(_, ident, _) = input.pat.kind {
1950-
ident.name == kw::Empty
1951-
} else {
1952-
false
1953-
};
1954-
if !invalid {
1949+
if !matches!(input.pat.kind, PatKind::Missing) {
19551950
self.print_pat(&input.pat);
19561951
self.word(":");
19571952
self.space();

Diff for: compiler/rustc_hir/src/hir.rs

+5-1
Original file line numberDiff line numberDiff line change
@@ -1516,6 +1516,7 @@ impl<'hir> Pat<'hir> {
15161516

15171517
use PatKind::*;
15181518
match self.kind {
1519+
Missing => unreachable!(),
15191520
Wild | Never | Expr(_) | Range(..) | Binding(.., None) | Err(_) => true,
15201521
Box(s) | Deref(s) | Ref(s, _) | Binding(.., Some(s)) | Guard(s, _) => s.walk_short_(it),
15211522
Struct(_, fields, _) => fields.iter().all(|field| field.pat.walk_short_(it)),
@@ -1543,7 +1544,7 @@ impl<'hir> Pat<'hir> {
15431544

15441545
use PatKind::*;
15451546
match self.kind {
1546-
Wild | Never | Expr(_) | Range(..) | Binding(.., None) | Err(_) => {}
1547+
Missing | Wild | Never | Expr(_) | Range(..) | Binding(.., None) | Err(_) => {}
15471548
Box(s) | Deref(s) | Ref(s, _) | Binding(.., Some(s)) | Guard(s, _) => s.walk_(it),
15481549
Struct(_, fields, _) => fields.iter().for_each(|field| field.pat.walk_(it)),
15491550
TupleStruct(_, s, _) | Tuple(s, _) | Or(s) => s.iter().for_each(|p| p.walk_(it)),
@@ -1681,6 +1682,9 @@ pub enum TyPatKind<'hir> {
16811682

16821683
#[derive(Debug, Clone, Copy, HashStable_Generic)]
16831684
pub enum PatKind<'hir> {
1685+
/// A missing pattern, e.g. for an anonymous param in a bare fn like `fn f(u32)`.
1686+
Missing,
1687+
16841688
/// Represents a wildcard pattern (i.e., `_`).
16851689
Wild,
16861690

Diff for: compiler/rustc_hir/src/intravisit.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -744,7 +744,7 @@ pub fn walk_pat<'v, V: Visitor<'v>>(visitor: &mut V, pattern: &'v Pat<'v>) -> V:
744744
visit_opt!(visitor, visit_pat_expr, lower_bound);
745745
visit_opt!(visitor, visit_pat_expr, upper_bound);
746746
}
747-
PatKind::Never | PatKind::Wild | PatKind::Err(_) => (),
747+
PatKind::Missing | PatKind::Never | PatKind::Wild | PatKind::Err(_) => (),
748748
PatKind::Slice(prepatterns, ref slice_pattern, postpatterns) => {
749749
walk_list!(visitor, visit_pat, prepatterns);
750750
visit_opt!(visitor, visit_pat, slice_pattern);

Diff for: compiler/rustc_hir_analysis/src/check/region.rs

+1
Original file line numberDiff line numberDiff line change
@@ -701,6 +701,7 @@ fn resolve_local<'tcx>(
701701

702702
PatKind::Ref(_, _)
703703
| PatKind::Binding(hir::BindingMode(hir::ByRef::No, _), ..)
704+
| PatKind::Missing
704705
| PatKind::Wild
705706
| PatKind::Never
706707
| PatKind::Expr(_)

Diff for: compiler/rustc_hir_pretty/src/lib.rs

+1
Original file line numberDiff line numberDiff line change
@@ -1875,6 +1875,7 @@ impl<'a> State<'a> {
18751875
// Pat isn't normalized, but the beauty of it
18761876
// is that it doesn't matter
18771877
match pat.kind {
1878+
PatKind::Missing => unreachable!(),
18781879
PatKind::Wild => self.word("_"),
18791880
PatKind::Never => self.word("!"),
18801881
PatKind::Binding(BindingMode(by_ref, mutbl), _, ident, sub) => {

Diff for: compiler/rustc_hir_typeck/src/expr.rs

+2-1
Original file line numberDiff line numberDiff line change
@@ -482,7 +482,8 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
482482

483483
// All of these constitute a read, or match on something that isn't `!`,
484484
// which would require a `NeverToAny` coercion.
485-
hir::PatKind::Binding(_, _, _, _)
485+
hir::PatKind::Missing
486+
| hir::PatKind::Binding(_, _, _, _)
486487
| hir::PatKind::Struct(_, _, _)
487488
| hir::PatKind::TupleStruct(_, _, _)
488489
| hir::PatKind::Tuple(_, _)

Diff for: compiler/rustc_hir_typeck/src/expr_use_visitor.rs

+2
Original file line numberDiff line numberDiff line change
@@ -611,6 +611,7 @@ impl<'tcx, Cx: TypeInformationCtxt<'tcx>, D: Delegate<'tcx>> ExprUseVisitor<'tcx
611611
for pat in pats {
612612
self.cat_pattern(discr_place.clone(), pat, &mut |place, pat| {
613613
match &pat.kind {
614+
PatKind::Missing => unreachable!(),
614615
PatKind::Binding(.., opt_sub_pat) => {
615616
// If the opt_sub_pat is None, then the binding does not count as
616617
// a wildcard for the purpose of borrowing discr.
@@ -1884,6 +1885,7 @@ impl<'tcx, Cx: TypeInformationCtxt<'tcx>, D: Delegate<'tcx>> ExprUseVisitor<'tcx
18841885
| PatKind::Expr(..)
18851886
| PatKind::Range(..)
18861887
| PatKind::Never
1888+
| PatKind::Missing
18871889
| PatKind::Wild
18881890
| PatKind::Err(_) => {
18891891
// always ok

Diff for: compiler/rustc_hir_typeck/src/pat.rs

+7-4
Original file line numberDiff line numberDiff line change
@@ -341,7 +341,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
341341
};
342342

343343
let ty = match pat.kind {
344-
PatKind::Wild | PatKind::Err(_) => expected,
344+
PatKind::Missing | PatKind::Wild | PatKind::Err(_) => expected,
345345
// We allow any type here; we ensure that the type is uninhabited during match checking.
346346
PatKind::Never => expected,
347347
PatKind::Expr(PatExpr { kind: PatExprKind::Path(qpath), hir_id, span }) => {
@@ -505,9 +505,11 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
505505
},
506506

507507
// Ref patterns are complicated, we handle them in `check_pat_ref`.
508-
PatKind::Ref(..) => AdjustMode::Pass,
508+
PatKind::Ref(..)
509+
// No need to do anything on a missing pattern.
510+
| PatKind::Missing
509511
// A `_` pattern works with any expected type, so there's no need to do anything.
510-
PatKind::Wild
512+
| PatKind::Wild
511513
// A malformed pattern doesn't have an expected type, so let's just accept any type.
512514
| PatKind::Err(_)
513515
// Bindings also work with whatever the expected type is,
@@ -1037,7 +1039,8 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
10371039
| PatKind::Tuple(..)
10381040
| PatKind::Slice(..) => "binding",
10391041

1040-
PatKind::Wild
1042+
PatKind::Missing
1043+
| PatKind::Wild
10411044
| PatKind::Never
10421045
| PatKind::Binding(..)
10431046
| PatKind::Box(..)

Diff for: compiler/rustc_lint/src/builtin.rs

+12-14
Original file line numberDiff line numberDiff line change
@@ -778,21 +778,19 @@ impl EarlyLintPass for AnonymousParameters {
778778
}
779779
if let ast::AssocItemKind::Fn(box Fn { ref sig, .. }) = it.kind {
780780
for arg in sig.decl.inputs.iter() {
781-
if let ast::PatKind::Ident(_, ident, None) = arg.pat.kind {
782-
if ident.name == kw::Empty {
783-
let ty_snip = cx.sess().source_map().span_to_snippet(arg.ty.span);
781+
if let ast::PatKind::Missing = arg.pat.kind {
782+
let ty_snip = cx.sess().source_map().span_to_snippet(arg.ty.span);
784783

785-
let (ty_snip, appl) = if let Ok(ref snip) = ty_snip {
786-
(snip.as_str(), Applicability::MachineApplicable)
787-
} else {
788-
("<type>", Applicability::HasPlaceholders)
789-
};
790-
cx.emit_span_lint(
791-
ANONYMOUS_PARAMETERS,
792-
arg.pat.span,
793-
BuiltinAnonymousParams { suggestion: (arg.pat.span, appl), ty_snip },
794-
);
795-
}
784+
let (ty_snip, appl) = if let Ok(ref snip) = ty_snip {
785+
(snip.as_str(), Applicability::MachineApplicable)
786+
} else {
787+
("<type>", Applicability::HasPlaceholders)
788+
};
789+
cx.emit_span_lint(
790+
ANONYMOUS_PARAMETERS,
791+
arg.pat.span,
792+
BuiltinAnonymousParams { suggestion: (arg.pat.span, appl), ty_snip },
793+
);
796794
}
797795
}
798796
}

Diff for: compiler/rustc_lint/src/unused.rs

+2-1
Original file line numberDiff line numberDiff line change
@@ -1201,7 +1201,8 @@ impl EarlyLintPass for UnusedParens {
12011201
// Do not lint on `(..)` as that will result in the other arms being useless.
12021202
Paren(_)
12031203
// The other cases do not contain sub-patterns.
1204-
| Wild | Never | Rest | Expr(..) | MacCall(..) | Range(..) | Ident(.., None) | Path(..) | Err(_) => {},
1204+
| Missing | Wild | Never | Rest | Expr(..) | MacCall(..) | Range(..) | Ident(.., None)
1205+
| Path(..) | Err(_) => {},
12051206
// These are list-like patterns; parens can always be removed.
12061207
TupleStruct(_, _, ps) | Tuple(ps) | Slice(ps) | Or(ps) => for p in ps {
12071208
self.check_unused_parens_pat(cx, p, false, false, keep_space);

Diff for: compiler/rustc_middle/src/thir.rs

+3
Original file line numberDiff line numberDiff line change
@@ -747,6 +747,9 @@ pub struct Ascription<'tcx> {
747747

748748
#[derive(Clone, Debug, HashStable, TypeVisitable)]
749749
pub enum PatKind<'tcx> {
750+
/// A missing pattern, e.g. for an anonymous param in a bare fn like `fn f(u32)`.
751+
Missing,
752+
750753
/// A wildcard pattern: `_`.
751754
Wild,
752755

Diff for: compiler/rustc_middle/src/thir/visit.rs

+2-1
Original file line numberDiff line numberDiff line change
@@ -250,7 +250,8 @@ pub(crate) fn for_each_immediate_subpat<'a, 'tcx>(
250250
mut callback: impl FnMut(&'a Pat<'tcx>),
251251
) {
252252
match &pat.kind {
253-
PatKind::Wild
253+
PatKind::Missing
254+
| PatKind::Wild
254255
| PatKind::Binding { subpattern: None, .. }
255256
| PatKind::Constant { value: _ }
256257
| PatKind::Range(_)

Diff for: compiler/rustc_mir_build/src/builder/matches/match_pair.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -118,7 +118,7 @@ impl<'tcx> MatchPairTree<'tcx> {
118118
let place = place_builder.try_to_place(cx);
119119
let mut subpairs = Vec::new();
120120
let test_case = match pattern.kind {
121-
PatKind::Wild | PatKind::Error(_) => None,
121+
PatKind::Missing | PatKind::Wild | PatKind::Error(_) => None,
122122

123123
PatKind::Or { ref pats } => Some(TestCase::Or {
124124
pats: pats.iter().map(|pat| FlatPat::new(place_builder.clone(), pat, cx)).collect(),

Diff for: compiler/rustc_mir_build/src/builder/matches/mod.rs

+1
Original file line numberDiff line numberDiff line change
@@ -920,6 +920,7 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
920920

921921
PatKind::Constant { .. }
922922
| PatKind::Range { .. }
923+
| PatKind::Missing
923924
| PatKind::Wild
924925
| PatKind::Never
925926
| PatKind::Error(_) => {}

Diff for: compiler/rustc_mir_build/src/check_unsafety.rs

+1
Original file line numberDiff line numberDiff line change
@@ -313,6 +313,7 @@ impl<'a, 'tcx> Visitor<'a, 'tcx> for UnsafetyVisitor<'a, 'tcx> {
313313
fn visit_pat(&mut self, pat: &'a Pat<'tcx>) {
314314
if self.in_union_destructure {
315315
match pat.kind {
316+
PatKind::Missing => unreachable!(),
316317
// binding to a variable allows getting stuff out of variable
317318
PatKind::Binding { .. }
318319
// match is conditional on having this value

Diff for: compiler/rustc_mir_build/src/thir/pattern/mod.rs

+2
Original file line numberDiff line numberDiff line change
@@ -290,6 +290,8 @@ impl<'a, 'tcx> PatCtxt<'a, 'tcx> {
290290
let mut span = pat.span;
291291

292292
let kind = match pat.kind {
293+
hir::PatKind::Missing => PatKind::Missing,
294+
293295
hir::PatKind::Wild => PatKind::Wild,
294296

295297
hir::PatKind::Never => PatKind::Never,

Diff for: compiler/rustc_mir_build/src/thir/print.rs

+1
Original file line numberDiff line numberDiff line change
@@ -664,6 +664,7 @@ impl<'a, 'tcx> ThirPrinter<'a, 'tcx> {
664664
print_indented!(self, "kind: PatKind {", depth_lvl);
665665

666666
match pat_kind {
667+
PatKind::Missing => unreachable!(),
667668
PatKind::Wild => {
668669
print_indented!(self, "Wild", depth_lvl + 1);
669670
}

Diff for: compiler/rustc_parse/src/parser/item.rs

+1-3
Original file line numberDiff line numberDiff line change
@@ -2941,9 +2941,7 @@ impl<'a> Parser<'a> {
29412941
}
29422942
match ty {
29432943
Ok(ty) => {
2944-
let ident = Ident::new(kw::Empty, this.prev_token.span);
2945-
let bm = BindingMode::NONE;
2946-
let pat = this.mk_pat_ident(ty.span, bm, ident);
2944+
let pat = this.mk_pat(ty.span, PatKind::Missing);
29472945
(pat, ty)
29482946
}
29492947
// If this is a C-variadic argument and we hit an error, return the error.

Diff for: compiler/rustc_passes/src/input_stats.rs

+2
Original file line numberDiff line numberDiff line change
@@ -295,6 +295,7 @@ impl<'v> hir_visit::Visitor<'v> for StatCollector<'v> {
295295
record_variants!(
296296
(self, p, p.kind, Some(p.hir_id), hir, Pat, PatKind),
297297
[
298+
Missing,
298299
Wild,
299300
Binding,
300301
Struct,
@@ -597,6 +598,7 @@ impl<'v> ast_visit::Visitor<'v> for StatCollector<'v> {
597598
record_variants!(
598599
(self, p, p.kind, None, ast, Pat, PatKind),
599600
[
601+
Missing,
600602
Wild,
601603
Ident,
602604
Struct,

Diff for: compiler/rustc_pattern_analysis/src/rustc.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -457,7 +457,7 @@ impl<'p, 'tcx: 'p> RustcPatCtxt<'p, 'tcx> {
457457
PatKind::AscribeUserType { subpattern, .. }
458458
| PatKind::ExpandedConstant { subpattern, .. } => return self.lower_pat(subpattern),
459459
PatKind::Binding { subpattern: Some(subpat), .. } => return self.lower_pat(subpat),
460-
PatKind::Binding { subpattern: None, .. } | PatKind::Wild => {
460+
PatKind::Missing | PatKind::Binding { subpattern: None, .. } | PatKind::Wild => {
461461
ctor = Wildcard;
462462
fields = vec![];
463463
arity = 0;

Diff for: src/librustdoc/clean/utils.rs

+1
Original file line numberDiff line numberDiff line change
@@ -304,6 +304,7 @@ pub(crate) fn name_from_pat(p: &hir::Pat<'_>) -> Symbol {
304304

305305
Symbol::intern(&match &p.kind {
306306
// FIXME(never_patterns): does this make sense?
307+
PatKind::Missing => unreachable!(),
307308
PatKind::Wild
308309
| PatKind::Err(_)
309310
| PatKind::Never

Diff for: src/tools/clippy/clippy_lints/src/equatable_if_let.rs

+1
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,7 @@ fn unary_pattern(pat: &Pat<'_>) -> bool {
4545
pats.iter().all(unary_pattern)
4646
}
4747
match &pat.kind {
48+
PatKind::Missing => unreachable!(),
4849
PatKind::Slice(_, _, _)
4950
| PatKind::Range(_, _, _)
5051
| PatKind::Binding(..)

Diff for: src/tools/clippy/clippy_lints/src/matches/match_same_arms.rs

+1
Original file line numberDiff line numberDiff line change
@@ -253,6 +253,7 @@ fn iter_matching_struct_fields<'a>(
253253
impl<'a> NormalizedPat<'a> {
254254
fn from_pat(cx: &LateContext<'_>, arena: &'a DroplessArena, pat: &'a Pat<'_>) -> Self {
255255
match pat.kind {
256+
PatKind::Missing => unreachable!(),
256257
PatKind::Wild | PatKind::Binding(.., None) => Self::Wild,
257258
PatKind::Binding(.., Some(pat))
258259
| PatKind::Box(pat)

Diff for: src/tools/clippy/clippy_lints/src/matches/single_match.rs

+1
Original file line numberDiff line numberDiff line change
@@ -406,6 +406,7 @@ impl<'a> PatState<'a> {
406406
pats.iter().map(|p| p.pat),
407407
),
408408

409+
PatKind::Missing => unreachable!(),
409410
PatKind::Wild
410411
| PatKind::Binding(_, _, _, None)
411412
| PatKind::Expr(_)

0 commit comments

Comments
 (0)