Skip to content

Commit

Permalink
fix(rust-server): remove redundant clone (#16906)
Browse files Browse the repository at this point in the history
The generated example code would clone the context. However as context
is a generic type and is not declared to implement Clone, a clone of a
reference is just a copy of the reference and therefore unnecessary.
This change removes the redundant call and therefore avoids the `cargo
clippy` warning.
  • Loading branch information
nathanielc committed Oct 27, 2023
1 parent eb5b781 commit fbd0255
Show file tree
Hide file tree
Showing 9 changed files with 0 additions and 115 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@
{{/allParams}}
context: &C) -> Result<{{{operationId}}}Response, ApiError>
{
let context = context.clone();
info!("{{#vendorExtensions}}{{{x-operation-id}}}{{/vendorExtensions}}({{#allParams}}{{#vendorExtensions}}{{{x-format-string}}}{{/vendorExtensions}}{{^-last}}, {{/-last}}{{/allParams}}) - X-Span-ID: {:?}"{{#allParams}}, {{{paramName}}}{{/allParams}}, context.get().0.clone());
Err(ApiError("Generic failure".into()))
}
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,6 @@ impl<C> Api<C> for Server<C> where C: Has<XSpanIdString> + Send + Sync
optional_binary_field: Option<swagger::ByteArray>,
context: &C) -> Result<MultipartRelatedRequestPostResponse, ApiError>
{
let context = context.clone();
info!("multipart_related_request_post({:?}, {:?}, {:?}) - X-Span-ID: {:?}", required_binary_field, object_field, optional_binary_field, context.get().0.clone());
Err(ApiError("Generic failure".into()))
}
Expand All @@ -125,7 +124,6 @@ impl<C> Api<C> for Server<C> where C: Has<XSpanIdString> + Send + Sync
object_field: Option<models::MultipartRequestObjectField>,
context: &C) -> Result<MultipartRequestPostResponse, ApiError>
{
let context = context.clone();
info!("multipart_request_post(\"{}\", {:?}, {:?}, {:?}) - X-Span-ID: {:?}", string_field, binary_field, optional_string_field, object_field, context.get().0.clone());
Err(ApiError("Generic failure".into()))
}
Expand All @@ -136,7 +134,6 @@ impl<C> Api<C> for Server<C> where C: Has<XSpanIdString> + Send + Sync
binary2: Option<swagger::ByteArray>,
context: &C) -> Result<MultipleIdenticalMimeTypesPostResponse, ApiError>
{
let context = context.clone();
info!("multiple_identical_mime_types_post({:?}, {:?}) - X-Span-ID: {:?}", binary1, binary2, context.get().0.clone());
Err(ApiError("Generic failure".into()))
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,6 @@ impl<C> Api<C> for Server<C> where C: Has<XSpanIdString> + Send + Sync
op_get_request: models::OpGetRequest,
context: &C) -> Result<OpGetResponse, ApiError>
{
let context = context.clone();
info!("op_get({:?}) - X-Span-ID: {:?}", op_get_request, context.get().0.clone());
Err(ApiError("Generic failure".into()))
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,6 @@ impl<C> CallbackApi<C> for Server<C> where C: Has<XSpanIdString> + Send + Sync
information: Option<String>,
context: &C) -> Result<CallbackCallbackWithHeaderPostResponse, ApiError>
{
let context = context.clone();
info!("callback_callback_with_header_post({:?}) - X-Span-ID: {:?}", information, context.get().0.clone());
Err(ApiError("Generic failure".into()))
}
Expand All @@ -117,7 +116,6 @@ impl<C> CallbackApi<C> for Server<C> where C: Has<XSpanIdString> + Send + Sync
callback_request_query_url: String,
context: &C) -> Result<CallbackCallbackPostResponse, ApiError>
{
let context = context.clone();
info!("callback_callback_post() - X-Span-ID: {:?}", context.get().0.clone());
Err(ApiError("Generic failure".into()))
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,6 @@ impl<C> Api<C> for Server<C> where C: Has<XSpanIdString> + Send + Sync
any_of: Option<&Vec<models::AnyOfObject>>,
context: &C) -> Result<AnyOfGetResponse, ApiError>
{
let context = context.clone();
info!("any_of_get({:?}) - X-Span-ID: {:?}", any_of, context.get().0.clone());
Err(ApiError("Generic failure".into()))
}
Expand All @@ -143,7 +142,6 @@ impl<C> Api<C> for Server<C> where C: Has<XSpanIdString> + Send + Sync
url: String,
context: &C) -> Result<CallbackWithHeaderPostResponse, ApiError>
{
let context = context.clone();
info!("callback_with_header_post(\"{}\") - X-Span-ID: {:?}", url, context.get().0.clone());
Err(ApiError("Generic failure".into()))
}
Expand All @@ -153,7 +151,6 @@ impl<C> Api<C> for Server<C> where C: Has<XSpanIdString> + Send + Sync
list_of_strings: Option<&Vec<models::StringObject>>,
context: &C) -> Result<ComplexQueryParamGetResponse, ApiError>
{
let context = context.clone();
info!("complex_query_param_get({:?}) - X-Span-ID: {:?}", list_of_strings, context.get().0.clone());
Err(ApiError("Generic failure".into()))
}
Expand All @@ -163,7 +160,6 @@ impl<C> Api<C> for Server<C> where C: Has<XSpanIdString> + Send + Sync
path_param: models::StringEnum,
context: &C) -> Result<EnumInPathPathParamGetResponse, ApiError>
{
let context = context.clone();
info!("enum_in_path_path_param_get({:?}) - X-Span-ID: {:?}", path_param, context.get().0.clone());
Err(ApiError("Generic failure".into()))
}
Expand All @@ -173,7 +169,6 @@ impl<C> Api<C> for Server<C> where C: Has<XSpanIdString> + Send + Sync
list_of_strings: Option<&Vec<models::StringObject>>,
context: &C) -> Result<JsonComplexQueryParamGetResponse, ApiError>
{
let context = context.clone();
info!("json_complex_query_param_get({:?}) - X-Span-ID: {:?}", list_of_strings, context.get().0.clone());
Err(ApiError("Generic failure".into()))
}
Expand All @@ -183,7 +178,6 @@ impl<C> Api<C> for Server<C> where C: Has<XSpanIdString> + Send + Sync
x_header: String,
context: &C) -> Result<MandatoryRequestHeaderGetResponse, ApiError>
{
let context = context.clone();
info!("mandatory_request_header_get(\"{}\") - X-Span-ID: {:?}", x_header, context.get().0.clone());
Err(ApiError("Generic failure".into()))
}
Expand All @@ -192,7 +186,6 @@ impl<C> Api<C> for Server<C> where C: Has<XSpanIdString> + Send + Sync
&self,
context: &C) -> Result<MergePatchJsonGetResponse, ApiError>
{
let context = context.clone();
info!("merge_patch_json_get() - X-Span-ID: {:?}", context.get().0.clone());
Err(ApiError("Generic failure".into()))
}
Expand All @@ -202,7 +195,6 @@ impl<C> Api<C> for Server<C> where C: Has<XSpanIdString> + Send + Sync
&self,
context: &C) -> Result<MultigetGetResponse, ApiError>
{
let context = context.clone();
info!("multiget_get() - X-Span-ID: {:?}", context.get().0.clone());
Err(ApiError("Generic failure".into()))
}
Expand All @@ -211,7 +203,6 @@ impl<C> Api<C> for Server<C> where C: Has<XSpanIdString> + Send + Sync
&self,
context: &C) -> Result<MultipleAuthSchemeGetResponse, ApiError>
{
let context = context.clone();
info!("multiple_auth_scheme_get() - X-Span-ID: {:?}", context.get().0.clone());
Err(ApiError("Generic failure".into()))
}
Expand All @@ -220,7 +211,6 @@ impl<C> Api<C> for Server<C> where C: Has<XSpanIdString> + Send + Sync
&self,
context: &C) -> Result<OneOfGetResponse, ApiError>
{
let context = context.clone();
info!("one_of_get() - X-Span-ID: {:?}", context.get().0.clone());
Err(ApiError("Generic failure".into()))
}
Expand All @@ -229,7 +219,6 @@ impl<C> Api<C> for Server<C> where C: Has<XSpanIdString> + Send + Sync
&self,
context: &C) -> Result<OverrideServerGetResponse, ApiError>
{
let context = context.clone();
info!("override_server_get() - X-Span-ID: {:?}", context.get().0.clone());
Err(ApiError("Generic failure".into()))
}
Expand All @@ -242,7 +231,6 @@ impl<C> Api<C> for Server<C> where C: Has<XSpanIdString> + Send + Sync
some_list: Option<models::MyIdList>,
context: &C) -> Result<ParamgetGetResponse, ApiError>
{
let context = context.clone();
info!("paramget_get({:?}, {:?}, {:?}) - X-Span-ID: {:?}", uuid, some_object, some_list, context.get().0.clone());
Err(ApiError("Generic failure".into()))
}
Expand All @@ -251,7 +239,6 @@ impl<C> Api<C> for Server<C> where C: Has<XSpanIdString> + Send + Sync
&self,
context: &C) -> Result<ReadonlyAuthSchemeGetResponse, ApiError>
{
let context = context.clone();
info!("readonly_auth_scheme_get() - X-Span-ID: {:?}", context.get().0.clone());
Err(ApiError("Generic failure".into()))
}
Expand All @@ -261,7 +248,6 @@ impl<C> Api<C> for Server<C> where C: Has<XSpanIdString> + Send + Sync
url: String,
context: &C) -> Result<RegisterCallbackPostResponse, ApiError>
{
let context = context.clone();
info!("register_callback_post(\"{}\") - X-Span-ID: {:?}", url, context.get().0.clone());
Err(ApiError("Generic failure".into()))
}
Expand All @@ -271,7 +257,6 @@ impl<C> Api<C> for Server<C> where C: Has<XSpanIdString> + Send + Sync
body: swagger::ByteArray,
context: &C) -> Result<RequiredOctetStreamPutResponse, ApiError>
{
let context = context.clone();
info!("required_octet_stream_put({:?}) - X-Span-ID: {:?}", body, context.get().0.clone());
Err(ApiError("Generic failure".into()))
}
Expand All @@ -280,7 +265,6 @@ impl<C> Api<C> for Server<C> where C: Has<XSpanIdString> + Send + Sync
&self,
context: &C) -> Result<ResponsesWithHeadersGetResponse, ApiError>
{
let context = context.clone();
info!("responses_with_headers_get() - X-Span-ID: {:?}", context.get().0.clone());
Err(ApiError("Generic failure".into()))
}
Expand All @@ -289,7 +273,6 @@ impl<C> Api<C> for Server<C> where C: Has<XSpanIdString> + Send + Sync
&self,
context: &C) -> Result<Rfc7807GetResponse, ApiError>
{
let context = context.clone();
info!("rfc7807_get() - X-Span-ID: {:?}", context.get().0.clone());
Err(ApiError("Generic failure".into()))
}
Expand All @@ -299,7 +282,6 @@ impl<C> Api<C> for Server<C> where C: Has<XSpanIdString> + Send + Sync
object_untyped_props: Option<models::ObjectUntypedProps>,
context: &C) -> Result<UntypedPropertyGetResponse, ApiError>
{
let context = context.clone();
info!("untyped_property_get({:?}) - X-Span-ID: {:?}", object_untyped_props, context.get().0.clone());
Err(ApiError("Generic failure".into()))
}
Expand All @@ -308,7 +290,6 @@ impl<C> Api<C> for Server<C> where C: Has<XSpanIdString> + Send + Sync
&self,
context: &C) -> Result<UuidGetResponse, ApiError>
{
let context = context.clone();
info!("uuid_get() - X-Span-ID: {:?}", context.get().0.clone());
Err(ApiError("Generic failure".into()))
}
Expand All @@ -318,7 +299,6 @@ impl<C> Api<C> for Server<C> where C: Has<XSpanIdString> + Send + Sync
duplicate_xml_object: Option<models::DuplicateXmlObject>,
context: &C) -> Result<XmlExtraPostResponse, ApiError>
{
let context = context.clone();
info!("xml_extra_post({:?}) - X-Span-ID: {:?}", duplicate_xml_object, context.get().0.clone());
Err(ApiError("Generic failure".into()))
}
Expand All @@ -328,7 +308,6 @@ impl<C> Api<C> for Server<C> where C: Has<XSpanIdString> + Send + Sync
another_xml_object: Option<models::AnotherXmlObject>,
context: &C) -> Result<XmlOtherPostResponse, ApiError>
{
let context = context.clone();
info!("xml_other_post({:?}) - X-Span-ID: {:?}", another_xml_object, context.get().0.clone());
Err(ApiError("Generic failure".into()))
}
Expand All @@ -338,7 +317,6 @@ impl<C> Api<C> for Server<C> where C: Has<XSpanIdString> + Send + Sync
another_xml_array: Option<models::AnotherXmlArray>,
context: &C) -> Result<XmlOtherPutResponse, ApiError>
{
let context = context.clone();
info!("xml_other_put({:?}) - X-Span-ID: {:?}", another_xml_array, context.get().0.clone());
Err(ApiError("Generic failure".into()))
}
Expand All @@ -349,7 +327,6 @@ impl<C> Api<C> for Server<C> where C: Has<XSpanIdString> + Send + Sync
xml_array: Option<models::XmlArray>,
context: &C) -> Result<XmlPostResponse, ApiError>
{
let context = context.clone();
info!("xml_post({:?}) - X-Span-ID: {:?}", xml_array, context.get().0.clone());
Err(ApiError("Generic failure".into()))
}
Expand All @@ -359,7 +336,6 @@ impl<C> Api<C> for Server<C> where C: Has<XSpanIdString> + Send + Sync
xml_object: Option<models::XmlObject>,
context: &C) -> Result<XmlPutResponse, ApiError>
{
let context = context.clone();
info!("xml_put({:?}) - X-Span-ID: {:?}", xml_object, context.get().0.clone());
Err(ApiError("Generic failure".into()))
}
Expand All @@ -369,7 +345,6 @@ impl<C> Api<C> for Server<C> where C: Has<XSpanIdString> + Send + Sync
object_param: models::ObjectParam,
context: &C) -> Result<CreateRepoResponse, ApiError>
{
let context = context.clone();
info!("create_repo({:?}) - X-Span-ID: {:?}", object_param, context.get().0.clone());
Err(ApiError("Generic failure".into()))
}
Expand All @@ -379,7 +354,6 @@ impl<C> Api<C> for Server<C> where C: Has<XSpanIdString> + Send + Sync
repo_id: String,
context: &C) -> Result<GetRepoInfoResponse, ApiError>
{
let context = context.clone();
info!("get_repo_info(\"{}\") - X-Span-ID: {:?}", repo_id, context.get().0.clone());
Err(ApiError("Generic failure".into()))
}
Expand Down
Loading

0 comments on commit fbd0255

Please sign in to comment.