From c19046f711911410c296947451acdd815dcf9452 Mon Sep 17 00:00:00 2001 From: Moritz Hoffmann Date: Wed, 9 Apr 2025 10:10:58 +0200 Subject: [PATCH 1/2] Deny use of anyhow macros Denies the use of the anyhow `anyhow` and `bail` macros, which are the main entry points to anyhow. It does not prevent using the error/result types as they're often just passed through. Part of MaterializeInc/database-issues#9092 Signed-off-by: Moritz Hoffmann --- clippy.toml | 2 ++ misc/bazel/cargo-gazelle/src/bin/main.rs | 3 +++ misc/bazel/cargo-gazelle/src/context.rs | 2 ++ misc/bazel/cargo-gazelle/src/targets.rs | 6 ++++++ src/adapter/src/active_compute_sink.rs | 4 ++++ src/adapter/src/catalog.rs | 2 ++ src/adapter/src/catalog/state.rs | 2 ++ src/adapter/src/catalog/transact.rs | 2 ++ src/adapter/src/client.rs | 4 ++++ src/adapter/src/config/frontend.rs | 2 ++ src/adapter/src/coord.rs | 2 ++ src/adapter/src/coord/ddl.rs | 4 ++++ src/adapter/src/coord/introspection.rs | 2 ++ src/adapter/src/coord/sequencer/inner.rs | 6 ++++++ src/adapter/src/coord/sequencer/inner/cluster.rs | 2 ++ .../src/coord/sequencer/inner/copy_from.rs | 4 ++++ .../sequencer/inner/create_materialized_view.rs | 2 ++ src/adapter/src/coord/sequencer/inner/secret.rs | 2 ++ src/adapter/src/coord/timestamp_selection.rs | 6 ++++++ src/adapter/src/explain/optimizer_trace.rs | 2 ++ src/adapter/src/session.rs | 2 ++ src/arrow-util/src/builder.rs | 12 ++++++++++++ src/arrow-util/src/reader.rs | 6 ++++++ src/aws-secrets-controller/src/lib.rs | 2 ++ src/aws-util/src/s3.rs | 2 ++ src/aws-util/src/s3_uploader.rs | 6 ++++++ src/balancerd/src/bin/balancerd.rs | 2 ++ src/balancerd/src/dyncfgs.rs | 4 +++- src/balancerd/src/lib.rs | 6 ++++++ src/catalog-debug/src/main.rs | 2 ++ src/catalog-protos/build.rs | 2 ++ src/catalog/src/config.rs | 2 ++ src/catalog/src/durable/transaction.rs | 8 ++++++++ src/ccsr/src/client.rs | 2 ++ src/cluster-client/src/lib.rs | 2 ++ src/cluster/src/client.rs | 2 ++ src/cluster/src/communication.rs | 2 ++ src/compute-client/src/controller/instance.rs | 2 ++ src/compute-client/src/controller/replica.rs | 2 ++ src/controller/src/clusters.rs | 2 ++ src/dyncfg-launchdarkly/src/lib.rs | 6 ++++++ src/environmentd/src/environmentd/main.rs | 2 ++ src/environmentd/src/http.rs | 2 ++ src/environmentd/src/http/sql.rs | 8 ++++++++ src/environmentd/src/http/webhook.rs | 4 ++++ src/environmentd/src/lib.rs | 4 ++++ src/environmentd/src/test_util.rs | 6 ++++++ src/environmentd/tests/server.rs | 9 ++++++++- src/environmentd/tests/sql.rs | 5 ++++- src/frontegg-auth/src/auth.rs | 2 ++ src/frontegg-mock/src/main.rs | 2 ++ src/interchange/src/avro/schema.rs | 8 ++++++-- src/interchange/src/confluent.rs | 4 ++++ src/interchange/src/protobuf.rs | 10 ++++++++++ src/kafka-util/src/admin.rs | 6 ++++++ src/kafka-util/src/aws.rs | 2 ++ src/kafka-util/src/bin/kgen.rs | 2 ++ src/kafka-util/src/client.rs | 6 ++++++ src/license-keys/src/lib.rs | 4 ++++ src/license-keys/src/signing.rs | 4 ++++ src/mysql-util/src/decoding.rs | 4 ++++ src/mysql-util/src/desc.rs | 2 ++ src/mysql-util/src/schemas.rs | 2 ++ src/mz-debug/src/docker_dumper.rs | 2 ++ src/mz-debug/src/k8s_dumper.rs | 2 ++ src/mz-debug/src/kubectl_port_forwarder.rs | 4 ++++ src/mz-debug/src/system_catalog_dumper.rs | 2 ++ src/npm/src/lib.rs | 2 ++ src/orchestrator-kubernetes/src/lib.rs | 12 ++++++++++++ src/orchestrator-kubernetes/src/secrets.rs | 2 ++ src/orchestrator-kubernetes/src/util.rs | 2 ++ src/orchestrator-process/src/lib.rs | 4 ++++ src/orchestratord/src/controller/materialize.rs | 2 ++ src/ore/src/error.rs | 4 ++++ src/ore/src/result.rs | 2 ++ src/ore/src/retry.rs | 10 ++++++++-- src/ore/src/test.rs | 2 ++ src/persist-cli/src/maelstrom/node.rs | 4 ++++ src/persist-cli/src/maelstrom/services.rs | 6 ++++++ src/persist-cli/src/open_loop.rs | 2 ++ src/persist-client/src/cli/admin.rs | 4 ++++ src/persist-client/src/cli/inspect.rs | 4 ++++ src/persist-client/src/fetch.rs | 2 ++ src/persist-client/src/internal/compact.rs | 6 ++++++ src/persist-client/src/internal/machine.rs | 16 ++++++++++++++++ src/persist-client/src/internal/restore.rs | 2 ++ src/persist-client/src/iter.rs | 4 ++++ src/persist-client/src/lib.rs | 2 ++ src/persist-client/src/rpc.rs | 2 ++ src/persist-types/src/columnar.rs | 4 ++++ src/persist-types/src/parquet.rs | 2 ++ src/persist-types/src/stats.rs | 10 ++++++++++ src/persist/src/azure.rs | 2 ++ src/persist/src/cfg.rs | 4 ++++ src/persist/src/file.rs | 8 ++++++++ src/persist/src/indexed/columnar/arrow.rs | 2 ++ src/persist/src/indexed/encoding.rs | 2 ++ src/persist/src/location.rs | 8 ++++++++ src/persist/src/mem.rs | 6 ++++++ src/persist/src/postgres.rs | 4 ++++ src/persist/src/s3.rs | 10 ++++++++++ src/persist/src/unreliable.rs | 2 ++ src/pgtest/src/lib.rs | 8 ++++++++ src/pgtz/build.rs | 2 ++ src/postgres-client/src/lib.rs | 2 ++ src/postgres-util/src/desc.rs | 2 ++ src/postgres-util/src/replication.rs | 6 ++++++ src/postgres-util/src/schemas.rs | 2 ++ src/postgres-util/src/tunnel.rs | 4 ++++ src/prof/src/time.rs | 2 ++ src/regexp/src/lib.rs | 2 ++ src/repr/src/adt/char.rs | 2 ++ src/repr/src/adt/date.rs | 2 ++ src/repr/src/adt/interval.rs | 12 ++++++++++++ src/repr/src/adt/mz_acl_item.rs | 12 ++++++++++++ src/repr/src/adt/numeric.rs | 8 ++++++++ src/repr/src/adt/varchar.rs | 2 ++ src/repr/src/catalog_item_id.rs | 2 ++ src/repr/src/global_id.rs | 2 ++ src/repr/src/network_policy_id.rs | 2 ++ src/repr/src/relation.rs | 4 ++++ src/repr/src/role_id.rs | 6 ++++++ src/repr/src/row/encode.rs | 8 ++++++++ src/repr/src/stats.rs | 2 ++ src/rocksdb-types/src/config.rs | 6 ++++++ src/secrets/src/lib.rs | 2 ++ src/server-core/src/lib.rs | 2 ++ src/sql-lexer/build.rs | 2 ++ src/sql-server-util/src/desc.rs | 2 ++ src/sql-server-util/src/lib.rs | 6 ++++++ src/sql/src/names.rs | 2 ++ src/sql/src/plan/with_options.rs | 2 ++ src/sql/src/pure.rs | 2 ++ src/sqllogictest/src/lib.rs | 3 +++ src/ssh-util/src/tunnel.rs | 4 ++++ src/ssh-util/src/tunnel_manager.rs | 2 ++ src/storage-client/src/client.rs | 2 ++ src/storage-client/src/sink.rs | 2 ++ src/storage-client/src/storage_collections.rs | 2 ++ src/storage-controller/src/collection_mgmt.rs | 2 ++ src/storage-controller/src/instance.rs | 2 ++ src/storage-controller/src/lib.rs | 4 ++++ src/storage-operators/src/s3_oneshot_sink.rs | 4 ++++ .../src/s3_oneshot_sink/parquet.rs | 2 ++ .../src/s3_oneshot_sink/pgcopy.rs | 6 ++++++ src/storage-types/src/connections.rs | 6 ++++++ src/storage-types/src/connections/aws.rs | 8 ++++++++ src/storage-types/src/errors.rs | 6 ++++++ src/storage-types/src/instances.rs | 2 ++ src/storage-types/src/sinks/s3_oneshot_sink.rs | 2 ++ src/storage-types/src/sources.rs | 2 ++ src/storage-types/src/sources/envelope.rs | 4 ++++ src/storage/examples/upsert_open_loop.rs | 2 ++ src/storage/src/render/persist_sink.rs | 2 ++ src/storage/src/sink/kafka.rs | 14 ++++++++++++++ src/storage/src/source/kafka.rs | 4 ++++ .../src/source/mysql/replication/events.rs | 6 ++++++ src/storage/src/source/mysql/snapshot.rs | 2 ++ src/storage/src/source/postgres.rs | 2 ++ src/storage/src/source/postgres/replication.rs | 2 ++ src/storage/src/source/postgres/snapshot.rs | 2 ++ src/storage/src/source/reclock/compat.rs | 2 ++ src/storage/src/upsert/autospill.rs | 2 ++ src/storage/src/upsert/memory.rs | 2 ++ src/storage/src/upsert/types.rs | 6 ++++++ src/testdrive/src/lib.rs | 2 ++ src/tls-util/src/lib.rs | 2 ++ src/transform/tests/test_runner.rs | 4 ++++ src/walkabout/src/ir.rs | 10 ++++++++++ .../smoketest/src/bin/metabase-smoketest.rs | 2 ++ 170 files changed, 651 insertions(+), 7 deletions(-) diff --git a/clippy.toml b/clippy.toml index 0f257f6826cc2..6878b47da66eb 100644 --- a/clippy.toml +++ b/clippy.toml @@ -88,6 +88,8 @@ disallowed-macros = [ { path = "proptest::prop_oneof", reason = "use `proptest::strategy::Union::new` instead" }, { path = "log::log", reason = "use the macros provided by `tracing` instead (database-issues#3001)" }, { path = "tracing::instrument", reason = "use `mz_ore::instrument` instead" }, + { path = "anyhow::anyhow", reason = "use structured errors instead" }, + { path = "anyhow::bail", reason = "use structured errors instead" }, ] disallowed-types = [ diff --git a/misc/bazel/cargo-gazelle/src/bin/main.rs b/misc/bazel/cargo-gazelle/src/bin/main.rs index f611cd642d864..5e9a6cc3325ec 100644 --- a/misc/bazel/cargo-gazelle/src/bin/main.rs +++ b/misc/bazel/cargo-gazelle/src/bin/main.rs @@ -7,6 +7,9 @@ // the Business Source License, use of this software will be governed // by the Apache License, Version 2.0. +// database-issues#9092: anyhow should not be used. +#![allow(clippy::disallowed_macros)] + use std::fmt; use std::io::{Read, Write}; use std::path::Path; diff --git a/misc/bazel/cargo-gazelle/src/context.rs b/misc/bazel/cargo-gazelle/src/context.rs index cc1e1a17666bb..a97233e13c537 100644 --- a/misc/bazel/cargo-gazelle/src/context.rs +++ b/misc/bazel/cargo-gazelle/src/context.rs @@ -59,6 +59,8 @@ pub struct BuildScriptContext { } impl BuildScriptContext { + // database-issues#9092: anyhow should not be used. + #[allow(clippy::disallowed_macros)] pub fn generate( config: &GlobalConfig, build_script_path: impl AsRef, diff --git a/misc/bazel/cargo-gazelle/src/targets.rs b/misc/bazel/cargo-gazelle/src/targets.rs index 56c0e0d589588..ba047ce0c9a6a 100644 --- a/misc/bazel/cargo-gazelle/src/targets.rs +++ b/misc/bazel/cargo-gazelle/src/targets.rs @@ -289,6 +289,8 @@ impl RustTarget for RustBinary { } impl RustBinary { + // database-issues#9092: anyhow should not be used. + #[allow(clippy::disallowed_macros)] pub fn generate( config: &GlobalConfig, metadata: &PackageMetadata, @@ -575,6 +577,8 @@ impl RustTest { ) } + // database-issues#9092: anyhow should not be used. + #[allow(clippy::disallowed_macros)] pub fn integration( config: &GlobalConfig, metadata: &PackageMetadata, @@ -818,6 +822,8 @@ impl RustTarget for CargoBuildScript { } impl CargoBuildScript { + // database-issues#9092: anyhow should not be used. + #[allow(clippy::disallowed_macros)] pub fn generate( config: &GlobalConfig, context: &CrateContext, diff --git a/src/adapter/src/active_compute_sink.rs b/src/adapter/src/active_compute_sink.rs index e6251e75a6022..f990c25997762 100644 --- a/src/adapter/src/active_compute_sink.rs +++ b/src/adapter/src/active_compute_sink.rs @@ -413,6 +413,8 @@ impl ActiveCopyTo { /// /// Either this method or `retire` must be called on every copy to before it /// is dropped. + // database-issues#9092: anyhow should not be used. + #[allow(clippy::disallowed_macros)] pub fn retire_with_response(self, response: Result) { let response = match response { Ok(n) => Ok(ExecuteResponse::Copied(usize::cast_from(n))), @@ -425,6 +427,8 @@ impl ActiveCopyTo { /// /// Either this method or `retire_with_response` must be called on every /// copy to before it is dropped. + // database-issues#9092: anyhow should not be used. + #[allow(clippy::disallowed_macros)] pub fn retire(self, reason: ActiveComputeSinkRetireReason) { let message = match reason { ActiveComputeSinkRetireReason::Finished => return, diff --git a/src/adapter/src/catalog.rs b/src/adapter/src/catalog.rs index 10a300ac9914d..0efb5d1fbaebc 100644 --- a/src/adapter/src/catalog.rs +++ b/src/adapter/src/catalog.rs @@ -1000,6 +1000,8 @@ impl Catalog { } } + // database-issues#9092: anyhow should not be used. + #[allow(clippy::disallowed_macros)] pub fn active_cluster(&self, session: &Session) -> Result<&Cluster, AdapterError> { // TODO(benesch): this check here is not sufficiently protective. It'd // be very easy for a code path to accidentally avoid this check by diff --git a/src/adapter/src/catalog/state.rs b/src/adapter/src/catalog/state.rs index 6432dacd605ef..48662e2353b80 100644 --- a/src/adapter/src/catalog/state.rs +++ b/src/adapter/src/catalog/state.rs @@ -991,6 +991,8 @@ impl CatalogState { /// Parses the given SQL string into a `CatalogItem`. #[mz_ore::instrument] + // database-issues#9092: anyhow should not be used. + #[allow(clippy::disallowed_macros)] pub(crate) fn parse_item( &self, global_id: GlobalId, diff --git a/src/adapter/src/catalog/transact.rs b/src/adapter/src/catalog/transact.rs index 752bdc6fa21c8..c0eab6e2c678d 100644 --- a/src/adapter/src/catalog/transact.rs +++ b/src/adapter/src/catalog/transact.rs @@ -369,6 +369,8 @@ impl Catalog { } #[instrument(name = "catalog::transact")] + // database-issues#9092: anyhow should not be used. + #[allow(clippy::disallowed_macros)] pub async fn transact( &mut self, // n.b. this is an option to prevent us from needing to build out a diff --git a/src/adapter/src/client.rs b/src/adapter/src/client.rs index 2de3e05ba9030..67d845dfe4af5 100644 --- a/src/adapter/src/client.rs +++ b/src/adapter/src/client.rs @@ -354,6 +354,8 @@ Issue a SQL query to get started. Need help? /// Executes a single SQL statement that returns rows as the /// `mz_support` user. + // database-issues#9092: anyhow should not be used. + #[allow(clippy::disallowed_macros)] pub async fn support_execute_one( &self, sql: &str, @@ -406,6 +408,8 @@ Issue a SQL query to get started. Need help? } /// Get a metadata and a channel that can be used to append to a webhook source. + // database-issues#9092: anyhow should not be used. + #[allow(clippy::disallowed_macros)] pub async fn get_webhook_appender( &self, database: String, diff --git a/src/adapter/src/config/frontend.rs b/src/adapter/src/config/frontend.rs index f1f839510304c..394eedcf7693f 100644 --- a/src/adapter/src/config/frontend.rs +++ b/src/adapter/src/config/frontend.rs @@ -152,6 +152,8 @@ async fn ld_client(sync_config: &SystemParameterSyncConfig) -> Result( &mut self, conn_id: Option<&ConnectionId>, @@ -1164,6 +1166,8 @@ impl Coordinator { self.drop_sources(source_ids) } + // database-issues#9092: anyhow should not be used. + #[allow(clippy::disallowed_macros)] fn drop_vpc_endpoints_in_background(&self, vpc_endpoints: Vec) { let cloud_resource_controller = Arc::clone(self.cloud_resource_controller .as_ref() diff --git a/src/adapter/src/coord/introspection.rs b/src/adapter/src/coord/introspection.rs index f880b405ef944..cf436afb62279 100644 --- a/src/adapter/src/coord/introspection.rs +++ b/src/adapter/src/coord/introspection.rs @@ -519,6 +519,8 @@ pub(super) struct SubscribeSpec { } impl SubscribeSpec { + // database-issues#9092: anyhow should not be used. + #![allow(clippy::disallowed_macros)] fn to_plan(&self, catalog: &dyn SessionCatalog) -> Result { let parsed = mz_sql::parse::parse(self.sql)?.into_element(); let (stmt, resolved_ids) = mz_sql::names::resolve(catalog, parsed.ast)?; diff --git a/src/adapter/src/coord/sequencer/inner.rs b/src/adapter/src/coord/sequencer/inner.rs index a83bd1a9b2091..c030c0790c7d0 100644 --- a/src/adapter/src/coord/sequencer/inner.rs +++ b/src/adapter/src/coord/sequencer/inner.rs @@ -770,6 +770,8 @@ impl Coordinator { } #[instrument] + // database-issues#9092: anyhow should not be used. + #[allow(clippy::disallowed_macros)] pub(super) async fn sequence_create_connection( &mut self, mut ctx: ExecuteContext, @@ -1764,6 +1766,8 @@ impl Coordinator { Ok(ExecuteResponse::DroppedOwned) } + // database-issues#9092: anyhow should not be used. + #[allow(clippy::disallowed_macros)] fn sequence_drop_common( &self, session: &Session, @@ -2797,6 +2801,8 @@ impl Coordinator { /// or read-then-writes can occur between the Peek and SendDiff otherwise a /// serializability violation could occur. #[instrument] + // database-issues#9092: anyhow should not be used. + #[allow(clippy::disallowed_macros)] pub(super) async fn sequence_read_then_write( &mut self, mut ctx: ExecuteContext, diff --git a/src/adapter/src/coord/sequencer/inner/cluster.rs b/src/adapter/src/coord/sequencer/inner/cluster.rs index 9ff0166142aa4..5e08e8cdad965 100644 --- a/src/adapter/src/coord/sequencer/inner/cluster.rs +++ b/src/adapter/src/coord/sequencer/inner/cluster.rs @@ -115,6 +115,8 @@ impl Staged for ClusterStage { } } +// database-issues#9092: anyhow should not be used. +#[allow(clippy::disallowed_macros)] impl Coordinator { #[instrument] pub(crate) async fn sequence_alter_cluster_staged( diff --git a/src/adapter/src/coord/sequencer/inner/copy_from.rs b/src/adapter/src/coord/sequencer/inner/copy_from.rs index e142fc5cf76e8..b7661cf40be3e 100644 --- a/src/adapter/src/coord/sequencer/inner/copy_from.rs +++ b/src/adapter/src/coord/sequencer/inner/copy_from.rs @@ -29,6 +29,8 @@ use crate::session::{TransactionOps, WriteOp}; use crate::{AdapterError, ExecuteContext, ExecuteResponse}; impl Coordinator { + // database-issues#9092: anyhow should not be used. + #[allow(clippy::disallowed_macros)] pub(crate) async fn sequence_copy_from( &mut self, ctx: ExecuteContext, @@ -212,6 +214,8 @@ impl Coordinator { .await; } + // database-issues#9092: anyhow should not be used. + #[allow(clippy::disallowed_macros)] pub(crate) fn commit_staged_batches( &mut self, conn_id: ConnectionId, diff --git a/src/adapter/src/coord/sequencer/inner/create_materialized_view.rs b/src/adapter/src/coord/sequencer/inner/create_materialized_view.rs index 929d109b3c84f..e53caabe3a558 100644 --- a/src/adapter/src/coord/sequencer/inner/create_materialized_view.rs +++ b/src/adapter/src/coord/sequencer/inner/create_materialized_view.rs @@ -877,6 +877,8 @@ impl Coordinator { Ok(StageResult::Response(Self::send_immediate_rows(rows))) } + // database-issues#9092: anyhow should not be used. + #[allow(clippy::disallowed_macros)] pub(crate) async fn explain_pushdown_materialized_view( &self, ctx: ExecuteContext, diff --git a/src/adapter/src/coord/sequencer/inner/secret.rs b/src/adapter/src/coord/sequencer/inner/secret.rs index 7fec9678f6d0f..7fad5941d22a6 100644 --- a/src/adapter/src/coord/sequencer/inner/secret.rs +++ b/src/adapter/src/coord/sequencer/inner/secret.rs @@ -139,6 +139,8 @@ impl Coordinator { ))) } + // database-issues#9092: anyhow should not be used. + #[allow(clippy::disallowed_macros)] fn extract_secret( &self, session: &Session, diff --git a/src/adapter/src/coord/timestamp_selection.rs b/src/adapter/src/coord/timestamp_selection.rs index 9e99ef0aff300..679fff21b0697 100644 --- a/src/adapter/src/coord/timestamp_selection.rs +++ b/src/adapter/src/coord/timestamp_selection.rs @@ -248,6 +248,8 @@ pub trait TimestampProvider { } /// Determines the timestamp for a query using the classical logic (as opposed to constraint-based). + // database-issues#9092: anyhow should not be used. + #[allow(clippy::disallowed_macros)] fn determine_timestamp_classical( &self, session: &Session, @@ -407,6 +409,8 @@ pub trait TimestampProvider { /// Uses constraints and preferences to determine a timestamp for a query. /// Returns the determined timestamp, the constraints that were applied, and /// session_oracle_read_ts. + // database-issues#9092: anyhow should not be used. + #[allow(clippy::disallowed_macros)] fn determine_timestamp_via_constraints( &self, session: &Session, @@ -937,6 +941,8 @@ impl Coordinator { } } + // database-issues#9092: anyhow should not be used. + #[allow(clippy::disallowed_macros)] pub(crate) fn evaluate_when( catalog: &CatalogState, mut timestamp: MirScalarExpr, diff --git a/src/adapter/src/explain/optimizer_trace.rs b/src/adapter/src/explain/optimizer_trace.rs index 2f029bdce7024..4129c8d9a801e 100644 --- a/src/adapter/src/explain/optimizer_trace.rs +++ b/src/adapter/src/explain/optimizer_trace.rs @@ -128,6 +128,8 @@ impl OptimizerTrace { /// Convert the optimizer trace into a vector or rows that can be returned /// to the client. + // database-issues#9092: anyhow should not be used. + #[allow(clippy::disallowed_macros)] pub async fn into_rows( self, format: ExplainFormat, diff --git a/src/adapter/src/session.rs b/src/adapter/src/session.rs index 3315fb3f4a5aa..e203ea1b41171 100644 --- a/src/adapter/src/session.rs +++ b/src/adapter/src/session.rs @@ -745,6 +745,8 @@ impl Session { } /// Creates and installs a new portal. + // database-issues#9092: anyhow should not be used. + #[allow(clippy::disallowed_macros)] pub fn create_new_portal( &mut self, stmt: Option>, diff --git a/src/arrow-util/src/builder.rs b/src/arrow-util/src/builder.rs index 3596dfbcbcdb2..6f858d6100879 100644 --- a/src/arrow-util/src/builder.rs +++ b/src/arrow-util/src/builder.rs @@ -35,6 +35,8 @@ pub struct ArrowBuilder { impl ArrowBuilder { /// Helper to validate that a RelationDesc can be encoded into Arrow. + // database-issues#9092: anyhow should not be used. + #[allow(clippy::disallowed_macros)] pub fn validate_desc(desc: &RelationDesc) -> Result<(), anyhow::Error> { let mut errs = vec![]; for (col_name, col_type) in desc.iter() { @@ -54,6 +56,8 @@ impl ArrowBuilder { /// the number of values that can be appended to each column before reallocating. /// `data_capacity` is used to initialize the buffer size of the string and binary builders. /// Errors if the relation contains an unimplemented type. + // database-issues#9092: anyhow should not be used. + #[allow(clippy::disallowed_macros)] pub fn new( desc: &RelationDesc, item_capacity: usize, @@ -138,6 +142,8 @@ impl ArrowBuilder { /// Return the appropriate Arrow DataType for the given ScalarType, plus a string /// that should be used as part of the Arrow 'Extension Type' name for fields using /// this type: +// database-issues#9092: anyhow should not be used. +#[allow(clippy::disallowed_macros)] fn scalar_to_arrow_datatype(scalar_type: &ScalarType) -> Result<(DataType, String), anyhow::Error> { let (data_type, extension_name) = match scalar_type { ScalarType::Bool => (DataType::Boolean, "boolean"), @@ -288,6 +294,8 @@ fn scalar_to_arrow_datatype(scalar_type: &ScalarType) -> Result<(DataType, Strin Ok((data_type, extension_name.to_lowercase())) } +// database-issues#9092: anyhow should not be used. +#[allow(clippy::disallowed_macros)] fn builder_for_datatype( data_type: &DataType, item_capacity: usize, @@ -439,6 +447,8 @@ fn field_with_typename( } /// Extract the materialize 'type name' from the metadata of a Field. +// database-issues#9092: anyhow should not be used. +#[allow(clippy::disallowed_macros)] fn typename_from_field(field: &Field) -> Result { let metadata = field.metadata(); let extension_name = metadata @@ -581,6 +591,8 @@ make_col_builder!( ); impl ArrowColumn { + // database-issues#9092: anyhow should not be used. + #[allow(clippy::disallowed_macros)] fn append_datum(&mut self, datum: Datum) -> Result<(), anyhow::Error> { match (&mut self.inner, datum) { (s, Datum::Null) => s.append_null(), diff --git a/src/arrow-util/src/reader.rs b/src/arrow-util/src/reader.rs index 0f67ec063896c..9e4dc39b40fa5 100644 --- a/src/arrow-util/src/reader.rs +++ b/src/arrow-util/src/reader.rs @@ -64,6 +64,8 @@ impl ArrowReader { /// columns, perform some lightweight casting, and matching not on column name but column /// position. /// TODO(cf2): Allow specifying an optional `arrow::Schema` for extra metadata. + // database-issues#9092: anyhow should not be used. + #[allow(clippy::disallowed_macros)] pub fn new(desc: &RelationDesc, array: StructArray) -> Result { let inner_columns = array.columns(); let desc_columns = desc.typ().columns(); @@ -113,6 +115,8 @@ impl ArrowReader { } } +// database-issues#9092: anyhow should not be used. +#[allow(clippy::disallowed_macros)] fn scalar_type_and_array_to_reader( scalar_type: &ScalarType, array: Arc, @@ -448,6 +452,8 @@ enum ColReader { } impl ColReader { + // database-issues#9092: anyhow should not be used. + #[allow(clippy::disallowed_macros)] fn read(&self, idx: usize, packer: &mut RowPacker) -> Result<(), anyhow::Error> { let datum = match self { ColReader::Boolean(array) => array.is_valid(idx).then(|| array.value(idx)).map(|x| { diff --git a/src/aws-secrets-controller/src/lib.rs b/src/aws-secrets-controller/src/lib.rs index 64f74ddf874f8..790d2532f417b 100644 --- a/src/aws-secrets-controller/src/lib.rs +++ b/src/aws-secrets-controller/src/lib.rs @@ -211,6 +211,8 @@ impl AwsSecretsClient { #[async_trait] impl SecretsReader for AwsSecretsClient { + // database-issues#9092: anyhow should not be used. + #[allow(clippy::disallowed_macros)] async fn read(&self, id: CatalogItemId) -> Result, anyhow::Error> { let op_id = Uuid::new_v4(); info!(secret_id = %id, %op_id, "reading secret from AWS"); diff --git a/src/aws-util/src/s3.rs b/src/aws-util/src/s3.rs index fd7382ea91837..117c819b97480 100644 --- a/src/aws-util/src/s3.rs +++ b/src/aws-util/src/s3.rs @@ -35,6 +35,8 @@ pub fn new_presigned_config() -> PresigningConfig { PresigningConfig::expires_in(Duration::from_secs(5 * 60)).expect("known valid") } +// database-issues#9092: anyhow should not be used. +#[allow(clippy::disallowed_macros)] pub async fn list_bucket_path( client: &Client, bucket: &str, diff --git a/src/aws-util/src/s3_uploader.rs b/src/aws-util/src/s3_uploader.rs index 4e82c4e465617..d9147c985a975 100644 --- a/src/aws-util/src/s3_uploader.rs +++ b/src/aws-util/src/s3_uploader.rs @@ -101,6 +101,8 @@ impl S3MultiPartUploaderConfig { /// As per S3 limits, the part size cannot be less than 5MiB and cannot exceed 5GiB. /// As per S3 limits, the object size cannot exceed 5TiB. + // database-issues#9092: anyhow should not be used. + #[allow(clippy::disallowed_macros)] fn validate(&self) -> Result<(), anyhow::Error> { let S3MultiPartUploaderConfig { part_size_limit, @@ -151,6 +153,8 @@ impl S3MultiPartUploader { /// Creates a an instance of `S3MultiPartUploader` for the given `bucket` and `path`. /// This starts the multi part upload by making a `create_multipart_upload` call, and /// initializes all the internal state required to track the ongoing upload. + // database-issues#9092: anyhow should not be used. + #[allow(clippy::disallowed_macros)] pub async fn try_new( sdk_config: &SdkConfig, bucket: String, @@ -217,6 +221,8 @@ impl S3MultiPartUploader { /// Finishes the multi part upload. /// /// Returns the number of parts and number of bytes uploaded. + // database-issues#9092: anyhow should not be used. + #[allow(clippy::disallowed_macros)] pub async fn finish(mut self) -> Result { let remaining = self.buffer.split(); self.upload_part_internal(remaining.freeze())?; diff --git a/src/balancerd/src/bin/balancerd.rs b/src/balancerd/src/bin/balancerd.rs index b459e5db20991..a592df93e2177 100644 --- a/src/balancerd/src/bin/balancerd.rs +++ b/src/balancerd/src/bin/balancerd.rs @@ -190,6 +190,8 @@ fn main() { drop(_tracing_guard); } +// database-issues#9092: anyhow should not be used. +#[allow(clippy::disallowed_macros)] pub async fn run(args: ServiceArgs, tracing_handle: TracingHandle) -> Result<(), anyhow::Error> { let metrics_registry = MetricsRegistry::new(); let (resolver, cancellation_resolver) = diff --git a/src/balancerd/src/dyncfgs.rs b/src/balancerd/src/dyncfgs.rs index 6803c3b7497ef..fc18fae0db13f 100644 --- a/src/balancerd/src/dyncfgs.rs +++ b/src/balancerd/src/dyncfgs.rs @@ -112,7 +112,9 @@ pub fn all_dyncfgs(configs: ConfigSet) -> ConfigSet { /// Not all ConfigSet values can be defaulted with this /// function. An error will be returned if a key does /// not accept default overrides, or if there is a value -/// parsing error.. +/// parsing error. +// database-issues#9092: anyhow should not be used. +#[allow(clippy::disallowed_macros)] pub(crate) fn set_defaults( config_set: &ConfigSet, default_config: Vec<(String, String)>, diff --git a/src/balancerd/src/lib.rs b/src/balancerd/src/lib.rs index a164ef2ed3723..cab38b31aed01 100644 --- a/src/balancerd/src/lib.rs +++ b/src/balancerd/src/lib.rs @@ -186,6 +186,8 @@ pub struct BalancerService { } impl BalancerService { + // database-issues#9092: anyhow should not be used. + #[allow(clippy::disallowed_macros)] pub async fn new(cfg: BalancerConfig) -> Result { let pgwire = listen(&cfg.pgwire_listen_addr).await?; let https = listen(&cfg.https_listen_addr).await?; @@ -1226,6 +1228,8 @@ pub enum Resolver { } impl Resolver { + // database-issues#9092: anyhow should not be used. + #[allow(clippy::disallowed_macros)] async fn resolve( &self, conn: &mut FramedConn, @@ -1278,6 +1282,8 @@ impl Resolver { } /// Returns the first IP address resolved from the provided hostname. +// database-issues#9092: anyhow should not be used. +#[allow(clippy::disallowed_macros)] async fn lookup(name: &str) -> Result { let mut addrs = tokio::net::lookup_host(name).await?; match addrs.next() { diff --git a/src/catalog-debug/src/main.rs b/src/catalog-debug/src/main.rs index da05a7ce106f7..0097ce754bf3f 100644 --- a/src/catalog-debug/src/main.rs +++ b/src/catalog-debug/src/main.rs @@ -546,6 +546,8 @@ async fn epoch( Ok(()) } +// database-issues#9092: anyhow should not be used. +#[allow(clippy::disallowed_macros)] async fn upgrade_check( args: Args, openable_state: Box, diff --git a/src/catalog-protos/build.rs b/src/catalog-protos/build.rs index 16cce303e0dec..1371b287d91c3 100644 --- a/src/catalog-protos/build.rs +++ b/src/catalog-protos/build.rs @@ -28,6 +28,8 @@ struct ProtoHash { const PROTO_DIRECTORY: &str = "protos"; const PROTO_HASHES: &str = "protos/hashes.json"; +// database-issues#9092: anyhow should not be used. +#[allow(clippy::disallowed_macros)] fn main() -> anyhow::Result<()> { println!("cargo:rerun-if-changed={PROTO_DIRECTORY}"); diff --git a/src/catalog/src/config.rs b/src/catalog/src/config.rs index fd4c978e33b7e..d9cd31bca1a81 100644 --- a/src/catalog/src/config.rs +++ b/src/catalog/src/config.rs @@ -108,6 +108,8 @@ pub struct BuiltinItemMigrationConfig { pub struct ClusterReplicaSizeMap(pub BTreeMap); impl ClusterReplicaSizeMap { + // database-issues#9092: anyhow should not be used. + #[allow(clippy::disallowed_macros)] pub fn parse_from_str(s: &str, credit_consumption_from_memory: bool) -> anyhow::Result { let mut cluster_replica_sizes: BTreeMap = serde_json::from_str(s)?; diff --git a/src/catalog/src/durable/transaction.rs b/src/catalog/src/durable/transaction.rs index b62a93ca4e0ad..79a329b9ef3a8 100644 --- a/src/catalog/src/durable/transaction.rs +++ b/src/catalog/src/durable/transaction.rs @@ -866,6 +866,8 @@ impl<'a> Transaction<'a> { /// Allocates `amount` OIDs. OIDs can be recycled if they aren't currently assigned to any /// object. #[mz_ore::instrument] + // database-issues#9092: anyhow should not be used. + #[allow(clippy::disallowed_macros)] fn allocate_oids( &mut self, amount: u64, @@ -2487,6 +2489,8 @@ impl StorageTxn for Transaction<'_> { .collect() } + // database-issues#9092: anyhow should not be used. + #[allow(clippy::disallowed_macros)] fn insert_collection_metadata( &mut self, metadata: BTreeMap, @@ -2538,6 +2542,8 @@ impl StorageTxn for Transaction<'_> { .collect() } + // database-issues#9092: anyhow should not be used. + #[allow(clippy::disallowed_macros)] fn insert_unfinalized_shards( &mut self, s: BTreeSet, @@ -2571,6 +2577,8 @@ impl StorageTxn for Transaction<'_> { .map(|TxnWalShardValue { shard }| *shard) } + // database-issues#9092: anyhow should not be used. + #[allow(clippy::disallowed_macros)] fn write_txn_wal_shard( &mut self, shard: ShardId, diff --git a/src/ccsr/src/client.rs b/src/ccsr/src/client.rs index fc959d9e3da19..78238ddd1c296 100644 --- a/src/ccsr/src/client.rs +++ b/src/ccsr/src/client.rs @@ -41,6 +41,8 @@ impl fmt::Debug for Client { } impl Client { + // database-issues#9092: anyhow should not be used. + #[allow(clippy::disallowed_macros)] pub(crate) fn new( inner: reqwest::Client, url: Arc Url + Send + Sync + 'static>, diff --git a/src/cluster-client/src/lib.rs b/src/cluster-client/src/lib.rs index e4784254339ad..f917bc8fea42e 100644 --- a/src/cluster-client/src/lib.rs +++ b/src/cluster-client/src/lib.rs @@ -66,6 +66,8 @@ impl fmt::Display for ReplicaId { impl FromStr for ReplicaId { type Err = anyhow::Error; + // database-issues#9092: anyhow should not be used. + #[allow(clippy::disallowed_macros)] fn from_str(s: &str) -> Result { let first = s.chars().next(); let rest = s.get(1..); diff --git a/src/cluster/src/client.rs b/src/cluster/src/client.rs index e690ed8402466..dbe7ee20b4134 100644 --- a/src/cluster/src/client.rs +++ b/src/cluster/src/client.rs @@ -229,6 +229,8 @@ pub trait ClusterSpec: Clone + Send + Sync + 'static { ); /// Build a Timely cluster using the given config. + // database-issues#9092: anyhow should not be used. + #[allow(clippy::disallowed_macros)] async fn build_cluster( &self, config: TimelyConfig, diff --git a/src/cluster/src/communication.rs b/src/cluster/src/communication.rs index 0851ecaa59165..8c7808dbd39c2 100644 --- a/src/cluster/src/communication.rs +++ b/src/cluster/src/communication.rs @@ -52,6 +52,8 @@ use timely::communication::allocator::{GenericBuilder, PeerBuilder}; use tracing::{debug, info, warn}; /// Creates communication mesh from cluster config +// database-issues#9092: anyhow should not be used. +#[allow(clippy::disallowed_macros)] pub async fn initialize_networking

