Merge pull request #2670 from serde-rs/exhaustive

Pick up changes to non_exhaustive_omitted_patterns lint
This commit is contained in:
David Tolnay 2024-01-03 18:42:59 -08:00 committed by GitHub
commit 961fa59a74
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 8 additions and 11 deletions

View File

@ -144,6 +144,7 @@ pub fn with_bound(
fn visit_type(&mut self, ty: &'ast syn::Type) { fn visit_type(&mut self, ty: &'ast syn::Type) {
match ty { match ty {
#![cfg_attr(all(test, exhaustive), deny(non_exhaustive_omitted_patterns))]
syn::Type::Array(ty) => self.visit_type(&ty.elem), syn::Type::Array(ty) => self.visit_type(&ty.elem),
syn::Type::BareFn(ty) => { syn::Type::BareFn(ty) => {
for arg in &ty.inputs { for arg in &ty.inputs {
@ -181,7 +182,6 @@ pub fn with_bound(
syn::Type::Infer(_) | syn::Type::Never(_) | syn::Type::Verbatim(_) => {} syn::Type::Infer(_) | syn::Type::Never(_) | syn::Type::Verbatim(_) => {}
#[cfg_attr(all(test, exhaustive), deny(non_exhaustive_omitted_patterns))]
_ => {} _ => {}
} }
} }
@ -196,16 +196,13 @@ pub fn with_bound(
syn::PathArguments::AngleBracketed(arguments) => { syn::PathArguments::AngleBracketed(arguments) => {
for arg in &arguments.args { for arg in &arguments.args {
match arg { match arg {
#![cfg_attr(all(test, exhaustive), deny(non_exhaustive_omitted_patterns))]
syn::GenericArgument::Type(arg) => self.visit_type(arg), syn::GenericArgument::Type(arg) => self.visit_type(arg),
syn::GenericArgument::AssocType(arg) => self.visit_type(&arg.ty), syn::GenericArgument::AssocType(arg) => self.visit_type(&arg.ty),
syn::GenericArgument::Lifetime(_) syn::GenericArgument::Lifetime(_)
| syn::GenericArgument::Const(_) | syn::GenericArgument::Const(_)
| syn::GenericArgument::AssocConst(_) | syn::GenericArgument::AssocConst(_)
| syn::GenericArgument::Constraint(_) => {} | syn::GenericArgument::Constraint(_) => {}
#[cfg_attr(
all(test, exhaustive),
deny(non_exhaustive_omitted_patterns)
)]
_ => {} _ => {}
} }
} }
@ -228,9 +225,9 @@ pub fn with_bound(
fn visit_type_param_bound(&mut self, bound: &'ast syn::TypeParamBound) { fn visit_type_param_bound(&mut self, bound: &'ast syn::TypeParamBound) {
match bound { match bound {
#![cfg_attr(all(test, exhaustive), deny(non_exhaustive_omitted_patterns))]
syn::TypeParamBound::Trait(bound) => self.visit_path(&bound.path), syn::TypeParamBound::Trait(bound) => self.visit_path(&bound.path),
syn::TypeParamBound::Lifetime(_) | syn::TypeParamBound::Verbatim(_) => {} syn::TypeParamBound::Lifetime(_) | syn::TypeParamBound::Verbatim(_) => {}
#[cfg_attr(all(test, exhaustive), deny(non_exhaustive_omitted_patterns))]
_ => {} _ => {}
} }
} }

View File

@ -1794,6 +1794,7 @@ fn borrowable_lifetimes(
fn collect_lifetimes(ty: &syn::Type, out: &mut BTreeSet<syn::Lifetime>) { fn collect_lifetimes(ty: &syn::Type, out: &mut BTreeSet<syn::Lifetime>) {
match ty { match ty {
#![cfg_attr(all(test, exhaustive), deny(non_exhaustive_omitted_patterns))]
syn::Type::Slice(ty) => { syn::Type::Slice(ty) => {
collect_lifetimes(&ty.elem, out); collect_lifetimes(&ty.elem, out);
} }
@ -1854,7 +1855,6 @@ fn collect_lifetimes(ty: &syn::Type, out: &mut BTreeSet<syn::Lifetime>) {
| syn::Type::Infer(_) | syn::Type::Infer(_)
| syn::Type::Verbatim(_) => {} | syn::Type::Verbatim(_) => {}
#[cfg_attr(all(test, exhaustive), deny(non_exhaustive_omitted_patterns))]
_ => {} _ => {}
} }
} }

View File

@ -107,6 +107,7 @@ impl ReplaceReceiver<'_> {
fn visit_type_mut_impl(&mut self, ty: &mut Type) { fn visit_type_mut_impl(&mut self, ty: &mut Type) {
match ty { match ty {
#![cfg_attr(all(test, exhaustive), deny(non_exhaustive_omitted_patterns))]
Type::Array(ty) => { Type::Array(ty) => {
self.visit_type_mut(&mut ty.elem); self.visit_type_mut(&mut ty.elem);
self.visit_expr_mut(&mut ty.len); self.visit_expr_mut(&mut ty.len);
@ -147,7 +148,6 @@ impl ReplaceReceiver<'_> {
Type::Infer(_) | Type::Never(_) | Type::Verbatim(_) => {} Type::Infer(_) | Type::Never(_) | Type::Verbatim(_) => {}
#[cfg_attr(all(test, exhaustive), deny(non_exhaustive_omitted_patterns))]
_ => {} _ => {}
} }
} }
@ -178,13 +178,13 @@ impl ReplaceReceiver<'_> {
PathArguments::AngleBracketed(arguments) => { PathArguments::AngleBracketed(arguments) => {
for arg in &mut arguments.args { for arg in &mut arguments.args {
match arg { match arg {
#![cfg_attr(all(test, exhaustive), deny(non_exhaustive_omitted_patterns))]
GenericArgument::Type(arg) => self.visit_type_mut(arg), GenericArgument::Type(arg) => self.visit_type_mut(arg),
GenericArgument::AssocType(arg) => self.visit_type_mut(&mut arg.ty), GenericArgument::AssocType(arg) => self.visit_type_mut(&mut arg.ty),
GenericArgument::Lifetime(_) GenericArgument::Lifetime(_)
| GenericArgument::Const(_) | GenericArgument::Const(_)
| GenericArgument::AssocConst(_) | GenericArgument::AssocConst(_)
| GenericArgument::Constraint(_) => {} | GenericArgument::Constraint(_) => {}
#[cfg_attr(all(test, exhaustive), deny(non_exhaustive_omitted_patterns))]
_ => {} _ => {}
} }
} }
@ -207,9 +207,9 @@ impl ReplaceReceiver<'_> {
fn visit_type_param_bound_mut(&mut self, bound: &mut TypeParamBound) { fn visit_type_param_bound_mut(&mut self, bound: &mut TypeParamBound) {
match bound { match bound {
#![cfg_attr(all(test, exhaustive), deny(non_exhaustive_omitted_patterns))]
TypeParamBound::Trait(bound) => self.visit_path_mut(&mut bound.path), TypeParamBound::Trait(bound) => self.visit_path_mut(&mut bound.path),
TypeParamBound::Lifetime(_) | TypeParamBound::Verbatim(_) => {} TypeParamBound::Lifetime(_) | TypeParamBound::Verbatim(_) => {}
#[cfg_attr(all(test, exhaustive), deny(non_exhaustive_omitted_patterns))]
_ => {} _ => {}
} }
} }
@ -228,6 +228,7 @@ impl ReplaceReceiver<'_> {
if let Some(where_clause) = &mut generics.where_clause { if let Some(where_clause) = &mut generics.where_clause {
for predicate in &mut where_clause.predicates { for predicate in &mut where_clause.predicates {
match predicate { match predicate {
#![cfg_attr(all(test, exhaustive), deny(non_exhaustive_omitted_patterns))]
WherePredicate::Type(predicate) => { WherePredicate::Type(predicate) => {
self.visit_type_mut(&mut predicate.bounded_ty); self.visit_type_mut(&mut predicate.bounded_ty);
for bound in &mut predicate.bounds { for bound in &mut predicate.bounds {
@ -235,7 +236,6 @@ impl ReplaceReceiver<'_> {
} }
} }
WherePredicate::Lifetime(_) => {} WherePredicate::Lifetime(_) => {}
#[cfg_attr(all(test, exhaustive), deny(non_exhaustive_omitted_patterns))]
_ => {} _ => {}
} }
} }