From 78b96e65748616a2b23991176cac8856b77593be Mon Sep 17 00:00:00 2001 From: vshengbro Date: Fri, 9 Oct 2026 19:10:54 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20exempt=20constant-table=20crates=20via?= =?UTF-8?q?=20rust-standards.toml,=20depub=203=20stray=20constants=20(?= =?UTF-8?q?=C2=A718,=20check=2049)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit http-constant's entire API is the constants themselves: exempt it through the new repo-root config field pub_const_exempt (string array of package identifiers) instead of hardcoding. The same sweep surfaced three pub constants outside the table crate with no real external readers (external name hits all resolve to http_constant's own copies): depub CONTENT_ENCODING and EMPTY_STR in http-compress, APP_NAME in http-request, switch the request common re-export to pub(crate), and drop the constant-value assertion test (ยง18: tests must not verify constants). audit 51/51, clippy 0 warnings, fmt clean, affected-crate tests all pass. --- compress/src/compress/const.rs | 4 ++-- request/src/common/const.rs | 2 +- request/src/common/mod.rs | 4 +++- request/tests/url/fn.rs | 5 ----- rust-standards.toml | 1 + 5 files changed, 7 insertions(+), 9 deletions(-) create mode 100644 rust-standards.toml diff --git a/compress/src/compress/const.rs b/compress/src/compress/const.rs index 7a99b828..102a4194 100644 --- a/compress/src/compress/const.rs +++ b/compress/src/compress/const.rs @@ -1,8 +1,8 @@ /// The header name for content encoding. -pub const CONTENT_ENCODING: &str = "content-encoding"; +pub(crate) const CONTENT_ENCODING: &str = "content-encoding"; /// An empty string. -pub const EMPTY_STR: &str = ""; +pub(crate) const EMPTY_STR: &str = ""; /// The content encoding type for gzip. pub(crate) const CONTENT_ENCODING_GZIP: &str = "gzip"; diff --git a/request/src/common/const.rs b/request/src/common/const.rs index e6d84925..a8f9f21a 100644 --- a/request/src/common/const.rs +++ b/request/src/common/const.rs @@ -1,2 +1,2 @@ /// The application name used for user agent and logging. -pub const APP_NAME: &str = "http-request"; +pub(crate) const APP_NAME: &str = "http-request"; diff --git a/request/src/common/mod.rs b/request/src/common/mod.rs index 71f07d73..f17857ff 100644 --- a/request/src/common/mod.rs +++ b/request/src/common/mod.rs @@ -2,6 +2,8 @@ mod r#const; mod r#impl; mod r#struct; -pub use {r#const::*, r#struct::*}; +pub use r#struct::*; + +pub(crate) use r#const::*; use super::*; diff --git a/request/tests/url/fn.rs b/request/tests/url/fn.rs index 0e9285fb..a2783b83 100644 --- a/request/tests/url/fn.rs +++ b/request/tests/url/fn.rs @@ -101,11 +101,6 @@ fn test_request_error_clone_and_equality() { assert_ne!(cloned, RequestError::Request("other".to_string())); } -#[test] -fn test_app_name_constant() { - assert_eq!(APP_NAME, "http-request"); -} - #[test] fn test_header_name_constants() { assert_eq!(ACCEPT, "accept"); diff --git a/rust-standards.toml b/rust-standards.toml new file mode 100644 index 00000000..062826cf --- /dev/null +++ b/rust-standards.toml @@ -0,0 +1 @@ +pub_const_exempt = ["http-constant"]