Skip to content

Commit 2ba889c

Browse files
committed
remove all warnings in cargo check --manifest-path sqlx-core/Cargo.toml --no-default-features --features offline,all-databases,all-types,migrate,runtime-tokio-native-tls
1 parent 5f0b1fc commit 2ba889c

File tree

3 files changed

+21
-16
lines changed

3 files changed

+21
-16
lines changed

sqlx-core/src/net/tls/mod.rs

Lines changed: 14 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -141,26 +141,31 @@ where
141141
}
142142

143143
pub fn downgrade(&mut self) -> Result<(), Error> {
144-
let stream = match replace(self, MaybeTlsStream::Upgrading) {
144+
match replace(self, MaybeTlsStream::Upgrading) {
145145
MaybeTlsStream::Tls(stream) => {
146146
#[cfg(feature = "_tls-rustls")]
147-
let raw = stream.into_inner().0;
147+
{
148+
let raw = stream.into_inner().0;
149+
*self = MaybeTlsStream::Raw(raw);
150+
return Ok(());
151+
}
152+
148153
#[cfg(feature = "_tls-native-tls")]
149-
let raw = unimplemented!("No way to downgrade a native-tls stream, use rustls instead, or never disable tls");
150-
raw
154+
{
155+
let _ = stream; // Use the variable to avoid warning
156+
return Err(Error::tls("No way to downgrade a native-tls stream, use rustls instead, or never disable tls"));
157+
}
151158
}
152159

153-
MaybeTlsStream::Raw(_) => {
160+
MaybeTlsStream::Raw(stream) => {
161+
*self = MaybeTlsStream::Raw(stream);
154162
return Ok(());
155163
}
156164

157165
MaybeTlsStream::Upgrading => {
158166
return Err(Error::Io(io::ErrorKind::ConnectionAborted.into()));
159167
}
160-
};
161-
162-
*self = MaybeTlsStream::Raw(stream);
163-
Ok(())
168+
}
164169
}
165170
}
166171

sqlx-core/src/postgres/connection/executor.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ async fn prepare(
6363
conn.stream.flush().await?;
6464

6565
// indicates that the SQL query string is now successfully parsed and has semantic validity
66-
let _ = conn
66+
let _: () = conn
6767
.stream
6868
.recv_expect(MessageFormat::ParseComplete)
6969
.await?;

sqlx-core/src/postgres/copy.rs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -128,7 +128,7 @@ impl<C: DerefMut<Target = PgConnection>> PgCopyIn<C> {
128128
.send(CopyFail::new("failed to start COPY"))
129129
.await?;
130130
conn.stream
131-
.recv_expect(MessageFormat::ReadyForQuery)
131+
.recv_expect::<()>(MessageFormat::ReadyForQuery)
132132
.await?;
133133
Err(e)
134134
}
@@ -213,7 +213,7 @@ impl<C: DerefMut<Target = PgConnection>> PgCopyIn<C> {
213213
loop {
214214
let read = match () {
215215
// Tokio lets us read into the buffer without zeroing first
216-
#[cfg(feature = "runtime-tokio")]
216+
#[cfg(feature = "_rt-tokio")]
217217
_ if buf.len() != buf.capacity() => {
218218
// in case we have some data in the buffer, which can occur
219219
// if the previous write did not fill the buffer
@@ -267,7 +267,7 @@ impl<C: DerefMut<Target = PgConnection>> PgCopyIn<C> {
267267
Some(Cow::Borrowed("57014")) => {
268268
// postgres abort received error code
269269
conn.stream
270-
.recv_expect(MessageFormat::ReadyForQuery)
270+
.recv_expect::<()>(MessageFormat::ReadyForQuery)
271271
.await?;
272272
Ok(())
273273
}
@@ -294,7 +294,7 @@ impl<C: DerefMut<Target = PgConnection>> PgCopyIn<C> {
294294
.await?;
295295

296296
conn.stream
297-
.recv_expect(MessageFormat::ReadyForQuery)
297+
.recv_expect::<()>(MessageFormat::ReadyForQuery)
298298
.await?;
299299

300300
Ok(cc.rows_affected())
@@ -330,8 +330,8 @@ async fn pg_begin_copy_out<'c, C: DerefMut<Target = PgConnection> + Send + 'c>(
330330
MessageFormat::CopyData => r#yield!(msg.decode::<CopyData<Bytes>>()?.0),
331331
MessageFormat::CopyDone => {
332332
let _ = msg.decode::<CopyDone>()?;
333-
conn.stream.recv_expect(MessageFormat::CommandComplete).await?;
334-
conn.stream.recv_expect(MessageFormat::ReadyForQuery).await?;
333+
conn.stream.recv_expect::<CommandComplete>(MessageFormat::CommandComplete).await?;
334+
conn.stream.recv_expect::<()>(MessageFormat::ReadyForQuery).await?;
335335
return Ok(())
336336
},
337337
_ => return Err(err_protocol!("unexpected message format during copy out: {:?}", msg.format))

0 commit comments

Comments
 (0)