Skip to content

Commit ce73393

Browse files
authored
chore: support sync rust (#760)
1 parent 6475c2e commit ce73393

File tree

82 files changed

+1133
-626
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

82 files changed

+1133
-626
lines changed

.github/workflows/pull.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ jobs:
5353
# Rust code generation is under development and depends on pending changes to the
5454
# Dafny Rust code generation, so we test on a specific unreleased commit instead.
5555
dafny-version:
56-
- 5f2330113320f2af0476473fd267b5b547f94cba
56+
- d07403b6d6606257e1b5aada4d0156901f4a17de
5757
uses: ./.github/workflows/test_models_rust_tests.yml
5858
with:
5959
dafny: ${{ matrix.dafny-version }}

SmithyDafnyMakefile.mk

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -193,6 +193,7 @@ transpile_implementation: SRC_INDEX_TRANSPILE=$(if $(SRC_INDEX),$(SRC_INDEX),src
193193
# Also the expectation is that verification happens in the `verify` target
194194
# `find` looks for `Index.dfy` files in either V1 or V2-styled project directories (single vs. multiple model files).
195195
transpile_implementation:
196+
dafny --version
196197
find ./dafny/**/$(SRC_INDEX_TRANSPILE)/ ./$(SRC_INDEX_TRANSPILE)/ -name 'Index.dfy' | sed -e 's/^/include "/' -e 's/$$/"/' | dafny \
197198
translate $(TARGET) \
198199
--stdin \
@@ -231,6 +232,7 @@ _transpile_test_all: TRANSPILE_DEPENDENCIES=$(if ${DIR_STRUCTURE_V2}, $(patsubst
231232
_transpile_test_all: transpile_test
232233

233234
transpile_test:
235+
dafny --version
234236
find ./dafny/**/$(TEST_INDEX_TRANSPILE) ./$(TEST_INDEX_TRANSPILE) -name "*.dfy" -name '*.dfy' | sed -e 's/^/include "/' -e 's/$$/"/' | dafny \
235237
translate $(TARGET) \
236238
--stdin \
@@ -609,7 +611,7 @@ transpile_implementation_rust: SRC_INDEX=$(RUST_SRC_INDEX)
609611
transpile_implementation_rust: TEST_INDEX=$(RUST_TEST_INDEX)
610612
# The Dafny Rust code generator is not complete yet,
611613
# so we want to emit code even if there are unsupported features in the input.
612-
transpile_implementation_rust: DAFNY_OPTIONS=--emit-uncompilable-code --allow-warnings --compile-suffix --rust-module-name implementation_from_dafny
614+
transpile_implementation_rust: DAFNY_OPTIONS=--emit-uncompilable-code --allow-warnings --compile-suffix --rust-module-name implementation_from_dafny --rust-sync
613615
# The Dafny Rust code generator only supports a single crate for everything,
614616
# so we inline all dependencies by not passing `-library` to Dafny.
615617
transpile_implementation_rust: TRANSPILE_DEPENDENCIES=
@@ -629,14 +631,15 @@ _mv_implementation_rust:
629631
# Pre-process the Dafny-generated Rust code to remove them.
630632
sed -i -e 's/[[:space:]]*$$//' runtimes/rust/src/implementation_from_dafny.rs
631633
rm -f runtimes/rust/src/implementation_from_dafny.rs-e
632-
rustfmt --edition 2021 runtimes/rust/src/implementation_from_dafny.rs
634+
# rustfmt --edition 2021 runtimes/rust/src/implementation_from_dafny.rs
633635
rm -rf implementation_from_dafny-rust
634636

635637
build_rust:
636638
cd runtimes/rust; \
637639
cargo build
638640

639641
test_rust:
642+
rustc --version
640643
cd runtimes/rust; \
641644
cargo test --release -- --nocapture
642645

@@ -776,7 +779,7 @@ local_transpile_impl_rust_single: TARGET=rs
776779
local_transpile_impl_rust_single: OUT=implementation_from_dafny
777780
local_transpile_impl_rust_single: SRC_INDEX=$(RUST_SRC_INDEX)
778781
local_transpile_impl_rust_single: TEST_INDEX=$(RUST_TEST_INDEX)
779-
local_transpile_impl_rust_single: DAFNY_OPTIONS=--emit-uncompilable-code --allow-warnings --compile-suffix
782+
local_transpile_impl_rust_single: DAFNY_OPTIONS=--emit-uncompilable-code --allow-warnings --compile-suffix --rust-sync
780783
local_transpile_impl_rust_single: TRANSPILE_DEPENDENCIES=
781784
local_transpile_impl_rust_single: STD_LIBRARY=
782785
local_transpile_impl_rust_single: SRC_INDEX_TRANSPILE=$(if $(SRC_INDEX),$(SRC_INDEX),src)

TestModels/.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,9 @@
5050
**/src/types.rs
5151
**/src/types
5252
**/target
53+
**/src/validation.rs
54+
**/src/wrapped
55+
**/src/wrapped.rs
5356

5457
# .NET Artifacts
5558
**/bin

TestModels/Aggregate/runtimes/rust/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ wrapped-client = []
1212
aws-smithy-runtime = {version = "1.6.0", features = ["client"] }
1313
aws-smithy-runtime-api = {version = "1.7.0", features = ["client"] }
1414
aws-smithy-types = "1.2.0"
15-
dafny_runtime = { path = "../../../dafny-dependencies/dafny_runtime_rust"}
15+
dafny_runtime = { path = "../../../dafny-dependencies/dafny_runtime_rust", features = ["sync"]}
1616

1717
[dev-dependencies]
1818
simple_aggregate = { path = ".", features = ["wrapped-client"] }

TestModels/CallingAWSSDKFromLocalService/runtimes/rust/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ aws-config = "1.5.8"
1313
aws-smithy-runtime = {version = "1.7.1", features=["client"]}
1414
aws-smithy-runtime-api = {version = "1.7.2", features=["client"]}
1515
aws-smithy-types = "1.2.4"
16-
dafny_runtime = { path = "../../../dafny-dependencies/dafny_runtime_rust"}
16+
dafny_runtime = { path = "../../../dafny-dependencies/dafny_runtime_rust", features = ["sync"]}
1717
aws-sdk-dynamodb = "1.50.0"
1818
aws-sdk-kms = "1.47.0"
1919

TestModels/CallingAWSSDKFromLocalService/runtimes/rust/src/ddb.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,10 +17,10 @@ static DAFNY_TOKIO_RUNTIME: LazyLock<tokio::runtime::Runtime> = LazyLock::new(||
1717

1818
#[allow(non_snake_case)]
1919
impl crate::r#software::amazon::cryptography::services::dynamodb::internaldafny::_default {
20-
pub fn DynamoDBClient() -> ::std::rc::Rc<
20+
pub fn DynamoDBClient() -> ::dafny_runtime::Rc<
2121
crate::r#_Wrappers_Compile::Result<
2222
::dafny_runtime::Object<dyn crate::r#software::amazon::cryptography::services::dynamodb::internaldafny::types::IDynamoDBClient>,
23-
::std::rc::Rc<crate::r#software::amazon::cryptography::services::dynamodb::internaldafny::types::Error>
23+
::dafny_runtime::Rc<crate::r#software::amazon::cryptography::services::dynamodb::internaldafny::types::Error>
2424
>
2525
>{
2626
let shared_config = match tokio::runtime::Handle::try_current() {
@@ -36,7 +36,7 @@ impl crate::r#software::amazon::cryptography::services::dynamodb::internaldafny:
3636
let inner = aws_sdk_dynamodb::Client::new(&shared_config);
3737
let client = crate::deps::com_amazonaws_dynamodb::client::Client { inner };
3838
let dafny_client = ::dafny_runtime::upcast_object()(::dafny_runtime::object::new(client));
39-
std::rc::Rc::new(crate::r#_Wrappers_Compile::Result::Success {
39+
dafny_runtime::Rc::new(crate::r#_Wrappers_Compile::Result::Success {
4040
value: dafny_client,
4141
})
4242
}

TestModels/CallingAWSSDKFromLocalService/runtimes/rust/src/kms.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ static DAFNY_TOKIO_RUNTIME: LazyLock<tokio::runtime::Runtime> = LazyLock::new(||
1717

1818
impl crate::r#software::amazon::cryptography::services::kms::internaldafny::_default {
1919
#[allow(non_snake_case)]
20-
pub fn KMSClient() -> ::std::rc::Rc<crate::r#_Wrappers_Compile::Result<::dafny_runtime::Object<dyn crate::software::amazon::cryptography::services::kms::internaldafny::types::IKMSClient>, ::std::rc::Rc<crate::software::amazon::cryptography::services::kms::internaldafny::types::Error>>>{
20+
pub fn KMSClient() -> ::dafny_runtime::Rc<crate::r#_Wrappers_Compile::Result<::dafny_runtime::Object<dyn crate::software::amazon::cryptography::services::kms::internaldafny::types::IKMSClient>, ::dafny_runtime::Rc<crate::software::amazon::cryptography::services::kms::internaldafny::types::Error>>>{
2121
let shared_config = match tokio::runtime::Handle::try_current() {
2222
Ok(curr) => tokio::task::block_in_place(|| {
2323
curr.block_on(async {
@@ -32,7 +32,7 @@ impl crate::r#software::amazon::cryptography::services::kms::internaldafny::_def
3232
let inner = aws_sdk_kms::Client::new(&shared_config);
3333
let client = crate::deps::com_amazonaws_kms::client::Client { inner };
3434
let dafny_client = ::dafny_runtime::upcast_object()(::dafny_runtime::object::new(client));
35-
std::rc::Rc::new(crate::r#_Wrappers_Compile::Result::Success {
35+
dafny_runtime::Rc::new(crate::r#_Wrappers_Compile::Result::Success {
3636
value: dafny_client,
3737
})
3838
}

TestModels/CallingAWSSDKFromLocalService/runtimes/rust/src/lib.rs

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
#![allow(
2-
deprecated,
3-
non_upper_case_globals,
4-
unused,
5-
non_snake_case,
6-
non_camel_case_types
2+
deprecated,
3+
non_upper_case_globals,
4+
unused,
5+
non_snake_case,
6+
non_camel_case_types
77
)]
88

99
pub mod client;
@@ -14,10 +14,10 @@ pub mod error;
1414
pub(crate) mod implementation_from_dafny;
1515
/// All operations that this crate can perform.
1616
pub mod operation;
17-
pub mod validation;
1817
mod standard_library_conversions;
1918
mod standard_library_externs;
2019
pub mod types;
20+
pub mod validation;
2121
pub mod wrapped;
2222
pub(crate) use crate::implementation_from_dafny::r#_Wrappers_Compile;
2323
pub(crate) use crate::implementation_from_dafny::simple;
@@ -30,4 +30,4 @@ pub use crate::deps::com_amazonaws_kms;
3030
pub mod ddb;
3131
pub mod kms;
3232

33-
pub(crate) use crate::implementation_from_dafny::software;
33+
pub(crate) use crate::implementation_from_dafny::software;

TestModels/Constraints/runtimes/rust/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ wrapped-client = []
1212
aws-smithy-runtime = {version = "1.7.1", features=["client"]}
1313
aws-smithy-runtime-api = {version = "1.7.2", features=["client"]}
1414
aws-smithy-types = "1.2.4"
15-
dafny_runtime = { path = "../../../dafny-dependencies/dafny_runtime_rust"}
15+
dafny_runtime = { path = "../../../dafny-dependencies/dafny_runtime_rust", features = ["sync"]}
1616

1717
[dependencies.tokio]
1818
version = "1.26.0"

TestModels/Constructor/runtimes/rust/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ wrapped-client = []
1111
[dependencies]
1212
aws-smithy-runtime-api = {version = "1.7.0", features = ["client"] }
1313
aws-smithy-types = "1.2.0"
14-
dafny_runtime = { path = "../../../dafny-dependencies/dafny_runtime_rust"}
14+
dafny_runtime = { path = "../../../dafny-dependencies/dafny_runtime_rust", features = ["sync"]}
1515

1616
[dev-dependencies]
1717
constructor = { path = ".", features = ["wrapped-client"] }

0 commit comments

Comments
 (0)