Skip to content

Commit

Permalink
THRIFT-5819: use latest rustc version for rustlib (#3085)
Browse files Browse the repository at this point in the history
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: #3045

Co-authored-by: Jiayu Liu <[email protected]>
  • Loading branch information
cameron-martin and jimexist authored Jan 12, 2025
1 parent ab70652 commit da54fc8
Show file tree
Hide file tree
Showing 12 changed files with 16 additions and 17 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -400,7 +400,7 @@ jobs:
needs: compiler
runs-on: ubuntu-24.04
env:
TOOLCHAIN_VERSION: 1.65.0
TOOLCHAIN_VERSION: 1.83.0
steps:
- uses: actions/checkout@v4

Expand Down
2 changes: 1 addition & 1 deletion LANGUAGES.md
Original file line number Diff line number Diff line change
Expand Up @@ -319,7 +319,7 @@ Thrift's core protocol is TBinary, supported by all languages except for JavaScr
<td align=left><a href="https://github.com/apache/thrift/blob/master/lib/rs/README.md">Rust</a></td>
<!-- Since -----------------><td>0.11.0</td>
<!-- Build Systems ---------><td><img src="/doc/images/cgrn.png" alt="Yes"/></td><td><img src="/doc/images/cred.png" alt=""/></td>
<!-- Language Levels -------><td>1.65.0</td><td>1.xx.x</td>
<!-- Language Levels -------><td>1.83.0</td><td>1.xx.x</td>
<!-- Field types -----------><td><img src="/doc/images/cred.png" alt=""/></td>
<!-- Low-Level Transports --><td><img src="/doc/images/cred.png" alt=""/></td><td><img src="/doc/images/cred.png" alt=""/></td><td><img src="/doc/images/cgrn.png" alt="Yes"/></td><td><img src="/doc/images/cred.png" alt=""/></td><td><img src="/doc/images/cgrn.png" alt="Yes"/></td><td><img src="/doc/images/cred.png" alt=""/></td>
<!-- Transport Wrappers ----><td><img src="/doc/images/cgrn.png" alt="Yes"/></td><td><img src="/doc/images/cred.png" alt=""/></td><td><img src="/doc/images/cred.png" alt=""/></td><td><img src="/doc/images/cred.png" alt=""/></td>
Expand Down
2 changes: 1 addition & 1 deletion build/docker/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -196,6 +196,6 @@ Last updated: March 5, 2024
| python2 | 2.7.18 | | |
| python3 | 3.8.10 | 3.10.12 | |
| ruby | 2.7.0p0 | 3.0.2p107 | |
| rust | 1.65.0 | 1.65.0 | |
| rust | 1.83.0 | 1.83.0 | |
| smalltalk | | | Not in CI |
| swift | 5.7 | 5.7 | |
2 changes: 1 addition & 1 deletion build/docker/ubuntu-focal/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -273,7 +273,7 @@ RUN apt-get install -y --no-install-recommends \

USER ${user}
RUN `# Rust dependencies` \
curl https://sh.rustup.rs -sSf | sh -s -- --default-toolchain 1.65.0 -y
curl https://sh.rustup.rs -sSf | sh -s -- --default-toolchain 1.83.0 -y
ENV PATH /home/${user}/.cargo/bin:$PATH
USER root

Expand Down
2 changes: 1 addition & 1 deletion build/docker/ubuntu-jammy/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -272,7 +272,7 @@ RUN apt-get install -y --no-install-recommends \

USER ${user}
RUN `# Rust dependencies` \
curl https://sh.rustup.rs -sSf | sh -s -- --default-toolchain 1.65.0 -y
curl https://sh.rustup.rs -sSf | sh -s -- --default-toolchain 1.83.0 -y
ENV PATH /home/${user}/.cargo/bin:$PATH
USER root

Expand Down
4 changes: 2 additions & 2 deletions compiler/cpp/src/thrift/generate/t_rs_generator.cc
Original file line number Diff line number Diff line change
Expand Up @@ -749,8 +749,8 @@ void t_rs_generator::render_const_value(t_type* ttype,
} else if (ttype->is_enum()) {
f_gen_ << "{" << '\n';
indent_up();
f_gen_ << indent() << to_rust_type(ttype) << "::try_from(" << tvalue->get_integer()
<< ").expect(\"expecting valid const value\")" << '\n';
f_gen_ << indent() << to_rust_type(ttype) << "::from(" << tvalue->get_integer()
<< ")" << '\n';
indent_down();
f_gen_ << indent() << "}";
} else if (ttype->is_struct() || ttype->is_xception()) {
Expand Down
2 changes: 1 addition & 1 deletion lib/rs/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
4 changes: 1 addition & 3 deletions lib/rs/src/protocol/compact.rs
Original file line number Diff line number Diff line change
Expand Up @@ -681,8 +681,6 @@ fn u8_to_type(b: u8) -> crate::Result<TType> {
#[cfg(test)]
mod tests {

use std::i32;

use crate::protocol::{
TFieldIdentifier, TInputProtocol, TListIdentifier, TMapIdentifier, TMessageIdentifier,
TMessageType, TOutputProtocol, TSetIdentifier, TStructIdentifier, TType,
Expand Down Expand Up @@ -2818,7 +2816,7 @@ mod tests {
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]
Expand Down
4 changes: 4 additions & 0 deletions lib/rs/src/protocol/stored.rs
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,8 @@ pub struct TStoredInputProtocol<'a> {
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`
Expand All @@ -100,6 +102,8 @@ impl<'a> TStoredInputProtocol<'a> {
}
}

// 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(|| {
Expand Down
2 changes: 1 addition & 1 deletion lib/rs/src/transport/framed.rs
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ where
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;
}

Expand Down
2 changes: 1 addition & 1 deletion rust-toolchain
Original file line number Diff line number Diff line change
@@ -1 +1 @@
1.65.0
1.83.0
5 changes: 1 addition & 4 deletions test/rs/src/bin/test_client.rs
Original file line number Diff line number Diff line change
Expand Up @@ -252,10 +252,7 @@ fn make_thrift_calls(
info!("testi64");
// try!(verify_expected_result(thrift_test_client.test_i64(-8651829879438294565),
// -8651829879438294565));
verify_expected_result(
thrift_test_client.test_i64(i64::min_value()),
i64::min_value(),
)?;
verify_expected_result(thrift_test_client.test_i64(i64::MIN), i64::MIN)?;

info!("testDouble");
verify_expected_result(
Expand Down

0 comments on commit da54fc8

Please sign in to comment.