Deny clippy::large_futures and fix +nightly lint (#1895)

* Deny clippy::large_futures and fix +nightly lint

* Fix test errors

* Add clippy to cspell dictionary
This commit is contained in:
Heath Stewart 2024-11-05 15:39:31 -08:00 коммит произвёл GitHub
Родитель 2b536c6ed6
Коммит 0cede91bc7
Не найден ключ, соответствующий данной подписи
Идентификатор ключа GPG: B5690EEEBB952194
16 изменённых файлов: 36 добавлений и 47 удалений

5
.vscode/cspell.json поставляемый
Просмотреть файл

@ -24,7 +24,8 @@
"asyncoperation",
"azsdk",
"azurecli",
"Contoso",
"clippy",
"contoso",
"cplusplus",
"datalake",
"datetime",
@ -40,7 +41,7 @@
"iothub",
"keyvault",
"msrc",
"Newtonsoft",
"newtonsoft",
"oidc",
"pageable",
"pkce",

Просмотреть файл

@ -105,4 +105,5 @@ tz-rs = { version = "0.6" }
url = "2.2"
uuid = { version = "1.0", features = ["v4"] }
[workspace.lints]
[workspace.lints.clippy]
large_futures = "deny"

Просмотреть файл

@ -116,7 +116,7 @@ impl<'de> Visitor<'de> for RequestVisitor {
}
}
impl<'a> Serialize for RequestSerializer<'a> {
impl Serialize for RequestSerializer<'_> {
fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
where
S: Serializer,

Просмотреть файл

@ -9,6 +9,7 @@ use crate::{
};
/// Tries to create an HMAC SHA256 signature from the given `data` and `key`.
///
/// The `key` is expected to be a base64 encoded string and will be decoded
/// before using it for signing. The returned signature is also base64 encoded.
///

Просмотреть файл

@ -27,15 +27,15 @@ impl<'a> Fe2o3ClaimsBasedSecurity<'a> {
}
}
impl<'a> Fe2o3ClaimsBasedSecurity<'a> {}
impl Fe2o3ClaimsBasedSecurity<'_> {}
impl<'a> Drop for Fe2o3ClaimsBasedSecurity<'a> {
impl Drop for Fe2o3ClaimsBasedSecurity<'_> {
fn drop(&mut self) {
debug!("Dropping Fe2o3ClaimsBasedSecurity.");
}
}
impl<'a> AmqpClaimsBasedSecurityApis for Fe2o3ClaimsBasedSecurity<'a> {
impl AmqpClaimsBasedSecurityApis for Fe2o3ClaimsBasedSecurity<'_> {
async fn attach(&self) -> Result<()> {
let session = self.session.implementation.get()?;
let mut session = session.lock().await;

Просмотреть файл

@ -134,7 +134,7 @@ impl<'a> WithApplicationPropertiesRequest<'a> {
}
}
impl<'a> fe2o3_amqp_management::Request for WithApplicationPropertiesRequest<'a> {
impl fe2o3_amqp_management::Request for WithApplicationPropertiesRequest<'_> {
const OPERATION: &'static str = "READ";
type Response = ReadResponse;
type Body = ();

Просмотреть файл

@ -1054,7 +1054,8 @@ impl AmqpApplicationProperties {
}
}
/// An AMQP message
/// An AMQP message.
///
/// This is a simplified version of the AMQP message
/// that is used in the Azure SDK for Event Hubs
/// and is not a complete implementation of the AMQP message

Просмотреть файл

@ -54,14 +54,14 @@ pub async fn main() -> Result<(), Box<dyn Error>> {
.with_env_filter(tracing_subscriber::EnvFilter::from_default_env())
.init();
let mut args = ProgramArgs::parse();
let args = ProgramArgs::parse();
let Some(cmd) = args.subcommand else {
ProgramArgs::command().print_long_help()?;
return Ok(());
};
let client = create_client(&mut args.shared_args)?;
let client = create_client(&args.shared_args)?;
match cmd {
Subcommands::Create(cmd) => cmd.run(client).await,

Просмотреть файл

@ -6,30 +6,6 @@
// cspell: words amqp eventdata
#![doc = include_str!("../README.md")]
/// This module contains the implementation of the Azure Messaging Event Hubs SDK for Rust.
///
/// The SDK provides types and functions to interact with Azure Event Hubs, which is a highly scalable data streaming platform and event ingestion service.
/// It allows you to consume events from an Event Hub and create/send events to an Event Hub.
///
/// # Examples
///
/// Consuming events from an Event Hub:
///
/// ```no_run
/// # use azure_identity::{DefaultAzureCredential, TokenCredentialOptions};
/// # #[tokio::main]
/// # async fn main() -> Result<(), Box<dyn std::error::Error + 'static>> {
/// # let my_credentials = DefaultAzureCredential::new()?;
/// use azure_messaging_eventhubs::consumer::ConsumerClient;
/// use azure_messaging_eventhubs::models::EventData;
///
/// let consumer_client = ConsumerClient::new("fully_qualified_domain", "eventhub_name", None, my_credentials, None);
/// let partition_properties = consumer_client.get_partition_properties("0").await?;
/// # Ok(())
/// }
/// ```
///
pub(crate) mod common;
/// Types related to consuming events from an Event Hub.
@ -408,8 +384,8 @@ pub mod models {
}
/// Represents the data associated with an event received from an Event Hub.
/// This struct provides the event data, enqueued time, offset, sequence number, partition key, and system properties of the event.
///
/// This struct provides the event data, enqueued time, offset, sequence number, partition key, and system properties of the event.
pub struct ReceivedEventData {
message: AmqpMessage,
event_data: EventData,

Просмотреть файл

@ -9,7 +9,7 @@ use typespec_client_core::{fs::FileStreamBuilder, http::RequestContent};
#[tokio::main]
async fn main() -> Result<(), Box<dyn std::error::Error>> {
// Log traces to stdout.
let _log = tracing_subscriber::fmt()
tracing_subscriber::fmt()
.with_span_events(FmtSpan::ENTER | FmtSpan::EXIT)
.with_max_level(LevelFilter::DEBUG)
.init();

Просмотреть файл

@ -8,7 +8,7 @@ use tracing_subscriber::fmt::format::FmtSpan;
#[tokio::main]
async fn main() -> Result<(), Box<dyn std::error::Error>> {
// Log traces to stdout.
let _log = tracing_subscriber::fmt()
tracing_subscriber::fmt()
.with_span_events(FmtSpan::ENTER | FmtSpan::EXIT)
.with_max_level(LevelFilter::DEBUG)
.init();

Просмотреть файл

@ -123,7 +123,7 @@ impl<'a> Context<'a> {
}
}
impl<'a> Default for Context<'a> {
impl Default for Context<'_> {
fn default() -> Self {
Self::new()
}

Просмотреть файл

@ -25,7 +25,6 @@ pub enum Body {
/// A streaming body.
///
/// This is not currently supported on WASM targets.
// We cannot currently implement `Body::SeekableStream` for WASM
// because `reqwest::Body::wrap_stream()` is not implemented for WASM.
#[cfg(not(target_arch = "wasm32"))]

Просмотреть файл

@ -14,6 +14,7 @@ use std::{
};
/// Creates a future that resolves after a specified duration of time.
///
/// Uses a simple thread based implementation for sleep. A more efficient
/// implementation is available by using the `tokio_sleep` crate feature.
pub fn sleep(duration: Duration) -> Sleep {

Просмотреть файл

@ -1,10 +1,14 @@
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License.
use std::{collections::HashMap, io::BufReader, path::PathBuf, process::Stdio};
use cargo_metadata::{diagnostic::DiagnosticLevel, Message};
use serde::Serialize;
use std::{
collections::HashMap,
io::{BufReader, Read},
path::PathBuf,
process::Stdio,
};
#[derive(Serialize)]
struct MessageExpectation {
@ -27,6 +31,7 @@ struct FileResult {
}
#[test]
#[ignore = "https://github.com/Azure/azure-sdk-for-rust/issues/1896"]
pub fn compilation_tests() {
let test_root = {
let mut p = PathBuf::from(env!("CARGO_MANIFEST_DIR"));
@ -43,18 +48,22 @@ pub fn compilation_tests() {
p
};
// Probably save to assume cargo is on the path, but if that's not the case, tests will start failing and we'll figure it out.
let mut compilation = std::process::Command::new("cargo")
let compilation = std::process::Command::new(env!("CARGO"))
.arg("build")
.arg("--message-format")
.arg("json")
.current_dir(test_root.clone())
.stdout(Stdio::piped())
.stderr(Stdio::piped())
.spawn()
.output()
// An error here does not mean a non-zero exit code, it means a failure to run the process.
.expect("failed to execute compilation");
let reader = BufReader::new(compilation.stdout.take().unwrap());
assert!(
!compilation.status.success(),
"expected compilation to fail"
);
let reader = BufReader::new(compilation.stdout.take(u64::MAX));
let messages = Message::parse_stream(reader);
let file_messages = messages
.filter_map(|m| match m.expect("failed to parse message") {

Просмотреть файл

@ -9,5 +9,5 @@ edition = "2021"
publish = false
[dependencies]
typespec_client_core = { path = "../../typespec_client_core", features = ["derive"] }
typespec_client_core = { path = "../../../../typespec_client_core", features = ["derive"] }
serde = { version = "1.0", features = ["derive"] }