Skip to content

Commit febf30a

Browse files
committed
Enable more lints
1 parent 7c76721 commit febf30a

File tree

6 files changed

+38
-26
lines changed

6 files changed

+38
-26
lines changed

Cargo.toml

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,22 @@ allowed_external_types = [
7979
"rustls_pki_types::*",
8080
"serde_core::*",
8181
"serde_json::*",
82+
"time::*",
8283
]
8384

8485
[lints.rust]
86+
elided_lifetimes_in_paths = "warn"
87+
trivial_numeric_casts = "warn"
8588
unexpected_cfgs = { level = "warn", check-cfg = ["cfg(instant_acme_docsrs)"] }
89+
unnameable_types = "warn"
90+
unreachable_pub = "warn"
91+
unused_extern_crates = "warn"
92+
unused_import_braces = "warn"
93+
unused_qualifications = "warn"
94+
95+
[lints.clippy]
96+
cloned_instead_of_copied = "warn"
97+
manual_let_else = "warn"
98+
or_fun_call = "warn"
99+
upper_case_acronyms = "warn"
100+
use_self = "warn"

src/account.rs

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -153,13 +153,12 @@ impl Account {
153153

154154
/// Revokes a previously issued certificate
155155
pub async fn revoke<'a>(&'a self, payload: &RevocationRequest<'a>) -> Result<(), Error> {
156-
let revoke_url = match self.inner.client.directory.revoke_cert.as_deref() {
157-
Some(url) => url,
156+
let Some(revoke_url) = self.inner.client.directory.revoke_cert.as_deref() else {
158157
// This happens because the current account credentials were deserialized from an
159158
// older version which only serialized a subset of the directory URLs. You should
160159
// make sure the account credentials include a `directory` field containing a
161160
// string with the server's directory URL.
162-
None => return Err("no revokeCert URL found".into()),
161+
return Err("no revokeCert URL found".into());
163162
};
164163

165164
let rsp = self.inner.post(Some(payload), None, revoke_url).await?;
@@ -221,9 +220,8 @@ impl Account {
221220
///
222221
/// See <https://datatracker.ietf.org/doc/html/rfc8555#section-7.3.5> for more information.
223222
pub async fn update_key(&mut self) -> Result<AccountCredentials, Error> {
224-
let new_key_url = match self.inner.client.directory.key_change.as_deref() {
225-
Some(url) => url,
226-
None => return Err("Account key rollover not supported by ACME CA".into()),
223+
let Some(new_key_url) = self.inner.client.directory.key_change.as_deref() else {
224+
return Err("Account key rollover not supported by ACME CA".into());
227225
};
228226

229227
#[derive(Debug, Serialize)]

src/lib.rs

Lines changed: 10 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
//! Async pure-Rust ACME (RFC 8555) client.
22
3-
#![warn(unreachable_pub)]
43
#![warn(missing_docs)]
54
#![cfg_attr(instant_acme_docsrs, feature(doc_cfg))]
65

@@ -43,15 +42,15 @@ pub use order::{
4342
RetryPolicy,
4443
};
4544
mod types;
46-
#[cfg(feature = "time")]
47-
pub use types::RenewalInfo;
4845
pub use types::{
4946
AccountCredentials, Authorization, AuthorizationState, AuthorizationStatus,
50-
AuthorizedIdentifier, CertificateIdentifier, Challenge, ChallengeType, Error, Identifier,
51-
LetsEncrypt, NewAccount, NewOrder, OrderState, OrderStatus, Problem, ProfileMeta,
52-
RevocationReason, RevocationRequest, ZeroSsl,
47+
AuthorizedIdentifier, CertificateIdentifier, Challenge, ChallengeStatus, ChallengeType,
48+
DeviceAttestation, Error, Identifier, LetsEncrypt, NewAccount, NewOrder, OrderState,
49+
OrderStatus, Problem, ProfileMeta, RevocationReason, RevocationRequest, Subproblem, ZeroSsl,
5350
};
5451
use types::{Directory, JoseJson, Signer};
52+
#[cfg(feature = "time")]
53+
pub use types::{RenewalInfo, SuggestedWindow};
5554

5655
struct Client {
5756
http: Box<dyn HttpClient>,
@@ -68,7 +67,7 @@ impl Client {
6867
.expect("infallible error should not occur");
6968
let rsp = http.request(request).await?;
7069
let body = rsp.body().await.map_err(Error::Other)?;
71-
Ok(Client {
70+
Ok(Self {
7271
http,
7372
directory: serde_json::from_slice(&body)?,
7473
directory_url: Some(directory_url),
@@ -203,15 +202,15 @@ struct DefaultClient(HyperClient<hyper_rustls::HttpsConnector<HttpConnector>, Bo
203202
impl DefaultClient {
204203
fn try_new() -> Result<Self, Error> {
205204
Ok(Self::new(
206-
hyper_rustls::HttpsConnectorBuilder::new()
205+
HttpsConnectorBuilder::new()
207206
.try_with_platform_verifier()
208207
.map_err(|e| Error::Other(Box::new(e)))?,
209208
))
210209
}
211210

212211
fn with_roots(roots: rustls::RootCertStore) -> Result<Self, Error> {
213212
Ok(Self::new(
214-
hyper_rustls::HttpsConnectorBuilder::new().with_tls_config(
213+
HttpsConnectorBuilder::new().with_tls_config(
215214
rustls::ClientConfig::builder()
216215
.with_root_certificates(roots)
217216
.with_no_client_auth(),
@@ -347,15 +346,15 @@ impl http_body::Body for BodyWrapper<Bytes> {
347346

348347
impl From<Vec<u8>> for BodyWrapper<Bytes> {
349348
fn from(data: Vec<u8>) -> Self {
350-
BodyWrapper {
349+
Self {
351350
inner: Some(Bytes::from(data)),
352351
}
353352
}
354353
}
355354

356355
#[async_trait]
357356
impl BytesBody for Bytes {
358-
async fn into_bytes(&mut self) -> Result<Bytes, Box<dyn StdError + Send + Sync + 'static>> {
357+
async fn into_bytes(&mut self) -> Result<Self, Box<dyn StdError + Send + Sync + 'static>> {
359358
Ok(self.to_owned())
360359
}
361360
}

src/order.rs

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -127,9 +127,8 @@ impl Order {
127127
return Err(Error::Str("invalid order state"));
128128
}
129129

130-
let cert_url = match &self.state.certificate {
131-
Some(cert_url) => cert_url,
132-
None => return Err(Error::Str("no certificate URL found")),
130+
let Some(cert_url) = &self.state.certificate else {
131+
return Err(Error::Str("no certificate URL found"));
133132
};
134133

135134
let rsp = self

src/types.rs

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@ impl Error {
7474

7575
impl From<&'static str> for Error {
7676
fn from(s: &'static str) -> Self {
77-
Error::Str(s)
77+
Self::Str(s)
7878
}
7979
}
8080

@@ -173,7 +173,7 @@ impl Problem {
173173
let body = rsp.body().await.map_err(Error::Other)?;
174174
match status.is_informational() || status.is_success() || status.is_redirection() {
175175
true => Ok(body),
176-
false => Err(serde_json::from_slice::<Problem>(&body)?.into()),
176+
false => Err(serde_json::from_slice::<Self>(&body)?.into()),
177177
}
178178
}
179179
}
@@ -730,6 +730,7 @@ pub enum ChallengeType {
730730
Unknown(String),
731731
}
732732

733+
#[allow(missing_docs)]
733734
#[derive(Clone, Copy, Debug, Deserialize, Eq, PartialEq)]
734735
#[serde(rename_all = "camelCase")]
735736
pub enum ChallengeStatus {
@@ -869,7 +870,7 @@ impl Serialize for CertificateIdentifier<'_> {
869870
impl<'a> TryFrom<&'a CertificateDer<'_>> for CertificateIdentifier<'_> {
870871
type Error = String;
871872

872-
fn try_from(cert: &'a CertificateDer) -> Result<Self, Self::Error> {
873+
fn try_from(cert: &'a CertificateDer<'_>) -> Result<Self, Self::Error> {
873874
let (_, parsed_cert) = parse_x509_certificate(cert.as_ref())
874875
.map_err(|e| format!("failed to parse certificate: {e}"))?;
875876

tests/pebble.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -362,7 +362,7 @@ async fn update_key() -> Result<(), Box<dyn StdError>> {
362362
);
363363

364364
// Change the Pebble environment to use the new ACME account key.
365-
env.account = instant_acme::Account::builder_with_http(Box::new(env.client.clone()))
365+
env.account = Account::builder_with_http(Box::new(env.client.clone()))
366366
.from_credentials(new_credentials)
367367
.await?;
368368

@@ -403,7 +403,7 @@ async fn account_from_key() -> Result<(), Box<dyn StdError>> {
403403
}
404404

405405
let json1 = serde_json::to_string(&credentials)?;
406-
let json_key = serde_json::from_str::<JsonKey>(&json1)?;
406+
let json_key = serde_json::from_str::<JsonKey<'_>>(&json1)?;
407407
let key_der = BASE64_URL_SAFE_NO_PAD.decode(json_key.key_pkcs8)?;
408408
let key = Key::from_pkcs8_der(PrivatePkcs8KeyDer::from(key_der.clone()))?;
409409

@@ -476,7 +476,7 @@ async fn account_create_from_key() -> Result<(), Box<dyn StdError>> {
476476
}
477477

478478
let json1 = serde_json::to_string(&credentials1)?;
479-
let json_key = serde_json::from_str::<JsonKey>(&json1)?;
479+
let json_key = serde_json::from_str::<JsonKey<'_>>(&json1)?;
480480
let key_der = BASE64_URL_SAFE_NO_PAD.decode(json_key.key_pkcs8)?;
481481

482482
// Verify the key matches

0 commit comments

Comments
 (0)