Skip to content

Commit 0c5295e

Browse files
authored
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._
1 parent 616cd77 commit 0c5295e

File tree

2 files changed

+24
-5
lines changed

2 files changed

+24
-5
lines changed

codegen-client/src/main/kotlin/software/amazon/smithy/rust/codegen/client/smithy/generators/config/ServiceConfigGenerator.kt

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -228,12 +228,25 @@ class ServiceConfigGenerator(private val customizations: List<ConfigCustomizatio
228228
}
229229

230230
writer.docs("Builder for creating a `Config`.")
231-
writer.raw("#[derive(Clone, Debug, Default)]")
231+
writer.raw("#[derive(Clone, Default)]")
232232
writer.rustBlock("pub struct Builder") {
233233
customizations.forEach {
234234
it.section(ServiceConfig.BuilderStruct)(this)
235235
}
236236
}
237+
238+
// Custom implementation for Debug so we don't need to enforce Debug down the chain
239+
writer.rustBlock("impl std::fmt::Debug for Builder") {
240+
writer.rustTemplate(
241+
"""
242+
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
243+
let mut config = f.debug_struct("Builder");
244+
config.finish()
245+
}
246+
""",
247+
)
248+
}
249+
237250
writer.rustBlock("impl Builder") {
238251
writer.docs("Constructs a config builder.")
239252
writer.rustTemplate("pub fn new() -> Self { Self::default() }")

rust-runtime/aws-smithy-http/src/endpoint.rs

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ use crate::endpoint::error::InvalidEndpointError;
99
use crate::operation::error::BuildError;
1010
use http::uri::{Authority, Uri};
1111
use std::borrow::Cow;
12-
use std::fmt::Debug;
12+
use std::fmt::{Debug, Formatter};
1313
use std::result::Result as StdResult;
1414
use std::str::FromStr;
1515
use std::sync::Arc;
@@ -23,7 +23,7 @@ pub use error::ResolveEndpointError;
2323
pub type Result = std::result::Result<aws_smithy_types::endpoint::Endpoint, ResolveEndpointError>;
2424

2525
/// Implementors of this trait can resolve an endpoint that will be applied to a request.
26-
pub trait ResolveEndpoint<Params>: Debug + Send + Sync {
26+
pub trait ResolveEndpoint<Params>: Send + Sync {
2727
/// Given some endpoint parameters, resolve an endpoint or return an error when resolution is
2828
/// impossible.
2929
fn resolve_endpoint(&self, params: &Params) -> Result;
@@ -38,9 +38,15 @@ impl<T> ResolveEndpoint<T> for &'static str {
3838
}
3939

4040
/// Endpoint Resolver wrapper that may be shared
41-
#[derive(Clone, Debug)]
41+
#[derive(Clone)]
4242
pub struct SharedEndpointResolver<T>(Arc<dyn ResolveEndpoint<T>>);
4343

44+
impl<T> Debug for SharedEndpointResolver<T> {
45+
fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result {
46+
f.debug_struct("SharedEndpointResolver").finish()
47+
}
48+
}
49+
4450
impl<T> SharedEndpointResolver<T> {
4551
/// Create a new `SharedEndpointResolver` from `ResolveEndpoint`
4652
pub fn new(resolve_endpoint: impl ResolveEndpoint<T> + 'static) -> Self {
@@ -60,7 +66,7 @@ impl<T> From<Arc<dyn ResolveEndpoint<T>>> for SharedEndpointResolver<T> {
6066
}
6167
}
6268

63-
impl<T: Debug> ResolveEndpoint<T> for SharedEndpointResolver<T> {
69+
impl<T> ResolveEndpoint<T> for SharedEndpointResolver<T> {
6470
fn resolve_endpoint(&self, params: &T) -> Result {
6571
self.0.resolve_endpoint(params)
6672
}

0 commit comments

Comments
 (0)