diff options
| author | Stuart Cook <Zalathar@users.noreply.github.com> | 2025-04-07 22:29:17 +1000 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2025-04-07 22:29:17 +1000 |
| commit | 82df6229b6383ba1395eb0599309b30e257c3c3b (patch) | |
| tree | 8331b59a1afd22ffb5f782b3ff81ba654b987253 /compiler/rustc_lint/src/builtin.rs | |
| parent | 8fb32ab8e563124fe0968a2878b7f5b5d0e8d722 (diff) | |
| parent | 909f4492475988ba5e1b84efadacb16eb7d7ff0e (diff) | |
| download | rust-82df6229b6383ba1395eb0599309b30e257c3c3b.tar.gz rust-82df6229b6383ba1395eb0599309b30e257c3c3b.zip | |
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``
Diffstat (limited to 'compiler/rustc_lint/src/builtin.rs')
| -rw-r--r-- | compiler/rustc_lint/src/builtin.rs | 26 |
1 files changed, 12 insertions, 14 deletions
diff --git a/compiler/rustc_lint/src/builtin.rs b/compiler/rustc_lint/src/builtin.rs index dae0efcbbc4..38c2bf54432 100644 --- a/compiler/rustc_lint/src/builtin.rs +++ b/compiler/rustc_lint/src/builtin.rs @@ -779,21 +779,19 @@ impl EarlyLintPass for AnonymousParameters { } if let ast::AssocItemKind::Fn(box Fn { ref sig, .. }) = it.kind { for arg in sig.decl.inputs.iter() { - if let ast::PatKind::Ident(_, ident, None) = arg.pat.kind { - if ident.name == kw::Empty { - let ty_snip = cx.sess().source_map().span_to_snippet(arg.ty.span); + if let ast::PatKind::Missing = arg.pat.kind { + let ty_snip = cx.sess().source_map().span_to_snippet(arg.ty.span); - let (ty_snip, appl) = if let Ok(ref snip) = ty_snip { - (snip.as_str(), Applicability::MachineApplicable) - } else { - ("<type>", Applicability::HasPlaceholders) - }; - cx.emit_span_lint( - ANONYMOUS_PARAMETERS, - arg.pat.span, - BuiltinAnonymousParams { suggestion: (arg.pat.span, appl), ty_snip }, - ); - } + let (ty_snip, appl) = if let Ok(ref snip) = ty_snip { + (snip.as_str(), Applicability::MachineApplicable) + } else { + ("<type>", Applicability::HasPlaceholders) + }; + cx.emit_span_lint( + ANONYMOUS_PARAMETERS, + arg.pat.span, + BuiltinAnonymousParams { suggestion: (arg.pat.span, appl), ty_snip }, + ); } } } |
