mirror of
https://github.com/valitydev/thrift.git
synced 2024-11-06 10:25:18 +00:00
THRIFT-5600: rust lib to upgrade to edition 2021
Client: rs Patch: Jiayu Liu This closes #2628
This commit is contained in:
parent
f066d84ffb
commit
aa85593c89
@ -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.
|
||||
|
||||
|
@ -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())
|
||||
|
@ -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
|
||||
|
@ -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 = "../" }
|
||||
|
@ -1,7 +1,7 @@
|
||||
[package]
|
||||
name = "thrift-test"
|
||||
version = "0.1.0"
|
||||
edition = "2018"
|
||||
edition = "2021"
|
||||
license = "Apache-2.0"
|
||||
authors = ["Apache Thrift Developers <dev@thrift.apache.org>"]
|
||||
publish = false
|
||||
|
@ -254,7 +254,7 @@ impl ThriftTestSyncHandler for ThriftTestSyncHandlerImpl {
|
||||
info!("testMapMap({})", hello);
|
||||
|
||||
let mut inner_map_0: BTreeMap<i32, i32> = BTreeMap::new();
|
||||
for i in -4..0 {
|
||||
for i in -4..0_i32 {
|
||||
inner_map_0.insert(i, i);
|
||||
}
|
||||
|
||||
|
@ -15,5 +15,11 @@
|
||||
// specific language governing permissions and limitations
|
||||
// under the License.
|
||||
|
||||
// FIXME - need changes in gen before lifting this exception
|
||||
#![allow(
|
||||
clippy::match_single_binding,
|
||||
clippy::unnecessary_wraps,
|
||||
clippy::derivable_impls
|
||||
)]
|
||||
mod thrift_test;
|
||||
pub use crate::thrift_test::*;
|
||||
|
@ -1,7 +1,7 @@
|
||||
[package]
|
||||
name = "thrift-tutorial"
|
||||
version = "0.1.0"
|
||||
edition = "2018"
|
||||
edition = "2021"
|
||||
license = "Apache-2.0"
|
||||
authors = ["Apache Thrift Developers <dev@thrift.apache.org>"]
|
||||
exclude = ["Makefile*", "shared.rs", "tutorial.rs"]
|
||||
|
Loading…
Reference in New Issue
Block a user