( workers: usize, process: usize, diff --git a/src/compute-client/src/controller/instance.rs b/src/compute-client/src/controller/instance.rs index 05d621e7510aa..5267b10110389 100644 --- a/src/compute-client/src/controller/instance.rs +++ b/src/compute-client/src/controller/instance.rs @@ -1962,6 +1962,8 @@ where self.finish_peek(uuid, response) } + // database-issues#9092: anyhow should not be used. + #[allow(clippy::disallowed_macros)] fn handle_copy_to_response( &mut self, sink_id: GlobalId, diff --git a/src/compute-client/src/controller/replica.rs b/src/compute-client/src/controller/replica.rs index f70d89bff6d37..88517c2757100 100644 --- a/src/compute-client/src/controller/replica.rs +++ b/src/compute-client/src/controller/replica.rs @@ -230,6 +230,8 @@ where /// Returns (with an `Err`) if it encounters an error condition (e.g. the replica disconnects). /// If no error condition is encountered, the task runs until the controller disconnects from /// the command channel, or the task is dropped. + // database-issues#9092: anyhow should not be used. + #[allow(clippy::disallowed_macros)] async fn run_message_loop(mut self, mut client: Client) -> Result<(), anyhow::Error> where T: ComputeControllerTimestamp, diff --git a/src/controller/src/clusters.rs b/src/controller/src/clusters.rs index 28dcf67da260b..9a035eade669a 100644 --- a/src/controller/src/clusters.rs +++ b/src/controller/src/clusters.rs @@ -841,6 +841,8 @@ impl fmt::Display for ReplicaServiceName { impl FromStr for ReplicaServiceName { type Err = anyhow::Error; + // database-issues#9092: anyhow should not be used. + #[allow(clippy::disallowed_macros)] fn from_str(s: &str) -> Result { static SERVICE_NAME_RE: LazyLock = LazyLock::new(|| { Regex::new(r"(?-u)^([us]\d+)-replica-([us]\d+)(?:-gen-(\d+))?$").unwrap() diff --git a/src/dyncfg-launchdarkly/src/lib.rs b/src/dyncfg-launchdarkly/src/lib.rs index d8e6a23c38b31..65dcee9086b4d 100644 --- a/src/dyncfg-launchdarkly/src/lib.rs +++ b/src/dyncfg-launchdarkly/src/lib.rs @@ -102,6 +102,8 @@ where Ok(()) } +// database-issues#9092: anyhow should not be used. +#[allow(clippy::disallowed_macros)] fn ld_ctx(build_info: &'static BuildInfo, ctx_builder: F) -> Result where F: FnOnce(&mut ld::MultiContextBuilder) -> Result<(), anyhow::Error>, @@ -163,6 +165,8 @@ impl SyncedConfigSet { } /// Reads current values from LaunchDarkly and updates the ConfigSet. + // database-issues#9092: anyhow should not be used. + #[allow(clippy::disallowed_macros)] fn sync(&self) -> Result<(), anyhow::Error> { let mut updates = ConfigUpdates::default(); let Some(ld_client) = &self.ld_client else { @@ -211,6 +215,8 @@ impl SyncedConfigSet { /// Converts a dyncfg ConfigVal into a LaunchDarkly FlagValue. Returns an error if the ConfigVal /// type isn't supported by the FlagValue format. +// database-issues#9092: anyhow should not be used. +#[allow(clippy::disallowed_macros)] fn dyn_into_flag(val: ConfigVal) -> Result { // Note that errors must only (and always) occur when the ConfigVal type isn't fully supported. // That is, don't error only if the current value isn't supported (like None in an Opt type): diff --git a/src/environmentd/src/environmentd/main.rs b/src/environmentd/src/environmentd/main.rs index 9958582b37c29..0376157de3424 100644 --- a/src/environmentd/src/environmentd/main.rs +++ b/src/environmentd/src/environmentd/main.rs @@ -676,6 +676,8 @@ pub fn main() { } } +// database-issues#9092: anyhow should not be used. +#[allow(clippy::disallowed_macros)] fn run(mut args: Args) -> Result<(), anyhow::Error> { mz_ore::panic::install_enhanced_handler(); let envd_start = Instant::now(); diff --git a/src/environmentd/src/http.rs b/src/environmentd/src/http.rs index 17d7fa62901b8..d648e9223dcad 100644 --- a/src/environmentd/src/http.rs +++ b/src/environmentd/src/http.rs @@ -755,6 +755,8 @@ async fn http_auth( Ok(next.run(req).await) } +// database-issues#9092: anyhow should not be used. +#[allow(clippy::disallowed_macros)] async fn init_ws( WsState { frontegg, diff --git a/src/environmentd/src/http/sql.rs b/src/environmentd/src/http/sql.rs index 6f1f0c987e24a..e1b2f9e077271 100644 --- a/src/environmentd/src/http/sql.rs +++ b/src/environmentd/src/http/sql.rs @@ -826,6 +826,8 @@ impl ResultSender for WebSocket { // error the transaction, but remain connected. It is Ok(Ok(())) if the statement succeeded. The // second component of the return value is `Some` if execution still needs to be retired for // statement logging purposes. + // database-issues#9092: anyhow should not be used. + #[allow(clippy::disallowed_macros)] async fn add_result( &mut self, client: &mut SessionClient, @@ -1118,6 +1120,8 @@ async fn execute_stmt_group( /// /// See the user-facing documentation about the HTTP API for a description of /// the semantics of this function. +// database-issues#9092: anyhow should not be used. +#[allow(clippy::disallowed_macros)] async fn execute_request( client: &mut AuthedClient, request: SqlRequest, @@ -1178,6 +1182,8 @@ async fn execute_request( Ok(()) } + // database-issues#9092: anyhow should not be used. + #[allow(clippy::disallowed_macros)] fn parse<'a>( client: &SessionClient, query: &'a str, @@ -1257,6 +1263,8 @@ async fn execute_request( } /// Executes a single statement in a [`SqlRequest`]. +// database-issues#9092: anyhow should not be used. +#[allow(clippy::disallowed_macros)] async fn execute_stmt( client: &mut SessionClient, sender: &mut S, diff --git a/src/environmentd/src/http/webhook.rs b/src/environmentd/src/http/webhook.rs index 4665fae03255b..a183354b9b33a 100644 --- a/src/environmentd/src/http/webhook.rs +++ b/src/environmentd/src/http/webhook.rs @@ -229,6 +229,8 @@ fn transform_body( } /// Pack the headers of a request into a [`Row`]. +// database-issues#9092: anyhow should not be used. +#[allow(clippy::disallowed_macros)] fn pack_header( mut body_row: BodyRow, headers: &BTreeMap, @@ -333,6 +335,8 @@ pub enum WebhookError { } impl From for WebhookError { + // database-issues#9092: anyhow should not be used. + #[allow(clippy::disallowed_macros)] fn from(err: AppendWebhookError) -> Self { match err { AppendWebhookError::MissingSecret => WebhookError::SecretMissing, diff --git a/src/environmentd/src/lib.rs b/src/environmentd/src/lib.rs index 8e9430f90bae6..0417ea0d87c3e 100644 --- a/src/environmentd/src/lib.rs +++ b/src/environmentd/src/lib.rs @@ -270,6 +270,8 @@ impl Listeners { /// /// Returns a handle to the server once it is fully booted. #[instrument(name = "environmentd::serve")] + // database-issues#9092: anyhow should not be used. + #[allow(clippy::disallowed_macros)] pub async fn serve(self, config: Config) -> Result { let serve_start = Instant::now(); info!("startup: envd serve: beginning"); @@ -856,6 +858,8 @@ impl Listeners { } } +// database-issues#9092: anyhow should not be used. +#[allow(clippy::disallowed_macros)] fn get_ld_value( name: &str, remote_system_parameters: &Option>, diff --git a/src/environmentd/src/test_util.rs b/src/environmentd/src/test_util.rs index e6634d568df31..7ea1da72e40dc 100644 --- a/src/environmentd/src/test_util.rs +++ b/src/environmentd/src/test_util.rs @@ -364,6 +364,8 @@ impl Listeners { .await } + // database-issues#9092: anyhow should not be used. + #[allow(clippy::disallowed_macros)] pub async fn serve_with_trigger( self, config: TestHarness, @@ -1090,6 +1092,8 @@ pub async fn get_explain_timestamp_determination( /// /// WARNING: If multiple tests use this, and the tests are run in parallel, then make sure the test /// use different postgres tables. +// database-issues#9092: anyhow should not be used. +#[allow(clippy::disallowed_macros)] pub async fn create_postgres_source_with_table<'a>( server: &TestServer, mz_client: &Client, @@ -1281,6 +1285,8 @@ pub fn auth_with_ws( ) } +// database-issues#9092: anyhow should not be used. +#[allow(clippy::disallowed_macros)] pub fn auth_with_ws_impl( ws: &mut WebSocket>, auth_message: Message, diff --git a/src/environmentd/tests/server.rs b/src/environmentd/tests/server.rs index f35216afffc1c..73c0430447970 100644 --- a/src/environmentd/tests/server.rs +++ b/src/environmentd/tests/server.rs @@ -1176,6 +1176,8 @@ fn test_storage_usage_collection_interval() { /// Waits for the next storage collection to occur, then returns the /// timestamp at which the collection occurred. The timestamp of the last /// collection must be provided + // database-issues#9092: anyhow should not be used. + #[allow(clippy::disallowed_macros)] fn wait_for_next_collection( client: &mut postgres::Client, last_timestamp: DateTime, @@ -2785,6 +2787,8 @@ fn test_cancel_ws() { #[mz_ore::test(tokio::test(flavor = "multi_thread", worker_threads = 1))] #[cfg_attr(miri, ignore)] // too slow +// database-issues#9092: anyhow should not be used. +#[allow(clippy::disallowed_macros)] async fn smoketest_webhook_source() { let server = test_util::TestHarness::default().start().await; let client = server.connect().await.unwrap(); @@ -3090,7 +3094,10 @@ fn test_github_20262() { // Test that the server properly handles cancellation requests of read-then-write queries. // See database-issues#6134. #[mz_ore::test] -#[cfg_attr(miri, ignore)] // unsupported operation: can't call foreign function `epoll_wait` on OS `linux` +#[cfg_attr(miri, ignore)] +// unsupported operation: can't call foreign function `epoll_wait` on OS `linux` +// database-issues#9092: anyhow should not be used. +#[allow(clippy::disallowed_macros)] fn test_cancel_read_then_write() { let server = test_util::TestHarness::default() .unsafe_mode() diff --git a/src/environmentd/tests/sql.rs b/src/environmentd/tests/sql.rs index e962c22e4638e..a91ae85552439 100644 --- a/src/environmentd/tests/sql.rs +++ b/src/environmentd/tests/sql.rs @@ -3276,7 +3276,10 @@ async fn test_explain_as_of() { // Test that RETAIN HISTORY results in the since and upper being separated by the specified amount. #[mz_ore::test(tokio::test(flavor = "multi_thread", worker_threads = 1))] -#[ignore] // TODO: Reenable when database-issues#7450 is fixed +// TODO: Reenable when database-issues#7450 is fixed +#[ignore] +// database-issues#9092: anyhow should not be used. +#[allow(clippy::disallowed_macros)] async fn test_retain_history() { let server = test_util::TestHarness::default().start().await; let client = server.connect().await.unwrap(); diff --git a/src/frontegg-auth/src/auth.rs b/src/frontegg-auth/src/auth.rs index 4ee1ad15e5c4b..c090b2408eed8 100644 --- a/src/frontegg-auth/src/auth.rs +++ b/src/frontegg-auth/src/auth.rs @@ -122,6 +122,8 @@ impl Authenticator { } /// Create an [`Authenticator`] from [`FronteggCliArgs`]. + // database-issues#9092: anyhow should not be used. + #[allow(clippy::disallowed_macros)] pub fn from_args( args: FronteggCliArgs, registry: &MetricsRegistry, diff --git a/src/frontegg-mock/src/main.rs b/src/frontegg-mock/src/main.rs index d0bf92158841a..7163982f3b533 100644 --- a/src/frontegg-mock/src/main.rs +++ b/src/frontegg-mock/src/main.rs @@ -76,6 +76,8 @@ async fn main() { } } +// database-issues#9092: anyhow should not be used. +#[allow(clippy::disallowed_macros)] async fn run(args: Args) -> Result<(), anyhow::Error> { let mut addrs = tokio::net::lookup_host(&args.listen_addr) .await diff --git a/src/interchange/src/avro/schema.rs b/src/interchange/src/avro/schema.rs index bdd4f04a5e6fc..2d4462e312c10 100644 --- a/src/interchange/src/avro/schema.rs +++ b/src/interchange/src/avro/schema.rs @@ -41,7 +41,7 @@ use std::fmt; use std::str::FromStr; use std::sync::Arc; -use anyhow::{anyhow, bail, Context}; +use anyhow::{bail, Context}; use mz_avro::error::Error as AvroError; use mz_avro::schema::{resolve_schemas, Schema, SchemaNode, SchemaPiece, SchemaPieceOrNamed}; use mz_ore::cast::CastFrom; @@ -94,6 +94,8 @@ fn validate_schema_1(schema: SchemaNode) -> anyhow::Result( seen_avro_nodes: &mut BTreeSet, schema: SchemaNode<'a>, @@ -106,7 +108,7 @@ fn get_union_columns<'a>( let mut columns = vec![]; let vs = us.variants(); if vs.is_empty() || (vs.len() == 1 && is_null(&vs[0])) { - bail!(anyhow!("Empty or null-only unions are not supported")); + bail!("Empty or null-only unions are not supported"); } else { for (i, v) in vs.iter().filter(|v| !is_null(v)).enumerate() { let named_idx = match v { @@ -185,6 +187,8 @@ fn get_named_columns<'a>( /// Get the single column corresponding to a schema node. /// It is an error if this node should correspond to more than one column /// (because it is an Essential Union in the sense described in the module docs). +// database-issues#9092: anyhow should not be used. +#[allow(clippy::disallowed_macros)] fn validate_schema_2( seen_avro_nodes: &mut BTreeSet, schema: SchemaNode, diff --git a/src/interchange/src/confluent.rs b/src/interchange/src/confluent.rs index b8c456ba45888..1523c362e9452 100644 --- a/src/interchange/src/confluent.rs +++ b/src/interchange/src/confluent.rs @@ -14,6 +14,8 @@ use byteorder::{BigEndian, ByteOrder}; /// Optionally expect an empty /// /// This function returns the schema_id and a subslice of the rest of the buffer +// database-issues#9092: anyhow should not be used. +#[allow(clippy::disallowed_macros)] fn extract_schema_id<'buf>(buf: &'buf [u8], protocol: &str) -> Result<(i32, &'buf [u8])> { // The first byte is a magic byte (0) that indicates the Confluent // serialization format version, and the next four bytes are a big @@ -52,6 +54,8 @@ pub fn extract_avro_header(buf: &[u8]) -> Result<(i32, &[u8])> { extract_schema_id(buf, "avro") } +// database-issues#9092: anyhow should not be used. +#[allow(clippy::disallowed_macros)] pub fn extract_protobuf_header(buf: &[u8]) -> Result<(i32, &[u8])> { let (schema_id, buf) = extract_schema_id(buf, "protobuf")?; diff --git a/src/interchange/src/protobuf.rs b/src/interchange/src/protobuf.rs index c0a6458a2eb0c..1072a96e2cd05 100644 --- a/src/interchange/src/protobuf.rs +++ b/src/interchange/src/protobuf.rs @@ -28,6 +28,8 @@ pub struct DecodedDescriptors { impl DecodedDescriptors { /// Builds a `DecodedDescriptors` from an encoded `FileDescriptorSet` and /// the fully qualified name of a message inside that file descriptor set. + // database-issues#9092: anyhow should not be used. + #[allow(clippy::disallowed_macros)] pub fn from_bytes(bytes: &[u8], message_name: String) -> Result { let fds = DescriptorPool::decode(bytes).context("decoding file descriptor set")?; let message_descriptor = fds.get_message_by_name(&message_name).ok_or_else(|| { @@ -111,6 +113,8 @@ impl Decoder { } } +// database-issues#9092: anyhow should not be used. +#[allow(clippy::disallowed_macros)] fn derive_column_type( seen_messages: &mut BTreeSet, field: &FieldDescriptor, @@ -133,6 +137,8 @@ fn derive_column_type( } } +// database-issues#9092: anyhow should not be used. +#[allow(clippy::disallowed_macros)] fn derive_inner_type( seen_messages: &mut BTreeSet, ty: Kind, @@ -169,6 +175,8 @@ fn derive_inner_type( } } +// database-issues#9092: anyhow should not be used. +#[allow(clippy::disallowed_macros)] fn pack_message(packer: &mut RowPacker, message: &DynamicMessage) -> Result<(), anyhow::Error> { for field_desc in message.descriptor().fields() { if !message.has_field(&field_desc) { @@ -189,6 +197,8 @@ fn pack_message(packer: &mut RowPacker, message: &DynamicMessage) -> Result<(), Ok(()) } +// database-issues#9092: anyhow should not be used. +#[allow(clippy::disallowed_macros)] fn pack_value( packer: &mut RowPacker, field_desc: &FieldDescriptor, diff --git a/src/kafka-util/src/admin.rs b/src/kafka-util/src/admin.rs index 533a3f8961f08..624f2ac55a398 100644 --- a/src/kafka-util/src/admin.rs +++ b/src/kafka-util/src/admin.rs @@ -30,6 +30,8 @@ use tracing::{info, warn}; /// /// Materialize may not have permission to list configs for the topic, so callers of this method /// should "fail open" if the configs are not available. +// database-issues#9092: anyhow should not be used. +#[allow(clippy::disallowed_macros)] pub async fn get_topic_config<'a, C>( client: &'a AdminClient, admin_opts: &AdminOptions, @@ -58,6 +60,8 @@ where /// /// Materialize may not have permission to alter configs for the topic, so callers of this method /// should "fail open" if the configs are not available. +// database-issues#9092: anyhow should not be used. +#[allow(clippy::disallowed_macros)] pub async fn alter_topic_config<'a, C>( client: &'a AdminClient, admin_opts: &AdminOptions, @@ -197,6 +201,8 @@ where /// succeed. /// /// Returns a boolean indicating whether the topic already existed. +// database-issues#9092: anyhow should not be used. +#[allow(clippy::disallowed_macros)] pub async fn ensure_topic<'a, C>( client: &'a AdminClient, admin_opts: &AdminOptions, diff --git a/src/kafka-util/src/aws.rs b/src/kafka-util/src/aws.rs index b66b0a1992ea5..908d1fdad1833 100644 --- a/src/kafka-util/src/aws.rs +++ b/src/kafka-util/src/aws.rs @@ -52,6 +52,8 @@ pub enum SignerError { /// Generate a base64-encoded signed url as an auth token by loading IAM /// credentials from an AWS credentials provider. +// database-issues#9092: anyhow should not be used. +#[allow(clippy::disallowed_macros)] pub async fn generate_auth_token(sdk_config: &SdkConfig) -> Result<(String, i64), anyhow::Error> { let Some(region) = sdk_config.region() else { bail!("internal error: AWS configuration missing region"); diff --git a/src/kafka-util/src/bin/kgen.rs b/src/kafka-util/src/bin/kgen.rs index aa92ad29a86c4..1ec02a0fd6fee 100644 --- a/src/kafka-util/src/bin/kgen.rs +++ b/src/kafka-util/src/bin/kgen.rs @@ -588,6 +588,8 @@ struct Args { } #[tokio::main] +// database-issues#9092: anyhow should not be used. +#[allow(clippy::disallowed_macros)] async fn main() -> anyhow::Result<()> { let args: Args = cli::parse_args(CliConfig::default()); diff --git a/src/kafka-util/src/client.rs b/src/kafka-util/src/client.rs index b5c37ad49a21a..44d83d788ed01 100644 --- a/src/kafka-util/src/client.rs +++ b/src/kafka-util/src/client.rs @@ -448,6 +448,8 @@ where { const ENABLE_REFRESH_OAUTH_TOKEN: bool = true; + // database-issues#9092: anyhow should not be used. + #[allow(clippy::disallowed_macros)] fn generate_oauth_token( &self, _oauthbearer_config: Option<&str>, @@ -679,6 +681,8 @@ pub enum GetPartitionsError { } /// Retrieve number of partitions for a given `topic` using the given `client` +// database-issues#9092: anyhow should not be used. +#[allow(clippy::disallowed_macros)] pub fn get_partitions( client: &Client, topic: &str, @@ -693,6 +697,8 @@ pub fn get_partitions( ))?; } + // database-issues#9092: anyhow should not be used. + #[allow(clippy::disallowed_macros)] fn check_err(err: Option) -> Result<(), GetPartitionsError> { match err.map(RDKafkaErrorCode::from) { Some(RDKafkaErrorCode::UnknownTopic | RDKafkaErrorCode::UnknownTopicOrPartition) => { diff --git a/src/license-keys/src/lib.rs b/src/license-keys/src/lib.rs index 654024354ae6a..d78d2d0476b3e 100644 --- a/src/license-keys/src/lib.rs +++ b/src/license-keys/src/lib.rs @@ -79,6 +79,8 @@ impl Default for ValidatedLicenseKey { } } +// database-issues#9092: anyhow should not be used. +#[allow(clippy::disallowed_macros)] pub fn validate(license_key: &str, environment_id: &str) -> anyhow::Result { let mut err = anyhow!("no public key found"); for pubkey in PUBLIC_KEYS { @@ -144,6 +146,8 @@ struct Payload { expiration_behavior: ExpirationBehavior, } +// database-issues#9092: anyhow should not be used. +#[allow(clippy::disallowed_macros)] fn validate_with_pubkey_v1( license_key: &str, pubkey_pem: &str, diff --git a/src/license-keys/src/signing.rs b/src/license-keys/src/signing.rs index d8101d95a73c0..b3e8c1e334022 100644 --- a/src/license-keys/src/signing.rs +++ b/src/license-keys/src/signing.rs @@ -67,6 +67,8 @@ pub async fn make_license_key( Ok(format!("{}.{}", signing_string, signature)) } +// database-issues#9092: anyhow should not be used. +#[allow(clippy::disallowed_macros)] async fn get_pubkey(client: &aws_sdk_kms::Client, key_id: &str) -> anyhow::Result> { if let Some(pubkey) = client .get_public_key() @@ -81,6 +83,8 @@ async fn get_pubkey(client: &aws_sdk_kms::Client, key_id: &str) -> anyhow::Resul } } +// database-issues#9092: anyhow should not be used. +#[allow(clippy::disallowed_macros)] async fn sign( client: &aws_sdk_kms::Client, key_id: &str, diff --git a/src/mysql-util/src/decoding.rs b/src/mysql-util/src/decoding.rs index 15076c9ca0d33..91a04b99fabea 100644 --- a/src/mysql-util/src/decoding.rs +++ b/src/mysql-util/src/decoding.rs @@ -70,6 +70,8 @@ pub fn pack_mysql_row( // TODO(guswynn|roshan): This function has various `.to_string()` and `format!` calls that should // use a shared allocation if possible. +// database-issues#9092: anyhow should not be used. +#[allow(clippy::disallowed_macros)] fn pack_val_as_datum( value: Value, col_desc: &MySqlColumnDesc, @@ -334,6 +336,8 @@ fn pack_val_as_datum( Ok(()) } +// database-issues#9092: anyhow should not be used. +#[allow(clippy::disallowed_macros)] fn check_char_length( length: Option, val: &str, diff --git a/src/mysql-util/src/desc.rs b/src/mysql-util/src/desc.rs index b46c89af2223f..ccfc8884d61d6 100644 --- a/src/mysql-util/src/desc.rs +++ b/src/mysql-util/src/desc.rs @@ -76,6 +76,8 @@ impl MySqlTableDesc { /// exceptions: /// - `self`'s columns are a prefix of `other`'s columns. /// - `self`'s keys are all present in `other` + // database-issues#9092: anyhow should not be used. + #[allow(clippy::disallowed_macros)] pub fn determine_compatibility(&self, other: &MySqlTableDesc) -> Result<(), anyhow::Error> { if self == other { return Ok(()); diff --git a/src/mysql-util/src/schemas.rs b/src/mysql-util/src/schemas.rs index e9b9ee29910ac..e2aef2d28851a 100644 --- a/src/mysql-util/src/schemas.rs +++ b/src/mysql-util/src/schemas.rs @@ -526,6 +526,8 @@ static ENUM_VAL_REGEX: LazyLock = /// "enum('apple','banana','cher,ry','ora''nge')" /// We need to handle the case where the enum value itself contains a comma or a /// single quote (escaped with another quote), so we use a regex to do so +// database-issues#9092: anyhow should not be used. +#[allow(clippy::disallowed_macros)] fn enum_vals_from_column_type(s: &str) -> Result, anyhow::Error> { let vals_str = s .strip_prefix("enum(") diff --git a/src/mz-debug/src/docker_dumper.rs b/src/mz-debug/src/docker_dumper.rs index f3314e71334d2..e5ae789634563 100644 --- a/src/mz-debug/src/docker_dumper.rs +++ b/src/mz-debug/src/docker_dumper.rs @@ -44,6 +44,8 @@ impl DockerDumper { } /// Execute a Docker command and return (stdout, stderr). + // database-issues#9092: anyhow should not be used. + #[allow(clippy::disallowed_macros)] async fn execute_docker_command( &self, args: &[String], diff --git a/src/mz-debug/src/k8s_dumper.rs b/src/mz-debug/src/k8s_dumper.rs index 850dd92b237ee..4028c11847616 100644 --- a/src/mz-debug/src/k8s_dumper.rs +++ b/src/mz-debug/src/k8s_dumper.rs @@ -166,6 +166,8 @@ impl<'n> K8sDumper<'n> { } } + // database-issues#9092: anyhow should not be used. + #[allow(clippy::disallowed_macros)] async fn _dump_kubectl_describe( &self, namespace: Option<&String>, diff --git a/src/mz-debug/src/kubectl_port_forwarder.rs b/src/mz-debug/src/kubectl_port_forwarder.rs index 5379fe6d972aa..6f1cc3ec1f39f 100644 --- a/src/mz-debug/src/kubectl_port_forwarder.rs +++ b/src/mz-debug/src/kubectl_port_forwarder.rs @@ -41,6 +41,8 @@ impl KubectlPortForwarder { /// The process will retry if the port-forwarding fails and /// will terminate once the port forwarding reaches the max number of retries. /// We retry since kubectl port-forward is flaky. + // database-issues#9092: anyhow should not be used. + #[allow(clippy::disallowed_macros)] pub async fn port_forward(&self) { if let Err(err) = retry::Retry::default() .max_duration(Duration::from_secs(60)) @@ -118,6 +120,8 @@ impl KubectlPortForwarder { } } +// database-issues#9092: anyhow should not be used. +#[allow(clippy::disallowed_macros)] pub async fn create_kubectl_port_forwarder( client: &Client, args: &SelfManagedDebugMode, diff --git a/src/mz-debug/src/system_catalog_dumper.rs b/src/mz-debug/src/system_catalog_dumper.rs index 9ca0d4968aff0..c752ba51bec3d 100644 --- a/src/mz-debug/src/system_catalog_dumper.rs +++ b/src/mz-debug/src/system_catalog_dumper.rs @@ -484,6 +484,8 @@ pub struct SystemCatalogDumper<'n> { _pg_conn_handle: JoinHandle>, } +// database-issues#9092: anyhow should not be used. +#[allow(clippy::disallowed_macros)] pub async fn create_postgres_connection( connection_string: &str, ) -> Result< diff --git a/src/npm/src/lib.rs b/src/npm/src/lib.rs index 3639ad8485e26..51c3b52bb0d5f 100644 --- a/src/npm/src/lib.rs +++ b/src/npm/src/lib.rs @@ -196,6 +196,8 @@ impl NpmPackage { } } +// database-issues#9092: anyhow should not be used. +#[allow(clippy::disallowed_macros)] pub fn ensure(out_dir: Option) -> Result<(), anyhow::Error> { println!("ensuring all npm packages are up-to-date..."); diff --git a/src/orchestrator-kubernetes/src/lib.rs b/src/orchestrator-kubernetes/src/lib.rs index 5e92576d84a83..48628c6ff6ac8 100644 --- a/src/orchestrator-kubernetes/src/lib.rs +++ b/src/orchestrator-kubernetes/src/lib.rs @@ -413,6 +413,8 @@ impl NamespacedKubernetesOrchestrator { format!("{}.environmentd.materialize.cloud/{}", self.namespace, key) } + // database-issues#9092: anyhow should not be used. + #[allow(clippy::disallowed_macros)] fn label_selector_to_k8s( &self, MzLabelSelector { label_name, logic }: MzLabelSelector, @@ -491,6 +493,8 @@ impl ScaledQuantity { // (1) Handle negative numbers (because it's not useful for that use-case) // (2) Handle non-integers (because I have never observed them being actually sent) // (3) Handle scientific notation (e.g. 1.23e2) +// database-issues#9092: anyhow should not be used. +#[allow(clippy::disallowed_macros)] fn parse_k8s_quantity(s: &str) -> Result { const DEC_SUFFIXES: &[(&str, i8)] = &[ ("n", -9), @@ -550,6 +554,8 @@ fn parse_k8s_quantity(s: &str) -> Result { #[async_trait] impl NamespacedOrchestrator for NamespacedKubernetesOrchestrator { + // database-issues#9092: anyhow should not be used. + #[allow(clippy::disallowed_macros)] async fn fetch_service_metrics( &self, id: &str, @@ -573,6 +579,8 @@ impl NamespacedOrchestrator for NamespacedKubernetesOrchestrator { Ok(metrics) } + // database-issues#9092: anyhow should not be used. + #[allow(clippy::disallowed_macros)] fn ensure_service( &self, id: &str, @@ -1236,6 +1244,8 @@ impl NamespacedOrchestrator for NamespacedKubernetesOrchestrator { } /// Drops the identified service, if it exists. + // database-issues#9092: anyhow should not be used. + #[allow(clippy::disallowed_macros)] fn drop_service(&self, id: &str) -> Result<(), anyhow::Error> { fail::fail_point!("kubernetes_drop_service", |_| Err(anyhow!("failpoint"))); self.service_infos.lock().expect("poisoned lock").remove(id); @@ -1260,6 +1270,8 @@ impl NamespacedOrchestrator for NamespacedKubernetesOrchestrator { } fn watch_services(&self) -> BoxStream<'static, Result> { + // database-issues#9092: anyhow should not be used. + #[allow(clippy::disallowed_macros)] fn into_service_event(pod: Pod) -> Result { let process_id = pod.name_any().split('-').last().unwrap().parse()?; let service_id_label = "environmentd.materialize.cloud/service-id"; diff --git a/src/orchestrator-kubernetes/src/secrets.rs b/src/orchestrator-kubernetes/src/secrets.rs index 3438c6268bdad..7fc088af4554c 100644 --- a/src/orchestrator-kubernetes/src/secrets.rs +++ b/src/orchestrator-kubernetes/src/secrets.rs @@ -119,6 +119,8 @@ impl KubernetesSecretsReader { #[async_trait] impl SecretsReader for KubernetesSecretsReader { + // database-issues#9092: anyhow should not be used. + #[allow(clippy::disallowed_macros)] async fn read(&self, id: CatalogItemId) -> Result, anyhow::Error> { let secret = self .secret_api diff --git a/src/orchestrator-kubernetes/src/util.rs b/src/orchestrator-kubernetes/src/util.rs index b465d61d192f4..87793234c31d2 100644 --- a/src/orchestrator-kubernetes/src/util.rs +++ b/src/orchestrator-kubernetes/src/util.rs @@ -18,6 +18,8 @@ use kube::{Client, Config}; /// /// Returns the constructed client and the default namespace loaded from the /// configuration. +// database-issues#9092: anyhow should not be used. +#[allow(clippy::disallowed_macros)] pub async fn create_client(context: String) -> Result<(Client, String), anyhow::Error> { let kubeconfig_options = KubeConfigOptions { context: Some(context), diff --git a/src/orchestrator-process/src/lib.rs b/src/orchestrator-process/src/lib.rs index 744640d96bd78..467790169ed26 100644 --- a/src/orchestrator-process/src/lib.rs +++ b/src/orchestrator-process/src/lib.rs @@ -547,6 +547,8 @@ impl OrchestratorWorker { } } + // database-issues#9092: anyhow should not be used. + #[allow(clippy::disallowed_macros)] fn fetch_service_metrics( &mut self, id: &str, @@ -751,6 +753,8 @@ impl OrchestratorWorker { Ok(()) } + // database-issues#9092: anyhow should not be used. + #[allow(clippy::disallowed_macros)] async fn list_services(&self) -> Result, anyhow::Error> { let mut services = vec![]; let namespace_prefix = format!("{}-", self.config.namespace); diff --git a/src/orchestratord/src/controller/materialize.rs b/src/orchestratord/src/controller/materialize.rs index 409a1d904bb4f..06e52f1fd3d79 100644 --- a/src/orchestratord/src/controller/materialize.rs +++ b/src/orchestratord/src/controller/materialize.rs @@ -299,6 +299,8 @@ impl k8s_controller::Context for Context { const FINALIZER_NAME: &'static str = "orchestratord.materialize.cloud/materialize"; #[instrument(fields(organization_name=mz.name_unchecked()))] + // database-issues#9092: anyhow should not be used. + #[allow(clippy::disallowed_macros)] async fn apply( &self, client: Client, diff --git a/src/ore/src/error.rs b/src/ore/src/error.rs index 797923a6a57bd..fc0ab41eb837c 100644 --- a/src/ore/src/error.rs +++ b/src/ore/src/error.rs @@ -92,6 +92,8 @@ mod tests { use super::*; #[crate::test] + // database-issues#9092: anyhow should not be used. + #[allow(clippy::disallowed_macros)] fn basic_usage() { let error = anyhow!("root"); let error = error.context("context"); @@ -99,6 +101,8 @@ mod tests { } #[crate::test] + // database-issues#9092: anyhow should not be used. + #[allow(clippy::disallowed_macros)] fn basic_usage_with_arc() { // The reason for this signature is that our Plan errors have a `cause` field like this: // ``` diff --git a/src/ore/src/result.rs b/src/ore/src/result.rs index b32fa40aef65b..aa68a9bb1f26a 100644 --- a/src/ore/src/result.rs +++ b/src/ore/src/result.rs @@ -99,6 +99,8 @@ mod test { use super::*; #[crate::test] + // database-issues#9092: anyhow should not be used. + #[allow(clippy::disallowed_macros)] fn prints_error_chain() { let error = anyhow!("root"); let error = error.context("context"); diff --git a/src/ore/src/retry.rs b/src/ore/src/retry.rs index 8fada7316ac24..cb09621aceb2d 100644 --- a/src/ore/src/retry.rs +++ b/src/ore/src/retry.rs @@ -868,7 +868,10 @@ mod tests { /// Test that canceling retry operations surface the last error when the /// underlying future is not explicitly timed out. #[crate::test(tokio::test)] - #[cfg_attr(miri, ignore)] // unsupported operation: cannot write to event + // unsupported operation: cannot write to event + #[cfg_attr(miri, ignore)] + // database-issues#9092: anyhow should not be used. + #[allow(clippy::disallowed_macros)] async fn test_retry_async_canceling_uncanceled_failure() { let res = Retry::default() .max_duration(Duration::from_millis(100)) @@ -880,7 +883,10 @@ mod tests { /// Test that canceling retry operations surface the last error when the /// underlying future *is* not explicitly timed out. #[crate::test(tokio::test)] - #[cfg_attr(miri, ignore)] // unsupported operation: cannot write to event + // unsupported operation: cannot write to event + #[cfg_attr(miri, ignore)] + // database-issues#9092: anyhow should not be used. + #[allow(clippy::disallowed_macros)] async fn test_retry_async_canceling_canceled_failure() { let res = Retry::default() .max_duration(Duration::from_millis(100)) diff --git a/src/ore/src/test.rs b/src/ore/src/test.rs index 549be568917ff..14720780ab837 100644 --- a/src/ore/src/test.rs +++ b/src/ore/src/test.rs @@ -62,6 +62,8 @@ pub fn init_logging_default(level: &str) { /// Note that if the invoked function does not complete in the timeout, it is /// not killed; it is left to wind down normally. Therefore this function is /// only appropriate in tests, where the resource leak doesn't matter. +// database-issues#9092: anyhow should not be used. +#[allow(clippy::disallowed_macros)] pub fn timeout(duration: Duration, f: F) -> Result where F: FnOnce() -> Result + Send + 'static, diff --git a/src/persist-cli/src/maelstrom/node.rs b/src/persist-cli/src/maelstrom/node.rs index 291f403b437ea..3e9280918a84e 100644 --- a/src/persist-cli/src/maelstrom/node.rs +++ b/src/persist-cli/src/maelstrom/node.rs @@ -50,6 +50,8 @@ pub trait Service: Sized + Send + Sync { /// Runs the RPC loop, accepting Maelstrom workload requests, issuing responses, /// and communicating with Maelstrom services. +// database-issues#9092: anyhow should not be used. +#[allow(clippy::disallowed_macros)] pub fn run(args: Args, read: R, write: W) -> Result<(), anyhow::Error> where R: BufRead, @@ -306,6 +308,8 @@ impl Handle { /// Returns a [ShardId] for this Maelstrom run. /// /// Uses Maelstrom services to ensure all nodes end up with the same id. + // database-issues#9092: anyhow should not be used. + #[allow(clippy::disallowed_macros)] pub async fn maybe_init_shard_id(&self) -> Result { let proposal = ShardId::new(); let key = "SHARD"; diff --git a/src/persist-cli/src/maelstrom/services.rs b/src/persist-cli/src/maelstrom/services.rs index 839f8d54e243c..9f1d1c7b8d0ee 100644 --- a/src/persist-cli/src/maelstrom/services.rs +++ b/src/persist-cli/src/maelstrom/services.rs @@ -185,6 +185,8 @@ impl MaelstromBlob { #[async_trait] impl Blob for MaelstromBlob { + // database-issues#9092: anyhow should not be used. + #[allow(clippy::disallowed_macros)] async fn get(&self, key: &str) -> Result, ExternalError> { let value = match self .handle @@ -231,6 +233,8 @@ impl Blob for MaelstromBlob { Ok(Some(0)) } + // database-issues#9092: anyhow should not be used. + #[allow(clippy::disallowed_macros)] async fn restore(&self, key: &str) -> Result<(), ExternalError> { let read = self .handle @@ -399,6 +403,8 @@ impl MaelstromOracleKey { } } + // database-issues#9092: anyhow should not be used. + #[allow(clippy::disallowed_macros)] async fn peek(&mut self) -> Result { let value = self .handle diff --git a/src/persist-cli/src/open_loop.rs b/src/persist-cli/src/open_loop.rs index c0cb6b464efdd..28c9a65ecdff9 100644 --- a/src/persist-cli/src/open_loop.rs +++ b/src/persist-cli/src/open_loop.rs @@ -166,6 +166,8 @@ pub async fn run(args: Args) -> Result<(), anyhow::Error> { run_benchmark(args, metrics_registry, metrics, writers, readers).await } +// database-issues#9092: anyhow should not be used. +#[allow(clippy::disallowed_macros)] async fn run_benchmark( args: Args, metrics_registry: MetricsRegistry, diff --git a/src/persist-client/src/cli/admin.rs b/src/persist-client/src/cli/admin.rs index 0967b6e14f3e8..31b56f0da5784 100644 --- a/src/persist-client/src/cli/admin.rs +++ b/src/persist-client/src/cli/admin.rs @@ -124,6 +124,8 @@ pub(crate) struct RestoreBlobArgs { } /// Runs the given read-write admin command. +// database-issues#9092: anyhow should not be used. +#[allow(clippy::disallowed_macros)] pub async fn run(command: AdminArgs) -> Result<(), anyhow::Error> { match command.command { Command::ForceCompaction(args) => { @@ -553,6 +555,8 @@ async fn make_machine( .await } +// database-issues#9092: anyhow should not be used. +#[allow(clippy::disallowed_macros)] async fn make_typed_machine( cfg: &PersistConfig, consensus: Arc, diff --git a/src/persist-client/src/cli/inspect.rs b/src/persist-client/src/cli/inspect.rs index 9dde1b06b0d1d..0ee4db742a0f8 100644 --- a/src/persist-client/src/cli/inspect.rs +++ b/src/persist-client/src/cli/inspect.rs @@ -200,6 +200,8 @@ pub async fn fetch_latest_state(args: &StateArgs) -> Result Result { @@ -224,6 +226,8 @@ pub async fn fetch_state_rollup( } /// Fetches the state from all known rollups of a given shard +// database-issues#9092: anyhow should not be used. +#[allow(clippy::disallowed_macros)] pub async fn fetch_state_rollups(args: &StateArgs) -> Result { let shard_id = args.shard_id(); let state_versions = args.open().await?; diff --git a/src/persist-client/src/fetch.rs b/src/persist-client/src/fetch.rs index 74a49654d27e7..384868b32b862 100644 --- a/src/persist-client/src/fetch.rs +++ b/src/persist-client/src/fetch.rs @@ -420,6 +420,8 @@ pub(crate) async fn fetch_batch_part_blob( Ok(value) } +// database-issues#9092: anyhow should not be used. +#[allow(clippy::disallowed_macros)] pub(crate) fn decode_batch_part_blob( metrics: &Metrics, read_metrics: &ReadMetrics, diff --git a/src/persist-client/src/internal/compact.rs b/src/persist-client/src/internal/compact.rs index ce627d6f0cc14..2f713981ac28a 100644 --- a/src/persist-client/src/internal/compact.rs +++ b/src/persist-client/src/internal/compact.rs @@ -158,6 +158,8 @@ where T: Timestamp + Lattice + Codec64 + Sync, D: Semigroup + Ord + Codec64 + Send + Sync, { + // database-issues#9092: anyhow should not be used. + #[allow(clippy::disallowed_macros)] pub fn new( cfg: PersistConfig, metrics: Arc, @@ -303,6 +305,8 @@ where Some(compaction_completed_receiver) } + // database-issues#9092: anyhow should not be used. + #[allow(clippy::disallowed_macros)] pub(crate) async fn compact_and_apply( machine: &Machine, req: CompactReq, @@ -878,6 +882,8 @@ where Ok(batch.into_hollow_batch()) } + // database-issues#9092: anyhow should not be used. + #[allow(clippy::disallowed_macros)] fn validate_req(req: &CompactReq) -> Result<(), anyhow::Error> { let mut frontier = req.desc.lower(); for input in req.inputs.iter() { diff --git a/src/persist-client/src/internal/machine.rs b/src/persist-client/src/internal/machine.rs index 113c7c8c69c77..5c2dd5a527b31 100644 --- a/src/persist-client/src/internal/machine.rs +++ b/src/persist-client/src/internal/machine.rs @@ -1620,6 +1620,8 @@ pub mod datadriven { } #[allow(clippy::unused_async)] + // database-issues#9092: anyhow should not be used. + #[allow(clippy::disallowed_macros)] pub async fn dyncfg( datadriven: &MachineState, args: DirectiveArgs<'_>, @@ -1654,6 +1656,8 @@ pub mod datadriven { Ok("ok\n".to_string()) } + // database-issues#9092: anyhow should not be used. + #[allow(clippy::disallowed_macros)] pub async fn compare_and_downgrade_since( datadriven: &mut MachineState, args: DirectiveArgs<'_>, @@ -1703,6 +1707,8 @@ pub mod datadriven { )) } + // database-issues#9092: anyhow should not be used. + #[allow(clippy::disallowed_macros)] pub async fn add_rollup( datadriven: &mut MachineState, args: DirectiveArgs<'_>, @@ -2039,6 +2045,8 @@ pub mod datadriven { } #[allow(clippy::unused_async)] + // database-issues#9092: anyhow should not be used. + #[allow(clippy::disallowed_macros)] pub async fn rewrite_ts( datadriven: &mut MachineState, args: DirectiveArgs<'_>, @@ -2088,6 +2096,8 @@ pub mod datadriven { )) } + // database-issues#9092: anyhow should not be used. + #[allow(clippy::disallowed_macros)] pub async fn snapshot( datadriven: &MachineState, args: DirectiveArgs<'_>, @@ -2159,6 +2169,8 @@ pub mod datadriven { Ok(result) } + // database-issues#9092: anyhow should not be used. + #[allow(clippy::disallowed_macros)] pub async fn register_listen( datadriven: &mut MachineState, args: DirectiveArgs<'_>, @@ -2284,6 +2296,8 @@ pub mod datadriven { Ok(format!("{} ok\n", datadriven.machine.seqno())) } + // database-issues#9092: anyhow should not be used. + #[allow(clippy::disallowed_macros)] pub async fn compare_and_append_batches( datadriven: &MachineState, args: DirectiveArgs<'_>, @@ -2356,6 +2370,8 @@ pub mod datadriven { Ok(format!("{seqno} {tombstone}\n")) } + // database-issues#9092: anyhow should not be used. + #[allow(clippy::disallowed_macros)] pub async fn compare_and_append( datadriven: &mut MachineState, args: DirectiveArgs<'_>, diff --git a/src/persist-client/src/internal/restore.rs b/src/persist-client/src/internal/restore.rs index ac471b5ddc565..e17e9f894f788 100644 --- a/src/persist-client/src/internal/restore.rs +++ b/src/persist-client/src/internal/restore.rs @@ -23,6 +23,8 @@ use tracing::info; /// Attempt to restore all the blobs referenced by the current state in consensus. /// Returns a list of blobs that were not possible to restore. +// database-issues#9092: anyhow should not be used. +#[allow(clippy::disallowed_macros)] pub(crate) async fn restore_blob( versions: &StateVersions, blob: &dyn Blob, diff --git a/src/persist-client/src/iter.rs b/src/persist-client/src/iter.rs index b81f138ae82a5..ffd1ee5bc9069 100644 --- a/src/persist-client/src/iter.rs +++ b/src/persist-client/src/iter.rs @@ -195,6 +195,8 @@ impl RowSort for StructuredSor type FetchResult = Result, HollowRun>; impl FetchData { + // database-issues#9092: anyhow should not be used. + #[allow(clippy::disallowed_macros)] async fn fetch( self, shard_id: ShardId, @@ -513,6 +515,8 @@ where /// which may include the smallest remaining KVT. /// /// Returns success when we've successfully fetched enough parts to be able to make progress. + // database-issues#9092: anyhow should not be used. + #[allow(clippy::disallowed_macros)] async fn unblock_progress(&mut self) -> anyhow::Result<()> { if self.runs.is_empty() { return Ok(()); diff --git a/src/persist-client/src/lib.rs b/src/persist-client/src/lib.rs index 9eea1ce69c86b..4f9266421e733 100644 --- a/src/persist-client/src/lib.rs +++ b/src/persist-client/src/lib.rs @@ -670,6 +670,8 @@ impl PersistClient { /// We'll be thoughtful about making unnecessary changes, but the **output /// of this method needs to be gated from users**, so that it's not subject /// to our backward compatibility guarantees. + // database-issues#9092: anyhow should not be used. + #[allow(clippy::disallowed_macros)] pub async fn inspect_shard( &self, shard_id: &ShardId, diff --git a/src/persist-client/src/rpc.rs b/src/persist-client/src/rpc.rs index bcbe9e48a318e..7f749958975b4 100644 --- a/src/persist-client/src/rpc.rs +++ b/src/persist-client/src/rpc.rs @@ -407,6 +407,8 @@ impl GrpcPubSubClient { } } + // database-issues#9092: anyhow should not be used. + #[allow(clippy::disallowed_macros)] async fn consume_grpc_stream( mut responses: Streaming, receiver_input: &Sender, diff --git a/src/persist-types/src/columnar.rs b/src/persist-types/src/columnar.rs index 49919827db1e1..a5e6de19ce24b 100644 --- a/src/persist-types/src/columnar.rs +++ b/src/persist-types/src/columnar.rs @@ -121,6 +121,8 @@ pub trait Schema: Debug + Send + Sync { fn decoder(&self, col: Self::ArrowColumn) -> Result; /// Returns a type that is able to decode instances of `T` from a type erased /// [`arrow::array::Array`], erroring if the provided array is not [`Self::ArrowColumn`]. + // database-issues#9092: anyhow should not be used. + #[allow(clippy::disallowed_macros)] fn decoder_any(&self, col: &dyn arrow::array::Array) -> Result { let col = col .as_any() @@ -150,6 +152,8 @@ pub fn data_type(schema: &A::Schema) -> anyhow::Result { } /// Helper to convert from codec-encoded data to structured data. +// database-issues#9092: anyhow should not be used. +#[allow(clippy::disallowed_macros)] pub fn codec_to_schema( schema: &A::Schema, data: &BinaryArray, diff --git a/src/persist-types/src/parquet.rs b/src/persist-types/src/parquet.rs index 973a0b2419670..20f659ebc358c 100644 --- a/src/persist-types/src/parquet.rs +++ b/src/persist-types/src/parquet.rs @@ -190,6 +190,8 @@ pub fn encode_arrays( } /// Decodes a [`RecordBatch`] from the provided reader. +// database-issues#9092: anyhow should not be used. +#[allow(clippy::disallowed_macros)] pub fn decode_arrays( r: R, ) -> Result { diff --git a/src/persist-types/src/stats.rs b/src/persist-types/src/stats.rs index 90c136214687c..684e7cb21111f 100644 --- a/src/persist-types/src/stats.rs +++ b/src/persist-types/src/stats.rs @@ -95,6 +95,8 @@ impl ColumnarStats { } /// Helper method to "downcast" to stats of type `T`. + // database-issues#9092: anyhow should not be used. + #[allow(clippy::disallowed_macros)] fn try_as_stats<'a, T, F>(&'a self, map: F) -> Result where F: FnOnce(&'a ColumnStatKinds) -> Result, @@ -109,6 +111,8 @@ impl ColumnarStats { } /// Helper method to "downcast" [`OptionStats`]. + // database-issues#9092: anyhow should not be used. + #[allow(clippy::disallowed_macros)] fn try_as_option_stats<'a, T, F>(&'a self, map: F) -> Result, anyhow::Error> where F: FnOnce(&'a ColumnStatKinds) -> Result, @@ -127,6 +131,8 @@ impl ColumnarStats { /// Tries to "downcast" this instance of [`ColumnarStats`] to an [`OptionStats`] /// if the inner statistics are nullable and for a structured column. + // database-issues#9092: anyhow should not be used. + #[allow(clippy::disallowed_macros)] pub fn try_as_optional_struct(&self) -> Result, anyhow::Error> { self.try_as_option_stats(|values| match values { ColumnStatKinds::Struct(inner) => Ok(inner), @@ -136,6 +142,8 @@ impl ColumnarStats { /// Tries to "downcast" this instance of [`ColumnarStats`] to an [`OptionStats`] /// if the inner statistics are nullable and for a column of bytes. + // database-issues#9092: anyhow should not be used. + #[allow(clippy::disallowed_macros)] pub fn try_as_optional_bytes(&self) -> Result, anyhow::Error> { self.try_as_option_stats(|values| match values { ColumnStatKinds::Bytes(inner) => Ok(inner), @@ -145,6 +153,8 @@ impl ColumnarStats { /// Tries to "downcast" this instance of [`ColumnarStats`] to a [`PrimitiveStats`] /// if the inner statistics are nullable and for a structured column. + // database-issues#9092: anyhow should not be used. + #[allow(clippy::disallowed_macros)] pub fn try_as_string(&self) -> Result<&PrimitiveStats, anyhow::Error> { self.try_as_stats(|values| match values { ColumnStatKinds::Primitive(PrimitiveStatsVariants::String(inner)) => Ok(inner), diff --git a/src/persist/src/azure.rs b/src/persist/src/azure.rs index 590b1fe0387f6..d04e80b3ddd8f 100644 --- a/src/persist/src/azure.rs +++ b/src/persist/src/azure.rs @@ -395,6 +395,8 @@ impl Blob for AzureBlob { } } + // database-issues#9092: anyhow should not be used. + #[allow(clippy::disallowed_macros)] async fn restore(&self, key: &str) -> Result<(), ExternalError> { let path = self.get_path(key); let blob = self.client.blob_client(&path); diff --git a/src/persist/src/cfg.rs b/src/persist/src/cfg.rs index 3d0820db02c6c..faa97ebb6891f 100644 --- a/src/persist/src/cfg.rs +++ b/src/persist/src/cfg.rs @@ -80,6 +80,8 @@ impl BlobConfig { } /// Parses a [Blob] config from a uri string. + // database-issues#9092: anyhow should not be used. + #[allow(clippy::disallowed_macros)] pub async fn try_from( url: &SensitiveUrl, knobs: Box, @@ -229,6 +231,8 @@ impl ConsensusConfig { } /// Parses a [Consensus] config from a uri string. + // database-issues#9092: anyhow should not be used. + #[allow(clippy::disallowed_macros)] pub fn try_from( url: &SensitiveUrl, knobs: Box, diff --git a/src/persist/src/file.rs b/src/persist/src/file.rs index 6d10b20d4fe92..121e67521f850 100644 --- a/src/persist/src/file.rs +++ b/src/persist/src/file.rs @@ -97,6 +97,8 @@ impl Blob for FileBlob { Ok(Some(SegmentedBytes::from(buf))) } + // database-issues#9092: anyhow should not be used. + #[allow(clippy::disallowed_macros)] async fn list_keys_and_metadata( &self, key_prefix: &str, @@ -154,6 +156,8 @@ impl Blob for FileBlob { Ok(()) } + // database-issues#9092: anyhow should not be used. + #[allow(clippy::disallowed_macros)] async fn set(&self, key: &str, value: Bytes) -> Result<(), ExternalError> { let file_path = self.blob_path(&FileBlob::replace_forward_slashes(key)); @@ -192,6 +196,8 @@ impl Blob for FileBlob { Ok(()) } + // database-issues#9092: anyhow should not be used. + #[allow(clippy::disallowed_macros)] async fn delete(&self, key: &str) -> Result, ExternalError> { let file_path = self.blob_path(&FileBlob::replace_forward_slashes(key)); // TODO: strict correctness requires that we fsync the parent directory @@ -249,6 +255,8 @@ impl Blob for FileBlob { Ok(Some(usize::cast_from(size_bytes))) } + // database-issues#9092: anyhow should not be used. + #[allow(clippy::disallowed_macros)] async fn restore(&self, key: &str) -> Result<(), ExternalError> { let file_path = self.blob_path(&FileBlob::replace_forward_slashes(key)); diff --git a/src/persist/src/indexed/columnar/arrow.rs b/src/persist/src/indexed/columnar/arrow.rs index a7ef8d2f8f239..1cd4e9e7a2123 100644 --- a/src/persist/src/indexed/columnar/arrow.rs +++ b/src/persist/src/indexed/columnar/arrow.rs @@ -168,6 +168,8 @@ fn realloc_buffer(buffer: &Buffer, metrics: &ColumnarMetrics) -> Buffer { } /// Converts an [`arrow`] [RecordBatch] into a [BlobTraceUpdates] and reallocate the backing data. +// database-issues#9092: anyhow should not be used. +#[allow(clippy::disallowed_macros)] pub fn decode_arrow_batch( batch: &RecordBatch, metrics: &ColumnarMetrics, diff --git a/src/persist/src/indexed/encoding.rs b/src/persist/src/indexed/encoding.rs index 95152a8abb03d..75a775e7907be 100644 --- a/src/persist/src/indexed/encoding.rs +++ b/src/persist/src/indexed/encoding.rs @@ -403,6 +403,8 @@ impl BlobTraceUpdates { /// /// If `ensure_codec` is true, then we'll ensure the returned [`BlobTraceUpdates`] includes /// [`Codec`] data, re-encoding structured data if necessary. + // database-issues#9092: anyhow should not be used. + #[allow(clippy::disallowed_macros)] pub fn concat( mut updates: Vec, key_schema: &K::Schema, diff --git a/src/persist/src/location.rs b/src/persist/src/location.rs index ec7b9dd55f628..ce0dcc9f2bf8c 100644 --- a/src/persist/src/location.rs +++ b/src/persist/src/location.rs @@ -176,6 +176,8 @@ impl ExternalError { /// TODO: When we overhaul errors, this presumably should instead be a type /// that can be matched on. #[track_caller] + // database-issues#9092: anyhow should not be used. + #[allow(clippy::disallowed_macros)] pub fn new_timeout(deadline: Instant) -> Self { ExternalError::Indeterminate(Indeterminate { inner: anyhow!("timeout at {:?}", deadline), @@ -287,6 +289,8 @@ impl From for ExternalError { } impl From for ExternalError { + // database-issues#9092: anyhow should not be used. + #[allow(clippy::disallowed_macros)] fn from(value: azure_core::Error) -> Self { ExternalError::Indeterminate(Indeterminate { inner: anyhow!(value), @@ -812,6 +816,8 @@ pub mod tests { } /// Common test impl for different consensus implementations. + // database-issues#9092: anyhow should not be used. + #[allow(clippy::disallowed_macros)] pub async fn consensus_impl_test< C: Consensus, F: Future>, @@ -1117,6 +1123,8 @@ pub mod tests { } #[mz_ore::test] + // database-issues#9092: anyhow should not be used. + #[allow(clippy::disallowed_macros)] fn timeout_error() { assert!(ExternalError::new_timeout(Instant::now()).is_timeout()); assert!(!ExternalError::from(anyhow!("foo")).is_timeout()); diff --git a/src/persist/src/mem.rs b/src/persist/src/mem.rs index 13fce5a287039..4ec15fb4e48dd 100644 --- a/src/persist/src/mem.rs +++ b/src/persist/src/mem.rs @@ -145,6 +145,8 @@ impl MemBlobCore { Ok(bytes) } + // database-issues#9092: anyhow should not be used. + #[allow(clippy::disallowed_macros)] fn restore(&mut self, key: &str) -> Result<(), ExternalError> { match self.dataz.get_mut(key) { None => Err( @@ -284,6 +286,8 @@ impl Consensus for MemConsensus { Ok(values.last().cloned()) } + // database-issues#9092: anyhow should not be used. + #[allow(clippy::disallowed_macros)] async fn compare_and_set( &self, key: &str, @@ -336,6 +340,8 @@ impl Consensus for MemConsensus { Self::scan_store(&store, key, from, limit) } + // database-issues#9092: anyhow should not be used. + #[allow(clippy::disallowed_macros)] async fn truncate(&self, key: &str, seqno: SeqNo) -> Result { // Yield to maximize our chances for getting interesting orderings. let () = yield_now().await; diff --git a/src/persist/src/postgres.rs b/src/persist/src/postgres.rs index c15a461189a26..385786066d6c7 100644 --- a/src/persist/src/postgres.rs +++ b/src/persist/src/postgres.rs @@ -380,6 +380,8 @@ impl Consensus for PostgresConsensus { } } + // database-issues#9092: anyhow should not be used. + #[allow(clippy::disallowed_macros)] async fn scan( &self, key: &str, @@ -413,6 +415,8 @@ impl Consensus for PostgresConsensus { Ok(results) } + // database-issues#9092: anyhow should not be used. + #[allow(clippy::disallowed_macros)] async fn truncate(&self, key: &str, seqno: SeqNo) -> Result { let q = "DELETE FROM consensus WHERE shard = $1 AND sequence_number < $2 AND diff --git a/src/persist/src/s3.rs b/src/persist/src/s3.rs index be4ad295fcbe9..7f666c6d1cc36 100644 --- a/src/persist/src/s3.rs +++ b/src/persist/src/s3.rs @@ -346,6 +346,8 @@ pub(crate) const ENABLE_S3_LGALLOC_NONCC_SIZES: Config = Config::new( #[async_trait] impl Blob for S3Blob { + // database-issues#9092: anyhow should not be used. + #[allow(clippy::disallowed_macros)] async fn get(&self, key: &str) -> Result, ExternalError> { let start_overall = Instant::now(); let path = self.get_path(key); @@ -569,6 +571,8 @@ impl Blob for S3Blob { Ok(Some(SegmentedBytes::from(segments))) } + // database-issues#9092: anyhow should not be used. + #[allow(clippy::disallowed_macros)] async fn list_keys_and_metadata( &self, key_prefix: &str, @@ -644,6 +648,8 @@ impl Blob for S3Blob { } } + // database-issues#9092: anyhow should not be used. + #[allow(clippy::disallowed_macros)] async fn delete(&self, key: &str) -> Result, ExternalError> { // There is a race condition here where, if two delete calls for the // same key occur simultaneously, both might think they did the actual @@ -690,6 +696,8 @@ impl Blob for S3Blob { Ok(Some(usize::cast_from(size_bytes))) } + // database-issues#9092: anyhow should not be used. + #[allow(clippy::disallowed_macros)] async fn restore(&self, key: &str) -> Result<(), ExternalError> { let path = self.get_path(key); // Fetch the latest version of the object. If it's a normal version, return true; @@ -785,6 +793,8 @@ impl S3Blob { // TODO(benesch): remove this once this function no longer makes use of // potentially dangerous `as` conversions. #[allow(clippy::as_conversions)] + // database-issues#9092: anyhow should not be used. + #[allow(clippy::disallowed_macros)] async fn set_multi_part(&self, key: &str, value: Bytes) -> Result<(), ExternalError> { let start_overall = Instant::now(); let path = self.get_path(key); diff --git a/src/persist/src/unreliable.rs b/src/persist/src/unreliable.rs index 3de9f23bd4a1d..682d69b95a1b1 100644 --- a/src/persist/src/unreliable.rs +++ b/src/persist/src/unreliable.rs @@ -99,6 +99,8 @@ impl UnreliableHandle { core.rng.gen_bool(should_timeout) } + // database-issues#9092: anyhow should not be used. + #[allow(clippy::disallowed_macros)] async fn run_op(&self, name: &str, work_fn: WorkFn) -> Result where F: Future>, diff --git a/src/pgtest/src/lib.rs b/src/pgtest/src/lib.rs index 1dfb05db05348..ae41264f25f02 100644 --- a/src/pgtest/src/lib.rs +++ b/src/pgtest/src/lib.rs @@ -112,6 +112,8 @@ struct PgConn { } impl PgConn { + // database-issues#9092: anyhow should not be used. + #[allow(clippy::disallowed_macros)] fn new<'a>( addr: &str, user: &'a str, @@ -139,12 +141,16 @@ impl PgConn { Ok(conn) } + // database-issues#9092: anyhow should not be used. + #[allow(clippy::disallowed_macros)] fn send(&mut self, f: F) -> anyhow::Result<()> { self.send_buf.clear(); f(&mut self.send_buf); self.stream.write_all(&self.send_buf)?; Ok(()) } + // database-issues#9092: anyhow should not be used. + #[allow(clippy::disallowed_macros)] fn until( &mut self, until: Vec<&str>, @@ -323,6 +329,8 @@ impl PgConn { /// Returns the PostgreSQL message format and the `Message`. /// /// An error is returned if a new message is not received within the timeout. + // database-issues#9092: anyhow should not be used. + #[allow(clippy::disallowed_macros)] pub fn recv(&mut self) -> anyhow::Result<(char, Message)> { let mut buf = [0; 1024]; let until = Instant::now(); diff --git a/src/pgtz/build.rs b/src/pgtz/build.rs index 85037d101dd39..8528bcf51ecef 100644 --- a/src/pgtz/build.rs +++ b/src/pgtz/build.rs @@ -28,6 +28,8 @@ enum TimezoneAbbrevSpec<'a> { Tz(&'a str), } +// database-issues#9092: anyhow should not be used. +#[allow(clippy::disallowed_macros)] fn main() -> Result<()> { let out_dir = PathBuf::from(env::var_os("OUT_DIR").context("Cannot read OUT_DIR env var")?); diff --git a/src/postgres-client/src/lib.rs b/src/postgres-client/src/lib.rs index db5f76ca4a6d7..a411cc96dded8 100644 --- a/src/postgres-client/src/lib.rs +++ b/src/postgres-client/src/lib.rs @@ -93,6 +93,8 @@ impl std::fmt::Debug for PostgresClient { impl PostgresClient { /// Open a [PostgresClient] using the given `config`. + // database-issues#9092: anyhow should not be used. + #[allow(clippy::disallowed_macros)] pub fn open(config: PostgresClientConfig) -> Result { let mut pg_config: Config = config.url.to_string_unredacted().parse()?; pg_config.connect_timeout(config.knobs.connect_timeout()); diff --git a/src/postgres-util/src/desc.rs b/src/postgres-util/src/desc.rs index dd48b6ccdbc4d..e450d34e2088a 100644 --- a/src/postgres-util/src/desc.rs +++ b/src/postgres-util/src/desc.rs @@ -62,6 +62,8 @@ impl PostgresTableDesc { /// Compatibility is defined as returning `true` for /// `PostgresColumnDesc::is_compatible`. /// - `self`'s keys are all present in `other` + // database-issues#9092: anyhow should not be used. + #[allow(clippy::disallowed_macros)] pub fn determine_compatibility( &self, other: &PostgresTableDesc, diff --git a/src/postgres-util/src/replication.rs b/src/postgres-util/src/replication.rs index fd0bebe6fbdb5..e97c9bfb6a11e 100644 --- a/src/postgres-util/src/replication.rs +++ b/src/postgres-util/src/replication.rs @@ -23,6 +23,8 @@ pub enum WalLevel { impl std::str::FromStr for WalLevel { type Err = anyhow::Error; + // database-issues#9092: anyhow should not be used. + #[allow(clippy::disallowed_macros)] fn from_str(s: &str) -> Result { match s { "minimal" => Ok(Self::Minimal), @@ -86,6 +88,8 @@ pub async fn available_replication_slots(client: &Client) -> Result Result { if let Some(r) = simple_query_opt(replication_client, "IDENTIFY_SYSTEM").await? { r.get("timeline") diff --git a/src/postgres-util/src/schemas.rs b/src/postgres-util/src/schemas.rs index 0281167c06783..af47f8492c498 100644 --- a/src/postgres-util/src/schemas.rs +++ b/src/postgres-util/src/schemas.rs @@ -44,6 +44,8 @@ pub async fn get_schemas(client: &Client) -> Result, Pos /// /// - Invalid connection string, user information, or user permissions. /// - Upstream publication does not exist or contains invalid values. +// database-issues#9092: anyhow should not be used. +#[allow(clippy::disallowed_macros)] pub async fn publication_info( client: &Client, publication: &str, diff --git a/src/postgres-util/src/tunnel.rs b/src/postgres-util/src/tunnel.rs index 31754e0fb81f5..bcda1ac53895c 100644 --- a/src/postgres-util/src/tunnel.rs +++ b/src/postgres-util/src/tunnel.rs @@ -205,6 +205,8 @@ impl Config { .await } + // database-issues#9092: anyhow should not be used. + #[allow(clippy::disallowed_macros)] fn address(&self) -> Result<(&str, u16), PostgresError> { match (self.inner.get_hosts(), self.inner.get_ports()) { ([Host::Tcp(host)], [port]) => Ok((host, *port)), @@ -246,6 +248,8 @@ impl Config { } } + // database-issues#9092: anyhow should not be used. + #[allow(clippy::disallowed_macros)] async fn connect_internal( &self, task_name: &str, diff --git a/src/prof/src/time.rs b/src/prof/src/time.rs index 07f9a943fdb48..1fd03a215e322 100644 --- a/src/prof/src/time.rs +++ b/src/prof/src/time.rs @@ -24,6 +24,8 @@ use tokio::time::{self, Duration}; /// /// Nothing else must be attempting to unwind backtraces while this is called. /// In particular, jemalloc memory profiling must be off. +// database-issues#9092: anyhow should not be used. +#[allow(clippy::disallowed_macros)] pub async unsafe fn prof_time( total_time: Duration, sample_freq: u32, diff --git a/src/regexp/src/lib.rs b/src/regexp/src/lib.rs index fa52bd479ff1c..cd1b27dc89901 100644 --- a/src/regexp/src/lib.rs +++ b/src/regexp/src/lib.rs @@ -46,6 +46,8 @@ mod tests { use crate::regexp_split_to_array; + // database-issues#9092: anyhow should not be used. + #[allow(clippy::disallowed_macros)] fn build_regex(needle: &str, flags: &str) -> Result { let mut case_insensitive = false; // Note: Postgres accepts it when both flags are present, taking the last one. We do the same. diff --git a/src/repr/src/adt/char.rs b/src/repr/src/adt/char.rs index 57c6a19cc13e2..28bff516cc58f 100644 --- a/src/repr/src/adt/char.rs +++ b/src/repr/src/adt/char.rs @@ -129,6 +129,8 @@ impl CharWhiteSpace { /// /// This function should only fail when `fail_on_len` is `true` _and_ `length` /// is present and exceeded. +// database-issues#9092: anyhow should not be used. +#[allow(clippy::disallowed_macros)] fn format_char_str( s: &str, length: Option, diff --git a/src/repr/src/adt/date.rs b/src/repr/src/adt/date.rs index 24bce9572d0af..d8fb17243d274 100644 --- a/src/repr/src/adt/date.rs +++ b/src/repr/src/adt/date.rs @@ -50,6 +50,8 @@ impl RustType for Date { impl std::str::FromStr for Date { type Err = anyhow::Error; + // database-issues#9092: anyhow should not be used. + #[allow(clippy::disallowed_macros)] fn from_str(s: &str) -> Result { crate::strconv::parse_date(s).map_err(|e| anyhow!(e)) } diff --git a/src/repr/src/adt/interval.rs b/src/repr/src/adt/interval.rs index 64340d711df38..931bf81932c32 100644 --- a/src/repr/src/adt/interval.rs +++ b/src/repr/src/adt/interval.rs @@ -88,6 +88,8 @@ impl num_traits::ops::checked::CheckedNeg for Interval { impl std::str::FromStr for Interval { type Err = anyhow::Error; + // database-issues#9092: anyhow should not be used. + #[allow(clippy::disallowed_macros)] fn from_str(s: &str) -> Result { crate::strconv::parse_interval(s).map_err(|e| anyhow!(e)) } @@ -151,6 +153,8 @@ impl Interval { /// microseconds. Errors if /// - the number of microseconds doesn't fit in i64, or /// - the `Duration` involves fractional microseconds. + // database-issues#9092: anyhow should not be used. + #[allow(clippy::disallowed_macros)] pub fn from_duration(duration: &Duration) -> Result { if duration.subsec_nanos() % 1000 != 0 { return Err(anyhow!( @@ -412,6 +416,8 @@ impl Interval { Duration::try_days(self.days.into()).unwrap() + Duration::microseconds(self.micros) } + // database-issues#9092: anyhow should not be used. + #[allow(clippy::disallowed_macros)] pub fn duration(&self) -> Result { if self.months != 0 { bail!("cannot convert interval with months to duration"); @@ -452,6 +458,8 @@ impl Interval { /// /// # Errors /// - If `fsec_max_precision` is not None or within (0,6). + // database-issues#9092: anyhow should not be used. + #[allow(clippy::disallowed_macros)] pub fn truncate_low_fields( &mut self, f: DateTimeField, @@ -650,6 +658,8 @@ impl Interval { Ok(Self::new(months, days, self.micros)) } + // database-issues#9092: anyhow should not be used. + #[allow(clippy::disallowed_macros)] fn justify_days_inner(months: i32, days: i32) -> Result<(i32, i32), anyhow::Error> { let days_per_month = i32::from(Self::DAY_PER_MONTH); let whole_month = days / days_per_month; @@ -676,6 +686,8 @@ impl Interval { Ok(Self::new(self.months, days, micros)) } + // database-issues#9092: anyhow should not be used. + #[allow(clippy::disallowed_macros)] fn justify_hours_inner(days: i32, micros: i64) -> Result<(i32, i64), anyhow::Error> { let days = i32::try_from(micros / &*USECS_PER_DAY) .ok() diff --git a/src/repr/src/adt/mz_acl_item.rs b/src/repr/src/adt/mz_acl_item.rs index 75dc4f364b8ac..e5c14643a38c2 100644 --- a/src/repr/src/adt/mz_acl_item.rs +++ b/src/repr/src/adt/mz_acl_item.rs @@ -105,6 +105,8 @@ bitflags! { } impl AclMode { + // database-issues#9092: anyhow should not be used. + #[allow(clippy::disallowed_macros)] pub fn parse_single_privilege(s: &str) -> Result { match s.trim().to_uppercase().as_str() { INSERT_STR => Ok(AclMode::INSERT), @@ -173,6 +175,8 @@ impl AclMode { impl FromStr for AclMode { type Err = Error; + // database-issues#9092: anyhow should not be used. + #[allow(clippy::disallowed_macros)] fn from_str(s: &str) -> Result { let mut acl_mode = AclMode::empty(); for c in s.chars() { @@ -296,6 +300,8 @@ impl MzAclItem { res } + // database-issues#9092: anyhow should not be used. + #[allow(clippy::disallowed_macros)] pub fn decode_binary(raw: &[u8]) -> Result { if raw.len() != MzAclItem::binary_size() { return Err(anyhow!( @@ -328,6 +334,8 @@ impl MzAclItem { impl FromStr for MzAclItem { type Err = Error; + // database-issues#9092: anyhow should not be used. + #[allow(clippy::disallowed_macros)] fn from_str(s: &str) -> Result { let parts: Vec<_> = s.split('=').collect(); let &[grantee, rest] = parts.as_slice() else { @@ -549,6 +557,8 @@ impl AclItem { res } + // database-issues#9092: anyhow should not be used. + #[allow(clippy::disallowed_macros)] pub fn decode_binary(raw: &[u8]) -> Result { if raw.len() != AclItem::binary_size() { return Err(anyhow!( @@ -589,6 +599,8 @@ impl FromStr for AclItem { /// PostgreSQL is able to look up OIDs in the catalog while parsing, so it accepts aclitems that /// contain role OIDs or role names. We have no way to access the catalog here, so we can only /// accept oids. Therefore our implementation is much simpler than PostgreSQL's. + // database-issues#9092: anyhow should not be used. + #[allow(clippy::disallowed_macros)] fn from_str(s: &str) -> Result { let parts: Vec<_> = s.split('=').collect(); let &[grantee, rest] = parts.as_slice() else { diff --git a/src/repr/src/adt/numeric.rs b/src/repr/src/adt/numeric.rs index 2dc5b583541a0..4e9def647e31e 100644 --- a/src/repr/src/adt/numeric.rs +++ b/src/repr/src/adt/numeric.rs @@ -368,6 +368,8 @@ fn numeric_to_twos_complement_inner, const N: usize>( buf.reverse(); } +// database-issues#9092: anyhow should not be used. +#[allow(clippy::disallowed_macros)] pub fn twos_complement_be_to_numeric( input: &mut [u8], scale: u8, @@ -395,6 +397,8 @@ pub fn twos_complement_be_to_numeric( /// Parses a buffer of two's complement digits in big-endian order and converts /// them to [`Decimal`]. +// database-issues#9092: anyhow should not be used. +#[allow(clippy::disallowed_macros)] pub fn twos_complement_be_to_numeric_inner, const N: usize>( input: &mut [u8], ) -> Result, anyhow::Error> { @@ -689,6 +693,8 @@ pub fn munge_numeric(n: &mut Numeric) -> Result<(), anyhow::Error> { /// Rescale's `n` to fit within [`Numeric`]'s max precision or error if not /// possible. +// database-issues#9092: anyhow should not be used. +#[allow(clippy::disallowed_macros)] fn rescale_within_max_precision(n: &mut Numeric) -> Result<(), anyhow::Error> { let current_precision = get_precision(n); if current_precision > u32::from(NUMERIC_DATUM_MAX_PRECISION) { @@ -712,6 +718,8 @@ fn rescale_within_max_precision(n: &mut Numeric) -> Result<(), anyhow::Error> { /// - Rescaling exceeds max precision /// - `n` requires > [`NUMERIC_DATUM_MAX_PRECISION`] - `scale` digits of precision /// left of the decimal point +// database-issues#9092: anyhow should not be used. +#[allow(clippy::disallowed_macros)] pub fn rescale(n: &mut Numeric, scale: u8) -> Result<(), anyhow::Error> { let mut cx = cx_datum(); cx.rescale(n, &Numeric::from(-i32::from(scale))); diff --git a/src/repr/src/adt/varchar.rs b/src/repr/src/adt/varchar.rs index a4e56dc977ba1..fb91e3fb943a6 100644 --- a/src/repr/src/adt/varchar.rs +++ b/src/repr/src/adt/varchar.rs @@ -101,6 +101,8 @@ impl fmt::Display for InvalidVarCharMaxLengthError { impl Error for InvalidVarCharMaxLengthError {} +// database-issues#9092: anyhow should not be used. +#[allow(clippy::disallowed_macros)] pub fn format_str( s: &str, length: Option, diff --git a/src/repr/src/catalog_item_id.rs b/src/repr/src/catalog_item_id.rs index 0fc64304b9338..fdd23a607fdf5 100644 --- a/src/repr/src/catalog_item_id.rs +++ b/src/repr/src/catalog_item_id.rs @@ -67,6 +67,8 @@ impl CatalogItemId { impl FromStr for CatalogItemId { type Err = Error; + // database-issues#9092: anyhow should not be used. + #[allow(clippy::disallowed_macros)] fn from_str(mut s: &str) -> Result { if s.len() < 2 { return Err(anyhow!("couldn't parse id {}", s)); diff --git a/src/repr/src/global_id.rs b/src/repr/src/global_id.rs index acfb59a892389..43c7e5d0d44ca 100644 --- a/src/repr/src/global_id.rs +++ b/src/repr/src/global_id.rs @@ -83,6 +83,8 @@ impl GlobalId { impl FromStr for GlobalId { type Err = Error; + // database-issues#9092: anyhow should not be used. + #[allow(clippy::disallowed_macros)] fn from_str(mut s: &str) -> Result { if s.len() < 2 { return Err(anyhow!("couldn't parse id {}", s)); diff --git a/src/repr/src/network_policy_id.rs b/src/repr/src/network_policy_id.rs index 9725539e112e4..9bca71fd6e71f 100644 --- a/src/repr/src/network_policy_id.rs +++ b/src/repr/src/network_policy_id.rs @@ -56,6 +56,8 @@ impl NetworkPolicyId { impl FromStr for NetworkPolicyId { type Err = Error; + // database-issues#9092: anyhow should not be used. + #[allow(clippy::disallowed_macros)] fn from_str(s: &str) -> Result { fn parse_u64(s: &str) -> Result { if s.len() < 2 { diff --git a/src/repr/src/relation.rs b/src/repr/src/relation.rs index 8526b3814008d..8edb0f3377a71 100644 --- a/src/repr/src/relation.rs +++ b/src/repr/src/relation.rs @@ -61,6 +61,8 @@ fn return_true() -> bool { } impl ColumnType { + // database-issues#9092: anyhow should not be used. + #[allow(clippy::disallowed_macros)] pub fn union(&self, other: &Self) -> Result { match (self.scalar_type.clone(), other.scalar_type.clone()) { (scalar_type, other_scalar_type) if scalar_type == other_scalar_type => { @@ -1283,6 +1285,8 @@ impl VersionedRelationDesc { /// /// Panics if a constraint is not satisfied. fn validate(&self) { + // database-issues#9092: anyhow should not be used. + #[allow(clippy::disallowed_macros)] fn validate_inner(desc: &RelationDesc) -> Result<(), anyhow::Error> { if desc.typ.column_types.len() != desc.metadata.len() { anyhow::bail!("mismatch between number of types and metadatas"); diff --git a/src/repr/src/role_id.rs b/src/repr/src/role_id.rs index 966426611ec27..6b64d87138a30 100644 --- a/src/repr/src/role_id.rs +++ b/src/repr/src/role_id.rs @@ -98,6 +98,8 @@ impl RoleId { res } + // database-issues#9092: anyhow should not be used. + #[allow(clippy::disallowed_macros)] pub fn decode_binary(raw: &[u8]) -> Result { if raw.len() != RoleId::binary_size() { return Err(anyhow!( @@ -127,7 +129,11 @@ impl RoleId { impl FromStr for RoleId { type Err = Error; + // database-issues#9092: anyhow should not be used. + #[allow(clippy::disallowed_macros)] fn from_str(s: &str) -> Result { + // database-issues#9092: anyhow should not be used. + #[allow(clippy::disallowed_macros)] fn parse_u64(s: &str) -> Result { if s.len() < 2 { return Err(anyhow!("couldn't parse role id '{s}'")); diff --git a/src/repr/src/row/encode.rs b/src/repr/src/row/encode.rs index 3468a298ba202..37de00a146852 100644 --- a/src/repr/src/row/encode.rs +++ b/src/repr/src/row/encode.rs @@ -1268,6 +1268,8 @@ impl Schema for RelationDesc { RowColumnarDecoder::new(col, self) } + // database-issues#9092: anyhow should not be used. + #[allow(clippy::disallowed_macros)] fn encoder(&self) -> Result { RowColumnarEncoder::new(self) .ok_or_else(|| anyhow::anyhow!("Cannot encode a RelationDesc with no columns")) @@ -1311,6 +1313,8 @@ impl RowColumnarDecoder { /// /// Returns an error if the schema of the [`StructArray`] does not match /// the provided [`RelationDesc`]. + // database-issues#9092: anyhow should not be used. + #[allow(clippy::disallowed_macros)] pub fn new(col: StructArray, desc: &RelationDesc) -> Result { let inner_columns = col.columns(); let desc_columns = desc.typ().columns(); @@ -1525,6 +1529,8 @@ impl ColumnEncoder for RowColumnarEncoder { /// Note: it is _super_ important that we downcast as few times as possible. Datum encoding is a /// very hot path and downcasting is relatively slow #[inline] +// database-issues#9092: anyhow should not be used. +#[allow(clippy::disallowed_macros)] fn downcast_array(array: &Arc) -> Result<&T, anyhow::Error> { array .as_any() @@ -1536,6 +1542,8 @@ fn downcast_array(array: &Arc) -> Result<&T, anyhow::Erro /// /// Note: it is _super_ important that we downcast as few times as possible. Datum encoding is a /// very hot path and downcasting is relatively slow +// database-issues#9092: anyhow should not be used. +#[allow(clippy::disallowed_macros)] fn array_to_decoder( array: &Arc, col_ty: &ScalarType, diff --git a/src/repr/src/stats.rs b/src/repr/src/stats.rs index de7959070d7f4..2e3e85ca3523c 100644 --- a/src/repr/src/stats.rs +++ b/src/repr/src/stats.rs @@ -271,6 +271,8 @@ pub fn decode_numeric<'a>( stats: &PrimitiveStats>, arena: &'a RowArena, ) -> Result<(Datum<'a>, Datum<'a>), anyhow::Error> { + // database-issues#9092: anyhow should not be used. + #[allow(clippy::disallowed_macros)] fn decode<'a>(bytes: &[u8], arena: &'a RowArena) -> Result, anyhow::Error> { let proto = ProtoDatum::decode(bytes)?; let datum = arena.make_datum(|r| { diff --git a/src/rocksdb-types/src/config.rs b/src/rocksdb-types/src/config.rs index 13d444ccc223f..33573a9f484a4 100644 --- a/src/rocksdb-types/src/config.rs +++ b/src/rocksdb-types/src/config.rs @@ -181,6 +181,8 @@ impl Default for RocksDBTuningParameters { impl RocksDBTuningParameters { /// Build a `RocksDBTuningParameters` from strings and values from LD parameters. + // database-issues#9092: anyhow should not be used. + #[allow(clippy::disallowed_macros)] pub fn from_parameters( compaction_style: CompactionStyle, optimize_compaction_memtable_budget: usize, @@ -249,6 +251,8 @@ pub enum CompactionStyle { impl FromStr for CompactionStyle { type Err = anyhow::Error; + // database-issues#9092: anyhow should not be used. + #[allow(clippy::disallowed_macros)] fn from_str(s: &str) -> Result { let s = UncasedStr::new(s); if s == "level" { @@ -283,6 +287,8 @@ pub enum CompressionType { impl FromStr for CompressionType { type Err = anyhow::Error; + // database-issues#9092: anyhow should not be used. + #[allow(clippy::disallowed_macros)] fn from_str(s: &str) -> Result { let s = UncasedStr::new(s); if s == "zstd" { diff --git a/src/secrets/src/lib.rs b/src/secrets/src/lib.rs index bc12c42e5df9e..91f8b7e188507 100644 --- a/src/secrets/src/lib.rs +++ b/src/secrets/src/lib.rs @@ -101,6 +101,8 @@ impl SecretsController for InMemorySecretsController { #[async_trait] impl SecretsReader for InMemorySecretsController { + // database-issues#9092: anyhow should not be used. + #[allow(clippy::disallowed_macros)] async fn read(&self, id: CatalogItemId) -> Result, anyhow::Error> { let contents = self.data.lock().unwrap().get(&id).cloned(); contents.ok_or_else(|| anyhow::anyhow!("secret does not exist")) diff --git a/src/server-core/src/lib.rs b/src/server-core/src/lib.rs index 59c9c9f72dc86..4638e3655355d 100644 --- a/src/server-core/src/lib.rs +++ b/src/server-core/src/lib.rs @@ -555,6 +555,8 @@ pub struct TlsCliArgs { impl TlsCliArgs { /// Convert args into configuration. + // database-issues#9092: anyhow should not be used. + #[allow(clippy::disallowed_macros)] pub fn into_config(self) -> Result, anyhow::Error> { if self.tls_mode == "disable" { if self.tls_cert.is_some() { diff --git a/src/sql-lexer/build.rs b/src/sql-lexer/build.rs index 529d7e5edbb8e..35f4c60af52b1 100644 --- a/src/sql-lexer/build.rs +++ b/src/sql-lexer/build.rs @@ -22,6 +22,8 @@ use uncased::UncasedStr; const KEYWORDS_LIST: &str = "src/keywords.txt"; +// database-issues#9092: anyhow should not be used. +#[allow(clippy::disallowed_macros)] fn main() -> Result<()> { println!("cargo:rerun-if-changed={KEYWORDS_LIST}"); diff --git a/src/sql-server-util/src/desc.rs b/src/sql-server-util/src/desc.rs index ed6f98eff5a55..b46854abec3dd 100644 --- a/src/sql-server-util/src/desc.rs +++ b/src/sql-server-util/src/desc.rs @@ -551,6 +551,8 @@ impl SqlServerRowDecoder { /// Try to create a [`SqlServerRowDecoder`] that will decode [`tiberius::Row`]s that match /// the shape of the provided [`SqlServerTableDesc`], to [`mz_repr::Row`]s that match the /// shape of the provided [`RelationDesc`]. + // database-issues#9092: anyhow should not be used. + #[allow(clippy::disallowed_macros)] pub fn try_new( table: &SqlServerTableDesc, desc: &RelationDesc, diff --git a/src/sql-server-util/src/lib.rs b/src/sql-server-util/src/lib.rs index e44c0882a0a79..3738e0becab5e 100644 --- a/src/sql-server-util/src/lib.rs +++ b/src/sql-server-util/src/lib.rs @@ -60,6 +60,8 @@ impl Client { /// IntoFuture and does the default good thing of moving the `Connection` /// into a tokio task? And a `.raw()` option that will instead return both /// the Client and Connection for manual polling. + // database-issues#9092: anyhow should not be used. + #[allow(clippy::disallowed_macros)] pub async fn connect(config: Config) -> Result<(Self, Connection), SqlServerError> { // Setup our tunnelling and return any resources that need to be kept // alive for the duration of the connection. @@ -286,6 +288,8 @@ impl Client { } /// Returns the current transaction isolation level for the current session. + // database-issues#9092: anyhow should not be used. + #[allow(clippy::disallowed_macros)] pub async fn get_transaction_isolation( &mut self, ) -> Result { @@ -442,6 +446,8 @@ impl TransactionIsolationLevel { } /// Try to parse a [`TransactionIsolationLevel`] from the value returned from SQL Server. + // database-issues#9092: anyhow should not be used. + #[allow(clippy::disallowed_macros)] fn try_from_sql_server(val: i16) -> Result { let level = match val { 1 => TransactionIsolationLevel::ReadUncommitted, diff --git a/src/sql/src/names.rs b/src/sql/src/names.rs index dfff544402057..fa0a8392faea4 100644 --- a/src/sql/src/names.rs +++ b/src/sql/src/names.rs @@ -1062,6 +1062,8 @@ impl fmt::Display for ObjectId { impl TryFrom for ObjectId { type Error = anyhow::Error; + // database-issues#9092: anyhow should not be used. + #[allow(clippy::disallowed_macros)] fn try_from(name: ResolvedObjectName) -> Result { match name { ResolvedObjectName::Cluster(name) => Ok(ObjectId::Cluster(name.id)), diff --git a/src/sql/src/plan/with_options.rs b/src/sql/src/plan/with_options.rs index 44a3dbdea8adb..98f5ca3b0d29f 100644 --- a/src/sql/src/plan/with_options.rs +++ b/src/sql/src/plan/with_options.rs @@ -580,6 +580,8 @@ impl ImpliedValue for u64 { } impl>> TryFromValue> for Vec { + // database-issues#9092: anyhow should not be used. + #[allow(clippy::disallowed_macros)] fn try_from_value(v: WithOptionValue) -> Result { match v { WithOptionValue::Sequence(a) => { diff --git a/src/sql/src/pure.rs b/src/sql/src/pure.rs index 0d99f30dc31da..ebf90da80c412 100644 --- a/src/sql/src/pure.rs +++ b/src/sql/src/pure.rs @@ -2243,6 +2243,8 @@ async fn get_schema_with_strategy( } } +// database-issues#9092: anyhow should not be used. +#[allow(clippy::disallowed_macros)] async fn get_remote_csr_schema( ccsr_client: &mz_ccsr::Client, key_strategy: ReaderSchemaSelectionStrategy, diff --git a/src/sqllogictest/src/lib.rs b/src/sqllogictest/src/lib.rs index 1f3dc9661eb9d..0420c7255f1a0 100644 --- a/src/sqllogictest/src/lib.rs +++ b/src/sqllogictest/src/lib.rs @@ -16,6 +16,9 @@ //! This crate implements a parser and runner for sqllogictest files. //! The parser is generic, but the runner is specific to Materialize. +// database-issues#9092: anyhow should not be used. +#![allow(clippy::disallowed_macros)] + pub mod ast; pub mod parser; pub mod runner; diff --git a/src/ssh-util/src/tunnel.rs b/src/ssh-util/src/tunnel.rs index ea9f237d36b3c..d5e601c572273 100644 --- a/src/ssh-util/src/tunnel.rs +++ b/src/ssh-util/src/tunnel.rs @@ -232,6 +232,8 @@ impl SshTunnelHandle { } } +// database-issues#9092: anyhow should not be used. +#[allow(clippy::disallowed_macros)] async fn connect( config: &SshTunnelConfig, timeout_config: SshTimeoutConfig, @@ -288,6 +290,8 @@ async fn connect( .unwrap_or_else(|| anyhow::anyhow!("no hosts to connect to"))) } +// database-issues#9092: anyhow should not be used. +#[allow(clippy::disallowed_macros)] async fn port_forward(session: &Session, host: &str, port: u16) -> Result { // Loop trying to find an open port. for _ in 0..50 { diff --git a/src/ssh-util/src/tunnel_manager.rs b/src/ssh-util/src/tunnel_manager.rs index 74a73abc24565..84e984f2341b1 100644 --- a/src/ssh-util/src/tunnel_manager.rs +++ b/src/ssh-util/src/tunnel_manager.rs @@ -46,6 +46,8 @@ impl SshTunnelManager { /// The manager guarantees that there will never be more than one in flight /// connection attempt for the same tunnel, even when this method is called /// concurrently from multiple threads. + // database-issues#9092: anyhow should not be used. + #[allow(clippy::disallowed_macros)] pub async fn connect( &self, config: SshTunnelConfig, diff --git a/src/storage-client/src/client.rs b/src/storage-client/src/client.rs index 9693650a5d740..4104435789686 100644 --- a/src/storage-client/src/client.rs +++ b/src/storage-client/src/client.rs @@ -431,6 +431,8 @@ pub enum Status { impl std::str::FromStr for Status { type Err = anyhow::Error; /// Keep in sync with [`Status::to_str`]. + // database-issues#9092: anyhow should not be used. + #[allow(clippy::disallowed_macros)] fn from_str(s: &str) -> Result { Ok(match s { "starting" => Status::Starting, diff --git a/src/storage-client/src/sink.rs b/src/storage-client/src/sink.rs index 2208e167bbd6f..37a5575ab0829 100644 --- a/src/storage-client/src/sink.rs +++ b/src/storage-client/src/sink.rs @@ -59,6 +59,8 @@ struct TopicConfigs { replication_factor: i32, } +// database-issues#9092: anyhow should not be used. +#[allow(clippy::disallowed_macros)] async fn discover_topic_configs( client: &AdminClient, topic: &str, diff --git a/src/storage-client/src/storage_collections.rs b/src/storage-client/src/storage_collections.rs index df5da821d765c..49d8a1aae745c 100644 --- a/src/storage-client/src/storage_collections.rs +++ b/src/storage-client/src/storage_collections.rs @@ -2243,6 +2243,8 @@ where Ok(()) } + // database-issues#9092: anyhow should not be used. + #[allow(clippy::disallowed_macros)] async fn alter_table_desc( &self, existing_collection: GlobalId, diff --git a/src/storage-controller/src/collection_mgmt.rs b/src/storage-controller/src/collection_mgmt.rs index 7cffede743fc4..9f5edc240a9be 100644 --- a/src/storage-controller/src/collection_mgmt.rs +++ b/src/storage-controller/src/collection_mgmt.rs @@ -1462,6 +1462,8 @@ where /// # Panics /// /// Panics if `collection` is not a metrics history. +// database-issues#9092: anyhow should not be used. +#[allow(clippy::disallowed_macros)] async fn partially_truncate_metrics_history( id: GlobalId, introspection_type: IntrospectionType, diff --git a/src/storage-controller/src/instance.rs b/src/storage-controller/src/instance.rs index 55d3751183de3..cb46c5b397b06 100644 --- a/src/storage-controller/src/instance.rs +++ b/src/storage-controller/src/instance.rs @@ -927,6 +927,8 @@ where /// Returns (with an `Err`) if it encounters an error condition (e.g. the replica disconnects). /// If no error condition is encountered, the task runs until the controller disconnects from /// the command channel, or the task is dropped. + // database-issues#9092: anyhow should not be used. + #[allow(clippy::disallowed_macros)] async fn run_message_loop(mut self, mut client: ReplicaClient) -> Result<(), anyhow::Error> { loop { select! { diff --git a/src/storage-controller/src/lib.rs b/src/storage-controller/src/lib.rs index 0da34c982809d..d915d6592ce31 100644 --- a/src/storage-controller/src/lib.rs +++ b/src/storage-controller/src/lib.rs @@ -1525,6 +1525,8 @@ where } /// Create a oneshot ingestion. + // database-issues#9092: anyhow should not be used. + #[allow(clippy::disallowed_macros)] async fn create_oneshot_ingestion( &mut self, ingestion_id: uuid::Uuid, @@ -1566,6 +1568,8 @@ where } } + // database-issues#9092: anyhow should not be used. + #[allow(clippy::disallowed_macros)] fn cancel_oneshot_ingestion( &mut self, ingestion_id: uuid::Uuid, diff --git a/src/storage-operators/src/s3_oneshot_sink.rs b/src/storage-operators/src/s3_oneshot_sink.rs index 7a7bda930410a..12f56e8032388 100644 --- a/src/storage-operators/src/s3_oneshot_sink.rs +++ b/src/storage-operators/src/s3_oneshot_sink.rs @@ -206,6 +206,8 @@ where /// /// This cleanup work removes the INCOMPLETE sentinel file (see description /// of `render_initialization_operator` for more details). +// database-issues#9092: anyhow should not be used. +#[allow(clippy::disallowed_macros)] fn render_completion_operator( scope: G, connection_context: ConnectionContext, @@ -291,6 +293,8 @@ where /// /// The `input_collection` must be a stream of chains, partitioned and exchanged by the row's hash /// modulo the number of batches. +// database-issues#9092: anyhow should not be used. +#[allow(clippy::disallowed_macros)] fn render_upload_operator( scope: G, connection_context: ConnectionContext, diff --git a/src/storage-operators/src/s3_oneshot_sink/parquet.rs b/src/storage-operators/src/s3_oneshot_sink/parquet.rs index bc8c56013de8c..a56a63c44b92a 100644 --- a/src/storage-operators/src/s3_oneshot_sink/parquet.rs +++ b/src/storage-operators/src/s3_oneshot_sink/parquet.rs @@ -153,6 +153,8 @@ pub(super) struct ParquetUploader { } impl CopyToS3Uploader for ParquetUploader { + // database-issues#9092: anyhow should not be used. + #[allow(clippy::disallowed_macros)] fn new( sdk_config: SdkConfig, connection_details: S3UploadInfo, diff --git a/src/storage-operators/src/s3_oneshot_sink/pgcopy.rs b/src/storage-operators/src/s3_oneshot_sink/pgcopy.rs index 5bafce471f676..6ebe14dc97bc4 100644 --- a/src/storage-operators/src/s3_oneshot_sink/pgcopy.rs +++ b/src/storage-operators/src/s3_oneshot_sink/pgcopy.rs @@ -50,6 +50,8 @@ pub(super) struct PgCopyUploader { } impl CopyToS3Uploader for PgCopyUploader { + // database-issues#9092: anyhow should not be used. + #[allow(clippy::disallowed_macros)] fn new( sdk_config: SdkConfig, connection_details: S3UploadInfo, @@ -97,6 +99,8 @@ impl CopyToS3Uploader for PgCopyUploader { /// `part_size_limit` after which the `S3MultiPartUploader` will upload that part. In case it will /// exceed the max file size of the ongoing upload, then a new `S3MultiPartUploader` for a new file will /// be created and the row data will be appended there. + // database-issues#9092: anyhow should not be used. + #[allow(clippy::disallowed_macros)] async fn append_row(&mut self, row: &Row) -> Result<(), anyhow::Error> { let mut buf: Vec = vec![]; // encode the row and write to temp buffer. @@ -128,6 +132,8 @@ impl CopyToS3Uploader for PgCopyUploader { impl PgCopyUploader { /// Creates the uploader for the next file and starts the multi part upload. + // database-issues#9092: anyhow should not be used. + #[allow(clippy::disallowed_macros)] async fn start_new_file_upload(&mut self) -> Result<(), anyhow::Error> { self.finish().await?; assert_none!(self.current_file_uploader); diff --git a/src/storage-types/src/connections.rs b/src/storage-types/src/connections.rs index e3509c2cefdcf..15fa3725c11ab 100644 --- a/src/storage-types/src/connections.rs +++ b/src/storage-types/src/connections.rs @@ -1033,6 +1033,8 @@ impl CsrConnection { impl CsrConnection { /// Constructs a schema registry client from the connection. + // database-issues#9092: anyhow should not be used. + #[allow(clippy::disallowed_macros)] pub async fn connect( &self, storage_configuration: &StorageConfiguration, @@ -1508,6 +1510,8 @@ impl PostgresConnection { )?) } + // database-issues#9092: anyhow should not be used. + #[allow(clippy::disallowed_macros)] async fn validate( &self, _id: CatalogItemId, @@ -2275,6 +2279,8 @@ impl SshConnection { impl AwsPrivatelinkConnection { #[allow(clippy::unused_async)] + // database-issues#9092: anyhow should not be used. + #[allow(clippy::disallowed_macros)] async fn validate( &self, id: CatalogItemId, diff --git a/src/storage-types/src/connections/aws.rs b/src/storage-types/src/connections/aws.rs index 9d677ad4ace95..f5d9ccb2070c4 100644 --- a/src/storage-types/src/connections/aws.rs +++ b/src/storage-types/src/connections/aws.rs @@ -119,6 +119,8 @@ pub struct AwsCredentials { impl AwsCredentials { /// Loads a credentials provider with the configured credentials. + // database-issues#9092: anyhow should not be used. + #[allow(clippy::disallowed_macros)] async fn load_credentials_provider( &self, connection_context: &ConnectionContext, @@ -211,6 +213,8 @@ impl AwsAssumeRole { /// Only for use in the internal implementation of AWS connections. Using /// this method incorrectly can result in violating our AWS security /// requirements. + // database-issues#9092: anyhow should not be used. + #[allow(clippy::disallowed_macros)] async fn dangerously_load_credentials_provider( &self, connection_context: &ConnectionContext, @@ -262,6 +266,8 @@ impl AwsAssumeRole { Ok(credentials.build_from_provider(jump_credentials).await) } + // database-issues#9092: anyhow should not be used. + #[allow(clippy::disallowed_macros)] pub fn external_id( &self, connection_context: &ConnectionContext, @@ -273,6 +279,8 @@ impl AwsAssumeRole { Ok(format!("mz_{}_{}", aws_external_id_prefix, connection_id)) } + // database-issues#9092: anyhow should not be used. + #[allow(clippy::disallowed_macros)] pub fn example_trust_policy( &self, connection_context: &ConnectionContext, diff --git a/src/storage-types/src/errors.rs b/src/storage-types/src/errors.rs index fa5eeabe5f52f..00ca7a70638bf 100644 --- a/src/storage-types/src/errors.rs +++ b/src/storage-types/src/errors.rs @@ -1032,6 +1032,8 @@ impl ContextCreationErrorExt for Result where ContextCreationError: From, { + // database-issues#9092: anyhow should not be used. + #[allow(clippy::disallowed_macros)] fn check_ssh_status( self, cx: &TunnelingClientContext, @@ -1045,6 +1047,8 @@ where }) } + // database-issues#9092: anyhow should not be used. + #[allow(clippy::disallowed_macros)] fn add_context(self, msg: &'static str) -> Result { self.map_err(|e| { let e = ContextCreationError::from(e); @@ -1069,6 +1073,8 @@ where } impl From for ContextCreationError { + // database-issues#9092: anyhow should not be used. + #[allow(clippy::disallowed_macros)] fn from(csr: CsrConnectError) -> ContextCreationError { use ContextCreationError::*; diff --git a/src/storage-types/src/instances.rs b/src/storage-types/src/instances.rs index ad4c8bbd5995a..22895a97d60bc 100644 --- a/src/storage-types/src/instances.rs +++ b/src/storage-types/src/instances.rs @@ -76,6 +76,8 @@ impl StorageInstanceId { impl FromStr for StorageInstanceId { type Err = anyhow::Error; + // database-issues#9092: anyhow should not be used. + #[allow(clippy::disallowed_macros)] fn from_str(s: &str) -> Result { if s.len() < 2 { bail!("couldn't parse compute instance id {}", s); diff --git a/src/storage-types/src/sinks/s3_oneshot_sink.rs b/src/storage-types/src/sinks/s3_oneshot_sink.rs index eef51feb6ca63..ff0a638cd743b 100644 --- a/src/storage-types/src/sinks/s3_oneshot_sink.rs +++ b/src/storage-types/src/sinks/s3_oneshot_sink.rs @@ -33,6 +33,8 @@ use crate::sinks::S3UploadInfo; /// performed by multiple replicas it simplifies the user ergonomics by only /// having to listen for a single event (a PutObject sentinel would trigger once /// for each replica). +// database-issues#9092: anyhow should not be used. +#[allow(clippy::disallowed_macros)] pub async fn preflight( connection_context: ConnectionContext, aws_connection: &AwsConnection, diff --git a/src/storage-types/src/sources.rs b/src/storage-types/src/sources.rs index e9359ba1372d2..36c3003506e1b 100644 --- a/src/storage-types/src/sources.rs +++ b/src/storage-types/src/sources.rs @@ -1662,6 +1662,8 @@ pub struct SourceDataColumnarDecoder { } impl SourceDataColumnarDecoder { + // database-issues#9092: anyhow should not be used. + #[allow(clippy::disallowed_macros)] pub fn new(col: StructArray, desc: &RelationDesc) -> Result { // TODO(parkmcar): We should validate the fields here. let (_fields, arrays, nullability) = col.into_parts(); diff --git a/src/storage-types/src/sources/envelope.rs b/src/storage-types/src/sources/envelope.rs index 48892db1b7296..bfc9a5803bdec 100644 --- a/src/storage-types/src/sources/envelope.rs +++ b/src/storage-types/src/sources/envelope.rs @@ -202,6 +202,8 @@ impl RustType for UpsertStyle { /// Returns an error if it detects a common columns between the two relations that has the same /// name but a different type, if a key column is missing from the value, and if the key relation /// has a column with no name. +// database-issues#9092: anyhow should not be used. +#[allow(clippy::disallowed_macros)] fn match_key_indices( key_desc: &RelationDesc, value_desc: &RelationDesc, @@ -261,6 +263,8 @@ impl UnplannedSourceEnvelope { /// Computes the output relation of this envelope when applied on top of the decoded key and /// value relation desc + // database-issues#9092: anyhow should not be used. + #[allow(clippy::disallowed_macros)] pub fn desc( self, key_desc: Option, diff --git a/src/storage/examples/upsert_open_loop.rs b/src/storage/examples/upsert_open_loop.rs index e6e84579d4d6c..a45790339de3d 100644 --- a/src/storage/examples/upsert_open_loop.rs +++ b/src/storage/examples/upsert_open_loop.rs @@ -330,6 +330,8 @@ pub async fn run(args: Args) -> Result<(), anyhow::Error> { run_benchmark(args, metrics_registry, num_sources, num_workers).await } +// database-issues#9092: anyhow should not be used. +#[allow(clippy::disallowed_macros)] async fn run_benchmark( args: Args, _metrics_registry: MetricsRegistry, diff --git a/src/storage/src/render/persist_sink.rs b/src/storage/src/render/persist_sink.rs index 1ff95140ba899..cc2f388297239 100644 --- a/src/storage/src/render/persist_sink.rs +++ b/src/storage/src/render/persist_sink.rs @@ -873,6 +873,8 @@ where /// This also keeps the shared frontier that is stored in `compute_state` in /// sync with the upper of the persist shard, and updates various metrics /// and statistics objects. +// database-issues#9092: anyhow should not be used. +#[allow(clippy::disallowed_macros)] fn append_batches( scope: &G, collection_id: GlobalId, diff --git a/src/storage/src/sink/kafka.rs b/src/storage/src/sink/kafka.rs index b26aba9c3bcd7..795be9b282f4c 100644 --- a/src/storage/src/sink/kafka.rs +++ b/src/storage/src/sink/kafka.rs @@ -262,6 +262,8 @@ impl TransactionalProducer { /// Initializes a transcational producer for the sink identified by `sink_id`. After this call /// returns it is guranteed that all previous `TransactionalProducer` instances for the same /// sink have been fenced out (i.e `init_transations()` has been called successfully). + // database-issues#9092: anyhow should not be used. + #[allow(clippy::disallowed_macros)] async fn new( sink_id: GlobalId, connection: &KafkaSinkConnection, @@ -625,6 +627,8 @@ struct KafkaHeader { /// This operator exchanges all updates to a single worker by hashing on the given sink `id`. /// /// Updates are sent in ascending timestamp order. +// database-issues#9092: anyhow should not be used. +#[allow(clippy::disallowed_macros)] fn sink_collection>( name: String, input: &Collection, @@ -862,6 +866,8 @@ fn sink_collection>( /// IMPORTANT: to achieve exactly once guarantees, the producer that will resume /// production at the returned timestamp *must* have called `init_transactions` /// prior to calling this method. +// database-issues#9092: anyhow should not be used. +#[allow(clippy::disallowed_macros)] async fn determine_sink_progress( sink_id: GlobalId, connection: &KafkaSinkConnection, @@ -1073,6 +1079,8 @@ async fn determine_sink_progress( result } +// database-issues#9092: anyhow should not be used. +#[allow(clippy::disallowed_macros)] fn progress_search( progress_client_read_committed: &BaseConsumer, progress_record_fetch_timeout: Duration, @@ -1269,6 +1277,8 @@ where Ok(Antichain::from(times)) } +// database-issues#9092: anyhow should not be used. +#[allow(clippy::disallowed_macros)] fn parse_progress_record(payload: &[u8]) -> Result { Ok(match serde_json::from_slice::(payload) { Ok(progress) => progress, @@ -1295,6 +1305,8 @@ fn parse_progress_record(payload: &[u8]) -> Result>, sink_id: GlobalId, @@ -1355,6 +1367,8 @@ async fn fetch_partition_count_loop( /// Encodes a stream of `(Option, Option)` updates using the specified encoder. /// /// Input [`Row`] updates must me compatible with the given implementor of [`Encode`]. +// database-issues#9092: anyhow should not be used. +#[allow(clippy::disallowed_macros)] fn encode_collection( name: String, input: &Collection, DiffPair), Diff>, diff --git a/src/storage/src/source/kafka.rs b/src/storage/src/source/kafka.rs index caab7e1425eb2..ab08eb2cf9606 100644 --- a/src/storage/src/source/kafka.rs +++ b/src/storage/src/source/kafka.rs @@ -1370,6 +1370,8 @@ mod tests { // this test requires a running Kafka instance at localhost:9092. #[mz_ore::test] #[ignore] + // database-issues#9092: anyhow should not be used. + #[allow(clippy::disallowed_macros)] fn demonstrate_kafka_queue_race_condition() -> Result<(), anyhow::Error> { let topic_name = "queue-test"; let pid = 0; @@ -1442,6 +1444,8 @@ mod tests { } /// Fetches the list of partitions and their corresponding high watermark. +// database-issues#9092: anyhow should not be used. +#[allow(clippy::disallowed_macros)] fn fetch_partition_info( consumer: &BaseConsumer, topic: &str, diff --git a/src/storage/src/source/mysql/replication/events.rs b/src/storage/src/source/mysql/replication/events.rs index b2f45aa7eee1d..08cce2cb47873 100644 --- a/src/storage/src/source/mysql/replication/events.rs +++ b/src/storage/src/source/mysql/replication/events.rs @@ -25,6 +25,8 @@ use super::context::ReplContext; /// Returns the MySqlTableName for the given table name referenced in a /// SQL statement, using the current schema if the table name is unqualified. +// database-issues#9092: anyhow should not be used. +#[allow(clippy::disallowed_macros)] fn table_ident(name: &str, current_schema: &str) -> Result { let stripped = name.replace('`', ""); let mut name_iter = stripped.split('.'); @@ -49,6 +51,8 @@ fn table_ident(name: &str, current_schema: &str) -> Result, ctx: &mut ReplContext<'_>, @@ -213,6 +217,8 @@ pub(super) async fn handle_query_event( /// /// We use these events to update the dataflow with the new rows, and return a new /// frontier with which to advance the dataflow's progress. +// database-issues#9092: anyhow should not be used. +#[allow(clippy::disallowed_macros)] pub(super) async fn handle_rows_event( event: RowsEventData<'_>, ctx: &ReplContext<'_>, diff --git a/src/storage/src/source/mysql/snapshot.rs b/src/storage/src/source/mysql/snapshot.rs index 7a1f6aeda4c9a..b26bd1ec56660 100644 --- a/src/storage/src/source/mysql/snapshot.rs +++ b/src/storage/src/source/mysql/snapshot.rs @@ -552,6 +552,8 @@ struct TableStatistics { count: u64, } +// database-issues#9092: anyhow should not be used. +#[allow(clippy::disallowed_macros)] async fn collect_table_statistics( conn: &mut Q, table: &MySqlTableName, diff --git a/src/storage/src/source/postgres.rs b/src/storage/src/source/postgres.rs index 38213160bf5a7..4e0f42d2df5ac 100644 --- a/src/storage/src/source/postgres.rs +++ b/src/storage/src/source/postgres.rs @@ -429,6 +429,8 @@ async fn fetch_slot_metadata( } /// Fetch the `pg_current_wal_lsn`, used to report metrics. +// database-issues#9092: anyhow should not be used. +#[allow(clippy::disallowed_macros)] async fn fetch_max_lsn(client: &Client) -> Result { let query = "SELECT pg_current_wal_lsn()"; let row = simple_query_opt(client, query).await?; diff --git a/src/storage/src/source/postgres/replication.rs b/src/storage/src/source/postgres/replication.rs index a793dd090868e..86aa903182d6a 100644 --- a/src/storage/src/source/postgres/replication.rs +++ b/src/storage/src/source/postgres/replication.rs @@ -605,6 +605,8 @@ pub(crate) fn render>( /// keepalive messages with the provided `uppers` stream. /// /// The returned stream will contain all transactions that whose commit LSN is beyond `resume_lsn`. +// database-issues#9092: anyhow should not be used. +#[allow(clippy::disallowed_macros)] async fn raw_stream<'a>( config: &'a RawSourceCreationConfig, replication_client: Client, diff --git a/src/storage/src/source/postgres/snapshot.rs b/src/storage/src/source/postgres/snapshot.rs index 15e43053e1051..4a705145c8150 100644 --- a/src/storage/src/source/postgres/snapshot.rs +++ b/src/storage/src/source/postgres/snapshot.rs @@ -722,6 +722,8 @@ struct TableStatistics { count_latency: f64, } +// database-issues#9092: anyhow should not be used. +#[allow(clippy::disallowed_macros)] async fn collect_table_statistics( client: &Client, strict: bool, diff --git a/src/storage/src/source/reclock/compat.rs b/src/storage/src/source/reclock/compat.rs index e4c1afcabd07a..e1a0f08fff41c 100644 --- a/src/storage/src/source/reclock/compat.rs +++ b/src/storage/src/source/reclock/compat.rs @@ -65,6 +65,8 @@ where FromTime: SourceTimestamp, IntoTime: Timestamp + Lattice + Codec64, { + // database-issues#9092: anyhow should not be used. + #[allow(clippy::disallowed_macros)] pub async fn new( persist_clients: Arc, read_only_rx: watch::Receiver, diff --git a/src/storage/src/upsert/autospill.rs b/src/storage/src/upsert/autospill.rs index 47e638d9fe976..54ee8e1e5198c 100644 --- a/src/storage/src/upsert/autospill.rs +++ b/src/storage/src/upsert/autospill.rs @@ -122,6 +122,8 @@ where } } + // database-issues#9092: anyhow should not be used. + #[allow(clippy::disallowed_macros)] async fn multi_merge(&mut self, merges: M) -> Result where M: IntoIterator>)>, diff --git a/src/storage/src/upsert/memory.rs b/src/storage/src/upsert/memory.rs index 04524d3cf551e..578a93702f016 100644 --- a/src/storage/src/upsert/memory.rs +++ b/src/storage/src/upsert/memory.rs @@ -88,6 +88,8 @@ where Ok(stats) } + // database-issues#9092: anyhow should not be used. + #[allow(clippy::disallowed_macros)] async fn multi_merge(&mut self, _merges: M) -> Result where M: IntoIterator>)>, diff --git a/src/storage/src/upsert/types.rs b/src/storage/src/upsert/types.rs index 91dae0cc1cfae..bdd2faa3d6cb8 100644 --- a/src/storage/src/upsert/types.rs +++ b/src/storage/src/upsert/types.rs @@ -1124,6 +1124,8 @@ where /// /// Also note that we use `self.inner.multi_*`, not `self.multi_*`. This is /// to avoid erroneously changing metric and stats values. + // database-issues#9092: anyhow should not be used. + #[allow(clippy::disallowed_macros)] pub async fn consolidate_chunk( &mut self, updates: U, @@ -1366,6 +1368,8 @@ where /// Insert or delete for all `puts` keys, prioritizing the last value for /// repeated keys. + // database-issues#9092: anyhow should not be used. + #[allow(clippy::disallowed_macros)] pub async fn multi_put

