From 0c5295e4486a1d4e41b639957490f253a6ac67c7 Mon Sep 17 00:00:00 2001 From: Russell Cohen Date: Tue, 25 Apr 2023 11:24:15 -0400 Subject: [PATCH] Fix debug bound on 0.55.x (#2630) ## Motivation and Context - #2577 added a `Debug` bound on `ResolveEndpoint`, but this was a semver-incompatible change ## Description This removes that bound but re-adds a Debug implementation in areas that we need them ## Testing - CI - [ ] Backport this commit to main ---- _By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice._ --- .../generators/config/ServiceConfigGenerator.kt | 15 ++++++++++++++- rust-runtime/aws-smithy-http/src/endpoint.rs | 14 ++++++++++---- 2 files changed, 24 insertions(+), 5 deletions(-) diff --git a/codegen-client/src/main/kotlin/software/amazon/smithy/rust/codegen/client/smithy/generators/config/ServiceConfigGenerator.kt b/codegen-client/src/main/kotlin/software/amazon/smithy/rust/codegen/client/smithy/generators/config/ServiceConfigGenerator.kt index f6972f5e6a..bb0653f327 100644 --- a/codegen-client/src/main/kotlin/software/amazon/smithy/rust/codegen/client/smithy/generators/config/ServiceConfigGenerator.kt +++ b/codegen-client/src/main/kotlin/software/amazon/smithy/rust/codegen/client/smithy/generators/config/ServiceConfigGenerator.kt @@ -228,12 +228,25 @@ class ServiceConfigGenerator(private val customizations: List) -> std::fmt::Result { + let mut config = f.debug_struct("Builder"); + config.finish() + } + """, + ) + } + writer.rustBlock("impl Builder") { writer.docs("Constructs a config builder.") writer.rustTemplate("pub fn new() -> Self { Self::default() }") diff --git a/rust-runtime/aws-smithy-http/src/endpoint.rs b/rust-runtime/aws-smithy-http/src/endpoint.rs index d9d7844746..dcc1db18d7 100644 --- a/rust-runtime/aws-smithy-http/src/endpoint.rs +++ b/rust-runtime/aws-smithy-http/src/endpoint.rs @@ -9,7 +9,7 @@ use crate::endpoint::error::InvalidEndpointError; use crate::operation::error::BuildError; use http::uri::{Authority, Uri}; use std::borrow::Cow; -use std::fmt::Debug; +use std::fmt::{Debug, Formatter}; use std::result::Result as StdResult; use std::str::FromStr; use std::sync::Arc; @@ -23,7 +23,7 @@ pub use error::ResolveEndpointError; pub type Result = std::result::Result; /// Implementors of this trait can resolve an endpoint that will be applied to a request. -pub trait ResolveEndpoint: Debug + Send + Sync { +pub trait ResolveEndpoint: Send + Sync { /// Given some endpoint parameters, resolve an endpoint or return an error when resolution is /// impossible. fn resolve_endpoint(&self, params: &Params) -> Result; @@ -38,9 +38,15 @@ impl ResolveEndpoint for &'static str { } /// Endpoint Resolver wrapper that may be shared -#[derive(Clone, Debug)] +#[derive(Clone)] pub struct SharedEndpointResolver(Arc>); +impl Debug for SharedEndpointResolver { + fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result { + f.debug_struct("SharedEndpointResolver").finish() + } +} + impl SharedEndpointResolver { /// Create a new `SharedEndpointResolver` from `ResolveEndpoint` pub fn new(resolve_endpoint: impl ResolveEndpoint + 'static) -> Self { @@ -60,7 +66,7 @@ impl From>> for SharedEndpointResolver { } } -impl ResolveEndpoint for SharedEndpointResolver { +impl ResolveEndpoint for SharedEndpointResolver { fn resolve_endpoint(&self, params: &T) -> Result { self.0.resolve_endpoint(params) }