THRIFT-5819: use latest rustc version for rustlib (#3085)
Client: rust
This upgrades the version of rust in the rust-toolchain file, docs and dockerfiles. Doing so requires a few changes to the source, mainly to fix or silence new warnings.
Submitted on behalf of a third-party: Jiayu Liu
Derived from the following PR: https://github.com/apache/thrift/pull/3045
Co-authored-by: Jiayu Liu <jiayu@hey.com>
diff --git a/lib/rs/src/lib.rs b/lib/rs/src/lib.rs
index 84c1f9b..2f60188 100644
--- a/lib/rs/src/lib.rs
+++ b/lib/rs/src/lib.rs
@@ -53,7 +53,7 @@
//! [tutorial]: https://github.com/apache/thrift/tree/master/tutorial/rs
#![crate_type = "lib"]
-#![doc(test(attr(allow(unused_variables), deny(warnings))))]
+#![doc(test(attr(allow(unused_variables, dead_code), deny(warnings))))]
#![deny(bare_trait_objects)]
// NOTE: this macro has to be defined before any modules. See:
diff --git a/lib/rs/src/protocol/compact.rs b/lib/rs/src/protocol/compact.rs
index c0c4372..8ed4e06 100644
--- a/lib/rs/src/protocol/compact.rs
+++ b/lib/rs/src/protocol/compact.rs
@@ -681,8 +681,6 @@
#[cfg(test)]
mod tests {
- use std::i32;
-
use crate::protocol::{
TFieldIdentifier, TInputProtocol, TListIdentifier, TMapIdentifier, TMessageIdentifier,
TMessageType, TOutputProtocol, TSetIdentifier, TStructIdentifier, TType,
@@ -2818,7 +2816,7 @@
copy_write_buffer_to_read_buffer!(o_prot);
let read_double = i_prot.read_double().unwrap();
- assert!(read_double - double < std::f64::EPSILON);
+ assert!((read_double - double).abs() < f64::EPSILON);
}
#[test]
diff --git a/lib/rs/src/protocol/stored.rs b/lib/rs/src/protocol/stored.rs
index f4bdfb1..04d3277 100644
--- a/lib/rs/src/protocol/stored.rs
+++ b/lib/rs/src/protocol/stored.rs
@@ -83,6 +83,8 @@
message_ident: Option<TMessageIdentifier>,
}
+// Erroneous suggestion by clippy
+#[allow(clippy::needless_lifetimes)]
impl<'a> TStoredInputProtocol<'a> {
/// Create a `TStoredInputProtocol` that delegates all calls other than
/// `TInputProtocol::read_message_begin(...)` to a `wrapped`
@@ -100,6 +102,8 @@
}
}
+// Erroneous suggestion by clippy
+#[allow(clippy::needless_lifetimes)]
impl<'a> TInputProtocol for TStoredInputProtocol<'a> {
fn read_message_begin(&mut self) -> crate::Result<TMessageIdentifier> {
self.message_ident.take().ok_or_else(|| {
diff --git a/lib/rs/src/transport/framed.rs b/lib/rs/src/transport/framed.rs
index c30ccd9..d8a7448 100644
--- a/lib/rs/src/transport/framed.rs
+++ b/lib/rs/src/transport/framed.rs
@@ -97,7 +97,7 @@
self.buf.resize(buf_capacity, 0);
self.chan.read_exact(&mut self.buf[..message_size])?;
- self.cap = message_size as usize;
+ self.cap = message_size;
self.pos = 0;
}