Skip to content

Commit 6ade874

Browse files
committed
fix clippy errors
1 parent 9fe8de9 commit 6ade874

File tree

5 files changed

+18
-12
lines changed

5 files changed

+18
-12
lines changed

.github/workflows/ci.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@ jobs:
3737
id: rust-version
3838
- run: cargo generate-lockfile
3939
- run: cargo fetch
40+
- run: cargo fmt --check
4041
- run: cargo clippy --all-targets -- -D warnings
4142
- run: cargo test --features vendored
4243

Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ alpn = ["security-framework/alpn"]
2121
have_min_max_version = []
2222

2323
[target.'cfg(target_vendor = "apple")'.dependencies]
24-
security-framework = "2.0.0"
24+
security-framework = "3"
2525
security-framework-sys = "2.0.0"
2626
libc = "0.2"
2727

src/imp/schannel.rs

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ use crate::{TlsAcceptorBuilder, TlsConnectorBuilder};
1414

1515
const SEC_E_NO_CREDENTIALS: u32 = 0x8009030E;
1616

17-
static PROTOCOLS: &'static [Protocol] = &[
17+
static PROTOCOLS: &[Protocol] = &[
1818
Protocol::Ssl3,
1919
Protocol::Tls10,
2020
Protocol::Tls11,
@@ -104,7 +104,7 @@ impl Identity {
104104
}
105105

106106
let mut store = Memory::new()?.into_store();
107-
let mut cert_iter = pem::PemBlock::new(pem).into_iter();
107+
let mut cert_iter = pem::PemBlock::new(pem);
108108
let leaf = cert_iter.next().ok_or_else(|| {
109109
io::Error::new(
110110
io::ErrorKind::InvalidInput,
@@ -127,7 +127,7 @@ impl Identity {
127127
Ok(container) => container,
128128
Err(_) => options.new_keyset(true).acquire(type_)?,
129129
};
130-
container.import().import_pkcs8_pem(&key)?;
130+
container.import().import_pkcs8_pem(key)?;
131131

132132
cert.set_key_prov_info()
133133
.container(&name)
@@ -205,6 +205,7 @@ impl<S> MidHandshakeTlsStream<S>
205205
where
206206
S: io::Read + io::Write,
207207
{
208+
#[allow(clippy::result_large_err)]
208209
pub fn handshake(self) -> Result<TlsStream<S>, HandshakeError<S>> {
209210
match self.0.handshake() {
210211
Ok(s) => Ok(TlsStream(s)),
@@ -213,6 +214,7 @@ where
213214
}
214215
}
215216

217+
#[allow(clippy::large_enum_variant)]
216218
pub enum HandshakeError<S> {
217219
Failure(Error),
218220
WouldBlock(MidHandshakeTlsStream<S>),
@@ -271,6 +273,7 @@ impl TlsConnector {
271273
})
272274
}
273275

276+
#[allow(clippy::result_large_err)]
274277
pub fn connect<S>(&self, domain: &str, stream: S) -> Result<TlsStream<S>, HandshakeError<S>>
275278
where
276279
S: io::Read + io::Write,
@@ -292,10 +295,8 @@ impl TlsConnector {
292295
} else if self.disable_built_in_roots {
293296
let roots_copy = self.roots.clone();
294297
builder.verify_callback(move |res| {
295-
if let Err(err) = res.result() {
296-
// Propagate previous error encountered during normal cert validation.
297-
return Err(err);
298-
}
298+
// Propagate previous error encountered during normal cert validation.
299+
res.result()?;
299300

300301
if let Some(chain) = res.chain() {
301302
if chain
@@ -306,8 +307,7 @@ impl TlsConnector {
306307
}
307308
}
308309

309-
Err(io::Error::new(
310-
io::ErrorKind::Other,
310+
Err(io::Error::other(
311311
"unable to find any user-specified roots in the final cert chain",
312312
))
313313
});
@@ -343,6 +343,7 @@ impl TlsAcceptor {
343343
})
344344
}
345345

346+
#[allow(clippy::result_large_err)]
346347
pub fn accept<S>(&self, stream: S) -> Result<TlsStream<S>, HandshakeError<S>>
347348
where
348349
S: io::Read + io::Write,
@@ -472,7 +473,7 @@ mod pem {
472473
Some(end) => end + begin + 1,
473474
None => last,
474475
};
475-
return Some(&self.pem_block[begin..self.cur_end].as_bytes());
476+
Some(&self.pem_block.as_bytes()[begin..self.cur_end])
476477
}
477478
}
478479

src/imp/security_framework.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -153,7 +153,7 @@ impl Identity {
153153

154154
let cert = items
155155
.certificates
156-
.get(0)
156+
.first()
157157
.ok_or_else(|| Error(base::Error::from(errSecParam)))?;
158158
let ident = SecIdentity::with_certificate(&[keychain], cert)?;
159159
Ok(Identity {

src/lib.rs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -246,6 +246,7 @@ where
246246
/// Note that the error may not be fatal. For example if the underlying
247247
/// stream is an asynchronous one then `HandshakeError::WouldBlock` may
248248
/// just mean to wait for more I/O to happen later.
249+
#[allow(clippy::result_large_err)]
249250
pub fn handshake(self) -> result::Result<TlsStream<S>, HandshakeError<S>> {
250251
match self.0.handshake() {
251252
Ok(s) => Ok(TlsStream(s)),
@@ -256,6 +257,7 @@ where
256257

257258
/// An error returned from `ClientBuilder::handshake`.
258259
#[derive(Debug)]
260+
#[allow(clippy::large_enum_variant)]
259261
pub enum HandshakeError<S> {
260262
/// A fatal error.
261263
Failure(Error),
@@ -500,6 +502,7 @@ impl TlsConnector {
500502
///
501503
/// The domain is ignored if both SNI and hostname verification are
502504
/// disabled.
505+
#[allow(clippy::result_large_err)]
503506
pub fn connect<S>(
504507
&self,
505508
domain: &str,
@@ -616,6 +619,7 @@ impl TlsAcceptor {
616619
/// the handshake, a `HandshakeError::WouldBlock` error will be returned
617620
/// which can be used to restart the handshake when the socket is ready
618621
/// again.
622+
#[allow(clippy::result_large_err)]
619623
pub fn accept<S>(&self, stream: S) -> result::Result<TlsStream<S>, HandshakeError<S>>
620624
where
621625
S: io::Read + io::Write,

0 commit comments

Comments
 (0)