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``
This commit is contained in:
Stuart Cook 2025-04-07 22:29:17 +10:00 committed by GitHub
commit 82df6229b6
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
42 changed files with 92 additions and 66 deletions

View file

@ -295,6 +295,7 @@ impl<'v> hir_visit::Visitor<'v> for StatCollector<'v> {
record_variants!(
(self, p, p.kind, Some(p.hir_id), hir, Pat, PatKind),
[
Missing,
Wild,
Binding,
Struct,
@ -597,6 +598,7 @@ impl<'v> ast_visit::Visitor<'v> for StatCollector<'v> {
record_variants!(
(self, p, p.kind, None, ast, Pat, PatKind),
[
Missing,
Wild,
Ident,
Struct,

View file

@ -96,7 +96,7 @@ use rustc_middle::query::Providers;
use rustc_middle::span_bug;
use rustc_middle::ty::{self, RootVariableMinCaptureList, Ty, TyCtxt};
use rustc_session::lint;
use rustc_span::{BytePos, Span, Symbol, kw, sym};
use rustc_span::{BytePos, Span, Symbol, sym};
use tracing::{debug, instrument};
use self::LiveNodeKind::*;
@ -1481,9 +1481,6 @@ impl<'tcx> Liveness<'_, 'tcx> {
fn should_warn(&self, var: Variable) -> Option<String> {
let name = self.ir.variable_name(var);
if name == kw::Empty {
return None;
}
let name = name.as_str();
if name.as_bytes()[0] == b'_' {
return None;