From 62f3022632ae5f829e5102ea88bcd1976fcfa134 Mon Sep 17 00:00:00 2001 From: tottoto Date: Thu, 19 Jun 2025 07:19:30 +0900 Subject: [PATCH] chore(test): Simplify skip debug test --- tests/skip_debug/Cargo.toml | 3 +++ tests/skip_debug/src/lib.rs | 11 +++-------- tests/skip_debug/tests/skip_debug.rs | 8 -------- 3 files changed, 6 insertions(+), 16 deletions(-) delete mode 100644 tests/skip_debug/tests/skip_debug.rs diff --git a/tests/skip_debug/Cargo.toml b/tests/skip_debug/Cargo.toml index 586f33273..70884156a 100644 --- a/tests/skip_debug/Cargo.toml +++ b/tests/skip_debug/Cargo.toml @@ -10,5 +10,8 @@ name = "skip_debug" prost = "0.14" tonic = { path = "../../tonic" } +[dev-dependencies] +static_assertions = "1" + [build-dependencies] tonic-build = { path = "../../tonic-build" } diff --git a/tests/skip_debug/src/lib.rs b/tests/skip_debug/src/lib.rs index 46908f15d..79e2e11ca 100644 --- a/tests/skip_debug/src/lib.rs +++ b/tests/skip_debug/src/lib.rs @@ -1,11 +1,6 @@ pub mod pb { tonic::include_proto!("test"); - - // Add a dummy impl Debug to the skipped debug implementations to avoid - // missing impl Debug errors and check debug is not implemented for Output. - impl std::fmt::Debug for Output { - fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { - f.debug_struct("Output").finish() - } - } } + +#[cfg(test)] +static_assertions::assert_not_impl_all!(pb::Output: std::fmt::Debug); diff --git a/tests/skip_debug/tests/skip_debug.rs b/tests/skip_debug/tests/skip_debug.rs deleted file mode 100644 index a29d998d7..000000000 --- a/tests/skip_debug/tests/skip_debug.rs +++ /dev/null @@ -1,8 +0,0 @@ -use std::{fs, path::PathBuf}; - -#[test] -fn skip_debug() { - let path = PathBuf::from(std::env::var("OUT_DIR").unwrap()).join("test.rs"); - let s = fs::read_to_string(path).unwrap(); - assert!(s.contains("#[prost(skip_debug)]\npub struct Output {}")); -}