summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorJiayu Liu <jiayu@hey.com>2022-06-26 05:00:25 +0200
committerJens Geyer <jensg@apache.org>2022-09-05 22:56:04 +0200
commitaa85593c89b540b821b07f7611f5ac5de29c6665 (patch)
treededa02ddea251fcfe859ffbf8c82d853be145911 /lib
parentf066d84ffb7fe2eb0dc3b7e7cd0d0417a1ae7963 (diff)
downloadthrift-aa85593c89b540b821b07f7611f5ac5de29c6665.tar.gz
THRIFT-5600: rust lib to upgrade to edition 2021
Client: rs Patch: Jiayu Liu This closes #2628
Diffstat (limited to 'lib')
-rw-r--r--lib/rs/README.md30
-rw-r--r--lib/rs/src/server/multiplexed.rs8
-rw-r--r--lib/rs/test/Cargo.toml2
-rw-r--r--lib/rs/test_recursive/Cargo.toml2
4 files changed, 21 insertions, 21 deletions
diff --git a/lib/rs/README.md b/lib/rs/README.md
index 30e36d434..010bb17a3 100644
--- a/lib/rs/README.md
+++ b/lib/rs/README.md
@@ -40,7 +40,7 @@ Full [Rustdoc](https://docs.rs/thrift/)
## 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 @@ Breaking changes are minimized. When they are made they will be outlined below w
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 @@ Breaking changes are minimized. When they are made they will be outlined below w
```
used to generate:
-
+
```rust
// OLD AUTO-GENERATED RUST
pub enum Operation {
@@ -162,11 +162,11 @@ Breaking changes are minimized. When they are made they will be outlined below w
```
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 @@ Breaking changes are minimized. When they are made they will be outlined below w
##### 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 @@ Breaking changes are minimized. When they are made they will be outlined below w
DIVIDE,
}
```
-
+
used to generate:
-
+
```rust
// OLD AUTO-GENERATED RUST
pub enum Operation {
@@ -220,9 +220,9 @@ Breaking changes are minimized. When they are made they will be outlined below w
DIVIDE,
}
```
-
+
It *now* generates:
-
+
```rust
// NEW AUTO-GENERATED RUST
pub enum Operation {
@@ -232,7 +232,7 @@ Breaking changes are minimized. When they are made they will be outlined below w
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 b447d387e..f6811a42d 100644
--- a/lib/rs/src/server/multiplexed.rs
+++ b/lib/rs/src/server/multiplexed.rs
@@ -271,10 +271,10 @@ mod tests {
_: &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 47b8cbf7a..a1c6836da 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 6b2aa8591..28dbf385f 100644
--- a/lib/rs/test_recursive/Cargo.toml
+++ b/lib/rs/test_recursive/Cargo.toml
@@ -3,7 +3,7 @@ name = "thrift_4098_custom_rust_namespace_support"
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 = "../" }