( &mut self, update_per_record_stats: bool, @@ -1415,6 +1419,8 @@ where /// Get the `gets` keys, which must be unique, placing the results in `results_out`. /// /// Panics if `gets` and `results_out` are not the same length. + // database-issues#9092: anyhow should not be used. + #[allow(clippy::disallowed_macros)] pub async fn multi_get<'r, G, R>( &mut self, gets: G, diff --git a/src/testdrive/src/lib.rs b/src/testdrive/src/lib.rs index 134397c161b78..10ea9bbf9c9f8 100644 --- a/src/testdrive/src/lib.rs +++ b/src/testdrive/src/lib.rs @@ -10,6 +10,8 @@ //! Integration test driver for Materialize. #![warn(missing_docs)] +// database-issues#9092: anyhow should not be used. +#![allow(clippy::disallowed_macros)] use std::fs::File; use std::io::{self, Read, Write}; diff --git a/src/tls-util/src/lib.rs b/src/tls-util/src/lib.rs index dd0012c6674eb..812c585b2c95e 100644 --- a/src/tls-util/src/lib.rs +++ b/src/tls-util/src/lib.rs @@ -38,6 +38,8 @@ pub enum TlsError { } /// Creates a TLS connector for the given [`Config`](tokio_postgres::Config). +// database-issues#9092: anyhow should not be used. +#[allow(clippy::disallowed_macros)] pub fn make_tls(config: &tokio_postgres::Config) -> Result { let mut builder = SslConnector::builder(SslMethod::tls_client())?; // The mode dictates whether we verify peer certs and hostnames. By default, Postgres is diff --git a/src/transform/tests/test_runner.rs b/src/transform/tests/test_runner.rs index 88b3716315f7b..5a8f5a3a93c68 100644 --- a/src/transform/tests/test_runner.rs +++ b/src/transform/tests/test_runner.rs @@ -100,6 +100,8 @@ mod tests { // Converts string to MirRelationExpr. `args[in]` specifies which input // format is being used. + // database-issues#9092: anyhow should not be used. + #[allow(clippy::disallowed_macros)] fn parse_relation( s: &str, cat: &TestCatalog, @@ -262,6 +264,8 @@ mod tests { Ok(out) } + // database-issues#9092: anyhow should not be used. + #[allow(clippy::disallowed_macros)] fn get_transform(name: &str) -> Result, Error> { // TODO(justin): is there a way to just extract these from the Optimizer list of // transforms? diff --git a/src/walkabout/src/ir.rs b/src/walkabout/src/ir.rs index 2a5250a6afadc..ca82f0b9d96c6 100644 --- a/src/walkabout/src/ir.rs +++ b/src/walkabout/src/ir.rs @@ -145,6 +145,8 @@ pub enum Type { /// This is a very, very lightweight semantic analysis phase for Rust code. Our /// main goal is to determine the type of each field of a struct or enum /// variant, so we know how to visit it. See [`Type`] for details. +// database-issues#9092: anyhow should not be used. +#[allow(clippy::disallowed_macros)] pub(crate) fn analyze(syn_items: &[syn::DeriveInput]) -> Result { let mut items = BTreeMap::new(); for syn_item in syn_items { @@ -196,6 +198,8 @@ pub(crate) fn analyze(syn_items: &[syn::DeriveInput]) -> Result { Ok(Ir { items, generics }) } +// database-issues#9092: anyhow should not be used. +#[allow(clippy::disallowed_macros)] fn validate_fields<'a, I>(items: &BTreeMap, fields: I) -> Result<()> where I: IntoIterator, @@ -226,6 +230,8 @@ fn analyze_fields(fields: &syn::Fields) -> Result> { .collect() } +// database-issues#9092: anyhow should not be used. +#[allow(clippy::disallowed_macros)] fn analyze_generics(generics: &syn::Generics) -> Result> { let mut out = vec![]; for g in generics.params.iter() { @@ -251,6 +257,8 @@ fn analyze_generics(generics: &syn::Generics) -> Result> { Ok(out) } +// database-issues#9092: anyhow should not be used. +#[allow(clippy::disallowed_macros)] fn analyze_generic_bounds<'a, I>(bounds: I) -> Result> where I: IntoIterator, @@ -271,6 +279,8 @@ where Ok(out) } +// database-issues#9092: anyhow should not be used. +#[allow(clippy::disallowed_macros)] fn analyze_type(ty: &syn::Type) -> Result { match ty { syn::Type::Path(syn::TypePath { qself: None, path }) => match path.segments.len() { diff --git a/test/metabase/smoketest/src/bin/metabase-smoketest.rs b/test/metabase/smoketest/src/bin/metabase-smoketest.rs index cac9105069977..825c67f8f1416 100644 --- a/test/metabase/smoketest/src/bin/metabase-smoketest.rs +++ b/test/metabase/smoketest/src/bin/metabase-smoketest.rs @@ -103,6 +103,8 @@ async fn connect_metabase() -> Result { } #[tokio::main] +// database-issues#9092: anyhow should not be used. +#[allow(clippy::disallowed_macros)] async fn main() -> Result<(), anyhow::Error> { mz_ore::test::init_logging(); From a48813defd86e7a62edcf17150983875e1d139c4 Mon Sep 17 00:00:00 2001 From: Moritz Hoffmann Date: Wed, 9 Apr 2025 10:35:59 +0200 Subject: [PATCH 2/2] Disallow anyhow::Result Signed-off-by: Moritz Hoffmann --- clippy.toml | 1 + src/catalog-protos/build.rs | 1 + src/catalog/src/config.rs | 1 + src/interchange/src/avro.rs | 11 ++++- src/interchange/src/avro/decode.rs | 2 + src/interchange/src/avro/schema.rs | 14 ++++++ src/interchange/src/confluent.rs | 12 +++-- src/kafka-util/src/admin.rs | 5 +++ src/kafka-util/src/bin/kgen.rs | 1 + src/license-keys/src/lib.rs | 6 +++ src/mz-debug/src/kubectl_port_forwarder.rs | 4 +- src/mz-debug/src/system_catalog_dumper.rs | 36 +++++++++++---- src/persist-client/src/cli/admin.rs | 5 +++ src/persist-client/src/cli/args.rs | 4 ++ src/persist-client/src/cli/inspect.rs | 2 + src/persist-client/src/internal/compact.rs | 2 + src/persist-client/src/internal/machine.rs | 4 ++ src/persist-client/src/internal/restore.rs | 1 + src/persist-client/src/internal/state.rs | 2 + src/persist-client/src/iter.rs | 8 ++++ src/persist-types/src/columnar.rs | 5 +++ src/persist-types/src/part.rs | 8 ++++ src/persist/src/indexed/columnar/arrow.rs | 1 + src/persist/src/indexed/encoding.rs | 1 + src/pgtest/src/lib.rs | 13 ++++++ src/pgtz/build.rs | 5 ++- src/prof/src/jemalloc.rs | 12 +++++ src/prof/src/time.rs | 1 + src/proto/src/lib.rs | 2 + src/s3-datagen/src/main.rs | 2 + src/sql-lexer/build.rs | 5 ++- src/sql-parser/build.rs | 6 ++- src/sql/src/plan/statement/ddl.rs | 2 + src/ssh-util/src/keys.rs | 24 ++++++++++ .../src/connections/string_or_secret.rs | 2 + src/storage-types/src/sources/envelope.rs | 2 + src/storage/src/sink/kafka.rs | 2 + src/storage/src/source/reclock/compat.rs | 1 + src/testdrive/src/action/kafka/verify_data.rs | 2 + src/walkabout/src/ir.rs | 21 ++++++--- src/walkabout/src/lib.rs | 6 +-- src/walkabout/src/parse.rs | 10 +++-- test/test-util/src/mz_client.rs | 45 ++++++++++++++----- 43 files changed, 254 insertions(+), 46 deletions(-) diff --git a/clippy.toml b/clippy.toml index 6878b47da66eb..560dddf118056 100644 --- a/clippy.toml +++ b/clippy.toml @@ -93,6 +93,7 @@ disallowed-macros = [ ] disallowed-types = [ + { path = "anyhow::Result", reason = "use structured errors instead" }, { path = "std::collections::HashMap", reason = "use `std::collections::BTreeMap` or `mz_ore::collections::HashMap` instead" }, { path = "std::collections::HashSet", reason = "use `std::collections::BTreeSet` or `mz_ore::collections::HashSet` instead" }, ] diff --git a/src/catalog-protos/build.rs b/src/catalog-protos/build.rs index 1371b287d91c3..a403d9458c22f 100644 --- a/src/catalog-protos/build.rs +++ b/src/catalog-protos/build.rs @@ -30,6 +30,7 @@ const PROTO_HASHES: &str = "protos/hashes.json"; // database-issues#9092: anyhow should not be used. #[allow(clippy::disallowed_macros)] +#[allow(clippy::disallowed_types)] fn main() -> anyhow::Result<()> { println!("cargo:rerun-if-changed={PROTO_DIRECTORY}"); diff --git a/src/catalog/src/config.rs b/src/catalog/src/config.rs index d9cd31bca1a81..619598411d072 100644 --- a/src/catalog/src/config.rs +++ b/src/catalog/src/config.rs @@ -110,6 +110,7 @@ pub struct ClusterReplicaSizeMap(pub BTreeMap); impl ClusterReplicaSizeMap { // database-issues#9092: anyhow should not be used. #[allow(clippy::disallowed_macros)] + #[allow(clippy::disallowed_types)] pub fn parse_from_str(s: &str, credit_consumption_from_memory: bool) -> anyhow::Result { let mut cluster_replica_sizes: BTreeMap = serde_json::from_str(s)?; diff --git a/src/interchange/src/avro.rs b/src/interchange/src/avro.rs index 42cd68f9b4449..62415f0a79139 100644 --- a/src/interchange/src/avro.rs +++ b/src/interchange/src/avro.rs @@ -37,6 +37,8 @@ mod tests { use super::*; #[mz_ore::test] + // database-issues#9092: anyhow should not be used. + #[allow(clippy::disallowed_types)] fn record_without_fields() -> anyhow::Result<()> { let schema = r#"{ "type": "record", @@ -51,6 +53,8 @@ mod tests { } #[mz_ore::test] + // database-issues#9092: anyhow should not be used. + #[allow(clippy::disallowed_types)] fn basic_record() -> anyhow::Result<()> { let schema = r#"{ "type": "record", @@ -71,14 +75,17 @@ mod tests { Ok(()) } - #[mz_ore::test] - #[cfg_attr(miri, ignore)] // unsupported operation: can't call foreign function `decNumberFromInt32` on OS `linux` /// Test that primitive Avro Schema types are allow Datums to be correctly /// serialized into Avro Values. /// /// Complete list of primitive types in test, also found in this /// documentation: /// https://avro.apache.org/docs/current/spec.html#schemas + #[mz_ore::test] + // unsupported operation: can't call foreign function `decNumberFromInt32` on OS `linux` + #[cfg_attr(miri, ignore)] + // database-issues#9092: anyhow should not be used. + #[allow(clippy::disallowed_types)] fn test_diff_pair_to_avro_primitive_types() -> anyhow::Result<()> { use numeric::Numeric; // Data to be used later in assertions. diff --git a/src/interchange/src/avro/decode.rs b/src/interchange/src/avro/decode.rs index ed4cebe41f3cf..239b96ea531e5 100644 --- a/src/interchange/src/avro/decode.rs +++ b/src/interchange/src/avro/decode.rs @@ -74,6 +74,8 @@ impl Decoder { /// The provided schema is called the "reader schema", which is the schema /// that we are expecting to use to decode records. The records may indicate /// that they are encoded with a different schema; as long as those. + // database-issues#9092: anyhow should not be used. + #[allow(clippy::disallowed_types)] pub fn new( reader_schema: &str, ccsr_client: Option, diff --git a/src/interchange/src/avro/schema.rs b/src/interchange/src/avro/schema.rs index 2d4462e312c10..7a67b92d440ed 100644 --- a/src/interchange/src/avro/schema.rs +++ b/src/interchange/src/avro/schema.rs @@ -55,6 +55,8 @@ use tracing::warn; use crate::avro::is_null; +// database-issues#9092: anyhow should not be used. +#[allow(clippy::disallowed_types)] pub fn parse_schema(schema: &str) -> anyhow::Result { let schema = serde_json::from_str(schema)?; Ok(Schema::parse(&schema)?) @@ -72,6 +74,8 @@ pub fn schema_to_relationdesc(schema: Schema) -> Result anyhow::Result> { let mut columns = vec![]; let mut seen_avro_nodes = Default::default(); @@ -96,6 +100,7 @@ fn validate_schema_1(schema: SchemaNode) -> anyhow::Result( seen_avro_nodes: &mut BTreeSet, schema: SchemaNode<'a>, @@ -166,6 +171,8 @@ fn get_union_columns<'a>( Ok(columns) } +// database-issues#9092: anyhow should not be used. +#[allow(clippy::disallowed_types)] fn get_named_columns<'a>( seen_avro_nodes: &mut BTreeSet, schema: SchemaNode<'a>, @@ -189,6 +196,7 @@ fn get_named_columns<'a>( /// (because it is an Essential Union in the sense described in the module docs). // database-issues#9092: anyhow should not be used. #[allow(clippy::disallowed_macros)] +#[allow(clippy::disallowed_types)] fn validate_schema_2( seen_avro_nodes: &mut BTreeSet, schema: SchemaNode, @@ -306,6 +314,8 @@ pub struct ConfluentAvroResolver { } impl ConfluentAvroResolver { + // database-issues#9092: anyhow should not be used. + #[allow(clippy::disallowed_types)] pub fn new( reader_schema: &str, ccsr_client: Option, @@ -320,6 +330,8 @@ impl ConfluentAvroResolver { }) } + // database-issues#9092: anyhow should not be used. + #[allow(clippy::disallowed_types)] pub async fn resolve<'a, 'b>( &'a mut self, mut bytes: &'b [u8], @@ -404,6 +416,8 @@ impl SchemaCache { /// that this schema cache was initialized with, returns the schema directly. /// If not, performs schema resolution on the reader and writer and /// returns the result. + // database-issues#9092: anyhow should not be used. + #[allow(clippy::disallowed_types)] async fn get( &mut self, id: i32, diff --git a/src/interchange/src/confluent.rs b/src/interchange/src/confluent.rs index 1523c362e9452..e98b4397f07d1 100644 --- a/src/interchange/src/confluent.rs +++ b/src/interchange/src/confluent.rs @@ -7,7 +7,7 @@ // the Business Source License, use of this software will be governed // by the Apache License, Version 2.0. -use anyhow::{bail, Result}; +use anyhow::bail; use byteorder::{BigEndian, ByteOrder}; /// Extracts the schema_id placed in front of the serialized message by the confluent stack @@ -16,7 +16,8 @@ use byteorder::{BigEndian, ByteOrder}; /// This function returns the schema_id and a subslice of the rest of the buffer // database-issues#9092: anyhow should not be used. #[allow(clippy::disallowed_macros)] -fn extract_schema_id<'buf>(buf: &'buf [u8], protocol: &str) -> Result<(i32, &'buf [u8])> { +#[allow(clippy::disallowed_types)] +fn extract_schema_id<'buf>(buf: &'buf [u8], protocol: &str) -> anyhow::Result<(i32, &'buf [u8])> { // The first byte is a magic byte (0) that indicates the Confluent // serialization format version, and the next four bytes are a big // endian 32-bit schema ID. @@ -50,13 +51,16 @@ fn extract_schema_id<'buf>(buf: &'buf [u8], protocol: &str) -> Result<(i32, &'bu Ok((schema_id, &buf[expected_len..])) } -pub fn extract_avro_header(buf: &[u8]) -> Result<(i32, &[u8])> { +// database-issues#9092: anyhow should not be used. +#[allow(clippy::disallowed_types)] +pub fn extract_avro_header(buf: &[u8]) -> anyhow::Result<(i32, &[u8])> { extract_schema_id(buf, "avro") } // database-issues#9092: anyhow should not be used. #[allow(clippy::disallowed_macros)] -pub fn extract_protobuf_header(buf: &[u8]) -> Result<(i32, &[u8])> { +#[allow(clippy::disallowed_types)] +pub fn extract_protobuf_header(buf: &[u8]) -> anyhow::Result<(i32, &[u8])> { let (schema_id, buf) = extract_schema_id(buf, "protobuf")?; match buf.get(0) { diff --git a/src/kafka-util/src/admin.rs b/src/kafka-util/src/admin.rs index 624f2ac55a398..c0e57da74a702 100644 --- a/src/kafka-util/src/admin.rs +++ b/src/kafka-util/src/admin.rs @@ -32,6 +32,7 @@ use tracing::{info, warn}; /// should "fail open" if the configs are not available. // database-issues#9092: anyhow should not be used. #[allow(clippy::disallowed_macros)] +#[allow(clippy::disallowed_types)] pub async fn get_topic_config<'a, C>( client: &'a AdminClient, admin_opts: &AdminOptions, @@ -62,6 +63,7 @@ where /// should "fail open" if the configs are not available. // database-issues#9092: anyhow should not be used. #[allow(clippy::disallowed_macros)] +#[allow(clippy::disallowed_types)] pub async fn alter_topic_config<'a, C>( client: &'a AdminClient, admin_opts: &AdminOptions, @@ -112,6 +114,8 @@ pub enum EnsureTopicConfig { /// /// Materialize may not have permission to alter configs for the topic, so callers of this method /// should "fail open" if the configs are not available. +// database-issues#9092: anyhow should not be used. +#[allow(clippy::disallowed_types)] pub async fn ensure_topic_config<'a, C>( client: &'a AdminClient, admin_opts: &AdminOptions, @@ -203,6 +207,7 @@ where /// Returns a boolean indicating whether the topic already existed. // database-issues#9092: anyhow should not be used. #[allow(clippy::disallowed_macros)] +#[allow(clippy::disallowed_types)] pub async fn ensure_topic<'a, C>( client: &'a AdminClient, admin_opts: &AdminOptions, diff --git a/src/kafka-util/src/bin/kgen.rs b/src/kafka-util/src/bin/kgen.rs index 1ec02a0fd6fee..7796c63e8c707 100644 --- a/src/kafka-util/src/bin/kgen.rs +++ b/src/kafka-util/src/bin/kgen.rs @@ -590,6 +590,7 @@ struct Args { #[tokio::main] // database-issues#9092: anyhow should not be used. #[allow(clippy::disallowed_macros)] +#[allow(clippy::disallowed_types)] async fn main() -> anyhow::Result<()> { let args: Args = cli::parse_args(CliConfig::default()); diff --git a/src/license-keys/src/lib.rs b/src/license-keys/src/lib.rs index d78d2d0476b3e..8ec76cbb3897b 100644 --- a/src/license-keys/src/lib.rs +++ b/src/license-keys/src/lib.rs @@ -81,6 +81,7 @@ impl Default for ValidatedLicenseKey { // database-issues#9092: anyhow should not be used. #[allow(clippy::disallowed_macros)] +#[allow(clippy::disallowed_types)] pub fn validate(license_key: &str, environment_id: &str) -> anyhow::Result { let mut err = anyhow!("no public key found"); for pubkey in PUBLIC_KEYS { @@ -97,6 +98,8 @@ pub fn validate(license_key: &str, environment_id: &str) -> anyhow::Result e, }; + // database-issues#9092: anyhow should not be used. + #[allow(clippy::disallowed_types)] let previous_versions: Vec anyhow::Result>> = vec![ // add to this if/when we add new versions // for example, @@ -148,6 +153,7 @@ struct Payload { // database-issues#9092: anyhow should not be used. #[allow(clippy::disallowed_macros)] +#[allow(clippy::disallowed_types)] fn validate_with_pubkey_v1( license_key: &str, pubkey_pem: &str, diff --git a/src/mz-debug/src/kubectl_port_forwarder.rs b/src/mz-debug/src/kubectl_port_forwarder.rs index 6f1cc3ec1f39f..821ca6019929e 100644 --- a/src/mz-debug/src/kubectl_port_forwarder.rs +++ b/src/mz-debug/src/kubectl_port_forwarder.rs @@ -15,7 +15,6 @@ //! Port forwards k8s service via Kubectl -use anyhow::Result; use k8s_openapi::api::core::v1::Service; use kube::api::ListParams; use kube::{Api, Client}; @@ -122,10 +121,11 @@ impl KubectlPortForwarder { // database-issues#9092: anyhow should not be used. #[allow(clippy::disallowed_macros)] +#[allow(clippy::disallowed_types)] pub async fn create_kubectl_port_forwarder( client: &Client, args: &SelfManagedDebugMode, -) -> Result { +) -> anyhow::Result { for namespace in &args.k8s_namespaces { let services: Api = Api::namespaced(client.clone(), namespace); let services = services diff --git a/src/mz-debug/src/system_catalog_dumper.rs b/src/mz-debug/src/system_catalog_dumper.rs index c752ba51bec3d..baf36a68c6b5a 100644 --- a/src/mz-debug/src/system_catalog_dumper.rs +++ b/src/mz-debug/src/system_catalog_dumper.rs @@ -18,7 +18,7 @@ //! connection are run in serial anyways. Running the queries in serial also makes //! cleaning up / aborting queries much easier. -use anyhow::{Context as _, Result}; +use anyhow::Context as _; use chrono::{DateTime, Utc}; use csv_async::AsyncSerializer; use futures::TryStreamExt; @@ -481,14 +481,17 @@ pub struct SystemCatalogDumper<'n> { pg_client: Arc>, pg_tls: MakeTlsConnector, cluster_replicas: Vec, - _pg_conn_handle: JoinHandle>, + // database-issues#9092: anyhow should not be used. + #[allow(clippy::disallowed_types)] + _pg_conn_handle: JoinHandle>, } // database-issues#9092: anyhow should not be used. #[allow(clippy::disallowed_macros)] +#[allow(clippy::disallowed_types)] pub async fn create_postgres_connection( connection_string: &str, -) -> Result< +) -> anyhow::Result< ( PgClient, Connection>, @@ -515,12 +518,14 @@ pub async fn create_postgres_connection( Ok((pg_client, pg_conn, tls)) } +// database-issues#9092: anyhow should not be used. +#[allow(clippy::disallowed_types)] pub async fn write_copy_stream( transaction: &Transaction<'_>, copy_query: &str, file: &mut tokio::fs::File, relation_name: &str, -) -> Result<(), anyhow::Error> { +) -> anyhow::Result<(), anyhow::Error> { let copy_stream = transaction .copy_out(copy_query) .await @@ -535,12 +540,14 @@ pub async fn write_copy_stream( Ok::<(), anyhow::Error>(()) } +// database-issues#9092: anyhow should not be used. +#[allow(clippy::disallowed_types)] pub async fn copy_relation_to_csv( transaction: &Transaction<'_>, file_path_name: PathBuf, column_names: &Vec, relation: &Relation, -) -> Result<(), anyhow::Error> { +) -> anyhow::Result<(), anyhow::Error> { let mut file = tokio::fs::File::create(&file_path_name).await?; match relation.category { @@ -591,10 +598,12 @@ pub async fn copy_relation_to_csv( Ok::<(), anyhow::Error>(()) } +// database-issues#9092: anyhow should not be used. +#[allow(clippy::disallowed_types)] pub async fn query_column_names( pg_client: &PgClient, relation: &Relation, -) -> Result, anyhow::Error> { +) -> anyhow::Result, anyhow::Error> { let relation_name = relation.name; // We query the column names to write the header row of the CSV file. let mut column_names = pg_client @@ -619,13 +628,15 @@ pub async fn query_column_names( Ok(column_names) } +// database-issues#9092: anyhow should not be used. +#[allow(clippy::disallowed_types)] pub async fn query_relation( transaction: &Transaction<'_>, start_time: DateTime, relation: &Relation, column_names: &Vec, cluster_replica: Option<&ClusterReplica>, -) -> Result<(), anyhow::Error> { +) -> anyhow::Result<(), anyhow::Error> { let relation_name = relation.name; let relation_category = &relation.category; @@ -687,7 +698,12 @@ pub async fn query_relation( } impl<'n> SystemCatalogDumper<'n> { - pub async fn new(context: &'n Context, connection_string: &str) -> Result { + // database-issues#9092: anyhow should not be used. + #[allow(clippy::disallowed_types)] + pub async fn new( + context: &'n Context, + connection_string: &str, + ) -> anyhow::Result { let (pg_client, pg_conn, pg_tls) = create_postgres_connection(connection_string).await?; info!("Connected to PostgreSQL server at {}...", connection_string); @@ -734,11 +750,13 @@ impl<'n> SystemCatalogDumper<'n> { }) } + // database-issues#9092: anyhow should not be used. + #[allow(clippy::disallowed_types)] pub async fn dump_relation( &self, relation: &Relation, cluster_replica: Option<&ClusterReplica>, - ) -> Result<(), anyhow::Error> { + ) -> anyhow::Result<(), anyhow::Error> { info!( "Copying relation {}{}{}", relation.name, diff --git a/src/persist-client/src/cli/admin.rs b/src/persist-client/src/cli/admin.rs index 31b56f0da5784..02219db18258d 100644 --- a/src/persist-client/src/cli/admin.rs +++ b/src/persist-client/src/cli/admin.rs @@ -534,6 +534,8 @@ where } } +// database-issues#9092: anyhow should not be used. +#[allow(clippy::disallowed_types)] async fn make_machine( cfg: &PersistConfig, consensus: Arc, @@ -557,6 +559,7 @@ async fn make_machine( // database-issues#9092: anyhow should not be used. #[allow(clippy::disallowed_macros)] +#[allow(clippy::disallowed_types)] async fn make_typed_machine( cfg: &PersistConfig, consensus: Arc, @@ -639,6 +642,8 @@ where Ok(machine) } +// database-issues#9092: anyhow should not be used. +#[allow(clippy::disallowed_types)] async fn force_gc( cfg: PersistConfig, metrics_registry: &MetricsRegistry, diff --git a/src/persist-client/src/cli/args.rs b/src/persist-client/src/cli/args.rs index 8057cee1d7fda..dd93cf6c6ffc8 100644 --- a/src/persist-client/src/cli/args.rs +++ b/src/persist-client/src/cli/args.rs @@ -120,6 +120,8 @@ impl StateArgs { } } +// database-issues#9092: anyhow should not be used. +#[allow(clippy::disallowed_types)] pub(super) async fn make_consensus( cfg: &PersistConfig, consensus_uri: &SensitiveUrl, @@ -142,6 +144,8 @@ pub(super) async fn make_consensus( Ok(consensus) } +// database-issues#9092: anyhow should not be used. +#[allow(clippy::disallowed_types)] pub(super) async fn make_blob( cfg: &PersistConfig, blob_uri: &SensitiveUrl, diff --git a/src/persist-client/src/cli/inspect.rs b/src/persist-client/src/cli/inspect.rs index 0ee4db742a0f8..cfd08942d2324 100644 --- a/src/persist-client/src/cli/inspect.rs +++ b/src/persist-client/src/cli/inspect.rs @@ -486,6 +486,8 @@ pub async fn blob_counts(blob_uri: &SensitiveUrl) -> Result anyhow::Result<()> { let cfg = PersistConfig::new_default_configs(&READ_ALL_BUILD_INFO, SYSTEM_TIME.clone()); let metrics = Arc::new(Metrics::new(&cfg, &MetricsRegistry::new())); diff --git a/src/persist-client/src/internal/compact.rs b/src/persist-client/src/internal/compact.rs index 2f713981ac28a..9964a64a0c686 100644 --- a/src/persist-client/src/internal/compact.rs +++ b/src/persist-client/src/internal/compact.rs @@ -693,6 +693,8 @@ where /// b1 runs=[C] output=[A, C, D, B, E, F] /// b2 runs=[D, E, F] /// ``` + // database-issues#9092: anyhow should not be used. + #[allow(clippy::disallowed_types)] async fn order_runs<'a>( req: &'a CompactReq, target_order: RunOrder, diff --git a/src/persist-client/src/internal/machine.rs b/src/persist-client/src/internal/machine.rs index 5c2dd5a527b31..77ce5726cb9ce 100644 --- a/src/persist-client/src/internal/machine.rs +++ b/src/persist-client/src/internal/machine.rs @@ -2352,6 +2352,8 @@ pub mod datadriven { Ok(format!("{} ok\n", datadriven.machine.seqno())) } + // database-issues#9092: anyhow should not be used. + #[allow(clippy::disallowed_types)] pub(crate) async fn finalize( datadriven: &mut MachineState, _args: DirectiveArgs<'_>, @@ -2361,6 +2363,8 @@ pub mod datadriven { Ok(format!("{} ok\n", datadriven.machine.seqno())) } + // database-issues#9092: anyhow should not be used. + #[allow(clippy::disallowed_types)] pub(crate) fn is_finalized( datadriven: &MachineState, _args: DirectiveArgs<'_>, diff --git a/src/persist-client/src/internal/restore.rs b/src/persist-client/src/internal/restore.rs index e17e9f894f788..562f15dfb1a10 100644 --- a/src/persist-client/src/internal/restore.rs +++ b/src/persist-client/src/internal/restore.rs @@ -25,6 +25,7 @@ use tracing::info; /// Returns a list of blobs that were not possible to restore. // database-issues#9092: anyhow should not be used. #[allow(clippy::disallowed_macros)] +#[allow(clippy::disallowed_types)] pub(crate) async fn restore_blob( versions: &StateVersions, blob: &dyn Blob, diff --git a/src/persist-client/src/internal/state.rs b/src/persist-client/src/internal/state.rs index d1db90aed7e01..1ef83f055d9bc 100644 --- a/src/persist-client/src/internal/state.rs +++ b/src/persist-client/src/internal/state.rs @@ -208,6 +208,8 @@ pub enum BatchPart { }, } +// database-issues#9092: anyhow should not be used. +#[allow(clippy::disallowed_types)] fn decode_structured_lower(lower: &LazyProto) -> Option { let try_decode = |lower: &LazyProto| { let proto = lower.decode()?; diff --git a/src/persist-client/src/iter.rs b/src/persist-client/src/iter.rs index ffd1ee5bc9069..06273a40350ad 100644 --- a/src/persist-client/src/iter.rs +++ b/src/persist-client/src/iter.rs @@ -197,6 +197,7 @@ type FetchResult = Result, HollowRun>; impl FetchData { // database-issues#9092: anyhow should not be used. #[allow(clippy::disallowed_macros)] + #[allow(clippy::disallowed_types)] async fn fetch( self, shard_id: ShardId, @@ -257,6 +258,8 @@ impl PartIndices { } #[derive(Debug)] +// database-issues#9092: anyhow should not be used. +#[allow(clippy::disallowed_types)] enum ConsolidationPart { Queued { data: FetchData, @@ -517,6 +520,7 @@ where /// Returns success when we've successfully fetched enough parts to be able to make progress. // database-issues#9092: anyhow should not be used. #[allow(clippy::disallowed_macros)] + #[allow(clippy::disallowed_types)] async fn unblock_progress(&mut self) -> anyhow::Result<()> { if self.runs.is_empty() { return Ok(()); @@ -634,6 +638,8 @@ where /// consolidated chunk of output. If this method returns `None`, that all the data has been /// exhausted and the full consolidated dataset has been returned. #[allow(unused)] + // database-issues#9092: anyhow should not be used. + #[allow(clippy::disallowed_types)] pub(crate) async fn next( &mut self, ) -> anyhow::Result, T, D)>>> { @@ -673,6 +679,8 @@ where /// Wait until data is available, then return an iterator over the next /// consolidated chunk of output. If this method returns `None`, that all the data has been /// exhausted and the full consolidated dataset has been returned. + // database-issues#9092: anyhow should not be used. + #[allow(clippy::disallowed_types)] pub(crate) async fn next_chunk( &mut self, max_len: usize, diff --git a/src/persist-types/src/columnar.rs b/src/persist-types/src/columnar.rs index a5e6de19ce24b..952ac27c4a54d 100644 --- a/src/persist-types/src/columnar.rs +++ b/src/persist-types/src/columnar.rs @@ -146,6 +146,8 @@ pub trait Schema: Debug + Send + Sync { /// This obtains the dsta type by encoding an empty array and checking its type. /// The caller is generally expected to make sure that all columns generated by /// this schema have the same datatype. +// database-issues#9092: anyhow should not be used. +#[allow(clippy::disallowed_types)] pub fn data_type(schema: &A::Schema) -> anyhow::Result { let array = schema.encoder()?.finish(); Ok(Array::data_type(&array).clone()) @@ -154,6 +156,7 @@ pub fn data_type(schema: &A::Schema) -> anyhow::Result { /// Helper to convert from codec-encoded data to structured data. // database-issues#9092: anyhow should not be used. #[allow(clippy::disallowed_macros)] +#[allow(clippy::disallowed_types)] pub fn codec_to_schema( schema: &A::Schema, data: &BinaryArray, @@ -181,6 +184,8 @@ pub fn codec_to_schema( } /// Helper to convert from structured data to codec-encoded data. +// database-issues#9092: anyhow should not be used. +#[allow(clippy::disallowed_types)] pub fn schema_to_codec( schema: &A::Schema, data: &dyn Array, diff --git a/src/persist-types/src/part.rs b/src/persist-types/src/part.rs index 58e1c2f6eb84c..c4174b841eae3 100644 --- a/src/persist-types/src/part.rs +++ b/src/persist-types/src/part.rs @@ -47,6 +47,8 @@ impl Part { + self.diff.values().to_byte_slice().len() } + // database-issues#9092: anyhow should not be used. + #[allow(clippy::disallowed_types)] fn combine( parts: &[Part], mut combine_fn: impl FnMut(&[&dyn Array]) -> anyhow::Result, @@ -68,6 +70,8 @@ impl Part { } /// Executes [::arrow::compute::concat] columnwise, or returns `None` if no parts are given. + // database-issues#9092: anyhow should not be used. + #[allow(clippy::disallowed_types)] pub fn concat(parts: &[Part]) -> anyhow::Result> { match parts.len() { 0 => return Ok(None), @@ -79,6 +83,8 @@ impl Part { } /// Executes [::arrow::compute::interleave] columnwise. + // database-issues#9092: anyhow should not be used. + #[allow(clippy::disallowed_types)] pub fn interleave(parts: &[Part], indices: &[(usize, usize)]) -> anyhow::Result { Part::combine(parts, |cols| { ::arrow::compute::interleave(cols, indices).err_into() @@ -86,6 +92,8 @@ impl Part { } /// Iterate over the contents of this part, decoding as we go. + // database-issues#9092: anyhow should not be used. + #[allow(clippy::disallowed_types)] pub fn decode_iter< 'a, K: Default + Clone + 'static, diff --git a/src/persist/src/indexed/columnar/arrow.rs b/src/persist/src/indexed/columnar/arrow.rs index 1cd4e9e7a2123..4e4de7281b776 100644 --- a/src/persist/src/indexed/columnar/arrow.rs +++ b/src/persist/src/indexed/columnar/arrow.rs @@ -170,6 +170,7 @@ fn realloc_buffer(buffer: &Buffer, metrics: &ColumnarMetrics) -> Buffer { /// Converts an [`arrow`] [RecordBatch] into a [BlobTraceUpdates] and reallocate the backing data. // database-issues#9092: anyhow should not be used. #[allow(clippy::disallowed_macros)] +#[allow(clippy::disallowed_types)] pub fn decode_arrow_batch( batch: &RecordBatch, metrics: &ColumnarMetrics, diff --git a/src/persist/src/indexed/encoding.rs b/src/persist/src/indexed/encoding.rs index 75a775e7907be..48f482d82abd0 100644 --- a/src/persist/src/indexed/encoding.rs +++ b/src/persist/src/indexed/encoding.rs @@ -405,6 +405,7 @@ impl BlobTraceUpdates { /// [`Codec`] data, re-encoding structured data if necessary. // database-issues#9092: anyhow should not be used. #[allow(clippy::disallowed_macros)] + #[allow(clippy::disallowed_types)] pub fn concat( mut updates: Vec, key_schema: &K::Schema, diff --git a/src/pgtest/src/lib.rs b/src/pgtest/src/lib.rs index ae41264f25f02..673004429686f 100644 --- a/src/pgtest/src/lib.rs +++ b/src/pgtest/src/lib.rs @@ -114,6 +114,7 @@ struct PgConn { impl PgConn { // database-issues#9092: anyhow should not be used. #[allow(clippy::disallowed_macros)] + #[allow(clippy::disallowed_types)] fn new<'a>( addr: &str, user: &'a str, @@ -143,14 +144,17 @@ impl PgConn { // database-issues#9092: anyhow should not be used. #[allow(clippy::disallowed_macros)] + #[allow(clippy::disallowed_types)] fn send(&mut self, f: F) -> anyhow::Result<()> { self.send_buf.clear(); f(&mut self.send_buf); self.stream.write_all(&self.send_buf)?; Ok(()) } + // database-issues#9092: anyhow should not be used. #[allow(clippy::disallowed_macros)] + #[allow(clippy::disallowed_types)] fn until( &mut self, until: Vec<&str>, @@ -331,6 +335,7 @@ impl PgConn { /// An error is returned if a new message is not received within the timeout. // database-issues#9092: anyhow should not be used. #[allow(clippy::disallowed_macros)] + #[allow(clippy::disallowed_types)] pub fn recv(&mut self) -> anyhow::Result<(char, Message)> { let mut buf = [0; 1024]; let until = Instant::now(); @@ -369,6 +374,8 @@ pub struct PgTest { } impl PgTest { + // database-issues#9092: anyhow should not be used. + #[allow(clippy::disallowed_types)] pub fn new(addr: String, user: String, timeout: Duration) -> anyhow::Result { let verbose = std::env::var_os("PGTEST_VERBOSE").is_some(); let conn = PgConn::new(&addr, &user, timeout.clone(), verbose, vec![])?; @@ -386,6 +393,8 @@ impl PgTest { // Returns the named connection. If this is the first time that connection is // seen, sends options. + // database-issues#9092: anyhow should not be used. + #[allow(clippy::disallowed_types)] fn get_conn( &mut self, name: Option, @@ -405,6 +414,8 @@ impl PgTest { Ok(self.conns.get_mut(&name).expect("must exist")) } + // database-issues#9092: anyhow should not be used. + #[allow(clippy::disallowed_types)] pub fn send( &mut self, conn: Option, @@ -415,6 +426,8 @@ impl PgTest { conn.send(f) } + // database-issues#9092: anyhow should not be used. + #[allow(clippy::disallowed_types)] pub fn until( &mut self, conn: Option, diff --git a/src/pgtz/build.rs b/src/pgtz/build.rs index 8528bcf51ecef..6726c79eba3ff 100644 --- a/src/pgtz/build.rs +++ b/src/pgtz/build.rs @@ -16,7 +16,7 @@ use std::path::PathBuf; use std::{env, fs}; -use anyhow::{bail, Context, Result}; +use anyhow::{bail, Context}; use chrono_tz::TZ_VARIANTS; use mz_ore_build::codegen::CodegenBuf; use uncased::UncasedStr; @@ -30,7 +30,8 @@ enum TimezoneAbbrevSpec<'a> { // database-issues#9092: anyhow should not be used. #[allow(clippy::disallowed_macros)] -fn main() -> Result<()> { +#[allow(clippy::disallowed_types)] +fn main() -> anyhow::Result<()> { let out_dir = PathBuf::from(env::var_os("OUT_DIR").context("Cannot read OUT_DIR env var")?); // Build protobufs. diff --git a/src/prof/src/jemalloc.rs b/src/prof/src/jemalloc.rs index c02c035325113..7d286d5ac64bc 100644 --- a/src/prof/src/jemalloc.rs +++ b/src/prof/src/jemalloc.rs @@ -43,11 +43,17 @@ pub struct JemallocStats { } pub trait JemallocProfCtlExt { + // database-issues#9092: anyhow should not be used. + #[allow(clippy::disallowed_types)] fn dump_stats(&mut self, json_format: bool) -> anyhow::Result; + // database-issues#9092: anyhow should not be used. + #[allow(clippy::disallowed_types)] fn stats(&self) -> anyhow::Result; } impl JemallocProfCtlExt for JemallocProfCtl { + // database-issues#9092: anyhow should not be used. + #[allow(clippy::disallowed_types)] fn dump_stats(&mut self, json_format: bool) -> anyhow::Result { // Try to avoid allocations within `stats_print` let mut buf = Vec::with_capacity(1 << 22); @@ -57,12 +63,16 @@ impl JemallocProfCtlExt for JemallocProfCtl { Ok(String::from_utf8(buf)?) } + // database-issues#9092: anyhow should not be used. + #[allow(clippy::disallowed_types)] fn stats(&self) -> anyhow::Result { JemallocStats::get() } } impl JemallocStats { + // database-issues#9092: anyhow should not be used. + #[allow(clippy::disallowed_types)] pub fn get() -> anyhow::Result { epoch::advance()?; Ok(JemallocStats { @@ -125,6 +135,8 @@ impl JemallocMetrics { }); } + // database-issues#9092: anyhow should not be used. + #[allow(clippy::disallowed_types)] fn update(&self) -> anyhow::Result<()> { let s = JemallocStats::get()?; self.active.set(u64::cast_from(s.active)); diff --git a/src/prof/src/time.rs b/src/prof/src/time.rs index 1fd03a215e322..e8f7273e58481 100644 --- a/src/prof/src/time.rs +++ b/src/prof/src/time.rs @@ -26,6 +26,7 @@ use tokio::time::{self, Duration}; /// In particular, jemalloc memory profiling must be off. // database-issues#9092: anyhow should not be used. #[allow(clippy::disallowed_macros)] +#[allow(clippy::disallowed_types)] pub async unsafe fn prof_time( total_time: Duration, sample_freq: u32, diff --git a/src/proto/src/lib.rs b/src/proto/src/lib.rs index dd9f04af6eb23..51d856abe5bd2 100644 --- a/src/proto/src/lib.rs +++ b/src/proto/src/lib.rs @@ -658,6 +658,8 @@ where /// Blanket command for testing if `R` can be converted to its corresponding /// `ProtoType` and back. +// database-issues#9092: anyhow should not be used. +#[allow(clippy::disallowed_types)] pub fn protobuf_roundtrip(val: &R) -> anyhow::Result where P: ProtoType + ::prost::Message + Default, diff --git a/src/s3-datagen/src/main.rs b/src/s3-datagen/src/main.rs index 8e60bce3ff191..aecc7d5c9b219 100644 --- a/src/s3-datagen/src/main.rs +++ b/src/s3-datagen/src/main.rs @@ -69,6 +69,8 @@ async fn main() { } } +// database-issues#9092: anyhow should not be used. +#[allow(clippy::disallowed_types)] async fn run() -> anyhow::Result<()> { let args: Args = cli::parse_args(CliConfig::default()); diff --git a/src/sql-lexer/build.rs b/src/sql-lexer/build.rs index 35f4c60af52b1..4c32235f99a9e 100644 --- a/src/sql-lexer/build.rs +++ b/src/sql-lexer/build.rs @@ -16,7 +16,7 @@ use std::path::PathBuf; use std::{env, fs}; -use anyhow::{bail, Context, Result}; +use anyhow::{bail, Context}; use mz_ore_build::codegen::CodegenBuf; use uncased::UncasedStr; @@ -24,7 +24,8 @@ const KEYWORDS_LIST: &str = "src/keywords.txt"; // database-issues#9092: anyhow should not be used. #[allow(clippy::disallowed_macros)] -fn main() -> Result<()> { +#[allow(clippy::disallowed_types)] +fn main() -> anyhow::Result<()> { println!("cargo:rerun-if-changed={KEYWORDS_LIST}"); let out_dir = PathBuf::from(env::var_os("OUT_DIR").context("Cannot read OUT_DIR env var")?); diff --git a/src/sql-parser/build.rs b/src/sql-parser/build.rs index 67ecc8df3540b..d99e72c8ecf1d 100644 --- a/src/sql-parser/build.rs +++ b/src/sql-parser/build.rs @@ -16,11 +16,13 @@ use std::path::PathBuf; use std::{env, fs}; -use anyhow::{Context, Result}; +use anyhow::Context; const AST_DEFS_MOD: &str = "src/ast/defs.rs"; -fn main() -> Result<()> { +// database-issues#9092: anyhow should not be used. +#[allow(clippy::disallowed_types)] +fn main() -> anyhow::Result<()> { let out_dir = PathBuf::from(env::var_os("OUT_DIR").context("Cannot read OUT_DIR env var")?); let ir = mz_walkabout::load(AST_DEFS_MOD)?; diff --git a/src/sql/src/plan/statement/ddl.rs b/src/sql/src/plan/statement/ddl.rs index 98683711f753e..597615312b4b9 100644 --- a/src/sql/src/plan/statement/ddl.rs +++ b/src/sql/src/plan/statement/ddl.rs @@ -3230,6 +3230,8 @@ pub fn plan_create_sink( /// logic is reused by both CREATE SINK and ALTER SINK planning. It is the responsibility of the /// callers (plan_create_sink and plan_alter_sink) to check for name collisions if this is /// important. +// database-issues#9092: anyhow should not be used. +#[allow(clippy::disallowed_types)] fn plan_sink( scx: &StatementContext, mut stmt: CreateSinkStatement, diff --git a/src/ssh-util/src/keys.rs b/src/ssh-util/src/keys.rs index a3361485c729b..fe8b609d3ce43 100644 --- a/src/ssh-util/src/keys.rs +++ b/src/ssh-util/src/keys.rs @@ -49,12 +49,16 @@ impl SshKeyPair { /// Deserializes a key pair from a key pair set that was serialized with /// [`SshKeyPairSet::serialize`]. + // database-issues#9092: anyhow should not be used. + #[allow(clippy::disallowed_types)] pub fn from_bytes(data: &[u8]) -> anyhow::Result { let set = SshKeyPairSet::from_bytes(data)?; Ok(set.primary().clone()) } /// Deserializes a key pair from an OpenSSH-formatted private key. + // database-issues#9092: anyhow should not be used. + #[allow(clippy::disallowed_types)] fn from_private_key(private_key: &[u8]) -> Result { let private_key = PrivateKey::from_openssh(private_key)?; @@ -243,6 +247,8 @@ impl SshKeyPairSet { /// Deserializes a key pair set that was serialized with /// [`SshKeyPairSet::serialize`]. + // database-issues#9092: anyhow should not be used. + #[allow(clippy::disallowed_types)] pub fn from_bytes(data: &[u8]) -> anyhow::Result { Ok(serde_json::from_slice(data)?) } @@ -259,6 +265,8 @@ mod tests { use super::{SshKeyPair, SshKeyPairSet}; #[mz_ore::test] + // database-issues#9092: anyhow should not be used. + #[allow(clippy::disallowed_types)] fn test_key_pair_generation() -> anyhow::Result<()> { for _ in 0..100 { let key_pair = SshKeyPair::new()?; @@ -276,6 +284,8 @@ mod tests { } #[mz_ore::test] + // database-issues#9092: anyhow should not be used. + #[allow(clippy::disallowed_types)] fn test_unique_keys() -> anyhow::Result<()> { for _ in 0..100 { let key_set = SshKeyPairSet::new()?; @@ -285,6 +295,8 @@ mod tests { } #[mz_ore::test] + // database-issues#9092: anyhow should not be used. + #[allow(clippy::disallowed_types)] fn test_key_pair_serialization_roundtrip() -> anyhow::Result<()> { for _ in 0..100 { let key_pair = SshKeyPair::new()?; @@ -298,6 +310,8 @@ mod tests { } #[mz_ore::test] + // database-issues#9092: anyhow should not be used. + #[allow(clippy::disallowed_types)] fn test_key_set_serialization_roundtrip() -> anyhow::Result<()> { for _ in 0..100 { let key_set = SshKeyPairSet::new()?; @@ -309,6 +323,8 @@ mod tests { } #[mz_ore::test] + // database-issues#9092: anyhow should not be used. + #[allow(clippy::disallowed_types)] fn test_key_rotation() -> anyhow::Result<()> { for _ in 0..100 { let key_set = SshKeyPairSet::new()?; @@ -323,6 +339,8 @@ mod tests { /// Ensure the new code can read legacy generated Keypairs #[mz_ore::test] + // database-issues#9092: anyhow should not be used. + #[allow(clippy::disallowed_types)] fn test_deserializing_legacy_key_pairs() -> anyhow::Result<()> { for _ in 0..100 { let legacy_key_pair = LegacySshKeyPair::new()?; @@ -341,6 +359,8 @@ mod tests { /// Ensure the legacy code can read newly generated Keypairs, e.g. if we have to rollback #[mz_ore::test] + // database-issues#9092: anyhow should not be used. + #[allow(clippy::disallowed_types)] fn test_serializing_legacy_key_pairs() -> anyhow::Result<()> { for _ in 0..100 { let key_pair = SshKeyPair::new()?; @@ -358,6 +378,8 @@ mod tests { /// Ensure the new code can read legacy generated Keysets #[mz_ore::test] + // database-issues#9092: anyhow should not be used. + #[allow(clippy::disallowed_types)] fn test_deserializing_legacy_key_sets() -> anyhow::Result<()> { for _ in 0..100 { let legacy_key_pair = LegacySshKeyPairSet::new()?; @@ -384,6 +406,8 @@ mod tests { /// Ensure the legacy code can read newly generated Keysets, e.g. if we have to rollback #[mz_ore::test] + // database-issues#9092: anyhow should not be used. + #[allow(clippy::disallowed_types)] fn test_serializing_legacy_key_sets() -> anyhow::Result<()> { for _ in 0..100 { let key_pair = SshKeyPairSet::new()?; diff --git a/src/storage-types/src/connections/string_or_secret.rs b/src/storage-types/src/connections/string_or_secret.rs index 58f7391481dd2..72e4ce1dfced2 100644 --- a/src/storage-types/src/connections/string_or_secret.rs +++ b/src/storage-types/src/connections/string_or_secret.rs @@ -31,6 +31,8 @@ pub enum StringOrSecret { impl StringOrSecret { /// Gets the value as a string, reading the secret if necessary. + // database-issues#9092: anyhow should not be used. + #[allow(clippy::disallowed_types)] pub async fn get_string( &self, in_task: InTask, diff --git a/src/storage-types/src/sources/envelope.rs b/src/storage-types/src/sources/envelope.rs index bfc9a5803bdec..4c0bc2932d673 100644 --- a/src/storage-types/src/sources/envelope.rs +++ b/src/storage-types/src/sources/envelope.rs @@ -204,6 +204,7 @@ impl RustType for UpsertStyle { /// has a column with no name. // database-issues#9092: anyhow should not be used. #[allow(clippy::disallowed_macros)] +#[allow(clippy::disallowed_types)] fn match_key_indices( key_desc: &RelationDesc, value_desc: &RelationDesc, @@ -265,6 +266,7 @@ impl UnplannedSourceEnvelope { /// value relation desc // database-issues#9092: anyhow should not be used. #[allow(clippy::disallowed_macros)] + #[allow(clippy::disallowed_types)] pub fn desc( self, key_desc: Option, diff --git a/src/storage/src/sink/kafka.rs b/src/storage/src/sink/kafka.rs index 795be9b282f4c..001c1f1d48e20 100644 --- a/src/storage/src/sink/kafka.rs +++ b/src/storage/src/sink/kafka.rs @@ -629,6 +629,7 @@ struct KafkaHeader { /// Updates are sent in ascending timestamp order. // database-issues#9092: anyhow should not be used. #[allow(clippy::disallowed_macros)] +#[allow(clippy::disallowed_types)] fn sink_collection>( name: String, input: &Collection, @@ -1081,6 +1082,7 @@ async fn determine_sink_progress( // database-issues#9092: anyhow should not be used. #[allow(clippy::disallowed_macros)] +#[allow(clippy::disallowed_types)] fn progress_search( progress_client_read_committed: &BaseConsumer, progress_record_fetch_timeout: Duration, diff --git a/src/storage/src/source/reclock/compat.rs b/src/storage/src/source/reclock/compat.rs index e1a0f08fff41c..77c9a6d61a7e1 100644 --- a/src/storage/src/source/reclock/compat.rs +++ b/src/storage/src/source/reclock/compat.rs @@ -67,6 +67,7 @@ where { // database-issues#9092: anyhow should not be used. #[allow(clippy::disallowed_macros)] + #[allow(clippy::disallowed_types)] pub async fn new( persist_clients: Arc, read_only_rx: watch::Receiver, diff --git a/src/testdrive/src/action/kafka/verify_data.rs b/src/testdrive/src/action/kafka/verify_data.rs index e94de830f2ad1..64153282e1ed7 100644 --- a/src/testdrive/src/action/kafka/verify_data.rs +++ b/src/testdrive/src/action/kafka/verify_data.rs @@ -308,6 +308,8 @@ pub async fn run_verify_data( } /// Expect and split out `n` whitespace-delimited headers before the main contents of the 'expect' row. +// database-issues#9092: anyhow should not be used. +#[allow(clippy::disallowed_types)] fn split_headers(input: &str, n_headers: usize) -> anyhow::Result<(Vec, &str)> { let whitespace = Regex::new("\\s+").expect("building known-valid regex"); let mut parts = whitespace.splitn(input, n_headers + 1); diff --git a/src/walkabout/src/ir.rs b/src/walkabout/src/ir.rs index ca82f0b9d96c6..9f1876e90d648 100644 --- a/src/walkabout/src/ir.rs +++ b/src/walkabout/src/ir.rs @@ -12,7 +12,7 @@ use std::collections::{BTreeMap, BTreeSet}; use std::iter; -use anyhow::{bail, Result}; +use anyhow::bail; use itertools::Itertools; use quote::ToTokens; @@ -147,7 +147,8 @@ pub enum Type { /// variant, so we know how to visit it. See [`Type`] for details. // database-issues#9092: anyhow should not be used. #[allow(clippy::disallowed_macros)] -pub(crate) fn analyze(syn_items: &[syn::DeriveInput]) -> Result { +#[allow(clippy::disallowed_types)] +pub(crate) fn analyze(syn_items: &[syn::DeriveInput]) -> anyhow::Result { let mut items = BTreeMap::new(); for syn_item in syn_items { let name = syn_item.ident.to_string(); @@ -200,7 +201,8 @@ pub(crate) fn analyze(syn_items: &[syn::DeriveInput]) -> Result { // database-issues#9092: anyhow should not be used. #[allow(clippy::disallowed_macros)] -fn validate_fields<'a, I>(items: &BTreeMap, fields: I) -> Result<()> +#[allow(clippy::disallowed_types)] +fn validate_fields<'a, I>(items: &BTreeMap, fields: I) -> anyhow::Result<()> where I: IntoIterator, { @@ -218,7 +220,9 @@ where Ok(()) } -fn analyze_fields(fields: &syn::Fields) -> Result> { +// database-issues#9092: anyhow should not be used. +#[allow(clippy::disallowed_types)] +fn analyze_fields(fields: &syn::Fields) -> anyhow::Result> { fields .iter() .map(|f| { @@ -232,7 +236,8 @@ fn analyze_fields(fields: &syn::Fields) -> Result> { // database-issues#9092: anyhow should not be used. #[allow(clippy::disallowed_macros)] -fn analyze_generics(generics: &syn::Generics) -> Result> { +#[allow(clippy::disallowed_types)] +fn analyze_generics(generics: &syn::Generics) -> anyhow::Result> { let mut out = vec![]; for g in generics.params.iter() { match g { @@ -259,7 +264,8 @@ fn analyze_generics(generics: &syn::Generics) -> Result> { // database-issues#9092: anyhow should not be used. #[allow(clippy::disallowed_macros)] -fn analyze_generic_bounds<'a, I>(bounds: I) -> Result> +#[allow(clippy::disallowed_types)] +fn analyze_generic_bounds<'a, I>(bounds: I) -> anyhow::Result> where I: IntoIterator, { @@ -281,7 +287,8 @@ where // database-issues#9092: anyhow should not be used. #[allow(clippy::disallowed_macros)] -fn analyze_type(ty: &syn::Type) -> Result { +#[allow(clippy::disallowed_types)] +fn analyze_type(ty: &syn::Type) -> anyhow::Result { match ty { syn::Type::Path(syn::TypePath { qself: None, path }) => match path.segments.len() { 2 => { diff --git a/src/walkabout/src/lib.rs b/src/walkabout/src/lib.rs index 003cf7c117b2a..625971c06c5d0 100644 --- a/src/walkabout/src/lib.rs +++ b/src/walkabout/src/lib.rs @@ -34,8 +34,6 @@ use std::path::Path; -use anyhow::Result; - mod gen; mod parse; @@ -59,7 +57,9 @@ pub use gen::{gen_fold, gen_visit, gen_visit_mut}; /// Rust containers, like [`Option`] and [`Vec`]. It does, however, endeavor to /// produce understandable error messages when it encounters a type it does not /// know how to handle. -pub fn load

(path: P) -> Result +// database-issues#9092: anyhow should not be used. +#[allow(clippy::disallowed_types)] +pub fn load

(path: P) -> anyhow::Result where P: AsRef, { diff --git a/src/walkabout/src/parse.rs b/src/walkabout/src/parse.rs index b1f3f0e7a11f3..e6c979657e102 100644 --- a/src/walkabout/src/parse.rs +++ b/src/walkabout/src/parse.rs @@ -12,7 +12,7 @@ use std::fs; use std::path::Path; -use anyhow::{Context, Result}; +use anyhow::Context; use syn::{Data, DataEnum, DataStruct, DataUnion, DeriveInput, Item}; /// Parses the module at `path` and any contained submodules. @@ -20,7 +20,9 @@ use syn::{Data, DataEnum, DataStruct, DataUnion, DeriveInput, Item}; /// Returns [`DeriveInput`]s representing all struct and enum items in the /// module. This is exactly what a custom derive procedural macro would see, /// except that we can present information for all types simultaneously. -pub fn parse_mod

(path: P) -> Result> +// database-issues#9092: anyhow should not be used. +#[allow(clippy::disallowed_types)] +pub fn parse_mod

(path: P) -> anyhow::Result> where P: AsRef, { @@ -29,7 +31,9 @@ where Ok(out) } -fn collect_items

(path: P, out: &mut Vec) -> Result<()> +// database-issues#9092: anyhow should not be used. +#[allow(clippy::disallowed_types)] +fn collect_items

(path: P, out: &mut Vec) -> anyhow::Result<()> where P: AsRef, { diff --git a/test/test-util/src/mz_client.rs b/test/test-util/src/mz_client.rs index bb1f6e7d048dc..fe15b5f7d3636 100644 --- a/test/test-util/src/mz_client.rs +++ b/test/test-util/src/mz_client.rs @@ -7,7 +7,6 @@ // the Business Source License, use of this software will be governed // by the Apache License, Version 2.0. -use anyhow::Result; use tokio::time::{self, Duration}; use tokio_postgres::{error::SqlState, Client, Error, NoTls, Row}; use tracing::{debug, info}; @@ -16,7 +15,9 @@ use mz_ore::task; /// Create and return a new PostgreSQL client, spawning off the connection /// object along the way. -pub async fn client(host: &str, port: u16) -> Result { +// database-issues#9092: anyhow should not be used. +#[allow(clippy::disallowed_types)] +pub async fn client(host: &str, port: u16) -> anyhow::Result { let (mz_client, conn) = tokio_postgres::Config::new() .user("materialize") .host(host) @@ -37,7 +38,13 @@ pub async fn client(host: &str, port: u16) -> Result { /// Try running PostgresSQL's `query` function, checking for a common /// Materialize error in `check_error`. -pub async fn try_query(mz_client: &Client, query: &str, delay: Duration) -> Result> { +// database-issues#9092: anyhow should not be used. +#[allow(clippy::disallowed_types)] +pub async fn try_query( + mz_client: &Client, + query: &str, + delay: Duration, +) -> anyhow::Result> { loop { let timer = std::time::Instant::now(); match mz_client.query(&*query, &[]).await { @@ -50,7 +57,13 @@ pub async fn try_query(mz_client: &Client, query: &str, delay: Duration) -> Resu /// Try running PostgreSQL's `query_one` function, checking for a common /// Materialize error in `check_error`. -pub async fn try_query_one(mz_client: &Client, query: &str, delay: Duration) -> Result { +// database-issues#9092: anyhow should not be used. +#[allow(clippy::disallowed_types)] +pub async fn try_query_one( + mz_client: &Client, + query: &str, + delay: Duration, +) -> anyhow::Result { loop { let timer = std::time::Instant::now(); match mz_client.query_one(&*query, &[]).await { @@ -67,7 +80,9 @@ pub async fn try_query_one(mz_client: &Client, query: &str, delay: Duration) -> /// /// Since this error is likely transient, we should retry reading from the view /// instead of failing. -fn check_error(e: Error) -> Result<()> { +// database-issues#9092: anyhow should not be used. +#[allow(clippy::disallowed_types)] +fn check_error(e: Error) -> anyhow::Result<()> { if e.code() == Some(&SqlState::SQL_STATEMENT_NOT_YET_COMPLETE) { info!("Error querying, will try again... {}", e.to_string()); Ok(()) @@ -89,7 +104,9 @@ async fn delay_for(elapsed: Duration, delay: Duration) { } /// Run Materialize's `SHOW SOURCES` command -pub async fn show_sources(mz_client: &Client) -> Result> { +// database-issues#9092: anyhow should not be used. +#[allow(clippy::disallowed_types)] +pub async fn show_sources(mz_client: &Client) -> anyhow::Result> { let mut res = Vec::new(); for row in mz_client.query("SHOW SOURCES", &[]).await? { res.push(row.get(0)) @@ -99,7 +116,9 @@ pub async fn show_sources(mz_client: &Client) -> Result> { } /// Delete a source and all dependent views, if the source exists -pub async fn drop_source(mz_client: &Client, name: &str) -> Result<()> { +// database-issues#9092: anyhow should not be used. +#[allow(clippy::disallowed_types)] +pub async fn drop_source(mz_client: &Client, name: &str) -> anyhow::Result<()> { let q = format!("DROP SOURCE IF EXISTS {} CASCADE", name); debug!("deleting source=> {}", q); mz_client.execute(&*q, &[]).await?; @@ -107,7 +126,9 @@ pub async fn drop_source(mz_client: &Client, name: &str) -> Result<()> { } /// Delete a table and all dependent views, if the table exists -pub async fn drop_table(mz_client: &Client, name: &str) -> Result<()> { +// database-issues#9092: anyhow should not be used. +#[allow(clippy::disallowed_types)] +pub async fn drop_table(mz_client: &Client, name: &str) -> anyhow::Result<()> { let q = format!("DROP TABLE IF EXISTS {} CASCADE", name); debug!("deleting table=> {}", q); mz_client.execute(&*q, &[]).await?; @@ -115,7 +136,9 @@ pub async fn drop_table(mz_client: &Client, name: &str) -> Result<()> { } /// Delete an index -pub async fn drop_index(mz_client: &Client, name: &str) -> Result<()> { +// database-issues#9092: anyhow should not be used. +#[allow(clippy::disallowed_types)] +pub async fn drop_index(mz_client: &Client, name: &str) -> anyhow::Result<()> { let q = format!("DROP INDEX {}", name); debug!("deleting index=> {}", q); mz_client.execute(&*q, &[]).await?; @@ -123,7 +146,9 @@ pub async fn drop_index(mz_client: &Client, name: &str) -> Result<()> { } /// Run PostgreSQL's `execute` function -pub async fn execute(mz_client: &Client, query: &str) -> Result { +// database-issues#9092: anyhow should not be used. +#[allow(clippy::disallowed_types)] +pub async fn execute(mz_client: &Client, query: &str) -> anyhow::Result { debug!("exec=> {}", query); Ok(mz_client.execute(query, &[]).await?) }