Skip to content

Commit da54fc8

Browse files
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: #3045 Co-authored-by: Jiayu Liu <jiayu@hey.com>
1 parent ab70652 commit da54fc8

File tree

12 files changed

+16
-17
lines changed

12 files changed

+16
-17
lines changed

.github/workflows/build.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -400,7 +400,7 @@ jobs:
400400
needs: compiler
401401
runs-on: ubuntu-24.04
402402
env:
403-
TOOLCHAIN_VERSION: 1.65.0
403+
TOOLCHAIN_VERSION: 1.83.0
404404
steps:
405405
- uses: actions/checkout@v4
406406

LANGUAGES.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -319,7 +319,7 @@ Thrift's core protocol is TBinary, supported by all languages except for JavaScr
319319
<td align=left><a href="https://github.com/apache/thrift/blob/master/lib/rs/README.md">Rust</a></td>
320320
<!-- Since -----------------><td>0.11.0</td>
321321
<!-- Build Systems ---------><td><img src="/doc/images/cgrn.png" alt="Yes"/></td><td><img src="/doc/images/cred.png" alt=""/></td>
322-
<!-- Language Levels -------><td>1.65.0</td><td>1.xx.x</td>
322+
<!-- Language Levels -------><td>1.83.0</td><td>1.xx.x</td>
323323
<!-- Field types -----------><td><img src="/doc/images/cred.png" alt=""/></td>
324324
<!-- 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>
325325
<!-- 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>

build/docker/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -196,6 +196,6 @@ Last updated: March 5, 2024
196196
| python2 | 2.7.18 | | |
197197
| python3 | 3.8.10 | 3.10.12 | |
198198
| ruby | 2.7.0p0 | 3.0.2p107 | |
199-
| rust | 1.65.0 | 1.65.0 | |
199+
| rust | 1.83.0 | 1.83.0 | |
200200
| smalltalk | | | Not in CI |
201201
| swift | 5.7 | 5.7 | |

build/docker/ubuntu-focal/Dockerfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -273,7 +273,7 @@ RUN apt-get install -y --no-install-recommends \
273273

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

build/docker/ubuntu-jammy/Dockerfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -272,7 +272,7 @@ RUN apt-get install -y --no-install-recommends \
272272

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

compiler/cpp/src/thrift/generate/t_rs_generator.cc

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -749,8 +749,8 @@ void t_rs_generator::render_const_value(t_type* ttype,
749749
} else if (ttype->is_enum()) {
750750
f_gen_ << "{" << '\n';
751751
indent_up();
752-
f_gen_ << indent() << to_rust_type(ttype) << "::try_from(" << tvalue->get_integer()
753-
<< ").expect(\"expecting valid const value\")" << '\n';
752+
f_gen_ << indent() << to_rust_type(ttype) << "::from(" << tvalue->get_integer()
753+
<< ")" << '\n';
754754
indent_down();
755755
f_gen_ << indent() << "}";
756756
} else if (ttype->is_struct() || ttype->is_xception()) {

lib/rs/src/lib.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@
5353
//! [tutorial]: https://github.com/apache/thrift/tree/master/tutorial/rs
5454
5555
#![crate_type = "lib"]
56-
#![doc(test(attr(allow(unused_variables), deny(warnings))))]
56+
#![doc(test(attr(allow(unused_variables, dead_code), deny(warnings))))]
5757
#![deny(bare_trait_objects)]
5858

5959
// NOTE: this macro has to be defined before any modules. See:

lib/rs/src/protocol/compact.rs

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -681,8 +681,6 @@ fn u8_to_type(b: u8) -> crate::Result<TType> {
681681
#[cfg(test)]
682682
mod tests {
683683

684-
use std::i32;
685-
686684
use crate::protocol::{
687685
TFieldIdentifier, TInputProtocol, TListIdentifier, TMapIdentifier, TMessageIdentifier,
688686
TMessageType, TOutputProtocol, TSetIdentifier, TStructIdentifier, TType,
@@ -2818,7 +2816,7 @@ mod tests {
28182816
copy_write_buffer_to_read_buffer!(o_prot);
28192817

28202818
let read_double = i_prot.read_double().unwrap();
2821-
assert!(read_double - double < std::f64::EPSILON);
2819+
assert!((read_double - double).abs() < f64::EPSILON);
28222820
}
28232821

28242822
#[test]

lib/rs/src/protocol/stored.rs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,8 @@ pub struct TStoredInputProtocol<'a> {
8383
message_ident: Option<TMessageIdentifier>,
8484
}
8585

86+
// Erroneous suggestion by clippy
87+
#[allow(clippy::needless_lifetimes)]
8688
impl<'a> TStoredInputProtocol<'a> {
8789
/// Create a `TStoredInputProtocol` that delegates all calls other than
8890
/// `TInputProtocol::read_message_begin(...)` to a `wrapped`
@@ -100,6 +102,8 @@ impl<'a> TStoredInputProtocol<'a> {
100102
}
101103
}
102104

105+
// Erroneous suggestion by clippy
106+
#[allow(clippy::needless_lifetimes)]
103107
impl<'a> TInputProtocol for TStoredInputProtocol<'a> {
104108
fn read_message_begin(&mut self) -> crate::Result<TMessageIdentifier> {
105109
self.message_ident.take().ok_or_else(|| {

lib/rs/src/transport/framed.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,7 @@ where
9797
self.buf.resize(buf_capacity, 0);
9898

9999
self.chan.read_exact(&mut self.buf[..message_size])?;
100-
self.cap = message_size as usize;
100+
self.cap = message_size;
101101
self.pos = 0;
102102
}
103103

0 commit comments

Comments
 (0)