From fec050ce97239a8c63680c70572e043513880acb Mon Sep 17 00:00:00 2001 From: Kirill Bulatov Date: Fri, 22 Apr 2022 22:12:25 +0300 Subject: [PATCH] Fix macos clippy issues --- pageserver/src/http/routes.rs | 2 +- pageserver/src/profiling.rs | 16 +++++++++++----- run_clippy.sh | 15 +++++++++++---- 3 files changed, 23 insertions(+), 10 deletions(-) diff --git a/pageserver/src/http/routes.rs b/pageserver/src/http/routes.rs index 2db56015ad..05485ef3b6 100644 --- a/pageserver/src/http/routes.rs +++ b/pageserver/src/http/routes.rs @@ -453,7 +453,7 @@ async fn tenant_config_handler(mut request: Request) -> Result) -> Result, ApiError> { diff --git a/pageserver/src/profiling.rs b/pageserver/src/profiling.rs index e2c12c9e12..84132659d6 100644 --- a/pageserver/src/profiling.rs +++ b/pageserver/src/profiling.rs @@ -74,22 +74,28 @@ mod profiling_impl { } } -/// Dummy implementation when compiling without profiling feature +/// Dummy implementation when compiling without profiling feature or for non-linux OSes. #[cfg(not(feature = "profiling"))] mod profiling_impl { use super::*; - pub fn profpoint_start(_conf: &PageServerConf, _point: ProfilingConfig) -> () { - () + pub struct DummyProfilerGuard; + + pub fn profpoint_start( + _conf: &PageServerConf, + _point: ProfilingConfig, + ) -> Option { + None } - pub fn init_profiler(conf: &PageServerConf) -> () { + pub fn init_profiler(conf: &PageServerConf) -> Option { if conf.profiling != ProfilingConfig::Disabled { // shouldn't happen, we don't allow profiling in the config if the support // for it is disabled. panic!("profiling enabled but the binary was compiled without profiling support"); } + None } - pub fn exit_profiler(_conf: &PageServerConf, _guard: &()) {} + pub fn exit_profiler(_conf: &PageServerConf, _guard: &Option) {} } diff --git a/run_clippy.sh b/run_clippy.sh index f26dbaa0f3..13af3fd2c5 100755 --- a/run_clippy.sh +++ b/run_clippy.sh @@ -9,7 +9,14 @@ # In vscode, this setting is Rust-analyzer>Check On Save:Command -# * `-A unknown_lints` – do not warn about unknown lint suppressions -# that people with newer toolchains might use -# * `-D warnings` - fail on any warnings (`cargo` returns non-zero exit status) -cargo clippy --all --all-targets --all-features -- -A unknown_lints -D warnings +# Not every feature is supported in macOS builds, e.g. `profiling`, +# avoid running regular linting script that checks every feature. +if [[ "$OSTYPE" == "darwin"* ]]; then + # no extra features to test currently, add more here when needed + cargo clippy --all --all-targets -- -A unknown_lints -D warnings +else + # * `-A unknown_lints` – do not warn about unknown lint suppressions + # that people with newer toolchains might use + # * `-D warnings` - fail on any warnings (`cargo` returns non-zero exit status) + cargo clippy --all --all-targets --all-features -- -A unknown_lints -D warnings +fi