Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Squash warnings on main #535

Merged
merged 11 commits into from
Dec 9, 2021
5 changes: 4 additions & 1 deletion .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ on:
push:

env:
RUSTFLAGS: --deny warnings --allow unused_attributes
RUSTFLAGS: -Dwarnings
CARGO_INCREMENTAL: 0

jobs:
Expand All @@ -29,6 +29,9 @@ jobs:
- name: cargo clippy sdk
run: cargo clippy --all

- name: cargo doc sdk
run: cargo doc --all

- name: cargo fmt services
run: |
./eng/scripts/check_json_format.sh
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/services-all-features.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ on:
workflow_dispatch:

env:
RUSTFLAGS: --deny warnings --allow unused_attributes --allow unreachable-code --allow unused-assignments
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This workflow fails with this change. I'm going to revert it in my upcoming PR. I created #553 for removing the warnings from generated services.

RUSTFLAGS: -Dwarnings
CARGO_INCREMENTAL: 0

jobs:
Expand Down
4 changes: 2 additions & 2 deletions sdk/core/src/incompletevector.rs
Original file line number Diff line number Diff line change
Expand Up @@ -48,15 +48,15 @@ mod test {
let v = vec![0, 1, 2, 3, 4, 5];
let ic = IncompleteVector::new(None, v);

assert_eq!(ic.is_complete(), true);
assert!(ic.is_complete());
}

#[test]
fn test_incomplete_vector_incomplete() {
let v = vec![0, 1, 2, 3, 4, 5];
let ic = IncompleteVector::new(Some("aaa".into()), v);

assert_eq!(ic.is_complete(), false);
assert!(!ic.is_complete());
}

