THRIFT-5600: rust lib to upgrade to edition 2021
Client: rs
Patch: Jiayu Liu
This closes #2628
diff --git a/lib/rs/README.md b/lib/rs/README.md
index 30e36d4..010bb17 100644
--- a/lib/rs/README.md
+++ b/lib/rs/README.md
@@ -40,7 +40,7 @@
## Compatibility
The Rust library and auto-generated code targets Rust versions 1.28+.
-It does not currently use any Rust 2018 features.
+It does not currently use any Rust 2021 features.
### Breaking Changes
@@ -136,7 +136,7 @@
As a result of this change the Rust representation of an enum changes from a standard
Rust enum into a newtype struct with associated constants.
-
+
For example:
```thrift
@@ -150,7 +150,7 @@
```
used to generate:
-
+
```rust
// OLD AUTO-GENERATED RUST
pub enum Operation {
@@ -162,11 +162,11 @@
```
It *now* generates:
-
+
```rust
// NEW AUTO-GENERATED RUST
pub struct Operation(pub i32);
-
+
impl Operation {
pub const ADD: Operation = Operation(0);
pub const SUBTRACT: Operation = Operation(1);
@@ -177,19 +177,19 @@
##### Thrift 0.14.0
-* **[THRIFT-5158]** - Rust library and generator now support Rust 2018 only. Required rust 1.40.0 or higher
+* **[THRIFT-5158]** - Rust library and generator now support Rust 2021 only. Required rust 1.61.0 or higher
- The Rust `thrift` library was updated to Rust 2018 via `cargo fix --edition`.
+ The Rust `thrift` library was updated to Rust 2021 via `cargo fix --edition`.
All test code in the repo was updated as well. The code generator was also updated
- to support Rust 2018 only.
+ to support Rust 2021 only.
##### Thrift 0.13.0
* **[THRIFT-4536]** - Use TryFrom from std, required rust 1.34.0 or higher
Previously TryFrom was from try_from crate, it is now from the std library,
- but this functionality is only available in rust 1.34.0. Additionally,
- ordered-float is now re-exported under the thrift module to reduce
+ but this functionality is only available in rust 1.34.0. Additionally,
+ ordered-float is now re-exported under the thrift module to reduce
possible dependency mismatches.
##### Thrift 0.12.0
@@ -208,9 +208,9 @@
DIVIDE,
}
```
-
+
used to generate:
-
+
```rust
// OLD AUTO-GENERATED RUST
pub enum Operation {
@@ -220,9 +220,9 @@
DIVIDE,
}
```
-
+
It *now* generates:
-
+
```rust
// NEW AUTO-GENERATED RUST
pub enum Operation {
@@ -232,7 +232,7 @@
Divide,
}
```
-
+
You will have to change all enum variants in your code to use camel-cased names.
This should be a search and replace.
diff --git a/lib/rs/src/server/multiplexed.rs b/lib/rs/src/server/multiplexed.rs
index b447d38..f6811a4 100644
--- a/lib/rs/src/server/multiplexed.rs
+++ b/lib/rs/src/server/multiplexed.rs
@@ -271,10 +271,10 @@
_: &mut dyn TInputProtocol,
_: &mut dyn TOutputProtocol,
) -> crate::Result<()> {
- let res = self
- .invoked
- .compare_and_swap(false, true, Ordering::Relaxed);
- if res {
+ let res =
+ self.invoked
+ .compare_exchange(false, true, Ordering::Relaxed, Ordering::Relaxed);
+ if res.is_ok() {
Ok(())
} else {
Err("failed swap".into())
diff --git a/lib/rs/test/Cargo.toml b/lib/rs/test/Cargo.toml
index 47b8cbf..a1c6836 100644
--- a/lib/rs/test/Cargo.toml
+++ b/lib/rs/test/Cargo.toml
@@ -1,7 +1,7 @@
[package]
name = "kitchen-sink"
version = "0.1.0"
-edition = "2018"
+edition = "2021"
license = "Apache-2.0"
authors = ["Apache Thrift Developers <dev@thrift.apache.org>"]
publish = false
diff --git a/lib/rs/test_recursive/Cargo.toml b/lib/rs/test_recursive/Cargo.toml
index 6b2aa85..28dbf38 100644
--- a/lib/rs/test_recursive/Cargo.toml
+++ b/lib/rs/test_recursive/Cargo.toml
@@ -3,7 +3,7 @@
description = "Test namespace support in generated thrift files using recursive Make generation"
version = "0.1.0"
authors = ["Allen George <allengeorge@apache.org>"]
-edition = "2018"
+edition = "2021"
[dependencies]
thrift = { path = "../" }