Skip to content

Commit dfb715b

Browse files
authored
Fix clippy 1.90 lint (#2885)
After update to `+nightly` clippy 0.1.90 (7d82b83ed5 2025-08-06) we discovered a few more lints.
1 parent 3db4c45 commit dfb715b

File tree

8 files changed

+29
-11
lines changed

8 files changed

+29
-11
lines changed

sdk/core/azure_core/src/http/policies/bearer_token_policy.rs

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -198,7 +198,11 @@ mod tests {
198198
let mut req = Request::new("https://localhost".parse().unwrap(), Method::Get);
199199

200200
let err = policy
201-
.send(&Context::default(), &mut req, &[transport.clone()])
201+
.send(
202+
&Context::default(),
203+
&mut req,
204+
std::slice::from_ref(&(transport.clone() as Arc<dyn Policy>)),
205+
)
202206
.await
203207
.expect_err("request should fail");
204208

@@ -236,7 +240,11 @@ mod tests {
236240
let ctx = Context::default();
237241
let mut req = Request::new("https://localhost".parse().unwrap(), Method::Get);
238242
policy
239-
.send(&ctx, &mut req, &[transport.clone()])
243+
.send(
244+
&ctx,
245+
&mut req,
246+
std::slice::from_ref(&(transport.clone() as Arc<dyn Policy>)),
247+
)
240248
.await
241249
.expect("successful request");
242250
});

sdk/core/azure_core/src/http/policies/instrumentation/public_api_instrumentation.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -273,9 +273,9 @@ mod tests {
273273
}
274274
}
275275

276-
if api_information.is_some() {
276+
if let Some(api_information) = api_information {
277277
// If we have public API information, add it to the context.
278-
ctx = ctx.with_value(api_information.unwrap());
278+
ctx = ctx.with_value(api_information);
279279
}
280280
let _result = public_api_policy.send(&ctx, request, &next).await;
281281

sdk/core/azure_core_test/src/proxy/mod.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -314,6 +314,7 @@ impl FromStr for RecordingId {
314314
}
315315
}
316316

317+
#[cfg_attr(target_arch = "wasm32", allow(dead_code))]
317318
#[derive(Debug, Default, Eq, PartialEq, Ord, PartialOrd)]
318319
struct Version {
319320
major: i32,

sdk/eventhubs/azure_messaging_eventhubs_checkpointstore_blob/tests/ownership_unit_tests.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -231,7 +231,7 @@ async fn claim_ownership_update_existing(ctx: TestContext) -> Result<()> {
231231
};
232232

233233
let initial_claimed = checkpoint_store
234-
.claim_ownership(&[initial_ownership.clone()])
234+
.claim_ownership(std::slice::from_ref(&initial_ownership))
235235
.await?;
236236
assert_eq!(initial_claimed.len(), 1);
237237
let initial_etag = initial_claimed[0].etag.clone();

sdk/typespec/typespec_client_core/src/async_runtime/mod.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@ use std::{
3636
sync::{Arc, OnceLock},
3737
};
3838

39+
#[cfg_attr(feature = "tokio", allow(dead_code))]
3940
mod standard_runtime;
4041

4142
#[cfg(feature = "tokio")]

sdk/typespec/typespec_client_core/src/async_runtime/standard_runtime.rs

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,6 @@ impl Future for ThreadJoinFuture {
8080
}
8181

8282
/// An [`AsyncRuntime`] using [`std::thread::spawn`].
83-
#[allow(dead_code)]
8483
pub(crate) struct StdRuntime;
8584

8685
impl AsyncRuntime for StdRuntime {
@@ -163,9 +162,9 @@ impl AsyncRuntime for StdRuntime {
163162
}
164163
}
165164

166-
#[derive(Debug)]
167165
#[cfg(not(target_arch = "wasm32"))]
168-
pub struct Sleep {
166+
#[derive(Debug)]
167+
struct Sleep {
169168
signal: Option<Arc<AtomicBool>>,
170169
duration: Duration,
171170
}

sdk/typespec/typespec_client_core/src/async_runtime/tests.rs

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@ use crate::time::Duration;
66
use futures::FutureExt;
77
use std::sync::{Arc, Mutex};
88

9-
#[cfg(not(feature = "tokio"))]
109
#[test]
1110
fn test_task_spawner_execution() {
1211
let runtime = get_async_runtime();
@@ -172,7 +171,6 @@ fn std_multiple_tasks() {
172171

173172
// When the "tokio" feature is enabled, the azure_core::sleep::sleep function uses tokio::time::sleep which requires a tokio runtime.
174173
// When the "tokio" feature is not enabled, it uses std::thread::sleep which does not require a tokio runtime.
175-
#[cfg(not(feature = "tokio"))]
176174
#[test]
177175
fn std_task_execution() {
178176
let runtime = Arc::new(standard_runtime::StdRuntime);
@@ -199,7 +197,6 @@ fn std_task_execution() {
199197
// Basic test that launches 10k futures and waits for them to complete:
200198
// it has a high chance of failing if there is a race condition in the sleep method;
201199
// otherwise, it runs quickly.
202-
#[cfg(not(feature = "tokio"))]
203200
#[tokio::test]
204201
async fn test_timeout() {
205202
use super::*;

sdk/typespec/typespec_client_core/src/http/request/mod.rs

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -321,6 +321,10 @@ impl<T, F> TryFrom<&'static str> for RequestContent<T, F> {
321321
}
322322
}
323323

324+
#[allow(
325+
clippy::infallible_try_from,
326+
reason = "maintain a consistent pattern of `try_into()`"
327+
)]
324328
impl<F> TryFrom<bool> for RequestContent<bool, F> {
325329
type Error = Infallible;
326330
fn try_from(body: bool) -> Result<Self, Infallible> {
@@ -349,6 +353,10 @@ mod decimal {
349353
use super::*;
350354
use rust_decimal::Decimal;
351355

356+
#[allow(
357+
clippy::infallible_try_from,
358+
reason = "maintain a consistent pattern of `try_into()`"
359+
)]
352360
impl<T, F> TryFrom<Decimal> for RequestContent<T, F> {
353361
type Error = Infallible;
354362
fn try_from(value: Decimal) -> Result<Self, Infallible> {
@@ -359,6 +367,10 @@ mod decimal {
359367
}
360368
}
361369

370+
#[allow(
371+
clippy::infallible_try_from,
372+
reason = "maintain a consistent pattern of `try_into()`"
373+
)]
362374
impl<T, F> TryFrom<Option<Decimal>> for RequestContent<T, F> {
363375
type Error = Infallible;
364376
fn try_from(value: Option<Decimal>) -> Result<Self, Infallible> {

0 commit comments

Comments
 (0)