From b23a76841425c70926efb51d46353cccc45c1145 Mon Sep 17 00:00:00 2001 From: David Tolnay Date: Mon, 28 Mar 2022 10:07:23 -0700 Subject: [PATCH] Update exhaustive matching to syn 1.0.90 --- .github/workflows/ci.yml | 4 ++++ serde_derive/Cargo.toml | 2 +- serde_derive/src/bound.rs | 4 +--- serde_derive/src/internals/attr.rs | 4 +--- serde_derive/src/internals/receiver.rs | 4 +--- serde_derive/src/lib.rs | 1 + serde_derive_internals/Cargo.toml | 2 +- 7 files changed, 10 insertions(+), 11 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 323399ce..3c4b1308 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -59,6 +59,10 @@ jobs: - run: cd serde && cargo test --features derive,rc,unstable - run: cd test_suite/no_std && cargo build if: matrix.os != 'windows' + - run: cd serde_derive && cargo check --tests + env: + RUSTFLAGS: --cfg exhaustive ${{env.RUSTFLAGS}} + if: matrix.os != 'windows' msrv: name: Rust 1.13.0 diff --git a/serde_derive/Cargo.toml b/serde_derive/Cargo.toml index 47fda7ff..b4263a62 100644 --- a/serde_derive/Cargo.toml +++ b/serde_derive/Cargo.toml @@ -23,7 +23,7 @@ proc-macro = true [dependencies] proc-macro2 = "1.0" quote = "1.0" -syn = "1.0.60" +syn = "1.0.90" [dev-dependencies] serde = { version = "1.0", path = "../serde" } diff --git a/serde_derive/src/bound.rs b/serde_derive/src/bound.rs index abca467b..74c95069 100644 --- a/serde_derive/src/bound.rs +++ b/serde_derive/src/bound.rs @@ -184,9 +184,7 @@ pub fn with_bound( syn::Type::Infer(_) | syn::Type::Never(_) | syn::Type::Verbatim(_) => {} - #[cfg(test)] - syn::Type::__TestExhaustive(_) => unimplemented!(), - #[cfg(not(test))] + #[cfg_attr(all(test, exhaustive), deny(non_exhaustive_omitted_patterns))] _ => {} } } diff --git a/serde_derive/src/internals/attr.rs b/serde_derive/src/internals/attr.rs index 13f55250..dc532484 100644 --- a/serde_derive/src/internals/attr.rs +++ b/serde_derive/src/internals/attr.rs @@ -1912,9 +1912,7 @@ fn collect_lifetimes(ty: &syn::Type, out: &mut BTreeSet) { | syn::Type::Infer(_) | syn::Type::Verbatim(_) => {} - #[cfg(test)] - syn::Type::__TestExhaustive(_) => unimplemented!(), - #[cfg(not(test))] + #[cfg_attr(all(test, exhaustive), deny(non_exhaustive_omitted_patterns))] _ => {} } } diff --git a/serde_derive/src/internals/receiver.rs b/serde_derive/src/internals/receiver.rs index 2b722d8f..b08c6709 100644 --- a/serde_derive/src/internals/receiver.rs +++ b/serde_derive/src/internals/receiver.rs @@ -147,9 +147,7 @@ impl ReplaceReceiver<'_> { Type::Infer(_) | Type::Never(_) | Type::Verbatim(_) => {} - #[cfg(test)] - Type::__TestExhaustive(_) => unimplemented!(), - #[cfg(not(test))] + #[cfg_attr(all(test, exhaustive), deny(non_exhaustive_omitted_patterns))] _ => {} } } diff --git a/serde_derive/src/lib.rs b/serde_derive/src/lib.rs index 8079bb6c..2fe38e98 100644 --- a/serde_derive/src/lib.rs +++ b/serde_derive/src/lib.rs @@ -60,6 +60,7 @@ clippy::use_self, clippy::wildcard_imports )] +#![cfg_attr(all(test, exhaustive), feature(non_exhaustive_omitted_patterns_lint))] #[macro_use] extern crate quote; diff --git a/serde_derive_internals/Cargo.toml b/serde_derive_internals/Cargo.toml index b57b5a1d..b5f85fde 100644 --- a/serde_derive_internals/Cargo.toml +++ b/serde_derive_internals/Cargo.toml @@ -17,7 +17,7 @@ path = "lib.rs" [dependencies] proc-macro2 = "1.0" quote = "1.0" -syn = { version = "1.0.60", default-features = false, features = ["derive", "parsing", "printing", "clone-impls"] } +syn = { version = "1.0.90", default-features = false, features = ["derive", "parsing", "printing", "clone-impls"] } [package.metadata.docs.rs] targets = ["x86_64-unknown-linux-gnu"]