#[test]
Expand Down
14 changes: 1 addition & 13 deletions sdk/core/src/options.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ use std::time::Duration;
/// .retry(RetryOptions::default().max_retries(10u32))
/// .telemetry(TelemetryOptions::default().application_id("my-application"));
/// ```
#[derive(Clone, Debug)]
#[derive(Clone, Debug, Default)]
pub struct ClientOptions {
// TODO: Expose transport override.
/// Policies called per call.
Expand All @@ -34,18 +34,6 @@ pub struct ClientOptions {
pub(crate) transport: TransportOptions,
}

impl Default for ClientOptions {
fn default() -> Self {
Self {
per_call_policies: Vec::new(),
per_retry_policies: Vec::new(),
retry: RetryOptions::default(),
telemetry: TelemetryOptions::default(),
transport: TransportOptions::default(),
}
}
}

impl ClientOptions {
pub fn new() -> Self {
Self::default()
Expand Down
2 changes: 1 addition & 1 deletion sdk/core/src/pipeline.rs
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ use std::sync::Arc;
/// A pipeline is immutable. In other words a policy can either succeed and call the following
/// policy of fail and return to the calling policy. Arbitrary policy "skip" must be avoided (but
/// cannot be enforced by code). All policies except Transport policy can assume there is another following policy (so
/// self.pipeline[0] is always valid).
/// `self.pipeline[0]` is always valid).
///
/// The `C` generic contains the pipeline-specific context. Different crates can pass
/// different contexts using this generic. This way each crate can have its own specific pipeline
Expand Down
1 change: 1 addition & 0 deletions sdk/core/src/policies/mock_transport_player_policy.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ use std::sync::Arc;

#[derive(Debug, Clone)]
pub struct MockTransportPlayerPolicy {
#[allow(unused)]
pub(crate) transport_options: TransportOptions,
transaction: MockTransaction,
}
Expand Down
1 change: 1 addition & 0 deletions sdk/core/src/policies/transport.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ use std::sync::Arc;

#[derive(Debug, Clone)]
pub struct TransportPolicy {
#[allow(unused)]
pub(crate) transport_options: TransportOptions,
}

Expand Down
20 changes: 4 additions & 16 deletions sdk/cosmos/src/clients/collection_client.rs
Original file line number Diff line number Diff line change
Expand Up @@ -53,10 +53,7 @@ impl CollectionClient {

let response = self
.pipeline()
.send(
&mut ctx.clone().insert(ResourceType::Collections),
&mut request,
)
.send(ctx.clone().insert(ResourceType::Collections), &mut request)
.await?;

Ok(GetCollectionResponse::try_from(response).await?)
Expand All @@ -74,10 +71,7 @@ impl CollectionClient {

let response = self
.pipeline()
.send(
&mut ctx.clone().insert(ResourceType::Collections),
&mut request,
)
.send(ctx.clone().insert(ResourceType::Collections), &mut request)
.await?;

Ok(DeleteCollectionResponse::try_from(response).await?)
Expand All @@ -95,10 +89,7 @@ impl CollectionClient {

let response = self
.pipeline()
.send(
&mut ctx.clone().insert(ResourceType::Collections),
&mut request,
)
.send(ctx.clone().insert(ResourceType::Collections), &mut request)
.await?;

Ok(ReplaceCollectionResponse::try_from(response).await?)
Expand All @@ -121,10 +112,7 @@ impl CollectionClient {
options.decorate_request(&mut request, document)?;
let response = self
.pipeline()
.send(
&mut ctx.clone().insert(ResourceType::Documents),
&mut request,
)
.send(ctx.clone().insert(ResourceType::Documents), &mut request)
.await?;

Ok(CreateDocumentResponse::try_from(response).await?)
Expand Down
26 changes: 5 additions & 21 deletions sdk/cosmos/src/clients/cosmos_client.rs
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ pub struct CosmosClient {
}

/// Options for specifying how a Cosmos client will behave
#[derive(Debug, Clone)]
#[derive(Debug, Clone, Default)]
pub struct CosmosOptions {
options: ClientOptions,
}
Expand All @@ -55,14 +55,6 @@ impl CosmosOptions {
}
}

impl Default for CosmosOptions {
fn default() -> Self {
Self {
options: Default::default(),
}
}
}

/// Create a Pipeline from CosmosOptions
fn new_pipeline_from_options(
options: CosmosOptions,
Expand Down Expand Up @@ -188,10 +180,7 @@ impl CosmosClient {
options.decorate_request(&mut request, database_name.as_ref())?;
let response = self
.pipeline()
.send(
&mut ctx.clone().insert(ResourceType::Databases),
&mut request,
)
.send(ctx.clone().insert(ResourceType::Databases), &mut request)
.await?;

Ok(CreateDatabaseResponse::try_from(response).await?)
Expand Down Expand Up @@ -233,10 +222,7 @@ impl CosmosClient {
r#try!(options.decorate_request(&mut request).await);
let response = r#try!(
this.pipeline()
.send(
&mut ctx.clone().insert(ResourceType::Databases),
&mut request
)
.send(ctx.clone().insert(ResourceType::Databases), &mut request)
.await
);

Expand All @@ -250,10 +236,7 @@ impl CosmosClient {
r#try!(continuation.add_as_header2(&mut request));
let response = r#try!(
this.pipeline()
.send(
&mut ctx.clone().insert(ResourceType::Databases),
&mut request
)
.send(ctx.clone().insert(ResourceType::Databases), &mut request)
.await
);
ListDatabasesResponse::try_from(response).await
Expand Down Expand Up @@ -353,6 +336,7 @@ impl CosmosClient {
///
/// All variants require the cosmos account name. `Custom` also requires a valid
/// base URL (e.g. https://custom.documents.azure.com)
#[allow(unused)]
#[derive(Debug, Clone)]
enum CloudLocation {
/// Azure public cloud
Expand Down
29 changes: 7 additions & 22 deletions sdk/cosmos/src/clients/database_client.rs
Original file line number Diff line number Diff line change
Expand Up @@ -69,10 +69,7 @@ impl DatabaseClient {
options.decorate_request(&mut request)?;
let response = self
.pipeline()
.send(
&mut ctx.clone().insert(ResourceType::Databases),
&mut request,
)
.send(ctx.clone().insert(ResourceType::Databases), &mut request)
.await?;

Ok(GetDatabaseResponse::try_from(response).await?)
Expand All @@ -92,10 +89,7 @@ impl DatabaseClient {
options.decorate_request(&mut request)?;
let response = self
.pipeline()
.send(
&mut ctx.clone().insert(ResourceType::Databases),
&mut request,
)
.send(ctx.clone().insert(ResourceType::Databases), &mut request)
.await?;

Ok(DeleteDatabaseResponse::try_from(response).await?)
Expand All @@ -122,10 +116,7 @@ impl DatabaseClient {
r#try!(options.decorate_request(&mut request));
let response = r#try!(
this.pipeline()
.send(
&mut ctx.clone().insert(ResourceType::Collections),
&mut request
)
.send(ctx.clone().insert(ResourceType::Collections), &mut request)
.await
);
ListCollectionsResponse::try_from(response).await
Expand All @@ -141,10 +132,7 @@ impl DatabaseClient {
r#try!(continuation.add_as_header2(&mut request));
let response = r#try!(
this.pipeline()
.send(
&mut ctx.clone().insert(ResourceType::Collections),
&mut request
)
.send(ctx.clone().insert(ResourceType::Collections), &mut request)
.await
);
ListCollectionsResponse::try_from(response).await
Expand Down Expand Up @@ -180,10 +168,7 @@ impl DatabaseClient {
options.decorate_request(&mut request, collection_name.as_ref())?;
let response = self
.pipeline()
.send(
&mut ctx.clone().insert(ResourceType::Collections),
&mut request,
)
.send(ctx.clone().insert(ResourceType::Collections), &mut request)
.await?;

Ok(CreateCollectionResponse::try_from(response).await?)
Expand All @@ -210,7 +195,7 @@ impl DatabaseClient {
r#try!(options.decorate_request(&mut request));
let response = r#try!(
this.pipeline()
.send(&mut ctx.clone().insert(ResourceType::Users), &mut request)
.send(ctx.clone().insert(ResourceType::Users), &mut request)
.await
);
ListUsersResponse::try_from(response).await
Expand All @@ -226,7 +211,7 @@ impl DatabaseClient {
r#try!(continuation.add_as_header2(&mut request));
let response = r#try!(
this.pipeline()
.send(&mut ctx.clone().insert(ResourceType::Users), &mut request)
.send(ctx.clone().insert(ResourceType::Users), &mut request)
.await
);
ListUsersResponse::try_from(response).await
Expand Down
15 changes: 3 additions & 12 deletions sdk/cosmos/src/clients/document_client.rs
Original file line number Diff line number Diff line change
Expand Up @@ -74,10 +74,7 @@ impl DocumentClient {
let response = self
.cosmos_client()
.pipeline()
.send(
&mut ctx.clone().insert(ResourceType::Documents),
&mut request,
)
.send(ctx.clone().insert(ResourceType::Documents), &mut request)
.await?;

GetDocumentResponse::try_from(response).await
Expand All @@ -97,10 +94,7 @@ impl DocumentClient {
let response = self
.cosmos_client()
.pipeline()
.send(
&mut ctx.clone().insert(ResourceType::Documents),
&mut request,
)
.send(ctx.clone().insert(ResourceType::Documents), &mut request)
.await?;

ReplaceDocumentResponse::try_from(response).await
Expand All @@ -119,10 +113,7 @@ impl DocumentClient {
let response = self
.cosmos_client()
.pipeline()
.send(
&mut ctx.clone().insert(ResourceType::Documents),
&mut request,
)
.send(ctx.clone().insert(ResourceType::Documents), &mut request)
.await?;

DeleteDocumentResponse::try_from(response).await
Expand Down
20 changes: 4 additions & 16 deletions sdk/cosmos/src/clients/permission_client.rs
Original file line number Diff line number Diff line change
Expand Up @@ -63,10 +63,7 @@ impl PermissionClient {

let response = self
.pipeline()
.send(
&mut ctx.clone().insert(ResourceType::Permissions),
&mut request,
)
.send(ctx.clone().insert(ResourceType::Permissions), &mut request)
.await?;

Ok(PermissionResponse::try_from(response).await?)
Expand All @@ -85,10 +82,7 @@ impl PermissionClient {

let response = self
.pipeline()
.send(
&mut ctx.clone().insert(ResourceType::Permissions),
&mut request,
)
.send(ctx.clone().insert(ResourceType::Permissions), &mut request)
.await?;

Ok(PermissionResponse::try_from(response).await?)
Expand All @@ -106,10 +100,7 @@ impl PermissionClient {

let response = self
.pipeline()
.send(
&mut ctx.clone().insert(ResourceType::Permissions),
&mut request,
)
.send(ctx.clone().insert(ResourceType::Permissions), &mut request)
.await?;

Ok(PermissionResponse::try_from(response).await?)
Expand All @@ -127,10 +118,7 @@ impl PermissionClient {

let response = self
.pipeline()
.send(
&mut ctx.clone().insert(ResourceType::Permissions),
&mut request,
)
.send(ctx.clone().insert(ResourceType::Permissions), &mut request)
.await?;

Ok(DeletePermissionResponse::try_from(response).await?)
Expand Down
Loading