From 2ffb98dd1d1ad40f9944f6ca9c56b06e73697efb Mon Sep 17 00:00:00 2001 From: Robin Salkeld Date: Tue, 25 Jun 2024 11:19:21 -0700 Subject: [PATCH 01/53] Progress --- .../rust/src/implementation_from_dafny.rs | 641 ++++++++++++++++++ .../SimpleBoolean/runtimes/rust/src/lib.rs | 3 + .../runtimes/rust/src/wrapped.rs | 6 + .../rust/tests/simple_boolean_test.rs | 9 + .../rust/tests/tests_from_dafny/mod.rs | 288 ++++++++ 5 files changed, 947 insertions(+) create mode 100644 TestModels/SimpleTypes/SimpleBoolean/runtimes/rust/src/implementation_from_dafny.rs create mode 100644 TestModels/SimpleTypes/SimpleBoolean/runtimes/rust/src/wrapped.rs create mode 100644 TestModels/SimpleTypes/SimpleBoolean/runtimes/rust/tests/tests_from_dafny/mod.rs diff --git a/TestModels/SimpleTypes/SimpleBoolean/runtimes/rust/src/implementation_from_dafny.rs b/TestModels/SimpleTypes/SimpleBoolean/runtimes/rust/src/implementation_from_dafny.rs new file mode 100644 index 0000000000..b206ae102b --- /dev/null +++ b/TestModels/SimpleTypes/SimpleBoolean/runtimes/rust/src/implementation_from_dafny.rs @@ -0,0 +1,641 @@ +#![allow(warnings, unconditional_panic)] +#![allow(nonstandard_style)] +pub use dafny_standard_library::implementation_from_dafny::*; + +pub mod r#_simple_dtypes_dboolean_dinternaldafny_dtypes { + #[derive(PartialEq, Clone)] + pub enum DafnyCallEvent { + DafnyCallEvent { input: I, output: O }, + _PhantomVariant(::std::marker::PhantomData, ::std::marker::PhantomData), + } + + impl DafnyCallEvent { + pub fn input(&self) -> &I { + match self { + DafnyCallEvent::DafnyCallEvent { input, output } => input, + DafnyCallEvent::_PhantomVariant(..) => panic!(), + } + } + pub fn output(&self) -> &O { + match self { + DafnyCallEvent::DafnyCallEvent { input, output } => output, + DafnyCallEvent::_PhantomVariant(..) => panic!(), + } + } + } + + impl ::std::fmt::Debug + for DafnyCallEvent + { + fn fmt(&self, f: &mut ::std::fmt::Formatter) -> std::fmt::Result { + ::dafny_runtime::DafnyPrint::fmt_print(self, f, true) + } + } + + impl ::dafny_runtime::DafnyPrint + for DafnyCallEvent + { + fn fmt_print( + &self, + _formatter: &mut ::std::fmt::Formatter, + _in_seq: bool, + ) -> std::fmt::Result { + match self { + DafnyCallEvent::DafnyCallEvent { input, output } => { + write!(_formatter, "r#_simple_dtypes_dboolean_dinternaldafny_dtypes.DafnyCallEvent.DafnyCallEvent(")?; + ::dafny_runtime::DafnyPrint::fmt_print(input, _formatter, false)?; + write!(_formatter, ", ")?; + ::dafny_runtime::DafnyPrint::fmt_print(output, _formatter, false)?; + write!(_formatter, ")")?; + Ok(()) + } + DafnyCallEvent::_PhantomVariant(..) => { + panic!() + } + } + } + } + + impl Eq + for DafnyCallEvent + { + } + + impl< + I: ::dafny_runtime::DafnyType + ::std::hash::Hash, + O: ::dafny_runtime::DafnyType + ::std::hash::Hash, + > ::std::hash::Hash for DafnyCallEvent + { + fn hash<_H: ::std::hash::Hasher>(&self, _state: &mut _H) { + match self { + DafnyCallEvent::DafnyCallEvent { input, output } => { + input.hash(_state); + output.hash(_state) + } + DafnyCallEvent::_PhantomVariant(..) => { + panic!() + } + } + } + } + + impl< + I: ::dafny_runtime::DafnyType + ::std::default::Default, + O: ::dafny_runtime::DafnyType + ::std::default::Default, + > ::std::default::Default for DafnyCallEvent + { + fn default() -> DafnyCallEvent { + DafnyCallEvent::DafnyCallEvent { + input: ::std::default::Default::default(), + output: ::std::default::Default::default(), + } + } + } + + impl + ::std::convert::AsRef> for &DafnyCallEvent + { + fn as_ref(&self) -> Self { + self + } + } + + #[derive(PartialEq, Clone)] + pub enum GetBooleanInput { + GetBooleanInput { + value: ::std::rc::Rc>, + }, + } + + impl GetBooleanInput { + pub fn value(&self) -> &::std::rc::Rc> { + match self { + GetBooleanInput::GetBooleanInput { value } => value, + } + } + } + + impl ::std::fmt::Debug for GetBooleanInput { + fn fmt(&self, f: &mut ::std::fmt::Formatter) -> std::fmt::Result { + ::dafny_runtime::DafnyPrint::fmt_print(self, f, true) + } + } + + impl ::dafny_runtime::DafnyPrint for GetBooleanInput { + fn fmt_print( + &self, + _formatter: &mut ::std::fmt::Formatter, + _in_seq: bool, + ) -> std::fmt::Result { + match self { + GetBooleanInput::GetBooleanInput { value } => { + write!(_formatter, "r#_simple_dtypes_dboolean_dinternaldafny_dtypes.GetBooleanInput.GetBooleanInput(")?; + ::dafny_runtime::DafnyPrint::fmt_print(value, _formatter, false)?; + write!(_formatter, ")")?; + Ok(()) + } + } + } + } + + impl Eq for GetBooleanInput {} + + impl ::std::hash::Hash for GetBooleanInput { + fn hash<_H: ::std::hash::Hasher>(&self, _state: &mut _H) { + match self { + GetBooleanInput::GetBooleanInput { value } => value.hash(_state), + } + } + } + + impl ::std::default::Default for GetBooleanInput { + fn default() -> GetBooleanInput { + GetBooleanInput::GetBooleanInput { + value: ::std::default::Default::default(), + } + } + } + + impl ::std::convert::AsRef for &GetBooleanInput { + fn as_ref(&self) -> Self { + self + } + } + + #[derive(PartialEq, Clone)] + pub enum GetBooleanOutput { + GetBooleanOutput { + value: ::std::rc::Rc>, + }, + } + + impl GetBooleanOutput { + pub fn value(&self) -> &::std::rc::Rc> { + match self { + GetBooleanOutput::GetBooleanOutput { value } => value, + } + } + } + + impl ::std::fmt::Debug for GetBooleanOutput { + fn fmt(&self, f: &mut ::std::fmt::Formatter) -> std::fmt::Result { + ::dafny_runtime::DafnyPrint::fmt_print(self, f, true) + } + } + + impl ::dafny_runtime::DafnyPrint for GetBooleanOutput { + fn fmt_print( + &self, + _formatter: &mut ::std::fmt::Formatter, + _in_seq: bool, + ) -> std::fmt::Result { + match self { + GetBooleanOutput::GetBooleanOutput { value } => { + write!(_formatter, "r#_simple_dtypes_dboolean_dinternaldafny_dtypes.GetBooleanOutput.GetBooleanOutput(")?; + ::dafny_runtime::DafnyPrint::fmt_print(value, _formatter, false)?; + write!(_formatter, ")")?; + Ok(()) + } + } + } + } + + impl Eq for GetBooleanOutput {} + + impl ::std::hash::Hash for GetBooleanOutput { + fn hash<_H: ::std::hash::Hasher>(&self, _state: &mut _H) { + match self { + GetBooleanOutput::GetBooleanOutput { value } => value.hash(_state), + } + } + } + + impl ::std::default::Default for GetBooleanOutput { + fn default() -> GetBooleanOutput { + GetBooleanOutput::GetBooleanOutput { + value: ::std::default::Default::default(), + } + } + } + + impl ::std::convert::AsRef for &GetBooleanOutput { + fn as_ref(&self) -> Self { + self + } + } + + #[derive(PartialEq, Clone)] + pub enum SimpleBooleanConfig { + SimpleBooleanConfig {}, + } + + impl SimpleBooleanConfig {} + + impl ::std::fmt::Debug for SimpleBooleanConfig { + fn fmt(&self, f: &mut ::std::fmt::Formatter) -> std::fmt::Result { + ::dafny_runtime::DafnyPrint::fmt_print(self, f, true) + } + } + + impl ::dafny_runtime::DafnyPrint for SimpleBooleanConfig { + fn fmt_print( + &self, + _formatter: &mut ::std::fmt::Formatter, + _in_seq: bool, + ) -> std::fmt::Result { + match self { + SimpleBooleanConfig::SimpleBooleanConfig {} => { + write!(_formatter, "r#_simple_dtypes_dboolean_dinternaldafny_dtypes.SimpleBooleanConfig.SimpleBooleanConfig")?; + Ok(()) + } + } + } + } + + impl Eq for SimpleBooleanConfig {} + + impl ::std::hash::Hash for SimpleBooleanConfig { + fn hash<_H: ::std::hash::Hasher>(&self, _state: &mut _H) { + match self { + SimpleBooleanConfig::SimpleBooleanConfig {} => {} + } + } + } + + impl ::std::default::Default for SimpleBooleanConfig { + fn default() -> SimpleBooleanConfig { + SimpleBooleanConfig::SimpleBooleanConfig {} + } + } + + impl ::std::convert::AsRef for &SimpleBooleanConfig { + fn as_ref(&self) -> Self { + self + } + } + + pub struct ISimpleTypesBooleanClientCallHistory {} + + impl ISimpleTypesBooleanClientCallHistory { + pub fn _allocate_rcmut() -> ::dafny_runtime::Object { + ::dafny_runtime::allocate_rcmut::() + } + } + + pub trait ISimpleTypesBooleanClient { + fn GetBoolean( + &mut self, + input: &::std::rc::Rc< + super::r#_simple_dtypes_dboolean_dinternaldafny_dtypes::GetBooleanInput, + >, + ) -> ::std::rc::Rc< + super::r#_Wrappers_Compile::Result< + ::std::rc::Rc< + super::r#_simple_dtypes_dboolean_dinternaldafny_dtypes::GetBooleanOutput, + >, + ::std::rc::Rc, + >, + >; + } + + #[derive(PartialEq, Clone)] + pub enum Error { + CollectionOfErrors { + list: ::dafny_runtime::Sequence< + ::std::rc::Rc, + >, + message: ::dafny_runtime::Sequence<::dafny_runtime::DafnyCharUTF16>, + }, + Opaque { + obj: ::dafny_runtime::Object, + }, + } + + impl Error { + pub fn list( + &self, + ) -> &::dafny_runtime::Sequence< + ::std::rc::Rc, + > { + match self { + Error::CollectionOfErrors { list, message } => list, + Error::Opaque { obj } => panic!("field does not exist on this variant"), + } + } + pub fn message(&self) -> &::dafny_runtime::Sequence<::dafny_runtime::DafnyCharUTF16> { + match self { + Error::CollectionOfErrors { list, message } => message, + Error::Opaque { obj } => panic!("field does not exist on this variant"), + } + } + pub fn obj(&self) -> &::dafny_runtime::Object { + match self { + Error::CollectionOfErrors { list, message } => { + panic!("field does not exist on this variant") + } + Error::Opaque { obj } => obj, + } + } + } + + impl ::std::fmt::Debug for Error { + fn fmt(&self, f: &mut ::std::fmt::Formatter) -> std::fmt::Result { + ::dafny_runtime::DafnyPrint::fmt_print(self, f, true) + } + } + + impl ::dafny_runtime::DafnyPrint for Error { + fn fmt_print( + &self, + _formatter: &mut ::std::fmt::Formatter, + _in_seq: bool, + ) -> std::fmt::Result { + match self { + Error::CollectionOfErrors { list, message } => { + write!( + _formatter, + "r#_simple_dtypes_dboolean_dinternaldafny_dtypes.Error.CollectionOfErrors(" + )?; + ::dafny_runtime::DafnyPrint::fmt_print(list, _formatter, false)?; + write!(_formatter, ", ")?; + ::dafny_runtime::DafnyPrint::fmt_print(message, _formatter, false)?; + write!(_formatter, ")")?; + Ok(()) + } + Error::Opaque { obj } => { + write!( + _formatter, + "r#_simple_dtypes_dboolean_dinternaldafny_dtypes.Error.Opaque(" + )?; + ::dafny_runtime::DafnyPrint::fmt_print(obj, _formatter, false)?; + write!(_formatter, ")")?; + Ok(()) + } + } + } + } + + impl Eq for Error {} + + impl ::std::hash::Hash for Error { + fn hash<_H: ::std::hash::Hasher>(&self, _state: &mut _H) { + match self { + Error::CollectionOfErrors { list, message } => { + list.hash(_state); + message.hash(_state) + } + Error::Opaque { obj } => obj.hash(_state), + } + } + } + + impl ::std::default::Default for Error { + fn default() -> Error { + Error::CollectionOfErrors { + list: ::std::default::Default::default(), + message: ::std::default::Default::default(), + } + } + } + + impl ::std::convert::AsRef for &Error { + fn as_ref(&self) -> Self { + self + } + } + + pub type OpaqueError = + ::std::rc::Rc; +} +pub mod r#_SimpleBooleanImpl_Compile { + pub struct _default {} + + impl _default { + pub fn _allocate_rcmut() -> ::dafny_runtime::Object { + ::dafny_runtime::allocate_rcmut::() + } + pub fn GetBoolean( + config: &::std::rc::Rc, + input: &::std::rc::Rc< + super::r#_simple_dtypes_dboolean_dinternaldafny_dtypes::GetBooleanInput, + >, + ) -> ::std::rc::Rc< + super::r#_Wrappers_Compile::Result< + ::std::rc::Rc< + super::r#_simple_dtypes_dboolean_dinternaldafny_dtypes::GetBooleanOutput, + >, + ::std::rc::Rc, + >, + > { + let mut output = ::dafny_runtime::MaybePlacebo::<::std::rc::Rc, ::std::rc::Rc>>>::new(); + if !matches!( + input.value().as_ref(), + super::r#_Wrappers_Compile::Option::Some { .. } + ) { + panic!("Halt") + }; + if !(input.value().value().clone() == true || input.value().value().clone() == false) { + panic!("Halt") + }; + let mut res: ::std::rc::Rc = ::std::rc::Rc::new(super::r#_simple_dtypes_dboolean_dinternaldafny_dtypes::GetBooleanOutput::GetBooleanOutput { + value: input.value().clone() + }); + res = ::std::rc::Rc::new(super::r#_simple_dtypes_dboolean_dinternaldafny_dtypes::GetBooleanOutput::GetBooleanOutput { + value: input.value().clone() + }); + if !(res.value().value().clone() == true || res.value().value().clone() == false) { + panic!("Halt") + }; + if !(input.value().value().clone() == res.value().value().clone()) { + panic!("Halt") + }; + output = ::dafny_runtime::MaybePlacebo::from(::std::rc::Rc::new( + super::r#_Wrappers_Compile::Result::< + ::std::rc::Rc< + super::r#_simple_dtypes_dboolean_dinternaldafny_dtypes::GetBooleanOutput, + >, + ::std::rc::Rc, + >::Success { + value: res.clone(), + }, + )); + return output.read(); + return output.read(); + } + } + + #[derive(PartialEq, Clone)] + pub enum Config { + Config {}, + } + + impl Config {} + + impl ::std::fmt::Debug for Config { + fn fmt(&self, f: &mut ::std::fmt::Formatter) -> std::fmt::Result { + ::dafny_runtime::DafnyPrint::fmt_print(self, f, true) + } + } + + impl ::dafny_runtime::DafnyPrint for Config { + fn fmt_print( + &self, + _formatter: &mut ::std::fmt::Formatter, + _in_seq: bool, + ) -> std::fmt::Result { + match self { + Config::Config {} => { + write!(_formatter, "r#_SimpleBooleanImpl_Compile.Config.Config")?; + Ok(()) + } + } + } + } + + impl Eq for Config {} + + impl ::std::hash::Hash for Config { + fn hash<_H: ::std::hash::Hasher>(&self, _state: &mut _H) { + match self { + Config::Config {} => {} + } + } + } + + impl ::std::default::Default for Config { + fn default() -> Config { + Config::Config {} + } + } + + impl ::std::convert::AsRef for &Config { + fn as_ref(&self) -> Self { + self + } + } +} +pub mod r#_simple_dtypes_dboolean_dinternaldafny { + pub struct _default {} + + impl _default { + pub fn _allocate_rcmut() -> ::dafny_runtime::Object { + ::dafny_runtime::allocate_rcmut::() + } + pub fn DefaultSimpleBooleanConfig() -> ::std::rc::Rc< + super::r#_simple_dtypes_dboolean_dinternaldafny_dtypes::SimpleBooleanConfig, + > { + ::std::rc::Rc::new(super::r#_simple_dtypes_dboolean_dinternaldafny_dtypes::SimpleBooleanConfig::SimpleBooleanConfig {}) + } + pub fn SimpleBoolean( + config: &::std::rc::Rc< + super::r#_simple_dtypes_dboolean_dinternaldafny_dtypes::SimpleBooleanConfig, + >, + ) -> ::std::rc::Rc< + super::r#_Wrappers_Compile::Result< + ::dafny_runtime::Object< + super::r#_simple_dtypes_dboolean_dinternaldafny::SimpleBooleanClient, + >, + ::std::rc::Rc, + >, + > { + let mut res = ::dafny_runtime::MaybePlacebo::< + ::std::rc::Rc< + super::r#_Wrappers_Compile::Result< + ::dafny_runtime::Object< + super::r#_simple_dtypes_dboolean_dinternaldafny::SimpleBooleanClient, + >, + ::std::rc::Rc< + super::r#_simple_dtypes_dboolean_dinternaldafny_dtypes::Error, + >, + >, + >, + >::new(); + let mut client = ::dafny_runtime::MaybePlacebo::< + ::dafny_runtime::Object< + super::r#_simple_dtypes_dboolean_dinternaldafny::SimpleBooleanClient, + >, + >::new(); + let mut _nw0: ::dafny_runtime::Object = super::r#_simple_dtypes_dboolean_dinternaldafny::SimpleBooleanClient::_allocate_rcmut(); + super::r#_simple_dtypes_dboolean_dinternaldafny::SimpleBooleanClient::_ctor( + &_nw0, + &::std::rc::Rc::new(super::r#_SimpleBooleanImpl_Compile::Config::Config {}), + ); + client = ::dafny_runtime::MaybePlacebo::from(_nw0.clone()); + res = ::dafny_runtime::MaybePlacebo::from(::std::rc::Rc::new( + super::r#_Wrappers_Compile::Result::< + ::dafny_runtime::Object< + super::r#_simple_dtypes_dboolean_dinternaldafny::SimpleBooleanClient, + >, + ::std::rc::Rc, + >::Success { + value: client.read(), + }, + )); + return res.read(); + return res.read(); + } + pub fn CreateSuccessOfClient(client: &::dafny_runtime::Object) -> ::std::rc::Rc, ::std::rc::Rc>>{ + ::std::rc::Rc::new(super::r#_Wrappers_Compile::Result::<::dafny_runtime::Object, ::std::rc::Rc>::Success { + value: client.clone() + }) + } + pub fn CreateFailureOfError(error: &::std::rc::Rc) -> ::std::rc::Rc, ::std::rc::Rc>>{ + ::std::rc::Rc::new(super::r#_Wrappers_Compile::Result::<::dafny_runtime::Object, ::std::rc::Rc>::Failure { + error: error.clone() + }) + } + } + + pub struct SimpleBooleanClient { + pub r#__i_config: ::std::rc::Rc, + } + + impl SimpleBooleanClient { + pub fn _allocate_rcmut() -> ::dafny_runtime::Object { + ::dafny_runtime::allocate_rcmut::() + } + pub fn _ctor( + this: &::dafny_runtime::Object, + config: &::std::rc::Rc, + ) -> () { + let mut _set__i_config: bool = false; + ::dafny_runtime::update_field_uninit_rcmut!( + this.clone(), + r#__i_config, + _set__i_config, + config.clone() + ); + return (); + } + pub fn config(&self) -> ::std::rc::Rc { + self.r#__i_config.clone() + } + } + + impl super::r#_simple_dtypes_dboolean_dinternaldafny_dtypes::ISimpleTypesBooleanClient + for super::r#_simple_dtypes_dboolean_dinternaldafny::SimpleBooleanClient + { + fn GetBoolean( + &mut self, + input: &::std::rc::Rc< + super::r#_simple_dtypes_dboolean_dinternaldafny_dtypes::GetBooleanInput, + >, + ) -> ::std::rc::Rc< + super::r#_Wrappers_Compile::Result< + ::std::rc::Rc< + super::r#_simple_dtypes_dboolean_dinternaldafny_dtypes::GetBooleanOutput, + >, + ::std::rc::Rc, + >, + > { + let mut output = ::dafny_runtime::MaybePlacebo::<::std::rc::Rc, ::std::rc::Rc>>>::new(); + let mut _out0 = ::dafny_runtime::MaybePlacebo::<::std::rc::Rc, ::std::rc::Rc>>>::new(); + _out0 = ::dafny_runtime::MaybePlacebo::from( + super::r#_SimpleBooleanImpl_Compile::_default::GetBoolean(&self.config(), input), + ); + output = ::dafny_runtime::MaybePlacebo::from(_out0.read()); + return output.read(); + } + } +} +pub mod _module {} diff --git a/TestModels/SimpleTypes/SimpleBoolean/runtimes/rust/src/lib.rs b/TestModels/SimpleTypes/SimpleBoolean/runtimes/rust/src/lib.rs index 1d16c1915c..3990657aa5 100644 --- a/TestModels/SimpleTypes/SimpleBoolean/runtimes/rust/src/lib.rs +++ b/TestModels/SimpleTypes/SimpleBoolean/runtimes/rust/src/lib.rs @@ -13,5 +13,8 @@ pub mod operation; mod conversions; +pub mod implementation_from_dafny; +mod wrapped; + pub use client::Client; pub use types::simple_boolean_config::SimpleBooleanConfig; diff --git a/TestModels/SimpleTypes/SimpleBoolean/runtimes/rust/src/wrapped.rs b/TestModels/SimpleTypes/SimpleBoolean/runtimes/rust/src/wrapped.rs new file mode 100644 index 0000000000..a063ea7d37 --- /dev/null +++ b/TestModels/SimpleTypes/SimpleBoolean/runtimes/rust/src/wrapped.rs @@ -0,0 +1,6 @@ +impl crate::r#_simple_dtypes_dboolean_dinternaldafny_dwrapped::_default { + pub fn WrappedSimpleBoolean() { + + } + +} \ No newline at end of file diff --git a/TestModels/SimpleTypes/SimpleBoolean/runtimes/rust/tests/simple_boolean_test.rs b/TestModels/SimpleTypes/SimpleBoolean/runtimes/rust/tests/simple_boolean_test.rs index 8f5a0166c1..7092b9ac16 100644 --- a/TestModels/SimpleTypes/SimpleBoolean/runtimes/rust/tests/simple_boolean_test.rs +++ b/TestModels/SimpleTypes/SimpleBoolean/runtimes/rust/tests/simple_boolean_test.rs @@ -1,4 +1,8 @@ use simple_boolean::*; + + +mod tests_from_dafny; + /* method{:test} GetBooleanTrue(){ var client :- expect SimpleBoolean.SimpleBoolean(); @@ -50,3 +54,8 @@ pub fn client() -> Client { let config = SimpleBooleanConfig::builder().build().unwrap(); Client::from_conf(config).unwrap() } + +#[tokio::test] +async fn dafny_tests() { + crate::tests_from_dafny::_module::_default::_Test__Main_() +} diff --git a/TestModels/SimpleTypes/SimpleBoolean/runtimes/rust/tests/tests_from_dafny/mod.rs b/TestModels/SimpleTypes/SimpleBoolean/runtimes/rust/tests/tests_from_dafny/mod.rs new file mode 100644 index 0000000000..e09a52c221 --- /dev/null +++ b/TestModels/SimpleTypes/SimpleBoolean/runtimes/rust/tests/tests_from_dafny/mod.rs @@ -0,0 +1,288 @@ +#![allow(warnings, unconditional_panic)] +#![allow(nonstandard_style)] +use simple_boolean::*; +use simple_boolean::implementation_from_dafny::*; +pub mod r#_simple_dtypes_dboolean_dinternaldafny_dwrapped { + pub struct _default {} + + impl _default { + pub fn _allocate_rcmut() -> ::dafny_runtime::Object { + ::dafny_runtime::allocate_rcmut::() + } + pub fn WrappedDefaultSimpleBooleanConfig() -> ::std::rc::Rc< + super::r#_simple_dtypes_dboolean_dinternaldafny_dtypes::SimpleBooleanConfig, + > { + ::std::rc::Rc::new(super::r#_simple_dtypes_dboolean_dinternaldafny_dtypes::SimpleBooleanConfig::SimpleBooleanConfig {}) + } + } +} +pub mod r#_SimpleBooleanImplTest_Compile { + pub struct _default {} + + impl _default { + pub fn _allocate_rcmut() -> ::dafny_runtime::Object { + ::dafny_runtime::allocate_rcmut::() + } + pub fn GetBooleanTrue() -> () { + let mut client = ::dafny_runtime::MaybePlacebo::< + ::dafny_runtime::Object< + super::r#_simple_dtypes_dboolean_dinternaldafny::SimpleBooleanClient, + >, + >::new(); + let mut valueOrError0 = ::dafny_runtime::MaybePlacebo::< + ::std::rc::Rc< + super::r#_Wrappers_Compile::Result< + ::dafny_runtime::Object< + super::r#_simple_dtypes_dboolean_dinternaldafny::SimpleBooleanClient, + >, + ::std::rc::Rc< + super::r#_simple_dtypes_dboolean_dinternaldafny_dtypes::Error, + >, + >, + >, + >::new(); + let mut _out0 = ::dafny_runtime::MaybePlacebo::< + ::std::rc::Rc< + super::r#_Wrappers_Compile::Result< + ::dafny_runtime::Object< + super::r#_simple_dtypes_dboolean_dinternaldafny::SimpleBooleanClient, + >, + ::std::rc::Rc< + super::r#_simple_dtypes_dboolean_dinternaldafny_dtypes::Error, + >, + >, + >, + >::new(); + _out0 = ::dafny_runtime::MaybePlacebo::from(super::r#_simple_dtypes_dboolean_dinternaldafny::_default::SimpleBoolean(&super::r#_simple_dtypes_dboolean_dinternaldafny::_default::DefaultSimpleBooleanConfig())); + valueOrError0 = ::dafny_runtime::MaybePlacebo::from(_out0.read()); + if !(!valueOrError0.read().IsFailure()) { + panic!("Halt") + }; + client = ::dafny_runtime::MaybePlacebo::from( + valueOrError0.read().Extract().clone(), /* Coercion from T to ::dafny_runtime::Object not yet implemented */ + ); + super::r#_SimpleBooleanImplTest_Compile::_default::TestGetBooleanTrue(&::dafny_runtime::UpcastTo::<::dafny_runtime::Object>::upcast_to(&client.read())); + return (); + } + pub fn GetBooleanFalse() -> () { + let mut client = ::dafny_runtime::MaybePlacebo::< + ::dafny_runtime::Object< + super::r#_simple_dtypes_dboolean_dinternaldafny::SimpleBooleanClient, + >, + >::new(); + let mut valueOrError0 = ::dafny_runtime::MaybePlacebo::< + ::std::rc::Rc< + super::r#_Wrappers_Compile::Result< + ::dafny_runtime::Object< + super::r#_simple_dtypes_dboolean_dinternaldafny::SimpleBooleanClient, + >, + ::std::rc::Rc< + super::r#_simple_dtypes_dboolean_dinternaldafny_dtypes::Error, + >, + >, + >, + >::new(); + let mut _out1 = ::dafny_runtime::MaybePlacebo::< + ::std::rc::Rc< + super::r#_Wrappers_Compile::Result< + ::dafny_runtime::Object< + super::r#_simple_dtypes_dboolean_dinternaldafny::SimpleBooleanClient, + >, + ::std::rc::Rc< + super::r#_simple_dtypes_dboolean_dinternaldafny_dtypes::Error, + >, + >, + >, + >::new(); + _out1 = ::dafny_runtime::MaybePlacebo::from(super::r#_simple_dtypes_dboolean_dinternaldafny::_default::SimpleBoolean(&super::r#_simple_dtypes_dboolean_dinternaldafny::_default::DefaultSimpleBooleanConfig())); + valueOrError0 = ::dafny_runtime::MaybePlacebo::from(_out1.read()); + if !(!valueOrError0.read().IsFailure()) { + panic!("Halt") + }; + client = ::dafny_runtime::MaybePlacebo::from( + valueOrError0.read().Extract().clone(), /* Coercion from T to ::dafny_runtime::Object not yet implemented */ + ); + super::r#_SimpleBooleanImplTest_Compile::_default::TestGetBooleanFalse(&::dafny_runtime::UpcastTo::<::dafny_runtime::Object>::upcast_to(&client.read())); + return (); + } + pub fn TestGetBooleanTrue( + client: &::dafny_runtime::Object, + ) -> () { + let mut ret = ::dafny_runtime::MaybePlacebo::< + ::std::rc::Rc< + super::r#_simple_dtypes_dboolean_dinternaldafny_dtypes::GetBooleanOutput, + >, + >::new(); + let mut valueOrError0 = ::dafny_runtime::MaybePlacebo::<::std::rc::Rc, ::std::rc::Rc>>>::new(); + let mut _out2 = ::dafny_runtime::MaybePlacebo::<::std::rc::Rc, ::std::rc::Rc>>>::new(); + _out2 = ::dafny_runtime::MaybePlacebo::from(::dafny_runtime::md!(client).GetBoolean(&::std::rc::Rc::new(super::r#_simple_dtypes_dboolean_dinternaldafny_dtypes::GetBooleanInput::GetBooleanInput { + value: ::std::rc::Rc::new(super::r#_Wrappers_Compile::Option::::Some { + value: true + }) + }))); + valueOrError0 = ::dafny_runtime::MaybePlacebo::from(_out2.read()); + if !(!valueOrError0.read().IsFailure()) { + panic!("Halt") + }; + ret = ::dafny_runtime::MaybePlacebo::from( + valueOrError0.read().Extract(), /* Coercion from T to ::std::rc::Rc not yet implemented */ + ); + if !((ret.read().value().UnwrapOr( + &false, /* Coercion from bool to T not yet implemented */ + )/* Coercion from T to bool not yet implemented */) + == true) + { + panic!("Halt") + }; + print!("{}", ::dafny_runtime::DafnyPrintWrapper(&ret.read())); + return (); + } + pub fn TestGetBooleanFalse( + client: &::dafny_runtime::Object, + ) -> () { + let mut ret = ::dafny_runtime::MaybePlacebo::< + ::std::rc::Rc< + super::r#_simple_dtypes_dboolean_dinternaldafny_dtypes::GetBooleanOutput, + >, + >::new(); + let mut valueOrError0 = ::dafny_runtime::MaybePlacebo::<::std::rc::Rc, ::std::rc::Rc>>>::new(); + let mut _out3 = ::dafny_runtime::MaybePlacebo::<::std::rc::Rc, ::std::rc::Rc>>>::new(); + _out3 = ::dafny_runtime::MaybePlacebo::from(::dafny_runtime::md!(client).GetBoolean(&::std::rc::Rc::new(super::r#_simple_dtypes_dboolean_dinternaldafny_dtypes::GetBooleanInput::GetBooleanInput { + value: ::std::rc::Rc::new(super::r#_Wrappers_Compile::Option::::Some { + value: false + }) + }))); + valueOrError0 = ::dafny_runtime::MaybePlacebo::from(_out3.read()); + if !(!valueOrError0.read().IsFailure()) { + panic!("Halt") + }; + ret = ::dafny_runtime::MaybePlacebo::from( + valueOrError0.read().Extract(), /* Coercion from T to ::std::rc::Rc not yet implemented */ + ); + if !((ret.read().value().UnwrapOr( + &true, /* Coercion from bool to T not yet implemented */ + )/* Coercion from T to bool not yet implemented */) + == false) + { + panic!("Halt") + }; + print!("{}", ::dafny_runtime::DafnyPrintWrapper(&ret.read())); + return (); + } + } +} +pub mod r#_WrappedSimpleTypesBooleanTest_Compile { + pub struct _default {} + + impl _default { + pub fn _allocate_rcmut() -> ::dafny_runtime::Object { + ::dafny_runtime::allocate_rcmut::() + } + pub fn GetBooleanTrue() -> () { + let mut client = ::dafny_runtime::MaybePlacebo::<::dafny_runtime::Object>::new(); + let mut valueOrError0 = ::dafny_runtime::MaybePlacebo::<::std::rc::Rc, ::std::rc::Rc>>>::new(); + let mut _out4 = ::dafny_runtime::MaybePlacebo::<::std::rc::Rc, ::std::rc::Rc>>>::new(); + _out4 = ::dafny_runtime::MaybePlacebo::from(super::r#_simple_dtypes_dboolean_dinternaldafny_dwrapped::_default::WrappedSimpleBoolean(&super::r#_simple_dtypes_dboolean_dinternaldafny_dwrapped::_default::WrappedDefaultSimpleBooleanConfig())); + valueOrError0 = ::dafny_runtime::MaybePlacebo::from(_out4.read()); + if !(!valueOrError0.read().IsFailure()) { + panic!("Halt") + }; + client = ::dafny_runtime::MaybePlacebo::from( + valueOrError0.read().Extract().clone(), /* Coercion from T to ::dafny_runtime::Object not yet implemented */ + ); + super::r#_SimpleBooleanImplTest_Compile::_default::TestGetBooleanTrue(&client.read()); + return (); + } + pub fn GetBooleanFalse() -> () { + let mut client = ::dafny_runtime::MaybePlacebo::<::dafny_runtime::Object>::new(); + let mut valueOrError0 = ::dafny_runtime::MaybePlacebo::<::std::rc::Rc, ::std::rc::Rc>>>::new(); + let mut _out5 = ::dafny_runtime::MaybePlacebo::<::std::rc::Rc, ::std::rc::Rc>>>::new(); + _out5 = ::dafny_runtime::MaybePlacebo::from(super::r#_simple_dtypes_dboolean_dinternaldafny_dwrapped::_default::WrappedSimpleBoolean(&super::r#_simple_dtypes_dboolean_dinternaldafny_dwrapped::_default::WrappedDefaultSimpleBooleanConfig())); + valueOrError0 = ::dafny_runtime::MaybePlacebo::from(_out5.read()); + if !(!valueOrError0.read().IsFailure()) { + panic!("Halt") + }; + client = ::dafny_runtime::MaybePlacebo::from( + valueOrError0.read().Extract().clone(), /* Coercion from T to ::dafny_runtime::Object not yet implemented */ + ); + super::r#_SimpleBooleanImplTest_Compile::_default::TestGetBooleanFalse(&client.read()); + return (); + } + } +} +pub mod _module { + pub struct _default {} + + impl _default { + pub fn _allocate_rcmut() -> ::dafny_runtime::Object { + ::dafny_runtime::allocate_rcmut::() + } + pub fn _Test__Main_() -> () { + let mut success: bool = true; + success = true; + print!( + "{}", + ::dafny_runtime::DafnyPrintWrapper(&::dafny_runtime::string_utf16_of( + "SimpleBooleanImplTest.GetBooleanTrue: " + )) + ); + super::r#_SimpleBooleanImplTest_Compile::_default::GetBooleanTrue(); + print!( + "{}", + ::dafny_runtime::DafnyPrintWrapper(&::dafny_runtime::string_utf16_of( + "PASSED +" + )) + ); + print!( + "{}", + ::dafny_runtime::DafnyPrintWrapper(&::dafny_runtime::string_utf16_of( + "SimpleBooleanImplTest.GetBooleanFalse: " + )) + ); + super::r#_SimpleBooleanImplTest_Compile::_default::GetBooleanFalse(); + print!( + "{}", + ::dafny_runtime::DafnyPrintWrapper(&::dafny_runtime::string_utf16_of( + "PASSED +" + )) + ); + print!( + "{}", + ::dafny_runtime::DafnyPrintWrapper(&::dafny_runtime::string_utf16_of( + "WrappedSimpleTypesBooleanTest.GetBooleanTrue: " + )) + ); + super::r#_WrappedSimpleTypesBooleanTest_Compile::_default::GetBooleanTrue(); + print!( + "{}", + ::dafny_runtime::DafnyPrintWrapper(&::dafny_runtime::string_utf16_of( + "PASSED +" + )) + ); + print!( + "{}", + ::dafny_runtime::DafnyPrintWrapper(&::dafny_runtime::string_utf16_of( + "WrappedSimpleTypesBooleanTest.GetBooleanFalse: " + )) + ); + super::r#_WrappedSimpleTypesBooleanTest_Compile::_default::GetBooleanFalse(); + print!( + "{}", + ::dafny_runtime::DafnyPrintWrapper(&::dafny_runtime::string_utf16_of( + "PASSED +" + )) + ); + if !success { + panic!("Halt") + }; + return (); + } + } +} +fn main() { + _module::_default::_Test__Main_(); +} From 0710246368cef381ce4f5ca8e6bd58cc57c20603 Mon Sep 17 00:00:00 2001 From: Robin Salkeld Date: Tue, 25 Jun 2024 13:16:30 -0700 Subject: [PATCH 02/53] Progress --- .../SimpleTypes/SimpleBoolean/runtimes/rust/src/lib.rs | 1 - .../SimpleBoolean/runtimes/rust/src/wrapped.rs | 6 ------ .../runtimes/rust/tests/tests_from_dafny/_wrapped.rs | 9 +++++++++ .../runtimes/rust/tests/tests_from_dafny/lib.rs | 1 + .../runtimes/rust/tests/tests_from_dafny/mod.rs | 1 + 5 files changed, 11 insertions(+), 7 deletions(-) delete mode 100644 TestModels/SimpleTypes/SimpleBoolean/runtimes/rust/src/wrapped.rs create mode 100644 TestModels/SimpleTypes/SimpleBoolean/runtimes/rust/tests/tests_from_dafny/_wrapped.rs create mode 100644 TestModels/SimpleTypes/SimpleBoolean/runtimes/rust/tests/tests_from_dafny/lib.rs diff --git a/TestModels/SimpleTypes/SimpleBoolean/runtimes/rust/src/lib.rs b/TestModels/SimpleTypes/SimpleBoolean/runtimes/rust/src/lib.rs index 3990657aa5..75c80713e8 100644 --- a/TestModels/SimpleTypes/SimpleBoolean/runtimes/rust/src/lib.rs +++ b/TestModels/SimpleTypes/SimpleBoolean/runtimes/rust/src/lib.rs @@ -14,7 +14,6 @@ pub mod operation; mod conversions; pub mod implementation_from_dafny; -mod wrapped; pub use client::Client; pub use types::simple_boolean_config::SimpleBooleanConfig; diff --git a/TestModels/SimpleTypes/SimpleBoolean/runtimes/rust/src/wrapped.rs b/TestModels/SimpleTypes/SimpleBoolean/runtimes/rust/src/wrapped.rs deleted file mode 100644 index a063ea7d37..0000000000 --- a/TestModels/SimpleTypes/SimpleBoolean/runtimes/rust/src/wrapped.rs +++ /dev/null @@ -1,6 +0,0 @@ -impl crate::r#_simple_dtypes_dboolean_dinternaldafny_dwrapped::_default { - pub fn WrappedSimpleBoolean() { - - } - -} \ No newline at end of file diff --git a/TestModels/SimpleTypes/SimpleBoolean/runtimes/rust/tests/tests_from_dafny/_wrapped.rs b/TestModels/SimpleTypes/SimpleBoolean/runtimes/rust/tests/tests_from_dafny/_wrapped.rs new file mode 100644 index 0000000000..5a6303cea0 --- /dev/null +++ b/TestModels/SimpleTypes/SimpleBoolean/runtimes/rust/tests/tests_from_dafny/_wrapped.rs @@ -0,0 +1,9 @@ +use crate::tests_from_dafny::*; + +impl r#_simple_dtypes_dboolean_dinternaldafny_dwrapped::_default { + pub fn WrappedSimpleBoolean(config: ::std::rc::Rc< + super::r#_simple_dtypes_dboolean_dinternaldafny_dtypes::SimpleBooleanConfig, +>) -> ::std::rc::Rc, ::std::rc::Rc>> { + + } +} \ No newline at end of file diff --git a/TestModels/SimpleTypes/SimpleBoolean/runtimes/rust/tests/tests_from_dafny/lib.rs b/TestModels/SimpleTypes/SimpleBoolean/runtimes/rust/tests/tests_from_dafny/lib.rs new file mode 100644 index 0000000000..65c425e314 --- /dev/null +++ b/TestModels/SimpleTypes/SimpleBoolean/runtimes/rust/tests/tests_from_dafny/lib.rs @@ -0,0 +1 @@ +mod _wrapped; \ No newline at end of file diff --git a/TestModels/SimpleTypes/SimpleBoolean/runtimes/rust/tests/tests_from_dafny/mod.rs b/TestModels/SimpleTypes/SimpleBoolean/runtimes/rust/tests/tests_from_dafny/mod.rs index e09a52c221..a975676146 100644 --- a/TestModels/SimpleTypes/SimpleBoolean/runtimes/rust/tests/tests_from_dafny/mod.rs +++ b/TestModels/SimpleTypes/SimpleBoolean/runtimes/rust/tests/tests_from_dafny/mod.rs @@ -2,6 +2,7 @@ #![allow(nonstandard_style)] use simple_boolean::*; use simple_boolean::implementation_from_dafny::*; +mod _wrapped; pub mod r#_simple_dtypes_dboolean_dinternaldafny_dwrapped { pub struct _default {} From 323a1e5c38e114dca4fe192de230e537a40cc8c7 Mon Sep 17 00:00:00 2001 From: Robin Salkeld Date: Tue, 25 Jun 2024 16:11:51 -0700 Subject: [PATCH 03/53] Update package layout, most of the wrapped client impl --- .../SimpleBoolean/runtimes/rust/Cargo.toml | 1 - .../runtimes/rust/dafny_impl/Cargo.toml | 13 - .../src/implementation_from_dafny.rs | 641 ------------------ .../SimpleBoolean/runtimes/rust/src/client.rs | 8 +- .../rust/src/conversions/get_boolean.rs | 8 +- .../get_boolean/_get_boolean_input.rs | 14 +- .../get_boolean/_get_boolean_output.rs | 14 +- .../_simple_boolean_config.rs | 8 +- .../SimpleBoolean/runtimes/rust/src/lib.rs | 2 +- .../rust/src/operation/get_boolean.rs | 2 +- .../rust/tests/tests_from_dafny/_wrapped.rs | 58 +- 11 files changed, 86 insertions(+), 683 deletions(-) delete mode 100644 TestModels/SimpleTypes/SimpleBoolean/runtimes/rust/dafny_impl/Cargo.toml delete mode 100644 TestModels/SimpleTypes/SimpleBoolean/runtimes/rust/dafny_impl/src/implementation_from_dafny.rs diff --git a/TestModels/SimpleTypes/SimpleBoolean/runtimes/rust/Cargo.toml b/TestModels/SimpleTypes/SimpleBoolean/runtimes/rust/Cargo.toml index 8cc533de4f..e05d9345f3 100644 --- a/TestModels/SimpleTypes/SimpleBoolean/runtimes/rust/Cargo.toml +++ b/TestModels/SimpleTypes/SimpleBoolean/runtimes/rust/Cargo.toml @@ -11,7 +11,6 @@ aws-smithy-runtime-api = {version = "1.7.0", features = ["client"] } aws-smithy-types = "1.2.0" dafny_runtime = { path = "../../../../dafny-dependencies/dafny_runtime_rust"} dafny_standard_library = { path = "../../../../dafny-dependencies/StandardLibrary/runtimes/rust"} -simple_boolean_dafny = { path = "./dafny_impl"} [dev-dependencies.tokio] version = "1.26.0" diff --git a/TestModels/SimpleTypes/SimpleBoolean/runtimes/rust/dafny_impl/Cargo.toml b/TestModels/SimpleTypes/SimpleBoolean/runtimes/rust/dafny_impl/Cargo.toml deleted file mode 100644 index a7f8568c48..0000000000 --- a/TestModels/SimpleTypes/SimpleBoolean/runtimes/rust/dafny_impl/Cargo.toml +++ /dev/null @@ -1,13 +0,0 @@ -[package] -name = "simple_boolean_dafny" -version = "0.1.0" -edition = "2021" - -# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html - -[dependencies] -dafny_runtime = { path = "../../../../../dafny-dependencies/dafny_runtime_rust"} -dafny_standard_library = { path = "../../../../../dafny-dependencies/StandardLibrary/runtimes/rust"} - -[lib] -path = "src/implementation_from_dafny.rs" diff --git a/TestModels/SimpleTypes/SimpleBoolean/runtimes/rust/dafny_impl/src/implementation_from_dafny.rs b/TestModels/SimpleTypes/SimpleBoolean/runtimes/rust/dafny_impl/src/implementation_from_dafny.rs deleted file mode 100644 index 06c0c0eab0..0000000000 --- a/TestModels/SimpleTypes/SimpleBoolean/runtimes/rust/dafny_impl/src/implementation_from_dafny.rs +++ /dev/null @@ -1,641 +0,0 @@ -#![allow(warnings, unconditional_panic)] -#![allow(nonstandard_style)] -pub use dafny_standard_library::implementation_from_dafny::*; - -pub mod r#_simple_dtypes_dboolean_dinternaldafny_dtypes { - #[derive(PartialEq, Clone)] - pub enum DafnyCallEvent { - DafnyCallEvent { input: I, output: O }, - _PhantomVariant(::std::marker::PhantomData, ::std::marker::PhantomData), - } - - impl DafnyCallEvent { - pub fn input(&self) -> &I { - match self { - DafnyCallEvent::DafnyCallEvent { input, output } => input, - DafnyCallEvent::_PhantomVariant(..) => panic!(), - } - } - pub fn output(&self) -> &O { - match self { - DafnyCallEvent::DafnyCallEvent { input, output } => output, - DafnyCallEvent::_PhantomVariant(..) => panic!(), - } - } - } - - impl ::std::fmt::Debug - for DafnyCallEvent - { - fn fmt(&self, f: &mut ::std::fmt::Formatter) -> std::fmt::Result { - ::dafny_runtime::DafnyPrint::fmt_print(self, f, true) - } - } - - impl ::dafny_runtime::DafnyPrint - for DafnyCallEvent - { - fn fmt_print( - &self, - _formatter: &mut ::std::fmt::Formatter, - _in_seq: bool, - ) -> std::fmt::Result { - match self { - DafnyCallEvent::DafnyCallEvent { input, output } => { - write!(_formatter, "r#_simple_dtypes_dboolean_dinternaldafny_dtypes.DafnyCallEvent.DafnyCallEvent(")?; - ::dafny_runtime::DafnyPrint::fmt_print(input, _formatter, false)?; - write!(_formatter, ", ")?; - ::dafny_runtime::DafnyPrint::fmt_print(output, _formatter, false)?; - write!(_formatter, ")")?; - Ok(()) - } - DafnyCallEvent::_PhantomVariant(..) => { - panic!() - } - } - } - } - - impl Eq - for DafnyCallEvent - { - } - - impl< - I: ::dafny_runtime::DafnyType + ::std::hash::Hash, - O: ::dafny_runtime::DafnyType + ::std::hash::Hash, - > ::std::hash::Hash for DafnyCallEvent - { - fn hash<_H: ::std::hash::Hasher>(&self, _state: &mut _H) { - match self { - DafnyCallEvent::DafnyCallEvent { input, output } => { - input.hash(_state); - output.hash(_state) - } - DafnyCallEvent::_PhantomVariant(..) => { - panic!() - } - } - } - } - - impl< - I: ::dafny_runtime::DafnyType + ::std::default::Default, - O: ::dafny_runtime::DafnyType + ::std::default::Default, - > ::std::default::Default for DafnyCallEvent - { - fn default() -> DafnyCallEvent { - DafnyCallEvent::DafnyCallEvent { - input: ::std::default::Default::default(), - output: ::std::default::Default::default(), - } - } - } - - impl - ::std::convert::AsRef> for &DafnyCallEvent - { - fn as_ref(&self) -> Self { - self - } - } - - #[derive(PartialEq, Clone)] - pub enum GetBooleanInput { - GetBooleanInput { - value: ::std::rc::Rc>, - }, - } - - impl GetBooleanInput { - pub fn value(&self) -> &::std::rc::Rc> { - match self { - GetBooleanInput::GetBooleanInput { value } => value, - } - } - } - - impl ::std::fmt::Debug for GetBooleanInput { - fn fmt(&self, f: &mut ::std::fmt::Formatter) -> std::fmt::Result { - ::dafny_runtime::DafnyPrint::fmt_print(self, f, true) - } - } - - impl ::dafny_runtime::DafnyPrint for GetBooleanInput { - fn fmt_print( - &self, - _formatter: &mut ::std::fmt::Formatter, - _in_seq: bool, - ) -> std::fmt::Result { - match self { - GetBooleanInput::GetBooleanInput { value } => { - write!(_formatter, "r#_simple_dtypes_dboolean_dinternaldafny_dtypes.GetBooleanInput.GetBooleanInput(")?; - ::dafny_runtime::DafnyPrint::fmt_print(value, _formatter, false)?; - write!(_formatter, ")")?; - Ok(()) - } - } - } - } - - impl Eq for GetBooleanInput {} - - impl ::std::hash::Hash for GetBooleanInput { - fn hash<_H: ::std::hash::Hasher>(&self, _state: &mut _H) { - match self { - GetBooleanInput::GetBooleanInput { value } => value.hash(_state), - } - } - } - - impl ::std::default::Default for GetBooleanInput { - fn default() -> GetBooleanInput { - GetBooleanInput::GetBooleanInput { - value: ::std::default::Default::default(), - } - } - } - - impl ::std::convert::AsRef for &GetBooleanInput { - fn as_ref(&self) -> Self { - self - } - } - - #[derive(PartialEq, Clone)] - pub enum GetBooleanOutput { - GetBooleanOutput { - value: ::std::rc::Rc>, - }, - } - - impl GetBooleanOutput { - pub fn value(&self) -> &::std::rc::Rc> { - match self { - GetBooleanOutput::GetBooleanOutput { value } => value, - } - } - } - - impl ::std::fmt::Debug for GetBooleanOutput { - fn fmt(&self, f: &mut ::std::fmt::Formatter) -> std::fmt::Result { - ::dafny_runtime::DafnyPrint::fmt_print(self, f, true) - } - } - - impl ::dafny_runtime::DafnyPrint for GetBooleanOutput { - fn fmt_print( - &self, - _formatter: &mut ::std::fmt::Formatter, - _in_seq: bool, - ) -> std::fmt::Result { - match self { - GetBooleanOutput::GetBooleanOutput { value } => { - write!(_formatter, "r#_simple_dtypes_dboolean_dinternaldafny_dtypes.GetBooleanOutput.GetBooleanOutput(")?; - ::dafny_runtime::DafnyPrint::fmt_print(value, _formatter, false)?; - write!(_formatter, ")")?; - Ok(()) - } - } - } - } - - impl Eq for GetBooleanOutput {} - - impl ::std::hash::Hash for GetBooleanOutput { - fn hash<_H: ::std::hash::Hasher>(&self, _state: &mut _H) { - match self { - GetBooleanOutput::GetBooleanOutput { value } => value.hash(_state), - } - } - } - - impl ::std::default::Default for GetBooleanOutput { - fn default() -> GetBooleanOutput { - GetBooleanOutput::GetBooleanOutput { - value: ::std::default::Default::default(), - } - } - } - - impl ::std::convert::AsRef for &GetBooleanOutput { - fn as_ref(&self) -> Self { - self - } - } - - #[derive(PartialEq, Clone)] - pub enum SimpleBooleanConfig { - SimpleBooleanConfig {}, - } - - impl SimpleBooleanConfig {} - - impl ::std::fmt::Debug for SimpleBooleanConfig { - fn fmt(&self, f: &mut ::std::fmt::Formatter) -> std::fmt::Result { - ::dafny_runtime::DafnyPrint::fmt_print(self, f, true) - } - } - - impl ::dafny_runtime::DafnyPrint for SimpleBooleanConfig { - fn fmt_print( - &self, - _formatter: &mut ::std::fmt::Formatter, - _in_seq: bool, - ) -> std::fmt::Result { - match self { - SimpleBooleanConfig::SimpleBooleanConfig {} => { - write!(_formatter, "r#_simple_dtypes_dboolean_dinternaldafny_dtypes.SimpleBooleanConfig.SimpleBooleanConfig")?; - Ok(()) - } - } - } - } - - impl Eq for SimpleBooleanConfig {} - - impl ::std::hash::Hash for SimpleBooleanConfig { - fn hash<_H: ::std::hash::Hasher>(&self, _state: &mut _H) { - match self { - SimpleBooleanConfig::SimpleBooleanConfig {} => {} - } - } - } - - impl ::std::default::Default for SimpleBooleanConfig { - fn default() -> SimpleBooleanConfig { - SimpleBooleanConfig::SimpleBooleanConfig {} - } - } - - impl ::std::convert::AsRef for &SimpleBooleanConfig { - fn as_ref(&self) -> Self { - self - } - } - - pub struct ISimpleTypesBooleanClientCallHistory {} - - impl ISimpleTypesBooleanClientCallHistory { - pub fn _allocate_rcmut() -> ::dafny_runtime::Object { - ::dafny_runtime::allocate_rcmut::() - } - } - - pub trait ISimpleTypesBooleanClient { - fn GetBoolean( - &mut self, - input: &::std::rc::Rc< - super::r#_simple_dtypes_dboolean_dinternaldafny_dtypes::GetBooleanInput, - >, - ) -> ::std::rc::Rc< - super::r#_Wrappers_Compile::Result< - ::std::rc::Rc< - super::r#_simple_dtypes_dboolean_dinternaldafny_dtypes::GetBooleanOutput, - >, - ::std::rc::Rc, - >, - >; - } - - #[derive(PartialEq, Clone)] - pub enum Error { - CollectionOfErrors { - list: ::dafny_runtime::Sequence< - ::std::rc::Rc, - >, - message: ::dafny_runtime::Sequence<::dafny_runtime::DafnyCharUTF16>, - }, - Opaque { - obj: ::dafny_runtime::Object, - }, - } - - impl Error { - pub fn list( - &self, - ) -> &::dafny_runtime::Sequence< - ::std::rc::Rc, - > { - match self { - Error::CollectionOfErrors { list, message } => list, - Error::Opaque { obj } => panic!("field does not exist on this variant"), - } - } - pub fn message(&self) -> &::dafny_runtime::Sequence<::dafny_runtime::DafnyCharUTF16> { - match self { - Error::CollectionOfErrors { list, message } => message, - Error::Opaque { obj } => panic!("field does not exist on this variant"), - } - } - pub fn obj(&self) -> &::dafny_runtime::Object { - match self { - Error::CollectionOfErrors { list, message } => { - panic!("field does not exist on this variant") - } - Error::Opaque { obj } => obj, - } - } - } - - impl ::std::fmt::Debug for Error { - fn fmt(&self, f: &mut ::std::fmt::Formatter) -> std::fmt::Result { - ::dafny_runtime::DafnyPrint::fmt_print(self, f, true) - } - } - - impl ::dafny_runtime::DafnyPrint for Error { - fn fmt_print( - &self, - _formatter: &mut ::std::fmt::Formatter, - _in_seq: bool, - ) -> std::fmt::Result { - match self { - Error::CollectionOfErrors { list, message } => { - write!( - _formatter, - "r#_simple_dtypes_dboolean_dinternaldafny_dtypes.Error.CollectionOfErrors(" - )?; - ::dafny_runtime::DafnyPrint::fmt_print(list, _formatter, false)?; - write!(_formatter, ", ")?; - ::dafny_runtime::DafnyPrint::fmt_print(message, _formatter, false)?; - write!(_formatter, ")")?; - Ok(()) - } - Error::Opaque { obj } => { - write!( - _formatter, - "r#_simple_dtypes_dboolean_dinternaldafny_dtypes.Error.Opaque(" - )?; - ::dafny_runtime::DafnyPrint::fmt_print(obj, _formatter, false)?; - write!(_formatter, ")")?; - Ok(()) - } - } - } - } - - impl Eq for Error {} - - impl ::std::hash::Hash for Error { - fn hash<_H: ::std::hash::Hasher>(&self, _state: &mut _H) { - match self { - Error::CollectionOfErrors { list, message } => { - list.hash(_state); - message.hash(_state) - } - Error::Opaque { obj } => obj.hash(_state), - } - } - } - - impl ::std::default::Default for Error { - fn default() -> Error { - Error::CollectionOfErrors { - list: ::std::default::Default::default(), - message: ::std::default::Default::default(), - } - } - } - - impl ::std::convert::AsRef for &Error { - fn as_ref(&self) -> Self { - self - } - } - - pub type OpaqueError = - ::std::rc::Rc; -} -pub mod r#_SimpleBooleanImpl_Compile { - pub struct _default {} - - impl _default { - pub fn _allocate_rcmut() -> ::dafny_runtime::Object { - ::dafny_runtime::allocate_rcmut::() - } - pub fn GetBoolean( - config: &::std::rc::Rc, - input: &::std::rc::Rc< - super::r#_simple_dtypes_dboolean_dinternaldafny_dtypes::GetBooleanInput, - >, - ) -> ::std::rc::Rc< - super::r#_Wrappers_Compile::Result< - ::std::rc::Rc< - super::r#_simple_dtypes_dboolean_dinternaldafny_dtypes::GetBooleanOutput, - >, - ::std::rc::Rc, - >, - > { - let mut output = ::dafny_runtime::MaybePlacebo::<::std::rc::Rc, ::std::rc::Rc>>>::new(); - if !matches!( - input.value().as_ref(), - super::r#_Wrappers_Compile::Option::Some { .. } - ) { - panic!("Halt") - }; - if !(*input.value().value() == true || *input.value().value() == false) { - panic!("Halt") - }; - let mut res: ::std::rc::Rc = ::std::rc::Rc::new(super::r#_simple_dtypes_dboolean_dinternaldafny_dtypes::GetBooleanOutput::GetBooleanOutput { - value: input.value().clone() - }); - res = ::std::rc::Rc::new(super::r#_simple_dtypes_dboolean_dinternaldafny_dtypes::GetBooleanOutput::GetBooleanOutput { - value: input.value().clone() - }); - if !(*res.value().value() == true || *res.value().value() == false) { - panic!("Halt") - }; - if !(input.value().value() == res.value().value()) { - panic!("Halt") - }; - output = ::dafny_runtime::MaybePlacebo::from(::std::rc::Rc::new( - super::r#_Wrappers_Compile::Result::< - ::std::rc::Rc< - super::r#_simple_dtypes_dboolean_dinternaldafny_dtypes::GetBooleanOutput, - >, - ::std::rc::Rc, - >::Success { - value: res.clone(), - }, - )); - return output.read(); - return output.read(); - } - } - - #[derive(PartialEq, Clone)] - pub enum Config { - Config {}, - } - - impl Config {} - - impl ::std::fmt::Debug for Config { - fn fmt(&self, f: &mut ::std::fmt::Formatter) -> std::fmt::Result { - ::dafny_runtime::DafnyPrint::fmt_print(self, f, true) - } - } - - impl ::dafny_runtime::DafnyPrint for Config { - fn fmt_print( - &self, - _formatter: &mut ::std::fmt::Formatter, - _in_seq: bool, - ) -> std::fmt::Result { - match self { - Config::Config {} => { - write!(_formatter, "r#_SimpleBooleanImpl_Compile.Config.Config")?; - Ok(()) - } - } - } - } - - impl Eq for Config {} - - impl ::std::hash::Hash for Config { - fn hash<_H: ::std::hash::Hasher>(&self, _state: &mut _H) { - match self { - Config::Config {} => {} - } - } - } - - impl ::std::default::Default for Config { - fn default() -> Config { - Config::Config {} - } - } - - impl ::std::convert::AsRef for &Config { - fn as_ref(&self) -> Self { - self - } - } -} -pub mod r#_simple_dtypes_dboolean_dinternaldafny { - pub struct _default {} - - impl _default { - pub fn _allocate_rcmut() -> ::dafny_runtime::Object { - ::dafny_runtime::allocate_rcmut::() - } - pub fn DefaultSimpleBooleanConfig() -> ::std::rc::Rc< - super::r#_simple_dtypes_dboolean_dinternaldafny_dtypes::SimpleBooleanConfig, - > { - ::std::rc::Rc::new(super::r#_simple_dtypes_dboolean_dinternaldafny_dtypes::SimpleBooleanConfig::SimpleBooleanConfig {}) - } - pub fn SimpleBoolean( - config: &::std::rc::Rc< - super::r#_simple_dtypes_dboolean_dinternaldafny_dtypes::SimpleBooleanConfig, - >, - ) -> ::std::rc::Rc< - super::r#_Wrappers_Compile::Result< - ::dafny_runtime::Object< - super::r#_simple_dtypes_dboolean_dinternaldafny::SimpleBooleanClient, - >, - ::std::rc::Rc, - >, - > { - let mut res = ::dafny_runtime::MaybePlacebo::< - ::std::rc::Rc< - super::r#_Wrappers_Compile::Result< - ::dafny_runtime::Object< - super::r#_simple_dtypes_dboolean_dinternaldafny::SimpleBooleanClient, - >, - ::std::rc::Rc< - super::r#_simple_dtypes_dboolean_dinternaldafny_dtypes::Error, - >, - >, - >, - >::new(); - let mut client = ::dafny_runtime::MaybePlacebo::< - ::dafny_runtime::Object< - super::r#_simple_dtypes_dboolean_dinternaldafny::SimpleBooleanClient, - >, - >::new(); - let mut _nw0: ::dafny_runtime::Object = super::r#_simple_dtypes_dboolean_dinternaldafny::SimpleBooleanClient::_allocate_rcmut(); - super::r#_simple_dtypes_dboolean_dinternaldafny::SimpleBooleanClient::_ctor( - &_nw0, - &::std::rc::Rc::new(super::r#_SimpleBooleanImpl_Compile::Config::Config {}), - ); - client = ::dafny_runtime::MaybePlacebo::from(_nw0.clone()); - res = ::dafny_runtime::MaybePlacebo::from(::std::rc::Rc::new( - super::r#_Wrappers_Compile::Result::< - ::dafny_runtime::Object< - super::r#_simple_dtypes_dboolean_dinternaldafny::SimpleBooleanClient, - >, - ::std::rc::Rc, - >::Success { - value: client.read(), - }, - )); - return res.read(); - return res.read(); - } - pub fn CreateSuccessOfClient(client: &::dafny_runtime::Object) -> ::std::rc::Rc, ::std::rc::Rc>>{ - ::std::rc::Rc::new(super::r#_Wrappers_Compile::Result::<::dafny_runtime::Object, ::std::rc::Rc>::Success { - value: client.clone() - }) - } - pub fn CreateFailureOfError(error: &::std::rc::Rc) -> ::std::rc::Rc, ::std::rc::Rc>>{ - ::std::rc::Rc::new(super::r#_Wrappers_Compile::Result::<::dafny_runtime::Object, ::std::rc::Rc>::Failure { - error: error.clone() - }) - } - } - - pub struct SimpleBooleanClient { - pub r#__i_config: ::std::rc::Rc, - } - - impl SimpleBooleanClient { - pub fn _allocate_rcmut() -> ::dafny_runtime::Object { - ::dafny_runtime::allocate_rcmut::() - } - pub fn _ctor( - this: &::dafny_runtime::Object, - config: &::std::rc::Rc, - ) -> () { - let mut _set__i_config: bool = false; - ::dafny_runtime::update_field_uninit_rcmut!( - this.clone(), - r#__i_config, - _set__i_config, - config.clone() - ); - return (); - } - pub fn config(&self) -> ::std::rc::Rc { - self.r#__i_config.clone() - } - } - - impl super::r#_simple_dtypes_dboolean_dinternaldafny_dtypes::ISimpleTypesBooleanClient - for super::r#_simple_dtypes_dboolean_dinternaldafny::SimpleBooleanClient - { - fn GetBoolean( - &mut self, - input: &::std::rc::Rc< - super::r#_simple_dtypes_dboolean_dinternaldafny_dtypes::GetBooleanInput, - >, - ) -> ::std::rc::Rc< - super::r#_Wrappers_Compile::Result< - ::std::rc::Rc< - super::r#_simple_dtypes_dboolean_dinternaldafny_dtypes::GetBooleanOutput, - >, - ::std::rc::Rc, - >, - > { - let mut output = ::dafny_runtime::MaybePlacebo::<::std::rc::Rc, ::std::rc::Rc>>>::new(); - let mut _out0 = ::dafny_runtime::MaybePlacebo::<::std::rc::Rc, ::std::rc::Rc>>>::new(); - _out0 = ::dafny_runtime::MaybePlacebo::from( - super::r#_SimpleBooleanImpl_Compile::_default::GetBoolean(&self.config(), input), - ); - output = ::dafny_runtime::MaybePlacebo::from(_out0.read()); - return output.read(); - } - } -} -pub mod _module {} diff --git a/TestModels/SimpleTypes/SimpleBoolean/runtimes/rust/src/client.rs b/TestModels/SimpleTypes/SimpleBoolean/runtimes/rust/src/client.rs index 5170a9ce7e..f088d4a865 100644 --- a/TestModels/SimpleTypes/SimpleBoolean/runtimes/rust/src/client.rs +++ b/TestModels/SimpleTypes/SimpleBoolean/runtimes/rust/src/client.rs @@ -4,7 +4,7 @@ use aws_smithy_types::error::operation::BuildError; #[derive(::std::clone::Clone, ::std::fmt::Debug)] pub struct Client { - pub(crate) dafny_client: ::dafny_runtime::Object + pub(crate) dafny_client: ::dafny_runtime::Object } impl Client { @@ -14,12 +14,12 @@ impl Client { conf: crate::types::simple_boolean_config::SimpleBooleanConfig, ) -> Result { let inner = - ::simple_boolean_dafny::_simple_dtypes_dboolean_dinternaldafny::_default::SimpleBoolean( + crate::implementation_from_dafny::_simple_dtypes_dboolean_dinternaldafny::_default::SimpleBoolean( &crate::conversions::simple_boolean_config::_simple_boolean_config::to_dafny(conf), ); if matches!( inner.as_ref(), - ::simple_boolean_dafny::_Wrappers_Compile::Result::Failure { .. } + crate::implementation_from_dafny::_Wrappers_Compile::Result::Failure { .. } ) { // TODO: convert error - the potential types are not modeled! return Err(BuildError::other( @@ -29,7 +29,7 @@ impl Client { )); } Ok(Self { - dafny_client: ::dafny_runtime::UpcastTo::>::upcast_to(inner.Extract()), + dafny_client: ::dafny_runtime::UpcastTo::>::upcast_to(inner.Extract()), }) } } diff --git a/TestModels/SimpleTypes/SimpleBoolean/runtimes/rust/src/conversions/get_boolean.rs b/TestModels/SimpleTypes/SimpleBoolean/runtimes/rust/src/conversions/get_boolean.rs index 6f9f1b3ca8..64b557ccc3 100644 --- a/TestModels/SimpleTypes/SimpleBoolean/runtimes/rust/src/conversions/get_boolean.rs +++ b/TestModels/SimpleTypes/SimpleBoolean/runtimes/rust/src/conversions/get_boolean.rs @@ -5,21 +5,21 @@ use std::any::Any; #[allow(dead_code)] pub fn to_dafny_error( value: crate::operation::get_boolean::GetBooleanError, -) -> ::std::rc::Rc<::simple_boolean_dafny::r#_simple_dtypes_dboolean_dinternaldafny_dtypes::Error> { +) -> ::std::rc::Rc { match value { crate::operation::get_boolean::GetBooleanError::Unhandled(unhandled) => - ::std::rc::Rc::new(::simple_boolean_dafny::r#_simple_dtypes_dboolean_dinternaldafny_dtypes::Error::Opaque { obj: ::dafny_runtime::UpcastTo::<::dafny_runtime::Object>::upcast_to(::dafny_runtime::object::new(unhandled)) }) + ::std::rc::Rc::new(crate::implementation_from_dafny::r#_simple_dtypes_dboolean_dinternaldafny_dtypes::Error::Opaque { obj: ::dafny_runtime::UpcastTo::<::dafny_runtime::Object>::upcast_to(::dafny_runtime::object::new(unhandled)) }) } } #[allow(dead_code)] pub fn from_dafny_error( dafny_value: ::std::rc::Rc< - ::simple_boolean_dafny::r#_simple_dtypes_dboolean_dinternaldafny_dtypes::Error, + crate::implementation_from_dafny::r#_simple_dtypes_dboolean_dinternaldafny_dtypes::Error, >, ) -> crate::operation::get_boolean::GetBooleanError { // TODO: Losing information here, but we have to figure out how to wrap an arbitrary Dafny value as std::error::Error - if matches!(&dafny_value.as_ref(), ::simple_boolean_dafny::r#_simple_dtypes_dboolean_dinternaldafny_dtypes::Error::CollectionOfErrors { .. }) { + if matches!(&dafny_value.as_ref(), crate::implementation_from_dafny::r#_simple_dtypes_dboolean_dinternaldafny_dtypes::Error::CollectionOfErrors { .. }) { let error_message = "TODO: can't get message yet"; crate::operation::get_boolean::GetBooleanError::generic(::aws_smithy_types::error::metadata::ErrorMetadata::builder().message(error_message).build()) } else { diff --git a/TestModels/SimpleTypes/SimpleBoolean/runtimes/rust/src/conversions/get_boolean/_get_boolean_input.rs b/TestModels/SimpleTypes/SimpleBoolean/runtimes/rust/src/conversions/get_boolean/_get_boolean_input.rs index efd9d5f83b..27e4ef748c 100644 --- a/TestModels/SimpleTypes/SimpleBoolean/runtimes/rust/src/conversions/get_boolean/_get_boolean_input.rs +++ b/TestModels/SimpleTypes/SimpleBoolean/runtimes/rust/src/conversions/get_boolean/_get_boolean_input.rs @@ -3,13 +3,13 @@ pub fn to_dafny( value: crate::operation::get_boolean::GetBooleanInput, ) -> ::std::rc::Rc< - ::simple_boolean_dafny::r#_simple_dtypes_dboolean_dinternaldafny_dtypes::GetBooleanInput, + crate::implementation_from_dafny::r#_simple_dtypes_dboolean_dinternaldafny_dtypes::GetBooleanInput, > { let dafny_value = match value.value { - Some(b) => ::simple_boolean_dafny::_Wrappers_Compile::Option::Some { value: b }, - None => ::simple_boolean_dafny::_Wrappers_Compile::Option::None {}, + Some(b) => crate::implementation_from_dafny::_Wrappers_Compile::Option::Some { value: b }, + None => crate::implementation_from_dafny::_Wrappers_Compile::Option::None {}, }; - ::std::rc::Rc::new(::simple_boolean_dafny::r#_simple_dtypes_dboolean_dinternaldafny_dtypes::GetBooleanInput::GetBooleanInput { + ::std::rc::Rc::new(crate::implementation_from_dafny::r#_simple_dtypes_dboolean_dinternaldafny_dtypes::GetBooleanInput::GetBooleanInput { value: ::std::rc::Rc::new(dafny_value) }) } @@ -17,17 +17,17 @@ pub fn to_dafny( #[allow(dead_code)] pub fn from_dafny( dafny_value: ::std::rc::Rc< - ::simple_boolean_dafny::r#_simple_dtypes_dboolean_dinternaldafny_dtypes::GetBooleanInput, + crate::implementation_from_dafny::r#_simple_dtypes_dboolean_dinternaldafny_dtypes::GetBooleanInput, >, ) -> crate::operation::get_boolean::GetBooleanInput { let value = if matches!( dafny_value.value().as_ref(), - ::simple_boolean_dafny::_Wrappers_Compile::Option::Some { .. } + crate::implementation_from_dafny::_Wrappers_Compile::Option::Some { .. } ) { Some(dafny_value.value().Extract()) } else if matches!( dafny_value.value().as_ref(), - ::simple_boolean_dafny::_Wrappers_Compile::Option::None { .. } + crate::implementation_from_dafny::_Wrappers_Compile::Option::None { .. } ) { None } else { diff --git a/TestModels/SimpleTypes/SimpleBoolean/runtimes/rust/src/conversions/get_boolean/_get_boolean_output.rs b/TestModels/SimpleTypes/SimpleBoolean/runtimes/rust/src/conversions/get_boolean/_get_boolean_output.rs index 4b9dec69dd..719f9692fb 100644 --- a/TestModels/SimpleTypes/SimpleBoolean/runtimes/rust/src/conversions/get_boolean/_get_boolean_output.rs +++ b/TestModels/SimpleTypes/SimpleBoolean/runtimes/rust/src/conversions/get_boolean/_get_boolean_output.rs @@ -3,13 +3,13 @@ pub fn to_dafny( value: crate::operation::get_boolean::GetBooleanOutput, ) -> ::std::rc::Rc< - ::simple_boolean_dafny::r#_simple_dtypes_dboolean_dinternaldafny_dtypes::GetBooleanOutput, + crate::implementation_from_dafny::r#_simple_dtypes_dboolean_dinternaldafny_dtypes::GetBooleanOutput, > { let dafny_value = match value.value { - Some(b) => ::simple_boolean_dafny::_Wrappers_Compile::Option::Some { value: b }, - None => ::simple_boolean_dafny::_Wrappers_Compile::Option::None {}, + Some(b) => crate::implementation_from_dafny::_Wrappers_Compile::Option::Some { value: b }, + None => crate::implementation_from_dafny::_Wrappers_Compile::Option::None {}, }; - ::std::rc::Rc::new(::simple_boolean_dafny::r#_simple_dtypes_dboolean_dinternaldafny_dtypes::GetBooleanOutput::GetBooleanOutput { + ::std::rc::Rc::new(crate::implementation_from_dafny::r#_simple_dtypes_dboolean_dinternaldafny_dtypes::GetBooleanOutput::GetBooleanOutput { value: ::std::rc::Rc::new(dafny_value) }) } @@ -17,17 +17,17 @@ pub fn to_dafny( #[allow(dead_code)] pub fn from_dafny( dafny_value: ::std::rc::Rc< - ::simple_boolean_dafny::r#_simple_dtypes_dboolean_dinternaldafny_dtypes::GetBooleanOutput, + crate::implementation_from_dafny::r#_simple_dtypes_dboolean_dinternaldafny_dtypes::GetBooleanOutput, >, ) -> crate::operation::get_boolean::GetBooleanOutput { let value = if matches!( dafny_value.value().as_ref(), - ::simple_boolean_dafny::_Wrappers_Compile::Option::Some { .. } + crate::implementation_from_dafny::_Wrappers_Compile::Option::Some { .. } ) { Some(dafny_value.value().Extract()) } else if matches!( dafny_value.value().as_ref(), - ::simple_boolean_dafny::_Wrappers_Compile::Option::None { .. } + crate::implementation_from_dafny::_Wrappers_Compile::Option::None { .. } ) { None } else { diff --git a/TestModels/SimpleTypes/SimpleBoolean/runtimes/rust/src/conversions/simple_boolean_config/_simple_boolean_config.rs b/TestModels/SimpleTypes/SimpleBoolean/runtimes/rust/src/conversions/simple_boolean_config/_simple_boolean_config.rs index 6c7dc1765f..a19536aa3a 100644 --- a/TestModels/SimpleTypes/SimpleBoolean/runtimes/rust/src/conversions/simple_boolean_config/_simple_boolean_config.rs +++ b/TestModels/SimpleTypes/SimpleBoolean/runtimes/rust/src/conversions/simple_boolean_config/_simple_boolean_config.rs @@ -1,18 +1,20 @@ +use dafny_standard_library::implementation_from_dafny; + // Code generated by software.amazon.smithy.rust.codegen.smithy-rs. DO NOT EDIT. #[allow(dead_code)] pub fn to_dafny( value: crate::types::simple_boolean_config::SimpleBooleanConfig, ) -> ::std::rc::Rc< - ::simple_boolean_dafny::_simple_dtypes_dboolean_dinternaldafny_dtypes::SimpleBooleanConfig, + crate::implementation_from_dafny::_simple_dtypes_dboolean_dinternaldafny_dtypes::SimpleBooleanConfig, > { - ::std::rc::Rc::new(::simple_boolean_dafny::r#_simple_dtypes_dboolean_dinternaldafny_dtypes::SimpleBooleanConfig::SimpleBooleanConfig {}) + ::std::rc::Rc::new(crate::implementation_from_dafny::r#_simple_dtypes_dboolean_dinternaldafny_dtypes::SimpleBooleanConfig::SimpleBooleanConfig {}) } #[allow(dead_code)] pub fn from_dafny( dafny_value: ::std::rc::Rc< - ::simple_boolean_dafny::r#_simple_dtypes_dboolean_dinternaldafny_dtypes::SimpleBooleanConfig, + crate::implementation_from_dafny::r#_simple_dtypes_dboolean_dinternaldafny_dtypes::SimpleBooleanConfig, >, ) -> crate::types::simple_boolean_config::SimpleBooleanConfig { crate::types::simple_boolean_config::SimpleBooleanConfig {} diff --git a/TestModels/SimpleTypes/SimpleBoolean/runtimes/rust/src/lib.rs b/TestModels/SimpleTypes/SimpleBoolean/runtimes/rust/src/lib.rs index 75c80713e8..118aa67ed6 100644 --- a/TestModels/SimpleTypes/SimpleBoolean/runtimes/rust/src/lib.rs +++ b/TestModels/SimpleTypes/SimpleBoolean/runtimes/rust/src/lib.rs @@ -11,7 +11,7 @@ pub mod error; /// All operations that this crate can perform. pub mod operation; -mod conversions; +pub mod conversions; pub mod implementation_from_dafny; diff --git a/TestModels/SimpleTypes/SimpleBoolean/runtimes/rust/src/operation/get_boolean.rs b/TestModels/SimpleTypes/SimpleBoolean/runtimes/rust/src/operation/get_boolean.rs index 96381e1da6..5b1fec2184 100644 --- a/TestModels/SimpleTypes/SimpleBoolean/runtimes/rust/src/operation/get_boolean.rs +++ b/TestModels/SimpleTypes/SimpleBoolean/runtimes/rust/src/operation/get_boolean.rs @@ -20,7 +20,7 @@ impl GetBoolean { ::dafny_runtime::md!(client.dafny_client.clone()).GetBoolean(&inner_input); if matches!( inner_result.as_ref(), - ::simple_boolean_dafny::r#_Wrappers_Compile::Result::Success { .. } + crate::implementation_from_dafny::r#_Wrappers_Compile::Result::Success { .. } ) { Ok( crate::conversions::get_boolean::_get_boolean_output::from_dafny( diff --git a/TestModels/SimpleTypes/SimpleBoolean/runtimes/rust/tests/tests_from_dafny/_wrapped.rs b/TestModels/SimpleTypes/SimpleBoolean/runtimes/rust/tests/tests_from_dafny/_wrapped.rs index 5a6303cea0..097011f31b 100644 --- a/TestModels/SimpleTypes/SimpleBoolean/runtimes/rust/tests/tests_from_dafny/_wrapped.rs +++ b/TestModels/SimpleTypes/SimpleBoolean/runtimes/rust/tests/tests_from_dafny/_wrapped.rs @@ -1,9 +1,65 @@ +use simple_boolean::*; use crate::tests_from_dafny::*; +use aws_smithy_types::error::operation::BuildError; + +struct WrappedClient { + wrapped: Client +} + +impl super::r#_simple_dtypes_dboolean_dinternaldafny_dtypes::ISimpleTypesBooleanClient for WrappedClient { + fn GetBoolean( + &mut self, + input: &std::rc::Rc< + implementation_from_dafny::r#_simple_dtypes_dboolean_dinternaldafny_dtypes::GetBooleanInput, + >, + ) -> std::rc::Rc< + implementation_from_dafny::r#_Wrappers_Compile::Result< + std::rc::Rc< + implementation_from_dafny::r#_simple_dtypes_dboolean_dinternaldafny_dtypes::GetBooleanOutput, + >, + std::rc::Rc, + >, + > { + let result = self.wrapped.get_boolean().send().await; + match result { + Err(error) => ::std::rc::Rc::new( crate::implementation_from_dafny::_Wrappers_Compile::Result::Failure { + error: crate::conversions::get_boolean::to_dafny_error( + error.clone(), + ) + }), + Ok(client) => ::std::rc::Rc::new( crate::implementation_from_dafny::_Wrappers_Compile::Result::Success { + value: crate::conversions::get_boolean::_get_boolean_output::to_dafny( + client.clone(), + ) + }), + } + } +} impl r#_simple_dtypes_dboolean_dinternaldafny_dwrapped::_default { - pub fn WrappedSimpleBoolean(config: ::std::rc::Rc< + pub fn WrappedSimpleBoolean(config: &::std::rc::Rc< super::r#_simple_dtypes_dboolean_dinternaldafny_dtypes::SimpleBooleanConfig, >) -> ::std::rc::Rc, ::std::rc::Rc>> { + let result = Client::from_conf( + simple_boolean::conversions::simple_boolean_config::_simple_boolean_config::from_dafny(*config) + ); + match result { + Err(error) => { + let error_obj: ::dafny_runtime::Object = + ::dafny_runtime::Object(Some(::std::rc::Rc::new(::std::cell::UnsafeCell::new(error)))); + ::std::rc::Rc::new( crate::implementation_from_dafny::_Wrappers_Compile::Result::Failure { + error: ::std::rc::Rc::new(super::r#_simple_dtypes_dboolean_dinternaldafny_dtypes::Error::Opaque { obj: error_obj }) + }) + }, + Ok(client) => { + let wrap = WrappedClient { wrapped: client.clone() }; + let inner: ::std::rc::Rc<::std::cell::UnsafeCell> + = ::std::rc::Rc::new(::std::cell::UnsafeCell::new(wrap)); + ::std::rc::Rc::new( crate::implementation_from_dafny::_Wrappers_Compile::Result::Success { + value: ::dafny_runtime::Object(Some(inner)) + }) + } + } } } \ No newline at end of file From 644af7cd9cc4c362cc4e8fae6959cce3e4dcfced Mon Sep 17 00:00:00 2001 From: Robin Salkeld Date: Tue, 25 Jun 2024 16:22:28 -0700 Subject: [PATCH 04/53] Successfully run and panicking! --- .../runtimes/rust/src/operation/get_boolean.rs | 2 +- .../runtimes/rust/src/operation/get_boolean/builders.rs | 8 ++++---- .../runtimes/rust/tests/simple_boolean_test.rs | 4 ++-- .../runtimes/rust/tests/tests_from_dafny/_wrapped.rs | 8 ++++---- .../runtimes/rust/tests/tests_from_dafny/mod.rs | 8 ++++---- 5 files changed, 15 insertions(+), 15 deletions(-) diff --git a/TestModels/SimpleTypes/SimpleBoolean/runtimes/rust/src/operation/get_boolean.rs b/TestModels/SimpleTypes/SimpleBoolean/runtimes/rust/src/operation/get_boolean.rs index 5b1fec2184..1ff461faf8 100644 --- a/TestModels/SimpleTypes/SimpleBoolean/runtimes/rust/src/operation/get_boolean.rs +++ b/TestModels/SimpleTypes/SimpleBoolean/runtimes/rust/src/operation/get_boolean.rs @@ -8,7 +8,7 @@ impl GetBoolean { pub fn new() -> Self { Self } - pub(crate) async fn send( + pub(crate) fn send( client: &crate::client::Client, input: crate::operation::get_boolean::GetBooleanInput, ) -> ::std::result::Result< diff --git a/TestModels/SimpleTypes/SimpleBoolean/runtimes/rust/src/operation/get_boolean/builders.rs b/TestModels/SimpleTypes/SimpleBoolean/runtimes/rust/src/operation/get_boolean/builders.rs index e672a27053..b30d907271 100644 --- a/TestModels/SimpleTypes/SimpleBoolean/runtimes/rust/src/operation/get_boolean/builders.rs +++ b/TestModels/SimpleTypes/SimpleBoolean/runtimes/rust/src/operation/get_boolean/builders.rs @@ -5,7 +5,7 @@ pub use crate::operation::get_boolean::_get_boolean_input::GetBooleanInputBuilde impl GetBooleanInputBuilder { /// Sends a request with this input using the given client. - pub async fn send_with( + pub fn send_with( self, client: &crate::Client, ) -> ::std::result::Result< @@ -14,7 +14,7 @@ impl GetBooleanInputBuilder { > { let mut fluent_builder = client.get_boolean(); fluent_builder.inner = self; - fluent_builder.send().await + fluent_builder.send() } } /// Fluent builder constructing a request to `GetBoolean`. @@ -37,7 +37,7 @@ impl GetBooleanFluentBuilder { &self.inner } /// Sends the request and returns the response. - pub async fn send( + pub fn send( self, ) -> ::std::result::Result< crate::operation::get_boolean::GetBooleanOutput, @@ -52,7 +52,7 @@ impl GetBooleanFluentBuilder { // Vanilla smithy-rs uses SdkError::construction_failure, // but we aren't using SdkError. .map_err(crate::operation::get_boolean::GetBooleanError::unhandled)?; - crate::operation::get_boolean::GetBoolean::send(&self.client, input).await + crate::operation::get_boolean::GetBoolean::send(&self.client, input) } #[allow(missing_docs)] // documentation missing in model diff --git a/TestModels/SimpleTypes/SimpleBoolean/runtimes/rust/tests/simple_boolean_test.rs b/TestModels/SimpleTypes/SimpleBoolean/runtimes/rust/tests/simple_boolean_test.rs index 7092b9ac16..83dcad65b1 100644 --- a/TestModels/SimpleTypes/SimpleBoolean/runtimes/rust/tests/simple_boolean_test.rs +++ b/TestModels/SimpleTypes/SimpleBoolean/runtimes/rust/tests/simple_boolean_test.rs @@ -26,7 +26,7 @@ mod tests_from_dafny; } */ #[tokio::test] async fn test_get_boolean_true() { - let result = client().get_boolean().value(true).send().await; + let result = client().get_boolean().value(true).send(); let output = result.unwrap(); let value = output.value().unwrap(); assert!(value); @@ -44,7 +44,7 @@ async fn test_get_boolean_true() { } */ #[tokio::test] async fn test_get_boolean_false() { - let result = client().get_boolean().value(false).send().await; + let result = client().get_boolean().value(false).send(); let output = result.unwrap(); let value = output.value().unwrap(); assert!(!value); diff --git a/TestModels/SimpleTypes/SimpleBoolean/runtimes/rust/tests/tests_from_dafny/_wrapped.rs b/TestModels/SimpleTypes/SimpleBoolean/runtimes/rust/tests/tests_from_dafny/_wrapped.rs index 097011f31b..1d7d28300d 100644 --- a/TestModels/SimpleTypes/SimpleBoolean/runtimes/rust/tests/tests_from_dafny/_wrapped.rs +++ b/TestModels/SimpleTypes/SimpleBoolean/runtimes/rust/tests/tests_from_dafny/_wrapped.rs @@ -20,16 +20,16 @@ impl super::r#_simple_dtypes_dboolean_dinternaldafny_dtypes::ISimpleTypesBoolean std::rc::Rc, >, > { - let result = self.wrapped.get_boolean().send().await; + let result = self.wrapped.get_boolean().send(); match result { Err(error) => ::std::rc::Rc::new( crate::implementation_from_dafny::_Wrappers_Compile::Result::Failure { error: crate::conversions::get_boolean::to_dafny_error( - error.clone(), + error, ) }), Ok(client) => ::std::rc::Rc::new( crate::implementation_from_dafny::_Wrappers_Compile::Result::Success { value: crate::conversions::get_boolean::_get_boolean_output::to_dafny( - client.clone(), + client, ) }), } @@ -41,7 +41,7 @@ impl r#_simple_dtypes_dboolean_dinternaldafny_dwrapped::_default { super::r#_simple_dtypes_dboolean_dinternaldafny_dtypes::SimpleBooleanConfig, >) -> ::std::rc::Rc, ::std::rc::Rc>> { let result = Client::from_conf( - simple_boolean::conversions::simple_boolean_config::_simple_boolean_config::from_dafny(*config) + simple_boolean::conversions::simple_boolean_config::_simple_boolean_config::from_dafny(config.clone()) ); match result { Err(error) => { diff --git a/TestModels/SimpleTypes/SimpleBoolean/runtimes/rust/tests/tests_from_dafny/mod.rs b/TestModels/SimpleTypes/SimpleBoolean/runtimes/rust/tests/tests_from_dafny/mod.rs index a975676146..e0db9e01f8 100644 --- a/TestModels/SimpleTypes/SimpleBoolean/runtimes/rust/tests/tests_from_dafny/mod.rs +++ b/TestModels/SimpleTypes/SimpleBoolean/runtimes/rust/tests/tests_from_dafny/mod.rs @@ -62,7 +62,7 @@ pub mod r#_SimpleBooleanImplTest_Compile { client = ::dafny_runtime::MaybePlacebo::from( valueOrError0.read().Extract().clone(), /* Coercion from T to ::dafny_runtime::Object not yet implemented */ ); - super::r#_SimpleBooleanImplTest_Compile::_default::TestGetBooleanTrue(&::dafny_runtime::UpcastTo::<::dafny_runtime::Object>::upcast_to(&client.read())); + super::r#_SimpleBooleanImplTest_Compile::_default::TestGetBooleanTrue(&::dafny_runtime::UpcastTo::<::dafny_runtime::Object>::upcast_to(client.read())); return (); } pub fn GetBooleanFalse() -> () { @@ -103,7 +103,7 @@ pub mod r#_SimpleBooleanImplTest_Compile { client = ::dafny_runtime::MaybePlacebo::from( valueOrError0.read().Extract().clone(), /* Coercion from T to ::dafny_runtime::Object not yet implemented */ ); - super::r#_SimpleBooleanImplTest_Compile::_default::TestGetBooleanFalse(&::dafny_runtime::UpcastTo::<::dafny_runtime::Object>::upcast_to(&client.read())); + super::r#_SimpleBooleanImplTest_Compile::_default::TestGetBooleanFalse(&::dafny_runtime::UpcastTo::<::dafny_runtime::Object>::upcast_to(client.read())); return (); } pub fn TestGetBooleanTrue( @@ -116,7 +116,7 @@ pub mod r#_SimpleBooleanImplTest_Compile { >::new(); let mut valueOrError0 = ::dafny_runtime::MaybePlacebo::<::std::rc::Rc, ::std::rc::Rc>>>::new(); let mut _out2 = ::dafny_runtime::MaybePlacebo::<::std::rc::Rc, ::std::rc::Rc>>>::new(); - _out2 = ::dafny_runtime::MaybePlacebo::from(::dafny_runtime::md!(client).GetBoolean(&::std::rc::Rc::new(super::r#_simple_dtypes_dboolean_dinternaldafny_dtypes::GetBooleanInput::GetBooleanInput { + _out2 = ::dafny_runtime::MaybePlacebo::from(::dafny_runtime::md!(client.clone()).GetBoolean(&::std::rc::Rc::new(super::r#_simple_dtypes_dboolean_dinternaldafny_dtypes::GetBooleanInput::GetBooleanInput { value: ::std::rc::Rc::new(super::r#_Wrappers_Compile::Option::::Some { value: true }) @@ -148,7 +148,7 @@ pub mod r#_SimpleBooleanImplTest_Compile { >::new(); let mut valueOrError0 = ::dafny_runtime::MaybePlacebo::<::std::rc::Rc, ::std::rc::Rc>>>::new(); let mut _out3 = ::dafny_runtime::MaybePlacebo::<::std::rc::Rc, ::std::rc::Rc>>>::new(); - _out3 = ::dafny_runtime::MaybePlacebo::from(::dafny_runtime::md!(client).GetBoolean(&::std::rc::Rc::new(super::r#_simple_dtypes_dboolean_dinternaldafny_dtypes::GetBooleanInput::GetBooleanInput { + _out3 = ::dafny_runtime::MaybePlacebo::from(::dafny_runtime::md!(client.clone()).GetBoolean(&::std::rc::Rc::new(super::r#_simple_dtypes_dboolean_dinternaldafny_dtypes::GetBooleanInput::GetBooleanInput { value: ::std::rc::Rc::new(super::r#_Wrappers_Compile::Option::::Some { value: false }) From 3f28cf7b6ef961d57b6df2b8fd0e252a800d715c Mon Sep 17 00:00:00 2001 From: Robin Salkeld Date: Tue, 25 Jun 2024 17:07:14 -0700 Subject: [PATCH 05/53] tests passing --- .../SimpleBoolean/runtimes/rust/src/operation/get_boolean.rs | 2 +- .../runtimes/rust/tests/tests_from_dafny/_wrapped.rs | 3 ++- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/TestModels/SimpleTypes/SimpleBoolean/runtimes/rust/src/operation/get_boolean.rs b/TestModels/SimpleTypes/SimpleBoolean/runtimes/rust/src/operation/get_boolean.rs index 1ff461faf8..bb1fb9f8f1 100644 --- a/TestModels/SimpleTypes/SimpleBoolean/runtimes/rust/src/operation/get_boolean.rs +++ b/TestModels/SimpleTypes/SimpleBoolean/runtimes/rust/src/operation/get_boolean.rs @@ -8,7 +8,7 @@ impl GetBoolean { pub fn new() -> Self { Self } - pub(crate) fn send( + pub fn send( client: &crate::client::Client, input: crate::operation::get_boolean::GetBooleanInput, ) -> ::std::result::Result< diff --git a/TestModels/SimpleTypes/SimpleBoolean/runtimes/rust/tests/tests_from_dafny/_wrapped.rs b/TestModels/SimpleTypes/SimpleBoolean/runtimes/rust/tests/tests_from_dafny/_wrapped.rs index 1d7d28300d..6eea7a3c9c 100644 --- a/TestModels/SimpleTypes/SimpleBoolean/runtimes/rust/tests/tests_from_dafny/_wrapped.rs +++ b/TestModels/SimpleTypes/SimpleBoolean/runtimes/rust/tests/tests_from_dafny/_wrapped.rs @@ -20,7 +20,8 @@ impl super::r#_simple_dtypes_dboolean_dinternaldafny_dtypes::ISimpleTypesBoolean std::rc::Rc, >, > { - let result = self.wrapped.get_boolean().send(); + let inner_input = crate::conversions::get_boolean::_get_boolean_input::from_dafny(input.clone()); + let result = crate::operation::get_boolean::GetBoolean::send(&self.wrapped, inner_input); match result { Err(error) => ::std::rc::Rc::new( crate::implementation_from_dafny::_Wrappers_Compile::Result::Failure { error: crate::conversions::get_boolean::to_dafny_error( From e3ce7ea40ccada1dec619486754468ad4d8c9a24 Mon Sep 17 00:00:00 2001 From: Robin Salkeld Date: Wed, 26 Jun 2024 08:22:05 -0700 Subject: [PATCH 06/53] Makefile updates --- SmithyDafnyMakefile.mk | 21 +++++++++------------ 1 file changed, 9 insertions(+), 12 deletions(-) diff --git a/SmithyDafnyMakefile.mk b/SmithyDafnyMakefile.mk index 2af2026458..7da9addb25 100644 --- a/SmithyDafnyMakefile.mk +++ b/SmithyDafnyMakefile.mk @@ -242,6 +242,7 @@ transpile_test: -functionSyntax:3 \ -useRuntimeLib \ -out $(OUT) \ + $(DAFNY_OPTIONS) \ $(if $(strip $(STD_LIBRARY)) , -library:$(PROJECT_ROOT)/$(STD_LIBRARY)/src/Index.dfy, ) \ $(TRANSPILE_DEPENDENCIES) \ @@ -296,6 +297,7 @@ _polymorph_wrapped: $(OUTPUT_DAFNY_WRAPPED) \ $(OUTPUT_DOTNET_WRAPPED) \ $(OUTPUT_JAVA_WRAPPED) \ + $(OUTPUT_RUST_WRAPPED) \ --model $(if $(DIR_STRUCTURE_V2),$(LIBRARY_ROOT)/dafny/$(SERVICE)/Model,$(LIBRARY_ROOT)/Model) \ --dependent-model $(PROJECT_ROOT)/$(SMITHY_DEPS) \ $(patsubst %, --dependent-model $(PROJECT_ROOT)/%/Model, $($(service_deps_var))) \ @@ -510,10 +512,7 @@ test_java: ########################## Rust targets -# TODO: Dafny test transpilation needs manual patching to work too, -# which isn't a high priority at this stage, -# so don't include transpile_test_rust for now. -transpile_rust: | transpile_implementation_rust transpile_dependencies_rust +transpile_rust: | transpile_implementation_rust transpile_test_rust transpile_dependencies_rust transpile_implementation_rust: TARGET=rs transpile_implementation_rust: OUT=implementation_from_dafny @@ -536,18 +535,16 @@ transpile_dependencies_rust: LANG=rust transpile_dependencies_rust: transpile_dependencies _mv_implementation_rust: - rm -rf runtimes/rust/dafny_impl/src - mkdir -p runtimes/rust/dafny_impl/src + rm -f runtimes/rust/src/implementation_from_dafny.rs # TODO: Currently need to insert an import of the the StandardLibrary. python -c "import sys; data = sys.stdin.buffer.read(); sys.stdout.buffer.write(data.replace(b'\npub mod', b'\npub use dafny_standard_library::implementation_from_dafny::*;\n\npub mod', 1) if b'\npub mod' in data else data)" \ - < implementation_from_dafny-rust/src/implementation_from_dafny.rs > runtimes/rust/dafny_impl/src/implementation_from_dafny.rs - rustfmt runtimes/rust/dafny_impl/src/implementation_from_dafny.rs + < implementation_from_dafny-rust/src/implementation_from_dafny.rs > runtimes/rust/src/implementation_from_dafny.rs + rustfmt runtimes/rust/src/implementation_from_dafny.rs rm -rf implementation_from_dafny-rust _mv_test_rust: - rm -rf runtimes/rust/dafny_impl/tests - mkdir -p runtimes/rust/dafny_impl/tests - mv tests_from_dafny-rust/src/tests_from_dafny.rs runtimes/rust/dafny_impl/tests/tests_from_dafny.rs - rustfmt runtimes/rust/dafny_impl/tests/tests_from_dafny.rs + rm -f runtimes/rust/tests/tests_from_dafny/mod.rs + mv tests_from_dafny-rust/src/tests_from_dafny.rs runtimes/rust/tests/tests_from_dafny/mod.rs + rustfmt runtimes/rust/tests/tests_from_dafny/mod.rs rm -rf tests_from_dafny-rust build_rust: From ff1fcd6d33ae826b3347aede4754b6eaae09c09a Mon Sep 17 00:00:00 2001 From: Robin Salkeld Date: Wed, 26 Jun 2024 08:36:31 -0700 Subject: [PATCH 07/53] Better tests file layout --- TestModels/SharedMakefile.mk | 7 ++ .../mod.rs => tests_from_dafny.rs} | 2 +- .../rust/tests/tests_from_dafny/_wrapped.rs | 101 ++++++++++-------- .../rust/tests/tests_from_dafny/lib.rs | 1 - 4 files changed, 67 insertions(+), 44 deletions(-) rename TestModels/SimpleTypes/SimpleBoolean/runtimes/rust/tests/{tests_from_dafny/mod.rs => tests_from_dafny.rs} (100%) delete mode 100644 TestModels/SimpleTypes/SimpleBoolean/runtimes/rust/tests/tests_from_dafny/lib.rs diff --git a/TestModels/SharedMakefile.mk b/TestModels/SharedMakefile.mk index c1a4384aeb..4cb2257c64 100644 --- a/TestModels/SharedMakefile.mk +++ b/TestModels/SharedMakefile.mk @@ -69,3 +69,10 @@ _polymorph_dotnet: _polymorph _polymorph_dotnet: OUTPUT_DOTNET_WRAPPED=\ $(if $(DIR_STRUCTURE_V2), --output-dotnet $(LIBRARY_ROOT)/runtimes/net/Generated/Wrapped/$(SERVICE)/, --output-dotnet $(LIBRARY_ROOT)/runtimes/net/Generated/Wrapped) _polymorph_dotnet: _polymorph_wrapped + +_polymorph_rust: OUTPUT_RUST=--output-rust $(LIBRARY_ROOT)/runtimes/rust +_polymorph_rust: INPUT_DAFNY=\ + --include-dafny $(PROJECT_ROOT)/$(STD_LIBRARY)/src/Index.dfy +_polymorph_rust: _polymorph +_polymorph_rust: OUTPUT_RUST_WRAPPED=--output-rust $(LIBRARY_ROOT)/runtimes/rust +_polymorph_rust: _polymorph_wrapped diff --git a/TestModels/SimpleTypes/SimpleBoolean/runtimes/rust/tests/tests_from_dafny/mod.rs b/TestModels/SimpleTypes/SimpleBoolean/runtimes/rust/tests/tests_from_dafny.rs similarity index 100% rename from TestModels/SimpleTypes/SimpleBoolean/runtimes/rust/tests/tests_from_dafny/mod.rs rename to TestModels/SimpleTypes/SimpleBoolean/runtimes/rust/tests/tests_from_dafny.rs index e0db9e01f8..abc7273e8b 100644 --- a/TestModels/SimpleTypes/SimpleBoolean/runtimes/rust/tests/tests_from_dafny/mod.rs +++ b/TestModels/SimpleTypes/SimpleBoolean/runtimes/rust/tests/tests_from_dafny.rs @@ -1,7 +1,7 @@ #![allow(warnings, unconditional_panic)] #![allow(nonstandard_style)] -use simple_boolean::*; use simple_boolean::implementation_from_dafny::*; +use simple_boolean::*; mod _wrapped; pub mod r#_simple_dtypes_dboolean_dinternaldafny_dwrapped { pub struct _default {} diff --git a/TestModels/SimpleTypes/SimpleBoolean/runtimes/rust/tests/tests_from_dafny/_wrapped.rs b/TestModels/SimpleTypes/SimpleBoolean/runtimes/rust/tests/tests_from_dafny/_wrapped.rs index 6eea7a3c9c..b4df5c931b 100644 --- a/TestModels/SimpleTypes/SimpleBoolean/runtimes/rust/tests/tests_from_dafny/_wrapped.rs +++ b/TestModels/SimpleTypes/SimpleBoolean/runtimes/rust/tests/tests_from_dafny/_wrapped.rs @@ -1,12 +1,14 @@ -use simple_boolean::*; use crate::tests_from_dafny::*; use aws_smithy_types::error::operation::BuildError; +use simple_boolean::*; struct WrappedClient { - wrapped: Client + wrapped: Client, } -impl super::r#_simple_dtypes_dboolean_dinternaldafny_dtypes::ISimpleTypesBooleanClient for WrappedClient { +impl super::r#_simple_dtypes_dboolean_dinternaldafny_dtypes::ISimpleTypesBooleanClient + for WrappedClient +{ fn GetBoolean( &mut self, input: &std::rc::Rc< @@ -19,48 +21,63 @@ impl super::r#_simple_dtypes_dboolean_dinternaldafny_dtypes::ISimpleTypesBoolean >, std::rc::Rc, >, - > { - let inner_input = crate::conversions::get_boolean::_get_boolean_input::from_dafny(input.clone()); - let result = crate::operation::get_boolean::GetBoolean::send(&self.wrapped, inner_input); - match result { - Err(error) => ::std::rc::Rc::new( crate::implementation_from_dafny::_Wrappers_Compile::Result::Failure { - error: crate::conversions::get_boolean::to_dafny_error( - error, - ) - }), - Ok(client) => ::std::rc::Rc::new( crate::implementation_from_dafny::_Wrappers_Compile::Result::Success { - value: crate::conversions::get_boolean::_get_boolean_output::to_dafny( - client, - ) - }), - } - } + >{ + let inner_input = + crate::conversions::get_boolean::_get_boolean_input::from_dafny(input.clone()); + let result = crate::operation::get_boolean::GetBoolean::send(&self.wrapped, inner_input); + match result { + Err(error) => ::std::rc::Rc::new( + crate::implementation_from_dafny::_Wrappers_Compile::Result::Failure { + error: crate::conversions::get_boolean::to_dafny_error(error), + }, + ), + Ok(client) => ::std::rc::Rc::new( + crate::implementation_from_dafny::_Wrappers_Compile::Result::Success { + value: crate::conversions::get_boolean::_get_boolean_output::to_dafny(client), + }, + ), + } + } } impl r#_simple_dtypes_dboolean_dinternaldafny_dwrapped::_default { - pub fn WrappedSimpleBoolean(config: &::std::rc::Rc< + pub fn WrappedSimpleBoolean(config: &::std::rc::Rc< super::r#_simple_dtypes_dboolean_dinternaldafny_dtypes::SimpleBooleanConfig, ->) -> ::std::rc::Rc, ::std::rc::Rc>> { - let result = Client::from_conf( - simple_boolean::conversions::simple_boolean_config::_simple_boolean_config::from_dafny(config.clone()) - ); - match result { - Err(error) => { - let error_obj: ::dafny_runtime::Object = - ::dafny_runtime::Object(Some(::std::rc::Rc::new(::std::cell::UnsafeCell::new(error)))); - ::std::rc::Rc::new( crate::implementation_from_dafny::_Wrappers_Compile::Result::Failure { - error: ::std::rc::Rc::new(super::r#_simple_dtypes_dboolean_dinternaldafny_dtypes::Error::Opaque { obj: error_obj }) - }) - }, - Ok(client) => { - let wrap = WrappedClient { wrapped: client.clone() }; - let inner: ::std::rc::Rc<::std::cell::UnsafeCell> - = ::std::rc::Rc::new(::std::cell::UnsafeCell::new(wrap)); + >) -> ::std::rc::Rc, ::std::rc::Rc>>{ + let result = Client::from_conf( + simple_boolean::conversions::simple_boolean_config::_simple_boolean_config::from_dafny( + config.clone(), + ), + ); + match result { + Err(error) => { + let error_obj: ::dafny_runtime::Object = + ::dafny_runtime::Object(Some(::std::rc::Rc::new( + ::std::cell::UnsafeCell::new(error), + ))); + ::std::rc::Rc::new( + crate::implementation_from_dafny::_Wrappers_Compile::Result::Failure { + error: ::std::rc::Rc::new( + super::r#_simple_dtypes_dboolean_dinternaldafny_dtypes::Error::Opaque { + obj: error_obj, + }, + ), + }, + ) + } + Ok(client) => { + let wrap = WrappedClient { + wrapped: client.clone(), + }; + let inner: ::std::rc::Rc<::std::cell::UnsafeCell> + = ::std::rc::Rc::new(::std::cell::UnsafeCell::new(wrap)); - ::std::rc::Rc::new( crate::implementation_from_dafny::_Wrappers_Compile::Result::Success { - value: ::dafny_runtime::Object(Some(inner)) - }) - } + ::std::rc::Rc::new( + crate::implementation_from_dafny::_Wrappers_Compile::Result::Success { + value: ::dafny_runtime::Object(Some(inner)), + }, + ) + } + } } - } -} \ No newline at end of file +} diff --git a/TestModels/SimpleTypes/SimpleBoolean/runtimes/rust/tests/tests_from_dafny/lib.rs b/TestModels/SimpleTypes/SimpleBoolean/runtimes/rust/tests/tests_from_dafny/lib.rs deleted file mode 100644 index 65c425e314..0000000000 --- a/TestModels/SimpleTypes/SimpleBoolean/runtimes/rust/tests/tests_from_dafny/lib.rs +++ /dev/null @@ -1 +0,0 @@ -mod _wrapped; \ No newline at end of file From aa7f02e3541028e680d43c5af5a0bdd45216a22d Mon Sep 17 00:00:00 2001 From: Robin Salkeld Date: Wed, 26 Jun 2024 09:15:42 -0700 Subject: [PATCH 08/53] =?UTF-8?q?Don=E2=80=99t=20let=20polymorph=20delete?= =?UTF-8?q?=20implementation=5Ffrom=5Fdafny.rs?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- SmithyDafnyMakefile.mk | 6 +- .../codegen-patches/rust/dafny-4.5.0.patch | 183 ++- .../codegen-patches/rust/dafny-4.5.0.patch | 1464 ++--------------- .../amazon/polymorph/CodegenEngine.java | 18 +- 4 files changed, 262 insertions(+), 1409 deletions(-) diff --git a/SmithyDafnyMakefile.mk b/SmithyDafnyMakefile.mk index 7da9addb25..c3e94c35d0 100644 --- a/SmithyDafnyMakefile.mk +++ b/SmithyDafnyMakefile.mk @@ -542,9 +542,9 @@ _mv_implementation_rust: rustfmt runtimes/rust/src/implementation_from_dafny.rs rm -rf implementation_from_dafny-rust _mv_test_rust: - rm -f runtimes/rust/tests/tests_from_dafny/mod.rs - mv tests_from_dafny-rust/src/tests_from_dafny.rs runtimes/rust/tests/tests_from_dafny/mod.rs - rustfmt runtimes/rust/tests/tests_from_dafny/mod.rs + rm -f runtimes/rust/tests/tests_from_dafny.rs + mv tests_from_dafny-rust/src/tests_from_dafny.rs runtimes/rust/tests/tests_from_dafny.rs + rustfmt runtimes/rust/tests/tests_from_dafny.rs rm -rf tests_from_dafny-rust build_rust: diff --git a/TestModels/SimpleTypes/SimpleBoolean/codegen-patches/rust/dafny-4.5.0.patch b/TestModels/SimpleTypes/SimpleBoolean/codegen-patches/rust/dafny-4.5.0.patch index d43bbd3d8f..888ae36eff 100644 --- a/TestModels/SimpleTypes/SimpleBoolean/codegen-patches/rust/dafny-4.5.0.patch +++ b/TestModels/SimpleTypes/SimpleBoolean/codegen-patches/rust/dafny-4.5.0.patch @@ -1,28 +1,6 @@ -diff --git b/TestModels/SimpleTypes/SimpleBoolean/runtimes/rust/dafny_impl/src/implementation_from_dafny.rs a/TestModels/SimpleTypes/SimpleBoolean/runtimes/rust/dafny_impl/src/implementation_from_dafny.rs -index c2850c0e..06c0c0ea 100644 ---- b/TestModels/SimpleTypes/SimpleBoolean/runtimes/rust/dafny_impl/src/implementation_from_dafny.rs -+++ a/TestModels/SimpleTypes/SimpleBoolean/runtimes/rust/dafny_impl/src/implementation_from_dafny.rs -@@ -434,7 +434,7 @@ pub mod r#_SimpleBooleanImpl_Compile { - ) { - panic!("Halt") - }; -- if !(input.value().value() == true || input.value().value() == false) { -+ if !(*input.value().value() == true || *input.value().value() == false) { - panic!("Halt") - }; - let mut res: ::std::rc::Rc = ::std::rc::Rc::new(super::r#_simple_dtypes_dboolean_dinternaldafny_dtypes::GetBooleanOutput::GetBooleanOutput { -@@ -443,7 +443,7 @@ pub mod r#_SimpleBooleanImpl_Compile { - res = ::std::rc::Rc::new(super::r#_simple_dtypes_dboolean_dinternaldafny_dtypes::GetBooleanOutput::GetBooleanOutput { - value: input.value().clone() - }); -- if !(res.value().value() == true || res.value().value() == false) { -+ if !(*res.value().value() == true || *res.value().value() == false) { - panic!("Halt") - }; - if !(input.value().value() == res.value().value()) { diff --git b/TestModels/SimpleTypes/SimpleBoolean/runtimes/rust/src/client.rs a/TestModels/SimpleTypes/SimpleBoolean/runtimes/rust/src/client.rs new file mode 100644 -index 00000000..5170a9ce +index 00000000..f088d4a8 --- /dev/null +++ a/TestModels/SimpleTypes/SimpleBoolean/runtimes/rust/src/client.rs @@ -0,0 +1,37 @@ @@ -32,7 +10,7 @@ index 00000000..5170a9ce + +#[derive(::std::clone::Clone, ::std::fmt::Debug)] +pub struct Client { -+ pub(crate) dafny_client: ::dafny_runtime::Object ++ pub(crate) dafny_client: ::dafny_runtime::Object +} + +impl Client { @@ -42,12 +20,12 @@ index 00000000..5170a9ce + conf: crate::types::simple_boolean_config::SimpleBooleanConfig, + ) -> Result { + let inner = -+ ::simple_boolean_dafny::_simple_dtypes_dboolean_dinternaldafny::_default::SimpleBoolean( ++ crate::implementation_from_dafny::_simple_dtypes_dboolean_dinternaldafny::_default::SimpleBoolean( + &crate::conversions::simple_boolean_config::_simple_boolean_config::to_dafny(conf), + ); + if matches!( + inner.as_ref(), -+ ::simple_boolean_dafny::_Wrappers_Compile::Result::Failure { .. } ++ crate::implementation_from_dafny::_Wrappers_Compile::Result::Failure { .. } + ) { + // TODO: convert error - the potential types are not modeled! + return Err(BuildError::other( @@ -57,7 +35,7 @@ index 00000000..5170a9ce + )); + } + Ok(Self { -+ dafny_client: ::dafny_runtime::UpcastTo::>::upcast_to(inner.Extract()), ++ dafny_client: ::dafny_runtime::UpcastTo::>::upcast_to(inner.Extract()), + }) + } +} @@ -94,7 +72,7 @@ index 00000000..c1acac7b +pub mod simple_boolean_config; diff --git b/TestModels/SimpleTypes/SimpleBoolean/runtimes/rust/src/conversions/get_boolean.rs a/TestModels/SimpleTypes/SimpleBoolean/runtimes/rust/src/conversions/get_boolean.rs new file mode 100644 -index 00000000..6f9f1b3c +index 00000000..64b557cc --- /dev/null +++ a/TestModels/SimpleTypes/SimpleBoolean/runtimes/rust/src/conversions/get_boolean.rs @@ -0,0 +1,32 @@ @@ -105,21 +83,21 @@ index 00000000..6f9f1b3c +#[allow(dead_code)] +pub fn to_dafny_error( + value: crate::operation::get_boolean::GetBooleanError, -+) -> ::std::rc::Rc<::simple_boolean_dafny::r#_simple_dtypes_dboolean_dinternaldafny_dtypes::Error> { ++) -> ::std::rc::Rc { + match value { + crate::operation::get_boolean::GetBooleanError::Unhandled(unhandled) => -+ ::std::rc::Rc::new(::simple_boolean_dafny::r#_simple_dtypes_dboolean_dinternaldafny_dtypes::Error::Opaque { obj: ::dafny_runtime::UpcastTo::<::dafny_runtime::Object>::upcast_to(::dafny_runtime::object::new(unhandled)) }) ++ ::std::rc::Rc::new(crate::implementation_from_dafny::r#_simple_dtypes_dboolean_dinternaldafny_dtypes::Error::Opaque { obj: ::dafny_runtime::UpcastTo::<::dafny_runtime::Object>::upcast_to(::dafny_runtime::object::new(unhandled)) }) + } +} + +#[allow(dead_code)] +pub fn from_dafny_error( + dafny_value: ::std::rc::Rc< -+ ::simple_boolean_dafny::r#_simple_dtypes_dboolean_dinternaldafny_dtypes::Error, ++ crate::implementation_from_dafny::r#_simple_dtypes_dboolean_dinternaldafny_dtypes::Error, + >, +) -> crate::operation::get_boolean::GetBooleanError { + // TODO: Losing information here, but we have to figure out how to wrap an arbitrary Dafny value as std::error::Error -+ if matches!(&dafny_value.as_ref(), ::simple_boolean_dafny::r#_simple_dtypes_dboolean_dinternaldafny_dtypes::Error::CollectionOfErrors { .. }) { ++ if matches!(&dafny_value.as_ref(), crate::implementation_from_dafny::r#_simple_dtypes_dboolean_dinternaldafny_dtypes::Error::CollectionOfErrors { .. }) { + let error_message = "TODO: can't get message yet"; + crate::operation::get_boolean::GetBooleanError::generic(::aws_smithy_types::error::metadata::ErrorMetadata::builder().message(error_message).build()) + } else { @@ -132,7 +110,7 @@ index 00000000..6f9f1b3c +pub mod _get_boolean_output; diff --git b/TestModels/SimpleTypes/SimpleBoolean/runtimes/rust/src/conversions/get_boolean/_get_boolean_input.rs a/TestModels/SimpleTypes/SimpleBoolean/runtimes/rust/src/conversions/get_boolean/_get_boolean_input.rs new file mode 100644 -index 00000000..efd9d5f8 +index 00000000..27e4ef74 --- /dev/null +++ a/TestModels/SimpleTypes/SimpleBoolean/runtimes/rust/src/conversions/get_boolean/_get_boolean_input.rs @@ -0,0 +1,37 @@ @@ -141,13 +119,13 @@ index 00000000..efd9d5f8 +pub fn to_dafny( + value: crate::operation::get_boolean::GetBooleanInput, +) -> ::std::rc::Rc< -+ ::simple_boolean_dafny::r#_simple_dtypes_dboolean_dinternaldafny_dtypes::GetBooleanInput, ++ crate::implementation_from_dafny::r#_simple_dtypes_dboolean_dinternaldafny_dtypes::GetBooleanInput, +> { + let dafny_value = match value.value { -+ Some(b) => ::simple_boolean_dafny::_Wrappers_Compile::Option::Some { value: b }, -+ None => ::simple_boolean_dafny::_Wrappers_Compile::Option::None {}, ++ Some(b) => crate::implementation_from_dafny::_Wrappers_Compile::Option::Some { value: b }, ++ None => crate::implementation_from_dafny::_Wrappers_Compile::Option::None {}, + }; -+ ::std::rc::Rc::new(::simple_boolean_dafny::r#_simple_dtypes_dboolean_dinternaldafny_dtypes::GetBooleanInput::GetBooleanInput { ++ ::std::rc::Rc::new(crate::implementation_from_dafny::r#_simple_dtypes_dboolean_dinternaldafny_dtypes::GetBooleanInput::GetBooleanInput { + value: ::std::rc::Rc::new(dafny_value) + }) +} @@ -155,17 +133,17 @@ index 00000000..efd9d5f8 +#[allow(dead_code)] +pub fn from_dafny( + dafny_value: ::std::rc::Rc< -+ ::simple_boolean_dafny::r#_simple_dtypes_dboolean_dinternaldafny_dtypes::GetBooleanInput, ++ crate::implementation_from_dafny::r#_simple_dtypes_dboolean_dinternaldafny_dtypes::GetBooleanInput, + >, +) -> crate::operation::get_boolean::GetBooleanInput { + let value = if matches!( + dafny_value.value().as_ref(), -+ ::simple_boolean_dafny::_Wrappers_Compile::Option::Some { .. } ++ crate::implementation_from_dafny::_Wrappers_Compile::Option::Some { .. } + ) { + Some(dafny_value.value().Extract()) + } else if matches!( + dafny_value.value().as_ref(), -+ ::simple_boolean_dafny::_Wrappers_Compile::Option::None { .. } ++ crate::implementation_from_dafny::_Wrappers_Compile::Option::None { .. } + ) { + None + } else { @@ -175,7 +153,7 @@ index 00000000..efd9d5f8 +} diff --git b/TestModels/SimpleTypes/SimpleBoolean/runtimes/rust/src/conversions/get_boolean/_get_boolean_output.rs a/TestModels/SimpleTypes/SimpleBoolean/runtimes/rust/src/conversions/get_boolean/_get_boolean_output.rs new file mode 100644 -index 00000000..4b9dec69 +index 00000000..719f9692 --- /dev/null +++ a/TestModels/SimpleTypes/SimpleBoolean/runtimes/rust/src/conversions/get_boolean/_get_boolean_output.rs @@ -0,0 +1,37 @@ @@ -184,13 +162,13 @@ index 00000000..4b9dec69 +pub fn to_dafny( + value: crate::operation::get_boolean::GetBooleanOutput, +) -> ::std::rc::Rc< -+ ::simple_boolean_dafny::r#_simple_dtypes_dboolean_dinternaldafny_dtypes::GetBooleanOutput, ++ crate::implementation_from_dafny::r#_simple_dtypes_dboolean_dinternaldafny_dtypes::GetBooleanOutput, +> { + let dafny_value = match value.value { -+ Some(b) => ::simple_boolean_dafny::_Wrappers_Compile::Option::Some { value: b }, -+ None => ::simple_boolean_dafny::_Wrappers_Compile::Option::None {}, ++ Some(b) => crate::implementation_from_dafny::_Wrappers_Compile::Option::Some { value: b }, ++ None => crate::implementation_from_dafny::_Wrappers_Compile::Option::None {}, + }; -+ ::std::rc::Rc::new(::simple_boolean_dafny::r#_simple_dtypes_dboolean_dinternaldafny_dtypes::GetBooleanOutput::GetBooleanOutput { ++ ::std::rc::Rc::new(crate::implementation_from_dafny::r#_simple_dtypes_dboolean_dinternaldafny_dtypes::GetBooleanOutput::GetBooleanOutput { + value: ::std::rc::Rc::new(dafny_value) + }) +} @@ -198,17 +176,17 @@ index 00000000..4b9dec69 +#[allow(dead_code)] +pub fn from_dafny( + dafny_value: ::std::rc::Rc< -+ ::simple_boolean_dafny::r#_simple_dtypes_dboolean_dinternaldafny_dtypes::GetBooleanOutput, ++ crate::implementation_from_dafny::r#_simple_dtypes_dboolean_dinternaldafny_dtypes::GetBooleanOutput, + >, +) -> crate::operation::get_boolean::GetBooleanOutput { + let value = if matches!( + dafny_value.value().as_ref(), -+ ::simple_boolean_dafny::_Wrappers_Compile::Option::Some { .. } ++ crate::implementation_from_dafny::_Wrappers_Compile::Option::Some { .. } + ) { + Some(dafny_value.value().Extract()) + } else if matches!( + dafny_value.value().as_ref(), -+ ::simple_boolean_dafny::_Wrappers_Compile::Option::None { .. } ++ crate::implementation_from_dafny::_Wrappers_Compile::Option::None { .. } + ) { + None + } else { @@ -227,25 +205,27 @@ index 00000000..371a47e5 +pub mod _simple_boolean_config; diff --git b/TestModels/SimpleTypes/SimpleBoolean/runtimes/rust/src/conversions/simple_boolean_config/_simple_boolean_config.rs a/TestModels/SimpleTypes/SimpleBoolean/runtimes/rust/src/conversions/simple_boolean_config/_simple_boolean_config.rs new file mode 100644 -index 00000000..6c7dc176 +index 00000000..a19536aa --- /dev/null +++ a/TestModels/SimpleTypes/SimpleBoolean/runtimes/rust/src/conversions/simple_boolean_config/_simple_boolean_config.rs -@@ -0,0 +1,19 @@ +@@ -0,0 +1,21 @@ ++use dafny_standard_library::implementation_from_dafny; ++ +// Code generated by software.amazon.smithy.rust.codegen.smithy-rs. DO NOT EDIT. +#[allow(dead_code)] + +pub fn to_dafny( + value: crate::types::simple_boolean_config::SimpleBooleanConfig, +) -> ::std::rc::Rc< -+ ::simple_boolean_dafny::_simple_dtypes_dboolean_dinternaldafny_dtypes::SimpleBooleanConfig, ++ crate::implementation_from_dafny::_simple_dtypes_dboolean_dinternaldafny_dtypes::SimpleBooleanConfig, +> { -+ ::std::rc::Rc::new(::simple_boolean_dafny::r#_simple_dtypes_dboolean_dinternaldafny_dtypes::SimpleBooleanConfig::SimpleBooleanConfig {}) ++ ::std::rc::Rc::new(crate::implementation_from_dafny::r#_simple_dtypes_dboolean_dinternaldafny_dtypes::SimpleBooleanConfig::SimpleBooleanConfig {}) +} + +#[allow(dead_code)] +pub fn from_dafny( + dafny_value: ::std::rc::Rc< -+ ::simple_boolean_dafny::r#_simple_dtypes_dboolean_dinternaldafny_dtypes::SimpleBooleanConfig, ++ crate::implementation_from_dafny::r#_simple_dtypes_dboolean_dinternaldafny_dtypes::SimpleBooleanConfig, + >, +) -> crate::types::simple_boolean_config::SimpleBooleanConfig { + crate::types::simple_boolean_config::SimpleBooleanConfig {} @@ -300,10 +280,10 @@ index 00000000..9d21fbd6 +} diff --git b/TestModels/SimpleTypes/SimpleBoolean/runtimes/rust/src/lib.rs a/TestModels/SimpleTypes/SimpleBoolean/runtimes/rust/src/lib.rs new file mode 100644 -index 00000000..1d16c191 +index 00000000..118aa67e --- /dev/null +++ a/TestModels/SimpleTypes/SimpleBoolean/runtimes/rust/src/lib.rs -@@ -0,0 +1,17 @@ +@@ -0,0 +1,19 @@ +#![allow(deprecated)] + +// Code generated by software.amazon.smithy.rust.codegen.smithy-rs. DO NOT EDIT. @@ -317,7 +297,9 @@ index 00000000..1d16c191 +/// All operations that this crate can perform. +pub mod operation; + -+mod conversions; ++pub mod conversions; ++ ++pub mod implementation_from_dafny; + +pub use client::Client; +pub use types::simple_boolean_config::SimpleBooleanConfig; @@ -333,7 +315,7 @@ index 00000000..eb38b9f1 +pub mod get_boolean; diff --git b/TestModels/SimpleTypes/SimpleBoolean/runtimes/rust/src/operation/get_boolean.rs a/TestModels/SimpleTypes/SimpleBoolean/runtimes/rust/src/operation/get_boolean.rs new file mode 100644 -index 00000000..96381e1d +index 00000000..bb1fb9f8 --- /dev/null +++ a/TestModels/SimpleTypes/SimpleBoolean/runtimes/rust/src/operation/get_boolean.rs @@ -0,0 +1,145 @@ @@ -347,7 +329,7 @@ index 00000000..96381e1d + pub fn new() -> Self { + Self + } -+ pub(crate) async fn send( ++ pub fn send( + client: &crate::client::Client, + input: crate::operation::get_boolean::GetBooleanInput, + ) -> ::std::result::Result< @@ -359,7 +341,7 @@ index 00000000..96381e1d + ::dafny_runtime::md!(client.dafny_client.clone()).GetBoolean(&inner_input); + if matches!( + inner_result.as_ref(), -+ ::simple_boolean_dafny::r#_Wrappers_Compile::Result::Success { .. } ++ crate::implementation_from_dafny::r#_Wrappers_Compile::Result::Success { .. } + ) { + Ok( + crate::conversions::get_boolean::_get_boolean_output::from_dafny( @@ -614,7 +596,7 @@ index 00000000..d2943f38 +} diff --git b/TestModels/SimpleTypes/SimpleBoolean/runtimes/rust/src/operation/get_boolean/builders.rs a/TestModels/SimpleTypes/SimpleBoolean/runtimes/rust/src/operation/get_boolean/builders.rs new file mode 100644 -index 00000000..e672a270 +index 00000000..b30d9072 --- /dev/null +++ a/TestModels/SimpleTypes/SimpleBoolean/runtimes/rust/src/operation/get_boolean/builders.rs @@ -0,0 +1,72 @@ @@ -625,7 +607,7 @@ index 00000000..e672a270 + +impl GetBooleanInputBuilder { + /// Sends a request with this input using the given client. -+ pub async fn send_with( ++ pub fn send_with( + self, + client: &crate::Client, + ) -> ::std::result::Result< @@ -634,7 +616,7 @@ index 00000000..e672a270 + > { + let mut fluent_builder = client.get_boolean(); + fluent_builder.inner = self; -+ fluent_builder.send().await ++ fluent_builder.send() + } +} +/// Fluent builder constructing a request to `GetBoolean`. @@ -657,7 +639,7 @@ index 00000000..e672a270 + &self.inner + } + /// Sends the request and returns the response. -+ pub async fn send( ++ pub fn send( + self, + ) -> ::std::result::Result< + crate::operation::get_boolean::GetBooleanOutput, @@ -672,7 +654,7 @@ index 00000000..e672a270 + // Vanilla smithy-rs uses SdkError::construction_failure, + // but we aren't using SdkError. + .map_err(crate::operation::get_boolean::GetBooleanError::unhandled)?; -+ crate::operation::get_boolean::GetBoolean::send(&self.client, input).await ++ crate::operation::get_boolean::GetBoolean::send(&self.client, input) + } + + #[allow(missing_docs)] // documentation missing in model @@ -732,3 +714,76 @@ index 00000000..6bf027f6 + ::std::result::Result::Ok(SimpleBooleanConfig {}) + } +} +diff --git b/TestModels/SimpleTypes/SimpleBoolean/runtimes/rust/tests/tests_from_dafny.rs a/TestModels/SimpleTypes/SimpleBoolean/runtimes/rust/tests/tests_from_dafny.rs +index 917943b5..abc7273e 100644 +--- b/TestModels/SimpleTypes/SimpleBoolean/runtimes/rust/tests/tests_from_dafny.rs ++++ a/TestModels/SimpleTypes/SimpleBoolean/runtimes/rust/tests/tests_from_dafny.rs +@@ -1,5 +1,8 @@ + #![allow(warnings, unconditional_panic)] + #![allow(nonstandard_style)] ++use simple_boolean::implementation_from_dafny::*; ++use simple_boolean::*; ++mod _wrapped; + pub mod r#_simple_dtypes_dboolean_dinternaldafny_dwrapped { + pub struct _default {} + +@@ -57,9 +60,9 @@ pub mod r#_SimpleBooleanImplTest_Compile { + panic!("Halt") + }; + client = ::dafny_runtime::MaybePlacebo::from( +- ::std::option::Option::Some(valueOrError0.read().Extract().clone()), /* Coercion from T to ::dafny_runtime::Object not yet implemented */ ++ valueOrError0.read().Extract().clone(), /* Coercion from T to ::dafny_runtime::Object not yet implemented */ + ); +- super::r#_SimpleBooleanImplTest_Compile::_default::TestGetBooleanTrue(&::dafny_runtime::UpcastTo::<::dafny_runtime::Object>::upcast_to(&client.read())); ++ super::r#_SimpleBooleanImplTest_Compile::_default::TestGetBooleanTrue(&::dafny_runtime::UpcastTo::<::dafny_runtime::Object>::upcast_to(client.read())); + return (); + } + pub fn GetBooleanFalse() -> () { +@@ -98,9 +101,9 @@ pub mod r#_SimpleBooleanImplTest_Compile { + panic!("Halt") + }; + client = ::dafny_runtime::MaybePlacebo::from( +- ::std::option::Option::Some(valueOrError0.read().Extract().clone()), /* Coercion from T to ::dafny_runtime::Object not yet implemented */ ++ valueOrError0.read().Extract().clone(), /* Coercion from T to ::dafny_runtime::Object not yet implemented */ + ); +- super::r#_SimpleBooleanImplTest_Compile::_default::TestGetBooleanFalse(&::dafny_runtime::UpcastTo::<::dafny_runtime::Object>::upcast_to(&client.read())); ++ super::r#_SimpleBooleanImplTest_Compile::_default::TestGetBooleanFalse(&::dafny_runtime::UpcastTo::<::dafny_runtime::Object>::upcast_to(client.read())); + return (); + } + pub fn TestGetBooleanTrue( +@@ -113,7 +116,7 @@ pub mod r#_SimpleBooleanImplTest_Compile { + >::new(); + let mut valueOrError0 = ::dafny_runtime::MaybePlacebo::<::std::rc::Rc, ::std::rc::Rc>>>::new(); + let mut _out2 = ::dafny_runtime::MaybePlacebo::<::std::rc::Rc, ::std::rc::Rc>>>::new(); +- _out2 = ::dafny_runtime::MaybePlacebo::from(::dafny_runtime::md!(client).GetBoolean(&::std::rc::Rc::new(super::r#_simple_dtypes_dboolean_dinternaldafny_dtypes::GetBooleanInput::GetBooleanInput { ++ _out2 = ::dafny_runtime::MaybePlacebo::from(::dafny_runtime::md!(client.clone()).GetBoolean(&::std::rc::Rc::new(super::r#_simple_dtypes_dboolean_dinternaldafny_dtypes::GetBooleanInput::GetBooleanInput { + value: ::std::rc::Rc::new(super::r#_Wrappers_Compile::Option::::Some { + value: true + }) +@@ -145,7 +148,7 @@ pub mod r#_SimpleBooleanImplTest_Compile { + >::new(); + let mut valueOrError0 = ::dafny_runtime::MaybePlacebo::<::std::rc::Rc, ::std::rc::Rc>>>::new(); + let mut _out3 = ::dafny_runtime::MaybePlacebo::<::std::rc::Rc, ::std::rc::Rc>>>::new(); +- _out3 = ::dafny_runtime::MaybePlacebo::from(::dafny_runtime::md!(client).GetBoolean(&::std::rc::Rc::new(super::r#_simple_dtypes_dboolean_dinternaldafny_dtypes::GetBooleanInput::GetBooleanInput { ++ _out3 = ::dafny_runtime::MaybePlacebo::from(::dafny_runtime::md!(client.clone()).GetBoolean(&::std::rc::Rc::new(super::r#_simple_dtypes_dboolean_dinternaldafny_dtypes::GetBooleanInput::GetBooleanInput { + value: ::std::rc::Rc::new(super::r#_Wrappers_Compile::Option::::Some { + value: false + }) +@@ -186,7 +189,7 @@ pub mod r#_WrappedSimpleTypesBooleanTest_Compile { + panic!("Halt") + }; + client = ::dafny_runtime::MaybePlacebo::from( +- ::std::option::Option::Some(valueOrError0.read().Extract().clone()), /* Coercion from T to ::dafny_runtime::Object not yet implemented */ ++ valueOrError0.read().Extract().clone(), /* Coercion from T to ::dafny_runtime::Object not yet implemented */ + ); + super::r#_SimpleBooleanImplTest_Compile::_default::TestGetBooleanTrue(&client.read()); + return (); +@@ -201,7 +204,7 @@ pub mod r#_WrappedSimpleTypesBooleanTest_Compile { + panic!("Halt") + }; + client = ::dafny_runtime::MaybePlacebo::from( +- ::std::option::Option::Some(valueOrError0.read().Extract().clone()), /* Coercion from T to ::dafny_runtime::Object not yet implemented */ ++ valueOrError0.read().Extract().clone(), /* Coercion from T to ::dafny_runtime::Object not yet implemented */ + ); + super::r#_SimpleBooleanImplTest_Compile::_default::TestGetBooleanFalse(&client.read()); + return (); diff --git a/TestModels/dafny-dependencies/StandardLibrary/codegen-patches/rust/dafny-4.5.0.patch b/TestModels/dafny-dependencies/StandardLibrary/codegen-patches/rust/dafny-4.5.0.patch index 83baa808ef..3af8df4bea 100644 --- a/TestModels/dafny-dependencies/StandardLibrary/codegen-patches/rust/dafny-4.5.0.patch +++ b/TestModels/dafny-dependencies/StandardLibrary/codegen-patches/rust/dafny-4.5.0.patch @@ -183,1351 +183,135 @@ index 00000000..3b7c2e76 + } +} diff --git b/TestModels/dafny-dependencies/StandardLibrary/runtimes/rust/src/implementation_from_dafny.rs a/TestModels/dafny-dependencies/StandardLibrary/runtimes/rust/src/implementation_from_dafny.rs -new file mode 100644 -index 00000000..20cb9f07 ---- /dev/null +index ecfecc03..20cb9f07 100644 +--- b/TestModels/dafny-dependencies/StandardLibrary/runtimes/rust/src/implementation_from_dafny.rs +++ a/TestModels/dafny-dependencies/StandardLibrary/runtimes/rust/src/implementation_from_dafny.rs -@@ -0,0 +1,1340 @@ -+#![allow(warnings, unconditional_panic)] -+#![allow(nonstandard_style)] -+pub mod r#_Wrappers_Compile { -+ pub struct _default {} -+ -+ impl _default { -+ pub fn _allocate_rcmut() -> ::dafny_runtime::Object { -+ ::dafny_runtime::allocate_rcmut::() -+ } -+ pub fn Need<_E: ::dafny_runtime::DafnyType>( -+ condition: bool, -+ error: &_E, -+ ) -> ::std::rc::Rc> { -+ if condition { -+ ::std::rc::Rc::new(super::r#_Wrappers_Compile::Outcome::<_E>::Pass {}) -+ } else { -+ ::std::rc::Rc::new(super::r#_Wrappers_Compile::Outcome::<_E>::Fail { -+ error: error.clone(), -+ }) -+ } -+ } -+ } -+ -+ #[derive(PartialEq, Clone)] -+ pub enum Option { -+ None {}, -+ Some { value: T }, -+ _PhantomVariant(::std::marker::PhantomData), -+ } -+ -+ impl Option { -+ pub fn ToResult( -+ self: &::std::rc::Rc, -+ ) -> ::std::rc::Rc< -+ super::r#_Wrappers_Compile::Result< -+ T, -+ ::dafny_runtime::Sequence<::dafny_runtime::DafnyCharUTF16>, -+ >, -+ > { -+ let mut _source0: ::std::rc::Rc> = self.clone(); -+ if matches!( -+ (&_source0).as_ref(), -+ super::r#_Wrappers_Compile::Option::None { .. } -+ ) { -+ ::std::rc::Rc::new(super::r#_Wrappers_Compile::Result::< -+ T, -+ ::dafny_runtime::Sequence<::dafny_runtime::DafnyCharUTF16>, -+ >::Failure { -+ error: ::dafny_runtime::string_utf16_of("Option is None"), -+ }) -+ } else { -+ let mut r#___mcc_h0: T = _source0.value().clone(); -+ let mut v: T = r#___mcc_h0.clone(); -+ ::std::rc::Rc::new(super::r#_Wrappers_Compile::Result::< -+ T, -+ ::dafny_runtime::Sequence<::dafny_runtime::DafnyCharUTF16>, -+ >::Success { -+ value: v.clone(), -+ }) -+ } -+ } -+ pub fn UnwrapOr(self: &::std::rc::Rc, default: &T) -> T { -+ let mut _source1: ::std::rc::Rc> = self.clone(); -+ if matches!( -+ (&_source1).as_ref(), -+ super::r#_Wrappers_Compile::Option::None { .. } -+ ) { -+ default.clone() -+ } else { -+ let mut r#___mcc_h0: T = _source1.value().clone(); -+ let mut v: T = r#___mcc_h0.clone(); -+ v.clone() -+ } -+ } -+ pub fn IsFailure(self: &::std::rc::Rc) -> bool { -+ matches!( -+ self.as_ref(), -+ super::r#_Wrappers_Compile::Option::None { .. } -+ ) -+ } -+ pub fn PropagateFailure<_U: ::dafny_runtime::DafnyType>( -+ self: &::std::rc::Rc, -+ ) -> ::std::rc::Rc> { -+ ::std::rc::Rc::new(super::r#_Wrappers_Compile::Option::<_U>::None {}) -+ } -+ pub fn Extract(self: &::std::rc::Rc) -> T { -+ self.value().clone() -+ } -+ pub fn value(&self) -> &T { -+ match self { -+ Option::None {} => panic!("field does not exist on this variant"), -+ Option::Some { value } => value, -+ Option::_PhantomVariant(..) => panic!(), -+ } -+ } -+ } -+ -+ impl ::std::fmt::Debug for Option { -+ fn fmt(&self, f: &mut ::std::fmt::Formatter) -> std::fmt::Result { -+ ::dafny_runtime::DafnyPrint::fmt_print(self, f, true) -+ } -+ } -+ -+ impl ::dafny_runtime::DafnyPrint for Option { -+ fn fmt_print( -+ &self, -+ _formatter: &mut ::std::fmt::Formatter, -+ _in_seq: bool, -+ ) -> std::fmt::Result { -+ match self { -+ Option::None {} => { -+ write!(_formatter, "r#_Wrappers_Compile.Option.None")?; -+ Ok(()) -+ } -+ Option::Some { value } => { -+ write!(_formatter, "r#_Wrappers_Compile.Option.Some(")?; -+ ::dafny_runtime::DafnyPrint::fmt_print(value, _formatter, false)?; -+ write!(_formatter, ")")?; -+ Ok(()) -+ } -+ Option::_PhantomVariant(..) => { -+ panic!() -+ } -+ } -+ } -+ } -+ -+ impl Eq for Option {} -+ -+ impl ::std::hash::Hash for Option { -+ fn hash<_H: ::std::hash::Hasher>(&self, _state: &mut _H) { -+ match self { -+ Option::None {} => {} -+ Option::Some { value } => value.hash(_state), -+ Option::_PhantomVariant(..) => { -+ panic!() -+ } -+ } -+ } -+ } -+ -+ impl ::std::default::Default -+ for Option -+ { -+ fn default() -> Option { -+ Option::None {} -+ } -+ } -+ -+ impl ::std::convert::AsRef> for &Option { -+ fn as_ref(&self) -> Self { -+ self -+ } -+ } -+ -+ #[derive(PartialEq, Clone)] -+ pub enum Result { -+ Success { value: T }, -+ Failure { error: R }, -+ _PhantomVariant(::std::marker::PhantomData, ::std::marker::PhantomData), -+ } -+ -+ impl Result { -+ pub fn ToOption( -+ self: &::std::rc::Rc, -+ ) -> ::std::rc::Rc> { -+ let mut _source2: ::std::rc::Rc> = -+ self.clone(); -+ if matches!( -+ (&_source2).as_ref(), -+ super::r#_Wrappers_Compile::Result::Success { .. } -+ ) { -+ let mut r#___mcc_h0: T = _source2.value().clone(); -+ let mut s: T = r#___mcc_h0.clone(); -+ ::std::rc::Rc::new(super::r#_Wrappers_Compile::Option::::Some { -+ value: s.clone(), -+ }) -+ } else { -+ let mut r#___mcc_h1: R = _source2.error().clone(); -+ let mut e: R = r#___mcc_h1.clone(); -+ ::std::rc::Rc::new(super::r#_Wrappers_Compile::Option::::None {}) -+ } -+ } -+ pub fn UnwrapOr(self: &::std::rc::Rc, default: &T) -> T { -+ let mut _source3: ::std::rc::Rc> = -+ self.clone(); -+ if matches!( -+ (&_source3).as_ref(), -+ super::r#_Wrappers_Compile::Result::Success { .. } -+ ) { -+ let mut r#___mcc_h0: T = _source3.value().clone(); -+ let mut s: T = r#___mcc_h0.clone(); -+ s.clone() -+ } else { -+ let mut r#___mcc_h1: R = _source3.error().clone(); -+ let mut e: R = r#___mcc_h1.clone(); -+ default.clone() -+ } -+ } -+ pub fn IsFailure(self: &::std::rc::Rc) -> bool { -+ matches!( -+ self.as_ref(), -+ super::r#_Wrappers_Compile::Result::Failure { .. } -+ ) -+ } -+ pub fn PropagateFailure<_U: ::dafny_runtime::DafnyType>( -+ self: &::std::rc::Rc, -+ ) -> ::std::rc::Rc> { -+ ::std::rc::Rc::new(super::r#_Wrappers_Compile::Result::<_U, R>::Failure { -+ error: self.error().clone(), -+ }) -+ } -+ pub fn MapFailure<_NewR: ::dafny_runtime::DafnyType>( -+ self: &::std::rc::Rc, -+ reWrap: &::std::rc::Rc _NewR>, -+ ) -> ::std::rc::Rc> { -+ let mut _source4: ::std::rc::Rc> = -+ self.clone(); -+ if matches!( -+ (&_source4).as_ref(), -+ super::r#_Wrappers_Compile::Result::Success { .. } -+ ) { -+ let mut r#___mcc_h0: T = _source4.value().clone(); -+ let mut s: T = r#___mcc_h0.clone(); -+ ::std::rc::Rc::new(super::r#_Wrappers_Compile::Result::::Success { -+ value: s.clone(), -+ }) -+ } else { -+ let mut r#___mcc_h1: R = _source4.error().clone(); -+ let mut e: R = r#___mcc_h1.clone(); -+ ::std::rc::Rc::new(super::r#_Wrappers_Compile::Result::::Failure { -+ error: reWrap(&e), -+ }) -+ } -+ } -+ pub fn Extract(self: &::std::rc::Rc) -> T { -+ self.value().clone() -+ } -+ pub fn value(&self) -> &T { -+ match self { -+ Result::Success { value } => value, -+ Result::Failure { error } => panic!("field does not exist on this variant"), -+ Result::_PhantomVariant(..) => panic!(), -+ } -+ } -+ pub fn error(&self) -> &R { -+ match self { -+ Result::Success { value } => panic!("field does not exist on this variant"), -+ Result::Failure { error } => error, -+ Result::_PhantomVariant(..) => panic!(), -+ } -+ } -+ } -+ -+ impl ::std::fmt::Debug -+ for Result -+ { -+ fn fmt(&self, f: &mut ::std::fmt::Formatter) -> std::fmt::Result { -+ ::dafny_runtime::DafnyPrint::fmt_print(self, f, true) -+ } -+ } -+ -+ impl ::dafny_runtime::DafnyPrint -+ for Result -+ { -+ fn fmt_print( -+ &self, -+ _formatter: &mut ::std::fmt::Formatter, -+ _in_seq: bool, -+ ) -> std::fmt::Result { -+ match self { -+ Result::Success { value } => { -+ write!(_formatter, "r#_Wrappers_Compile.Result.Success(")?; -+ ::dafny_runtime::DafnyPrint::fmt_print(value, _formatter, false)?; -+ write!(_formatter, ")")?; -+ Ok(()) -+ } -+ Result::Failure { error } => { -+ write!(_formatter, "r#_Wrappers_Compile.Result.Failure(")?; -+ ::dafny_runtime::DafnyPrint::fmt_print(error, _formatter, false)?; -+ write!(_formatter, ")")?; -+ Ok(()) -+ } -+ Result::_PhantomVariant(..) => { -+ panic!() -+ } -+ } -+ } -+ } -+ -+ impl Eq for Result {} -+ -+ impl< -+ T: ::dafny_runtime::DafnyType + ::std::hash::Hash, -+ R: ::dafny_runtime::DafnyType + ::std::hash::Hash, -+ > ::std::hash::Hash for Result -+ { -+ fn hash<_H: ::std::hash::Hasher>(&self, _state: &mut _H) { -+ match self { -+ Result::Success { value } => value.hash(_state), -+ Result::Failure { error } => error.hash(_state), -+ Result::_PhantomVariant(..) => { -+ panic!() -+ } -+ } -+ } -+ } -+ -+ impl< -+ T: ::dafny_runtime::DafnyType + ::std::default::Default, -+ R: ::dafny_runtime::DafnyType + ::std::default::Default, -+ > ::std::default::Default for Result -+ { -+ fn default() -> Result { -+ Result::Success { -+ value: ::std::default::Default::default(), -+ } -+ } -+ } -+ -+ impl -+ ::std::convert::AsRef> for &Result -+ { -+ fn as_ref(&self) -> Self { -+ self -+ } -+ } -+ -+ #[derive(PartialEq, Clone)] -+ pub enum Outcome { -+ Pass {}, -+ Fail { error: E }, -+ _PhantomVariant(::std::marker::PhantomData), -+ } -+ -+ impl Outcome { -+ pub fn IsFailure(self: &::std::rc::Rc) -> bool { -+ matches!( -+ self.as_ref(), -+ super::r#_Wrappers_Compile::Outcome::Fail { .. } -+ ) -+ } -+ pub fn PropagateFailure<_U: ::dafny_runtime::DafnyType>( -+ self: &::std::rc::Rc, -+ ) -> ::std::rc::Rc> { -+ ::std::rc::Rc::new(super::r#_Wrappers_Compile::Result::<_U, E>::Failure { -+ error: self.error().clone(), -+ }) -+ } -+ pub fn error(&self) -> &E { -+ match self { -+ Outcome::Pass {} => panic!("field does not exist on this variant"), -+ Outcome::Fail { error } => error, -+ Outcome::_PhantomVariant(..) => panic!(), -+ } -+ } -+ } -+ -+ impl ::std::fmt::Debug for Outcome { -+ fn fmt(&self, f: &mut ::std::fmt::Formatter) -> std::fmt::Result { -+ ::dafny_runtime::DafnyPrint::fmt_print(self, f, true) -+ } -+ } -+ -+ impl ::dafny_runtime::DafnyPrint for Outcome { -+ fn fmt_print( -+ &self, -+ _formatter: &mut ::std::fmt::Formatter, -+ _in_seq: bool, -+ ) -> std::fmt::Result { -+ match self { -+ Outcome::Pass {} => { -+ write!(_formatter, "r#_Wrappers_Compile.Outcome.Pass")?; -+ Ok(()) -+ } -+ Outcome::Fail { error } => { -+ write!(_formatter, "r#_Wrappers_Compile.Outcome.Fail(")?; -+ ::dafny_runtime::DafnyPrint::fmt_print(error, _formatter, false)?; -+ write!(_formatter, ")")?; -+ Ok(()) -+ } -+ Outcome::_PhantomVariant(..) => { -+ panic!() -+ } -+ } -+ } -+ } -+ -+ impl Eq for Outcome {} -+ -+ impl ::std::hash::Hash for Outcome { -+ fn hash<_H: ::std::hash::Hasher>(&self, _state: &mut _H) { -+ match self { -+ Outcome::Pass {} => {} -+ Outcome::Fail { error } => error.hash(_state), -+ Outcome::_PhantomVariant(..) => { -+ panic!() -+ } -+ } -+ } -+ } -+ -+ impl ::std::default::Default -+ for Outcome -+ { -+ fn default() -> Outcome { -+ Outcome::Pass {} -+ } -+ } -+ -+ impl ::std::convert::AsRef> for &Outcome { -+ fn as_ref(&self) -> Self { -+ self -+ } -+ } -+} -+pub mod r#_StandardLibrary_Compile_dUInt_Compile { -+ pub struct _default {} -+ -+ impl _default { -+ pub fn _allocate_rcmut() -> ::dafny_runtime::Object { -+ ::dafny_runtime::allocate_rcmut::() -+ } -+ pub fn UInt8Less(a: u8, b: u8) -> bool { -+ a < b -+ } -+ pub fn HasUint16Len<_T: ::dafny_runtime::DafnyType>( -+ s: &::dafny_runtime::Sequence<_T>, -+ ) -> bool { -+ s.cardinality() -+ < super::r#_StandardLibrary_Compile_dUInt_Compile::_default::UINT16_LIMIT() -+ } -+ pub fn HasUint32Len<_T: ::dafny_runtime::DafnyType>( -+ s: &::dafny_runtime::Sequence<_T>, -+ ) -> bool { -+ s.cardinality() -+ < super::r#_StandardLibrary_Compile_dUInt_Compile::_default::UINT32_LIMIT() -+ } -+ pub fn HasUint64Len<_T: ::dafny_runtime::DafnyType>( -+ s: &::dafny_runtime::Sequence<_T>, -+ ) -> bool { -+ s.cardinality() -+ < super::r#_StandardLibrary_Compile_dUInt_Compile::_default::UINT64_LIMIT() -+ } -+ pub fn UInt16ToSeq(x: u16) -> ::dafny_runtime::Sequence { -+ let mut b0: u8 = (x / 256) as u8; -+ let mut b1: u8 = (x % 256) as u8; -+ ::dafny_runtime::seq![b0, b1] -+ } -+ pub fn SeqToUInt16(s: &::dafny_runtime::Sequence) -> u16 { -+ let mut x0: u16 = s.get(&::dafny_runtime::int!(0)) as u16 * 256; -+ x0 + s.get(&::dafny_runtime::int!(1)) as u16 -+ } -+ pub fn UInt32ToSeq(x: u32) -> ::dafny_runtime::Sequence { -+ let mut b0: u8 = (x / 16777216) as u8; -+ let mut x0: u32 = x - b0 as u32 * 16777216; -+ let mut b1: u8 = (x0 / 65536) as u8; -+ let mut x1: u32 = x0 - b1 as u32 * 65536; -+ let mut b2: u8 = (x1 / 256) as u8; -+ let mut b3: u8 = (x1 % 256) as u8; -+ ::dafny_runtime::seq![b0, b1, b2, b3] -+ } -+ pub fn SeqToUInt32(s: &::dafny_runtime::Sequence) -> u32 { -+ let mut x0: u32 = s.get(&::dafny_runtime::int!(0)) as u32 * 16777216; -+ let mut x1: u32 = x0 + s.get(&::dafny_runtime::int!(1)) as u32 * 65536; -+ let mut x2: u32 = x1 + s.get(&::dafny_runtime::int!(2)) as u32 * 256; -+ x2 + s.get(&::dafny_runtime::int!(3)) as u32 -+ } -+ pub fn UInt64ToSeq(x: u64) -> ::dafny_runtime::Sequence { -+ let mut b0: u8 = (x / 72057594037927936) as u8; -+ let mut x0: u64 = x - b0 as u64 * 72057594037927936; -+ let mut b1: u8 = (x0 / 281474976710656) as u8; -+ let mut x1: u64 = x0 - b1 as u64 * 281474976710656; -+ let mut b2: u8 = (x1 / 1099511627776) as u8; -+ let mut x2: u64 = x1 - b2 as u64 * 1099511627776; -+ let mut b3: u8 = (x2 / 4294967296) as u8; -+ let mut x3: u64 = x2 - b3 as u64 * 4294967296; -+ let mut b4: u8 = (x3 / 16777216) as u8; -+ let mut x4: u64 = x3 - b4 as u64 * 16777216; -+ let mut b5: u8 = (x4 / 65536) as u8; -+ let mut x5: u64 = x4 - b5 as u64 * 65536; -+ let mut b6: u8 = (x5 / 256) as u8; -+ let mut b7: u8 = (x5 % 256) as u8; -+ ::dafny_runtime::seq![b0, b1, b2, b3, b4, b5, b6, b7] -+ } -+ pub fn SeqToUInt64(s: &::dafny_runtime::Sequence) -> u64 { -+ let mut x0: u64 = s.get(&::dafny_runtime::int!(0)) as u64 * 72057594037927936; -+ let mut x1: u64 = x0 + s.get(&::dafny_runtime::int!(1)) as u64 * 281474976710656; -+ let mut x2: u64 = x1 + s.get(&::dafny_runtime::int!(2)) as u64 * 1099511627776; -+ let mut x3: u64 = x2 + s.get(&::dafny_runtime::int!(3)) as u64 * 4294967296; -+ let mut x4: u64 = x3 + s.get(&::dafny_runtime::int!(4)) as u64 * 16777216; -+ let mut x5: u64 = x4 + s.get(&::dafny_runtime::int!(5)) as u64 * 65536; -+ let mut x6: u64 = x5 + s.get(&::dafny_runtime::int!(6)) as u64 * 256; -+ let mut x: u64 = x6 + s.get(&::dafny_runtime::int!(7)) as u64; -+ x -+ } -+ pub fn UINT16_LIMIT() -> ::dafny_runtime::DafnyInt { -+ ::dafny_runtime::int!(b"65536") -+ } -+ pub fn UINT32_LIMIT() -> ::dafny_runtime::DafnyInt { -+ ::dafny_runtime::int!(b"4294967296") -+ } -+ pub fn UINT64_LIMIT() -> ::dafny_runtime::DafnyInt { -+ ::dafny_runtime::int!(b"18446744073709551616") -+ } -+ pub fn INT32_MAX_LIMIT() -> ::dafny_runtime::DafnyInt { -+ ::dafny_runtime::int!(b"2147483648") -+ } -+ pub fn INT64_MAX_LIMIT() -> ::dafny_runtime::DafnyInt { -+ ::dafny_runtime::int!(b"9223372036854775808") -+ } -+ } -+ -+ #[derive(Clone, PartialEq)] -+ #[repr(transparent)] -+ pub struct uint8(pub u8); -+ -+ impl ::std::default::Default for uint8 { -+ fn default() -> Self { -+ uint8(::std::default::Default::default()) -+ } -+ } -+ -+ impl ::dafny_runtime::DafnyPrint for uint8 { -+ fn fmt_print( -+ &self, -+ _formatter: &mut ::std::fmt::Formatter, -+ in_seq: bool, -+ ) -> ::std::fmt::Result { -+ ::dafny_runtime::DafnyPrint::fmt_print(&self.0, _formatter, in_seq) -+ } -+ } -+ -+ impl ::std::ops::Deref for uint8 { -+ type Target = u8; -+ fn deref(&self) -> &Self::Target { -+ &self.0 -+ } -+ } -+ -+ #[derive(Clone, PartialEq)] -+ #[repr(transparent)] -+ pub struct uint16(pub u16); -+ -+ impl ::std::default::Default for uint16 { -+ fn default() -> Self { -+ uint16(::std::default::Default::default()) -+ } -+ } -+ -+ impl ::dafny_runtime::DafnyPrint for uint16 { -+ fn fmt_print( -+ &self, -+ _formatter: &mut ::std::fmt::Formatter, -+ in_seq: bool, -+ ) -> ::std::fmt::Result { -+ ::dafny_runtime::DafnyPrint::fmt_print(&self.0, _formatter, in_seq) -+ } -+ } -+ -+ impl ::std::ops::Deref for uint16 { -+ type Target = u16; -+ fn deref(&self) -> &Self::Target { -+ &self.0 -+ } -+ } -+ -+ #[derive(Clone, PartialEq)] -+ #[repr(transparent)] -+ pub struct uint32(pub u32); -+ -+ impl ::std::default::Default for uint32 { -+ fn default() -> Self { -+ uint32(::std::default::Default::default()) -+ } -+ } -+ -+ impl ::dafny_runtime::DafnyPrint for uint32 { -+ fn fmt_print( -+ &self, -+ _formatter: &mut ::std::fmt::Formatter, -+ in_seq: bool, -+ ) -> ::std::fmt::Result { -+ ::dafny_runtime::DafnyPrint::fmt_print(&self.0, _formatter, in_seq) -+ } -+ } -+ -+ impl ::std::ops::Deref for uint32 { -+ type Target = u32; -+ fn deref(&self) -> &Self::Target { -+ &self.0 -+ } -+ } -+ -+ #[derive(Clone, PartialEq)] -+ #[repr(transparent)] -+ pub struct uint64(pub u64); -+ -+ impl ::std::default::Default for uint64 { -+ fn default() -> Self { -+ uint64(::std::default::Default::default()) -+ } -+ } -+ -+ impl ::dafny_runtime::DafnyPrint for uint64 { -+ fn fmt_print( -+ &self, -+ _formatter: &mut ::std::fmt::Formatter, -+ in_seq: bool, -+ ) -> ::std::fmt::Result { -+ ::dafny_runtime::DafnyPrint::fmt_print(&self.0, _formatter, in_seq) -+ } -+ } -+ -+ impl ::std::ops::Deref for uint64 { -+ type Target = u64; -+ fn deref(&self) -> &Self::Target { -+ &self.0 -+ } -+ } -+ -+ #[derive(Clone, PartialEq)] -+ #[repr(transparent)] -+ pub struct int32(pub i32); -+ -+ impl ::std::default::Default for int32 { -+ fn default() -> Self { -+ int32(::std::default::Default::default()) -+ } -+ } -+ -+ impl ::dafny_runtime::DafnyPrint for int32 { -+ fn fmt_print( -+ &self, -+ _formatter: &mut ::std::fmt::Formatter, -+ in_seq: bool, -+ ) -> ::std::fmt::Result { -+ ::dafny_runtime::DafnyPrint::fmt_print(&self.0, _formatter, in_seq) -+ } -+ } -+ -+ impl ::std::ops::Deref for int32 { -+ type Target = i32; -+ fn deref(&self) -> &Self::Target { -+ &self.0 -+ } -+ } -+ -+ #[derive(Clone, PartialEq)] -+ #[repr(transparent)] -+ pub struct int64(pub i64); -+ -+ impl ::std::default::Default for int64 { -+ fn default() -> Self { -+ int64(::std::default::Default::default()) -+ } -+ } -+ -+ impl ::dafny_runtime::DafnyPrint for int64 { -+ fn fmt_print( -+ &self, -+ _formatter: &mut ::std::fmt::Formatter, -+ in_seq: bool, -+ ) -> ::std::fmt::Result { -+ ::dafny_runtime::DafnyPrint::fmt_print(&self.0, _formatter, in_seq) -+ } -+ } -+ -+ impl ::std::ops::Deref for int64 { -+ type Target = i64; -+ fn deref(&self) -> &Self::Target { -+ &self.0 -+ } -+ } -+ -+ #[derive(Clone, PartialEq)] -+ #[repr(transparent)] -+ pub struct posInt64(pub u64); -+ -+ impl ::std::default::Default for posInt64 { -+ fn default() -> Self { -+ posInt64(1) -+ } -+ } -+ -+ impl ::dafny_runtime::DafnyPrint for posInt64 { -+ fn fmt_print( -+ &self, -+ _formatter: &mut ::std::fmt::Formatter, -+ in_seq: bool, -+ ) -> ::std::fmt::Result { -+ ::dafny_runtime::DafnyPrint::fmt_print(&self.0, _formatter, in_seq) -+ } -+ } -+ -+ impl ::std::ops::Deref for posInt64 { -+ type Target = u64; -+ fn deref(&self) -> &Self::Target { -+ &self.0 -+ } -+ } -+ -+ pub type seq16 = ::dafny_runtime::Sequence; -+ -+ pub type seq32 = ::dafny_runtime::Sequence; -+ -+ pub type seq64 = ::dafny_runtime::Sequence; -+} -+pub mod r#_StandardLibrary_Compile { -+ pub struct _default {} -+ -+ impl _default { -+ pub fn _allocate_rcmut() -> ::dafny_runtime::Object { -+ ::dafny_runtime::allocate_rcmut::() -+ } -+ pub fn Join<_T: ::dafny_runtime::DafnyType>( -+ ss: &::dafny_runtime::Sequence<::dafny_runtime::Sequence<_T>>, -+ joiner: &::dafny_runtime::Sequence<_T>, -+ ) -> ::dafny_runtime::Sequence<_T> { -+ let mut _accumulator: ::dafny_runtime::Sequence<_T> = -+ ::dafny_runtime::seq![] as ::dafny_runtime::Sequence<_T>; -+ let mut ss = ss.clone(); -+ let mut joiner = joiner.clone(); -+ let mut _accumulator = _accumulator.clone(); -+ 'TAIL_CALL_START: loop { -+ if ss.cardinality() == ::dafny_runtime::int!(1) { -+ return _accumulator.concat(&ss.get(&::dafny_runtime::int!(0))); -+ } else { -+ _accumulator = -+ _accumulator.concat(&ss.get(&::dafny_runtime::int!(0)).concat(&joiner)); -+ let mut _in0: ::dafny_runtime::Sequence<::dafny_runtime::Sequence<_T>> = -+ ss.drop(&::dafny_runtime::int!(1)); -+ let mut _in1: ::dafny_runtime::Sequence<_T> = joiner.clone(); -+ ss = _in0.clone(); -+ joiner = _in1.clone(); -+ continue 'TAIL_CALL_START; -+ } -+ } -+ } -+ pub fn Split<_T: ::dafny_runtime::DafnyTypeEq>( -+ s: &::dafny_runtime::Sequence<_T>, -+ delim: &_T, -+ ) -> ::dafny_runtime::Sequence<::dafny_runtime::Sequence<_T>> { -+ let mut _accumulator: ::dafny_runtime::Sequence<::dafny_runtime::Sequence<_T>> = -+ ::dafny_runtime::seq![] as ::dafny_runtime::Sequence<::dafny_runtime::Sequence<_T>>; -+ let mut s = s.clone(); -+ let mut delim = delim.clone(); -+ let mut _accumulator = _accumulator.clone(); -+ 'TAIL_CALL_START: loop { -+ let mut i: ::std::rc::Rc< -+ super::r#_Wrappers_Compile::Option<::dafny_runtime::_System::nat>, -+ > = super::r#_StandardLibrary_Compile::_default::FindIndexMatching::<_T>( -+ &s, -+ &delim, -+ &::dafny_runtime::int!(0), -+ ); -+ if matches!( -+ (&i).as_ref(), -+ super::r#_Wrappers_Compile::Option::Some { .. } -+ ) { -+ _accumulator = _accumulator.concat(&::dafny_runtime::seq![s.take(i.value())]); -+ let mut _in2: ::dafny_runtime::Sequence<_T> = -+ s.drop(&(i.value().clone() + ::dafny_runtime::int!(1))); -+ let mut _in3: _T = delim.clone(); -+ s = _in2.clone(); -+ delim = _in3.clone(); -+ continue 'TAIL_CALL_START; -+ } else { -+ return _accumulator.concat(&::dafny_runtime::seq![s.clone()]); -+ } -+ } -+ } -+ pub fn SplitOnce<_T: ::dafny_runtime::DafnyTypeEq>( -+ s: &::dafny_runtime::Sequence<_T>, -+ delim: &_T, -+ ) -> (::dafny_runtime::Sequence<_T>, ::dafny_runtime::Sequence<_T>) { -+ let mut i: ::std::rc::Rc< -+ super::r#_Wrappers_Compile::Option<::dafny_runtime::_System::nat>, -+ > = super::r#_StandardLibrary_Compile::_default::FindIndexMatching::<_T>( -+ s, -+ delim, -+ &::dafny_runtime::int!(0), -+ ); -+ ( -+ s.take(i.value()), -+ s.drop(&(i.value().clone() + ::dafny_runtime::int!(1))), -+ ) -+ } -+ pub fn r#_SplitOnce_q<_T: ::dafny_runtime::DafnyTypeEq>( -+ s: &::dafny_runtime::Sequence<_T>, -+ delim: &_T, -+ ) -> ::std::rc::Rc< -+ super::r#_Wrappers_Compile::Option<( -+ ::dafny_runtime::Sequence<_T>, -+ ::dafny_runtime::Sequence<_T>, -+ )>, -+ > { -+ let mut valueOrError0: ::std::rc::Rc< -+ super::r#_Wrappers_Compile::Option<::dafny_runtime::_System::nat>, -+ > = super::r#_StandardLibrary_Compile::_default::FindIndexMatching::<_T>( -+ s, -+ delim, -+ &::dafny_runtime::int!(0), -+ ); -+ if valueOrError0.IsFailure() { -+ valueOrError0.PropagateFailure::<(::dafny_runtime::Sequence<_T>, ::dafny_runtime::Sequence<_T>)>() -+ /* Coercion from ::std::rc::Rc> to ::std::rc::Rc, ::dafny_runtime::Sequence<_T>)>> not yet implemented */ -+ } else { -+ let mut i: ::dafny_runtime::_System::nat = valueOrError0.Extract()/* Coercion from T to ::dafny_runtime::DafnyInt not yet implemented */; -+ ::std::rc::Rc::new(super::r#_Wrappers_Compile::Option::<( -+ ::dafny_runtime::Sequence<_T>, -+ ::dafny_runtime::Sequence<_T>, -+ )>::Some { -+ value: (s.take(&i), s.drop(&(i.clone() + ::dafny_runtime::int!(1)))), -+ }) -+ } -+ } -+ pub fn FindIndexMatching<_T: ::dafny_runtime::DafnyTypeEq>( -+ s: &::dafny_runtime::Sequence<_T>, -+ c: &_T, -+ i: &::dafny_runtime::_System::nat, -+ ) -> ::std::rc::Rc> -+ { -+ super::r#_StandardLibrary_Compile::_default::FindIndex::<_T>( -+ s, -+ { -+ let c: _T = c.clone(); -+ &({ -+ let mut c = c.clone(); -+ ::std::rc::Rc::new(move |x: &_T| -> bool { x.clone() == c.clone() }) -+ }) -+ }, -+ i, -+ ) -+ } -+ pub fn FindIndex<_T: ::dafny_runtime::DafnyType>( -+ s: &::dafny_runtime::Sequence<_T>, -+ f: &::std::rc::Rc bool>, -+ i: &::dafny_runtime::_System::nat, -+ ) -> ::std::rc::Rc> -+ { -+ let mut s = s.clone(); -+ let mut f = f.clone(); -+ let mut i = i.clone(); -+ 'TAIL_CALL_START: loop { -+ if i.clone() == s.cardinality() { -+ return ::std::rc::Rc::new(super::r#_Wrappers_Compile::Option::< -+ ::dafny_runtime::_System::nat, -+ >::None {}); -+ } else { -+ if (&f)(&s.get(&i)) { -+ return ::std::rc::Rc::new(super::r#_Wrappers_Compile::Option::< -+ ::dafny_runtime::_System::nat, -+ >::Some { -+ value: i.clone(), -+ }); -+ } else { -+ let mut _in4: ::dafny_runtime::Sequence<_T> = s.clone(); -+ let mut _in5: ::std::rc::Rc bool> = f.clone(); -+ let mut _in6: ::dafny_runtime::DafnyInt = -+ i.clone() + ::dafny_runtime::int!(1); -+ s = _in4.clone(); -+ f = _in5.clone(); -+ i = _in6.clone(); -+ continue 'TAIL_CALL_START; -+ } -+ } -+ } -+ } -+ pub fn Filter<_T: ::dafny_runtime::DafnyType>( -+ s: &::dafny_runtime::Sequence<_T>, -+ f: &::std::rc::Rc bool>, -+ ) -> ::dafny_runtime::Sequence<_T> { -+ let mut _accumulator: ::dafny_runtime::Sequence<_T> = -+ ::dafny_runtime::seq![] as ::dafny_runtime::Sequence<_T>; -+ let mut s = s.clone(); -+ let mut f = f.clone(); -+ let mut _accumulator = _accumulator.clone(); -+ 'TAIL_CALL_START: loop { -+ if s.cardinality() == ::dafny_runtime::int!(0) { -+ return _accumulator -+ .concat(&(::dafny_runtime::seq![] as ::dafny_runtime::Sequence<_T>)); -+ } else { -+ if (&f)(&s.get(&::dafny_runtime::int!(0))) { -+ _accumulator = _accumulator -+ .concat(&::dafny_runtime::seq![s.get(&::dafny_runtime::int!(0))]); -+ let mut _in7: ::dafny_runtime::Sequence<_T> = -+ s.drop(&::dafny_runtime::int!(1)); -+ let mut _in8: ::std::rc::Rc bool> = f.clone(); -+ s = _in7.clone(); -+ f = _in8.clone(); -+ continue 'TAIL_CALL_START; -+ } else { -+ let mut _in9: ::dafny_runtime::Sequence<_T> = -+ s.drop(&::dafny_runtime::int!(1)); -+ let mut _in10: ::std::rc::Rc bool> = f.clone(); -+ s = _in9.clone(); -+ f = _in10.clone(); -+ continue 'TAIL_CALL_START; -+ } -+ } -+ } -+ } -+ pub fn Min( -+ a: &::dafny_runtime::DafnyInt, -+ b: &::dafny_runtime::DafnyInt, -+ ) -> ::dafny_runtime::DafnyInt { -+ if a.clone() < b.clone() { -+ a.clone() -+ } else { -+ b.clone() -+ } -+ } -+ pub fn Fill<_T: ::dafny_runtime::DafnyType>( -+ value: &_T, -+ n: &::dafny_runtime::_System::nat, -+ ) -> ::dafny_runtime::Sequence<_T> { -+ { -+ let _initializer = { -+ let value: _T = value.clone(); -+ { -+ let mut value = value.clone(); -+ ::std::rc::Rc::new(move |_v0: &::dafny_runtime::DafnyInt| -> _T { -+ value.clone() -+ }) -+ } -+ }; -+ ::dafny_runtime::integer_range(::dafny_runtime::Zero::zero(), n.clone()) -+ .map(|i| _initializer(&i)) -+ .collect::<::dafny_runtime::Sequence<_>>() -+ } -+ } -+ pub fn SeqToArray<_T: ::dafny_runtime::DafnyType>( -+ s: &::dafny_runtime::Sequence<_T>, -+ ) -> ::dafny_runtime::Object<[_T]> { -+ let mut a = ::dafny_runtime::MaybePlacebo::<::dafny_runtime::Object<[_T]>>::new(); -+ let mut _init0: ::std::rc::Rc _T> = { -+ let s: ::dafny_runtime::Sequence<_T> = s.clone(); -+ { -+ let mut s = s.clone(); -+ ::std::rc::Rc::new(move |i: &::dafny_runtime::DafnyInt| -> _T { s.get(i) }) -+ } -+ }; -+ let mut _nw0: ::dafny_runtime::Object<[::std::mem::MaybeUninit<_T>]> = -+ ::dafny_runtime::array::placebos_usize_rcmut::<_T>(s.cardinality().as_usize()); -+ for r#__i0_0 in -+ ::dafny_runtime::integer_range(0, ::dafny_runtime::rd!(_nw0.clone()).len()) -+ { -+ { -+ let __idx0 = -+ ::from(r#__i0_0.clone()).unwrap(); -+ ::dafny_runtime::md!(_nw0.clone())[__idx0] = ::std::mem::MaybeUninit::new( -+ (&_init0)(&::dafny_runtime::int!(r#__i0_0.clone())), -+ ); -+ } -+ } -+ a = ::dafny_runtime::MaybePlacebo::from(::dafny_runtime::array::construct_rcmut( -+ _nw0.clone(), -+ )); -+ return a.read(); -+ } -+ pub fn LexicographicLessOrEqual<_T: ::dafny_runtime::DafnyTypeEq>( -+ a: &::dafny_runtime::Sequence<_T>, -+ b: &::dafny_runtime::Sequence<_T>, -+ less: &::std::rc::Rc bool>, -+ ) -> bool { -+ ::dafny_runtime::integer_range(::dafny_runtime::int!(0), a.cardinality() + ::dafny_runtime::int!(1)).any(({ -+ let mut a = a.clone(); -+ let mut b = b.clone(); -+ let mut less = less.clone(); +@@ -515,12 +515,6 @@ pub mod r#_StandardLibrary_Compile_dUInt_Compile { + #[repr(transparent)] + pub struct uint8(pub u8); + +- impl uint8 { +- pub fn is(_source: u8) -> bool { +- return true; +- } +- } +- + impl ::std::default::Default for uint8 { + fn default() -> Self { + uint8(::std::default::Default::default()) +@@ -548,12 +542,6 @@ pub mod r#_StandardLibrary_Compile_dUInt_Compile { + #[repr(transparent)] + pub struct uint16(pub u16); + +- impl uint16 { +- pub fn is(_source: u16) -> bool { +- return true; +- } +- } +- + impl ::std::default::Default for uint16 { + fn default() -> Self { + uint16(::std::default::Default::default()) +@@ -581,12 +569,6 @@ pub mod r#_StandardLibrary_Compile_dUInt_Compile { + #[repr(transparent)] + pub struct uint32(pub u32); + +- impl uint32 { +- pub fn is(_source: u32) -> bool { +- return true; +- } +- } +- + impl ::std::default::Default for uint32 { + fn default() -> Self { + uint32(::std::default::Default::default()) +@@ -614,12 +596,6 @@ pub mod r#_StandardLibrary_Compile_dUInt_Compile { + #[repr(transparent)] + pub struct uint64(pub u64); + +- impl uint64 { +- pub fn is(_source: u64) -> bool { +- return true; +- } +- } +- + impl ::std::default::Default for uint64 { + fn default() -> Self { + uint64(::std::default::Default::default()) +@@ -647,12 +623,6 @@ pub mod r#_StandardLibrary_Compile_dUInt_Compile { + #[repr(transparent)] + pub struct int32(pub i32); + +- impl int32 { +- pub fn is(_source: i32) -> bool { +- return true; +- } +- } +- + impl ::std::default::Default for int32 { + fn default() -> Self { + int32(::std::default::Default::default()) +@@ -680,12 +650,6 @@ pub mod r#_StandardLibrary_Compile_dUInt_Compile { + #[repr(transparent)] + pub struct int64(pub i64); + +- impl int64 { +- pub fn is(_source: i64) -> bool { +- return true; +- } +- } +- + impl ::std::default::Default for int64 { + fn default() -> Self { + int64(::std::default::Default::default()) +@@ -713,15 +677,6 @@ pub mod r#_StandardLibrary_Compile_dUInt_Compile { + #[repr(transparent)] + pub struct posInt64(pub u64); + +- impl posInt64 { +- pub fn is(_source: u64) -> bool { +- let mut x: ::dafny_runtime::DafnyInt = +- Into::<::dafny_runtime::DafnyInt>::into(_source.clone()); +- return ::dafny_runtime::int!(0) < x.clone() +- && x.clone() < ::dafny_runtime::int!(b"9223372036854775808"); +- } +- } +- + impl ::std::default::Default for posInt64 { + fn default() -> Self { + posInt64(1) +@@ -1013,7 +968,7 @@ pub mod r#_StandardLibrary_Compile { + let mut a = a.clone(); + let mut b = b.clone(); + let mut less = less.clone(); +- ::std::rc::Rc::new(move |r#__exists_var_0: &::dafny_runtime::DafnyInt| -> bool { + ::std::rc::Rc::new(move |r#__exists_var_0: ::dafny_runtime::DafnyInt| -> bool { -+ let mut k: ::dafny_runtime::DafnyInt = r#__exists_var_0.clone(); -+ ::dafny_runtime::int!(0) <= k.clone() && k.clone() <= a.cardinality() && super::r#_StandardLibrary_Compile::_default::LexicographicLessOrEqualAux::<_T>(&a, &b, &less, &k) -+ }) -+ }).as_ref()) -+ } -+ pub fn LexicographicLessOrEqualAux<_T: ::dafny_runtime::DafnyTypeEq>( -+ a: &::dafny_runtime::Sequence<_T>, -+ b: &::dafny_runtime::Sequence<_T>, -+ less: &::std::rc::Rc bool>, -+ lengthOfCommonPrefix: &::dafny_runtime::_System::nat, -+ ) -> bool { -+ lengthOfCommonPrefix.clone() <= b.cardinality() -+ && ::dafny_runtime::integer_range( -+ ::dafny_runtime::int!(0), -+ lengthOfCommonPrefix.clone(), -+ ) -+ .all( -+ ({ -+ let mut lengthOfCommonPrefix = lengthOfCommonPrefix.clone(); -+ let mut a = a.clone(); -+ let mut b = b.clone(); -+ ::std::rc::Rc::new( + let mut k: ::dafny_runtime::DafnyInt = r#__exists_var_0.clone(); + ::dafny_runtime::int!(0) <= k.clone() && k.clone() <= a.cardinality() && super::r#_StandardLibrary_Compile::_default::LexicographicLessOrEqualAux::<_T>(&a, &b, &less, &k) + }) +@@ -1036,7 +991,7 @@ pub mod r#_StandardLibrary_Compile { + let mut a = a.clone(); + let mut b = b.clone(); + ::std::rc::Rc::new( +- move |r#__forall_var_0: &::dafny_runtime::DafnyInt| -> bool { + move |r#__forall_var_0: ::dafny_runtime::DafnyInt| -> bool { -+ let mut i: ::dafny_runtime::DafnyInt = r#__forall_var_0.clone(); -+ !(::dafny_runtime::int!(0) <= i.clone() -+ && i.clone() < lengthOfCommonPrefix.clone()) -+ || a.get(&i) == b.get(&i) -+ }, -+ ) -+ }) -+ .as_ref(), -+ ) -+ && (lengthOfCommonPrefix.clone() == a.cardinality() -+ || lengthOfCommonPrefix.clone() < b.cardinality() -+ && less(&a.get(lengthOfCommonPrefix), &b.get(lengthOfCommonPrefix))) -+ } -+ pub fn SetToOrderedSequence<_T: ::dafny_runtime::DafnyTypeEq>( -+ s: &::dafny_runtime::Set<::dafny_runtime::Sequence<_T>>, -+ less: &::std::rc::Rc bool>, -+ ) -> ::dafny_runtime::Sequence<::dafny_runtime::Sequence<_T>> { -+ let mut _accumulator: ::dafny_runtime::Sequence<::dafny_runtime::Sequence<_T>> = -+ ::dafny_runtime::seq![] as ::dafny_runtime::Sequence<::dafny_runtime::Sequence<_T>>; -+ let mut s = s.clone(); -+ let mut less = less.clone(); -+ let mut _accumulator = _accumulator.clone(); -+ 'TAIL_CALL_START: loop { -+ if s.clone() == ::dafny_runtime::set! {} { -+ return _accumulator.concat( -+ &(::dafny_runtime::seq![] -+ as ::dafny_runtime::Sequence<::dafny_runtime::Sequence<_T>>), -+ ); -+ } else { -+ return (&({ -+ let mut s = s.clone(); -+ let mut less = less.clone(); -+ ::std::rc::Rc::new(move |r#__let_dummy_0: &::dafny_runtime::DafnyInt| -> ::dafny_runtime::Sequence<::dafny_runtime::Sequence<_T>> { -+ let mut a = ::dafny_runtime::MaybePlacebo::<::dafny_runtime::Sequence<_T>>::new(); -+ 'label_goto__ASSIGN_SUCH_THAT_0: loop { -+ for r#__assign_such_that_0 in (&s).iter().cloned() { -+ a = ::dafny_runtime::MaybePlacebo::from(r#__assign_such_that_0.clone()); -+ if s.contains(&a.read()) && super::r#_StandardLibrary_Compile::_default::IsMinimum::<_T>(&a.read(), &s, &less) { -+ break 'label_goto__ASSIGN_SUCH_THAT_0; -+ } -+ } -+ panic!("Halt"); -+ break; -+ }; -+ ::dafny_runtime::seq![a.read()].concat(&super::r#_StandardLibrary_Compile::_default::SetToOrderedSequence::<_T>(&s.subtract(&::dafny_runtime::set!{a.read()}), &less)) -+ }) -+ }))(&::dafny_runtime::int!(0)); -+ } -+ } -+ } -+ pub fn IsMinimum<_T: ::dafny_runtime::DafnyTypeEq>( -+ a: &::dafny_runtime::Sequence<_T>, -+ s: &::dafny_runtime::Set<::dafny_runtime::Sequence<_T>>, -+ less: &::std::rc::Rc bool>, -+ ) -> bool { + let mut i: ::dafny_runtime::DafnyInt = r#__forall_var_0.clone(); + !(::dafny_runtime::int!(0) <= i.clone() + && i.clone() < lengthOfCommonPrefix.clone()) +@@ -1092,11 +1047,11 @@ pub mod r#_StandardLibrary_Compile { + s: &::dafny_runtime::Set<::dafny_runtime::Sequence<_T>>, + less: &::std::rc::Rc bool>, + ) -> bool { +- s.contains(a) && s.iter().all(({ + s.contains(a) && s.iter().cloned().all(({ -+ let mut a = a.clone(); -+ let mut s = s.clone(); -+ let mut less = less.clone(); + let mut a = a.clone(); + let mut s = s.clone(); + let mut less = less.clone(); +- ::std::rc::Rc::new(move |r#__forall_var_1: &::dafny_runtime::Sequence<_T>| -> bool { + ::std::rc::Rc::new(move |r#__forall_var_1: ::dafny_runtime::Sequence<_T>| -> bool { -+ let mut z: ::dafny_runtime::Sequence<_T> = r#__forall_var_1.clone(); -+ !s.contains(&z) || super::r#_StandardLibrary_Compile::_default::LexicographicLessOrEqual::<_T>(&a, &z, &less) -+ }) -+ }).as_ref()) -+ } -+ } -+} -+pub mod UTF8 { -+ pub struct _default {} -+ -+ impl _default { -+ pub fn _allocate_rcmut() -> ::dafny_runtime::Object { -+ ::dafny_runtime::allocate_rcmut::() -+ } -+ pub fn CreateEncodeSuccess( -+ bytes: &super::UTF8::ValidUTF8Bytes, -+ ) -> ::std::rc::Rc< -+ super::r#_Wrappers_Compile::Result< -+ super::UTF8::ValidUTF8Bytes, -+ ::dafny_runtime::Sequence<::dafny_runtime::DafnyCharUTF16>, -+ >, -+ > { -+ ::std::rc::Rc::new(super::r#_Wrappers_Compile::Result::< -+ super::UTF8::ValidUTF8Bytes, -+ ::dafny_runtime::Sequence<::dafny_runtime::DafnyCharUTF16>, -+ >::Success { -+ value: bytes.clone(), -+ }) -+ } -+ pub fn CreateEncodeFailure( -+ error: &::dafny_runtime::Sequence<::dafny_runtime::DafnyCharUTF16>, -+ ) -> ::std::rc::Rc< -+ super::r#_Wrappers_Compile::Result< -+ super::UTF8::ValidUTF8Bytes, -+ ::dafny_runtime::Sequence<::dafny_runtime::DafnyCharUTF16>, -+ >, -+ > { -+ ::std::rc::Rc::new(super::r#_Wrappers_Compile::Result::< -+ super::UTF8::ValidUTF8Bytes, -+ ::dafny_runtime::Sequence<::dafny_runtime::DafnyCharUTF16>, -+ >::Failure { -+ error: error.clone(), -+ }) -+ } -+ pub fn CreateDecodeSuccess( -+ s: &::dafny_runtime::Sequence<::dafny_runtime::DafnyCharUTF16>, -+ ) -> ::std::rc::Rc< -+ super::r#_Wrappers_Compile::Result< -+ ::dafny_runtime::Sequence<::dafny_runtime::DafnyCharUTF16>, -+ ::dafny_runtime::Sequence<::dafny_runtime::DafnyCharUTF16>, -+ >, -+ > { -+ ::std::rc::Rc::new(super::r#_Wrappers_Compile::Result::< -+ ::dafny_runtime::Sequence<::dafny_runtime::DafnyCharUTF16>, -+ ::dafny_runtime::Sequence<::dafny_runtime::DafnyCharUTF16>, -+ >::Success { -+ value: s.clone(), -+ }) -+ } -+ pub fn CreateDecodeFailure( -+ error: &::dafny_runtime::Sequence<::dafny_runtime::DafnyCharUTF16>, -+ ) -> ::std::rc::Rc< -+ super::r#_Wrappers_Compile::Result< -+ ::dafny_runtime::Sequence<::dafny_runtime::DafnyCharUTF16>, -+ ::dafny_runtime::Sequence<::dafny_runtime::DafnyCharUTF16>, -+ >, -+ > { -+ ::std::rc::Rc::new(super::r#_Wrappers_Compile::Result::< -+ ::dafny_runtime::Sequence<::dafny_runtime::DafnyCharUTF16>, -+ ::dafny_runtime::Sequence<::dafny_runtime::DafnyCharUTF16>, -+ >::Failure { -+ error: error.clone(), -+ }) -+ } -+ pub fn IsASCIIString( -+ s: &::dafny_runtime::Sequence<::dafny_runtime::DafnyCharUTF16>, -+ ) -> bool { -+ let mut _hresult: bool = ::default(); -+ let mut _hi0: ::dafny_runtime::DafnyInt = s.cardinality(); -+ for i in ::dafny_runtime::integer_range(::dafny_runtime::int!(0), _hi0.clone()) { -+ if !(::dafny_runtime::int!(s.get(&i).0) < ::dafny_runtime::int!(128)) { -+ _hresult = false; -+ return _hresult; -+ } -+ } -+ _hresult = true; -+ return _hresult; -+ return _hresult; -+ } -+ pub fn EncodeAscii( -+ s: &::dafny_runtime::Sequence<::dafny_runtime::DafnyCharUTF16>, -+ ) -> super::UTF8::ValidUTF8Bytes { -+ let mut _accumulator: super::UTF8::ValidUTF8Bytes = -+ ::dafny_runtime::seq![] as ::dafny_runtime::Sequence; -+ let mut s = s.clone(); -+ let mut _accumulator = _accumulator.clone(); -+ 'TAIL_CALL_START: loop { -+ if s.cardinality() == ::dafny_runtime::int!(0) { -+ return _accumulator -+ .concat(&(::dafny_runtime::seq![] as ::dafny_runtime::Sequence)); -+ } else { -+ let mut x: ::dafny_runtime::Sequence = -+ ::dafny_runtime::seq![s.get(&::dafny_runtime::int!(0)).0 as u8]; -+ _accumulator = _accumulator.concat(&x); -+ let mut _in11: ::dafny_runtime::Sequence<::dafny_runtime::DafnyCharUTF16> = -+ s.drop(&::dafny_runtime::int!(1)); -+ s = _in11.clone(); -+ continue 'TAIL_CALL_START; -+ } -+ } -+ } -+ pub fn Uses1Byte(s: &::dafny_runtime::Sequence) -> bool { -+ 0 <= s.get(&::dafny_runtime::int!(0)) && s.get(&::dafny_runtime::int!(0)) <= 127 -+ } -+ pub fn Uses2Bytes(s: &::dafny_runtime::Sequence) -> bool { -+ 194 <= s.get(&::dafny_runtime::int!(0)) -+ && s.get(&::dafny_runtime::int!(0)) <= 223 -+ && (128 <= s.get(&::dafny_runtime::int!(1)) -+ && s.get(&::dafny_runtime::int!(1)) <= 191) -+ } -+ pub fn Uses3Bytes(s: &::dafny_runtime::Sequence) -> bool { -+ s.get(&::dafny_runtime::int!(0)) == 224 -+ && (160 <= s.get(&::dafny_runtime::int!(1)) -+ && s.get(&::dafny_runtime::int!(1)) <= 191) -+ && (128 <= s.get(&::dafny_runtime::int!(2)) -+ && s.get(&::dafny_runtime::int!(2)) <= 191) -+ || 225 <= s.get(&::dafny_runtime::int!(0)) -+ && s.get(&::dafny_runtime::int!(0)) <= 236 -+ && (128 <= s.get(&::dafny_runtime::int!(1)) -+ && s.get(&::dafny_runtime::int!(1)) <= 191) -+ && (128 <= s.get(&::dafny_runtime::int!(2)) -+ && s.get(&::dafny_runtime::int!(2)) <= 191) -+ || s.get(&::dafny_runtime::int!(0)) == 237 -+ && (128 <= s.get(&::dafny_runtime::int!(1)) -+ && s.get(&::dafny_runtime::int!(1)) <= 159) -+ && (128 <= s.get(&::dafny_runtime::int!(2)) -+ && s.get(&::dafny_runtime::int!(2)) <= 191) -+ || 238 <= s.get(&::dafny_runtime::int!(0)) -+ && s.get(&::dafny_runtime::int!(0)) <= 239 -+ && (128 <= s.get(&::dafny_runtime::int!(1)) -+ && s.get(&::dafny_runtime::int!(1)) <= 191) -+ && (128 <= s.get(&::dafny_runtime::int!(2)) -+ && s.get(&::dafny_runtime::int!(2)) <= 191) -+ } -+ pub fn Uses4Bytes(s: &::dafny_runtime::Sequence) -> bool { -+ s.get(&::dafny_runtime::int!(0)) == 240 -+ && (144 <= s.get(&::dafny_runtime::int!(1)) -+ && s.get(&::dafny_runtime::int!(1)) <= 191) -+ && (128 <= s.get(&::dafny_runtime::int!(2)) -+ && s.get(&::dafny_runtime::int!(2)) <= 191) -+ && (128 <= s.get(&::dafny_runtime::int!(3)) -+ && s.get(&::dafny_runtime::int!(3)) <= 191) -+ || 241 <= s.get(&::dafny_runtime::int!(0)) -+ && s.get(&::dafny_runtime::int!(0)) <= 243 -+ && (128 <= s.get(&::dafny_runtime::int!(1)) -+ && s.get(&::dafny_runtime::int!(1)) <= 191) -+ && (128 <= s.get(&::dafny_runtime::int!(2)) -+ && s.get(&::dafny_runtime::int!(2)) <= 191) -+ && (128 <= s.get(&::dafny_runtime::int!(3)) -+ && s.get(&::dafny_runtime::int!(3)) <= 191) -+ || s.get(&::dafny_runtime::int!(0)) == 244 -+ && (128 <= s.get(&::dafny_runtime::int!(1)) -+ && s.get(&::dafny_runtime::int!(1)) <= 143) -+ && (128 <= s.get(&::dafny_runtime::int!(2)) -+ && s.get(&::dafny_runtime::int!(2)) <= 191) -+ && (128 <= s.get(&::dafny_runtime::int!(3)) -+ && s.get(&::dafny_runtime::int!(3)) <= 191) -+ } -+ pub fn ValidUTF8Range( -+ a: &::dafny_runtime::Sequence, -+ lo: &::dafny_runtime::_System::nat, -+ hi: &::dafny_runtime::_System::nat, -+ ) -> bool { -+ let mut a = a.clone(); -+ let mut lo = lo.clone(); -+ let mut hi = hi.clone(); -+ 'TAIL_CALL_START: loop { -+ if lo.clone() == hi.clone() { -+ return true; -+ } else { -+ let mut r: ::dafny_runtime::Sequence = a.slice(&lo, &hi); -+ if super::UTF8::_default::Uses1Byte(&r) { -+ let mut _in12: ::dafny_runtime::Sequence = a.clone(); -+ let mut _in13: ::dafny_runtime::DafnyInt = -+ lo.clone() + ::dafny_runtime::int!(1); -+ let mut _in14: ::dafny_runtime::_System::nat = hi.clone(); -+ a = _in12.clone(); -+ lo = _in13.clone(); -+ hi = _in14.clone(); -+ continue 'TAIL_CALL_START; -+ } else { -+ if ::dafny_runtime::int!(2) <= r.cardinality() -+ && super::UTF8::_default::Uses2Bytes(&r) -+ { -+ let mut _in15: ::dafny_runtime::Sequence = a.clone(); -+ let mut _in16: ::dafny_runtime::DafnyInt = -+ lo.clone() + ::dafny_runtime::int!(2); -+ let mut _in17: ::dafny_runtime::_System::nat = hi.clone(); -+ a = _in15.clone(); -+ lo = _in16.clone(); -+ hi = _in17.clone(); -+ continue 'TAIL_CALL_START; -+ } else { -+ if ::dafny_runtime::int!(3) <= r.cardinality() -+ && super::UTF8::_default::Uses3Bytes(&r) -+ { -+ let mut _in18: ::dafny_runtime::Sequence = a.clone(); -+ let mut _in19: ::dafny_runtime::DafnyInt = -+ lo.clone() + ::dafny_runtime::int!(3); -+ let mut _in20: ::dafny_runtime::_System::nat = hi.clone(); -+ a = _in18.clone(); -+ lo = _in19.clone(); -+ hi = _in20.clone(); -+ continue 'TAIL_CALL_START; -+ } else { -+ if ::dafny_runtime::int!(4) <= r.cardinality() -+ && super::UTF8::_default::Uses4Bytes(&r) -+ { -+ let mut _in21: ::dafny_runtime::Sequence = a.clone(); -+ let mut _in22: ::dafny_runtime::DafnyInt = -+ lo.clone() + ::dafny_runtime::int!(4); -+ let mut _in23: ::dafny_runtime::_System::nat = hi.clone(); -+ a = _in21.clone(); -+ lo = _in22.clone(); -+ hi = _in23.clone(); -+ continue 'TAIL_CALL_START; -+ } else { -+ return false; -+ } -+ } -+ } -+ } -+ } -+ } -+ } -+ pub fn ValidUTF8Seq(s: &::dafny_runtime::Sequence) -> bool { -+ super::UTF8::_default::ValidUTF8Range(s, &::dafny_runtime::int!(0), &s.cardinality()) -+ } -+ } -+ -+ pub type ValidUTF8Bytes = ::dafny_runtime::Sequence; -+ -+ pub fn r#__init_ValidUTF8Bytes() -> ::dafny_runtime::Sequence { -+ ::dafny_runtime::seq![] as ::dafny_runtime::Sequence -+ } -+} -+pub mod r#_StandardLibraryInterop_Compile { -+ pub struct WrappersInterop {} -+ -+ impl WrappersInterop { -+ pub fn _allocate_rcmut() -> ::dafny_runtime::Object { -+ ::dafny_runtime::allocate_rcmut::() -+ } -+ pub fn CreateStringSome( -+ s: &::dafny_runtime::Sequence<::dafny_runtime::DafnyCharUTF16>, -+ ) -> ::std::rc::Rc< -+ super::r#_Wrappers_Compile::Option< -+ ::dafny_runtime::Sequence<::dafny_runtime::DafnyCharUTF16>, -+ >, -+ > { -+ ::std::rc::Rc::new(super::r#_Wrappers_Compile::Option::< -+ ::dafny_runtime::Sequence<::dafny_runtime::DafnyCharUTF16>, -+ >::Some { -+ value: s.clone(), -+ }) -+ } -+ pub fn CreateStringNone() -> ::std::rc::Rc< -+ super::r#_Wrappers_Compile::Option< -+ ::dafny_runtime::Sequence<::dafny_runtime::DafnyCharUTF16>, -+ >, -+ > { -+ ::std::rc::Rc::new(super::r#_Wrappers_Compile::Option::< -+ ::dafny_runtime::Sequence<::dafny_runtime::DafnyCharUTF16>, -+ >::None {}) -+ } -+ pub fn CreateBooleanSome( -+ b: bool, -+ ) -> ::std::rc::Rc> { -+ ::std::rc::Rc::new(super::r#_Wrappers_Compile::Option::::Some { value: b }) -+ } -+ pub fn CreateBooleanNone() -> ::std::rc::Rc> { -+ ::std::rc::Rc::new(super::r#_Wrappers_Compile::Option::::None {}) -+ } -+ } -+} -+pub mod _module {} + let mut z: ::dafny_runtime::Sequence<_T> = r#__forall_var_1.clone(); + !s.contains(&z) || super::r#_StandardLibrary_Compile::_default::LexicographicLessOrEqual::<_T>(&a, &z, &less) + }) diff --git b/TestModels/dafny-dependencies/StandardLibrary/runtimes/rust/src/lib.rs a/TestModels/dafny-dependencies/StandardLibrary/runtimes/rust/src/lib.rs new file mode 100644 index 00000000..4b9fb6f8 diff --git a/codegen/smithy-dafny-codegen/src/main/java/software/amazon/polymorph/CodegenEngine.java b/codegen/smithy-dafny-codegen/src/main/java/software/amazon/polymorph/CodegenEngine.java index 8afcc12421..1f310f6cda 100644 --- a/codegen/smithy-dafny-codegen/src/main/java/software/amazon/polymorph/CodegenEngine.java +++ b/codegen/smithy-dafny-codegen/src/main/java/software/amazon/polymorph/CodegenEngine.java @@ -6,6 +6,8 @@ import com.google.common.base.Strings; import com.google.common.collect.ImmutableMap; import com.google.common.collect.Streams; + +import java.io.File; import java.io.IOException; import java.io.UncheckedIOException; import java.nio.file.Files; @@ -622,9 +624,21 @@ private void generateRust(final Path outputDir) { // It would be great to do this for all languages, // but we're not currently precise enough and do multiple passes // to generate code for things like wrapped services. + // + // Be sure to NOT delete src/implementation_from_dafny.rs though, + // by temporarily moving it out of src/ Path outputSrcDir = outputDir.resolve("src"); - software.amazon.smithy.utils.IoUtils.rmdir(outputSrcDir); - outputSrcDir.toFile().mkdirs(); + Path implementationFromDafnyPath = outputSrcDir.resolve("implementation_from_dafny.rs"); + try { + Path tmpPath = outputDir.resolve("implementation_from_dafny.rs"); + Files.move(implementationFromDafnyPath, tmpPath); + software.amazon.smithy.utils.IoUtils.rmdir(outputSrcDir); + outputSrcDir.toFile().mkdirs(); + Files.move(tmpPath, implementationFromDafnyPath); + } catch (IOException e) { + throw new RuntimeException(e); + } + handlePatching(TargetLanguage.RUST, outputDir); } From 0d1f49a9181c52cadb0317795833d36cbadfd08a Mon Sep 17 00:00:00 2001 From: Robin Salkeld Date: Wed, 26 Jun 2024 09:57:50 -0700 Subject: [PATCH 09/53] Formatting --- .../runtimes/rust/tests/tests_from_dafny/_wrapped.rs | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/TestModels/SimpleTypes/SimpleBoolean/runtimes/rust/tests/tests_from_dafny/_wrapped.rs b/TestModels/SimpleTypes/SimpleBoolean/runtimes/rust/tests/tests_from_dafny/_wrapped.rs index b4df5c931b..14279d3d61 100644 --- a/TestModels/SimpleTypes/SimpleBoolean/runtimes/rust/tests/tests_from_dafny/_wrapped.rs +++ b/TestModels/SimpleTypes/SimpleBoolean/runtimes/rust/tests/tests_from_dafny/_wrapped.rs @@ -43,7 +43,10 @@ impl super::r#_simple_dtypes_dboolean_dinternaldafny_dtypes::ISimpleTypesBoolean impl r#_simple_dtypes_dboolean_dinternaldafny_dwrapped::_default { pub fn WrappedSimpleBoolean(config: &::std::rc::Rc< super::r#_simple_dtypes_dboolean_dinternaldafny_dtypes::SimpleBooleanConfig, - >) -> ::std::rc::Rc, ::std::rc::Rc>>{ + >) -> ::std::rc::Rc, + ::std::rc::Rc + >>{ let result = Client::from_conf( simple_boolean::conversions::simple_boolean_config::_simple_boolean_config::from_dafny( config.clone(), From 3fccf32c9321edcb50f5e58f4c134e962aac49f0 Mon Sep 17 00:00:00 2001 From: Robin Salkeld Date: Tue, 9 Jul 2024 09:26:48 -0700 Subject: [PATCH 10/53] Update commit --- .github/workflows/pull.yml | 2 +- .github/workflows/push.yml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/pull.yml b/.github/workflows/pull.yml index 807b09150f..d53abfbb72 100644 --- a/.github/workflows/pull.yml +++ b/.github/workflows/pull.yml @@ -49,7 +49,7 @@ jobs: # Rust code generation is under development and depends on pending changes to the # Dafny Rust code generation, so we test on a specific commit from the feat-rust feature branch instead. dafny-version: - - ebe9aa5592bea6c0a7ed3fc204db2fb8addf0661 + - f82ce12a800efddb22c987be0adb559752c7b6b9 uses: ./.github/workflows/test_models_rust_tests.yml with: dafny: ${{ matrix.dafny-version }} diff --git a/.github/workflows/push.yml b/.github/workflows/push.yml index 92d6836c63..c33fbacea0 100644 --- a/.github/workflows/push.yml +++ b/.github/workflows/push.yml @@ -51,7 +51,7 @@ jobs: # Rust code generation is under development and depends on pending changes to the # Dafny Rust code generation, so we test on a specific commit from the feat-rust feature branch instead. dafny-version: - - ebe9aa5592bea6c0a7ed3fc204db2fb8addf0661 + - f82ce12a800efddb22c987be0adb559752c7b6b9 uses: ./.github/workflows/test_models_rust_tests.yml with: dafny: ${{ matrix.dafny-version }} From 6de828dbf36c5bb59924593b71d28272c9fa8497 Mon Sep 17 00:00:00 2001 From: Robin Salkeld Date: Tue, 9 Jul 2024 09:46:08 -0700 Subject: [PATCH 11/53] update copy of runtime --- .../dafny_runtime_rust/Cargo.toml | 3 +- .../dafny_runtime_rust/src/lib.rs | 556 +++++++++++++----- .../dafny_runtime_rust/src/tests/mod.rs | 172 +++--- 3 files changed, 501 insertions(+), 230 deletions(-) diff --git a/TestModels/dafny-dependencies/dafny_runtime_rust/Cargo.toml b/TestModels/dafny-dependencies/dafny_runtime_rust/Cargo.toml index 872ba7130e..3ddcbab787 100644 --- a/TestModels/dafny-dependencies/dafny_runtime_rust/Cargo.toml +++ b/TestModels/dafny-dependencies/dafny_runtime_rust/Cargo.toml @@ -8,5 +8,4 @@ once_cell = "1.18.0" paste = "1.0" num = "0.4" itertools = "0.11.0" -as-any = "0.3.1" -nightly-crimes = "=1.0.0" \ No newline at end of file +as-any = "0.3.1" \ No newline at end of file diff --git a/TestModels/dafny-dependencies/dafny_runtime_rust/src/lib.rs b/TestModels/dafny-dependencies/dafny_runtime_rust/src/lib.rs index 4ad5e3db1c..e4889103ae 100644 --- a/TestModels/dafny-dependencies/dafny_runtime_rust/src/lib.rs +++ b/TestModels/dafny-dependencies/dafny_runtime_rust/src/lib.rs @@ -236,6 +236,10 @@ pub mod dafny_runtime_conversions { } } +pub trait DafnyUsize { + fn into_usize(self) -> usize; +} + // ************** // Dafny integers // ************** @@ -255,6 +259,12 @@ impl DafnyInt { } } +impl DafnyUsize for DafnyInt { + fn into_usize(self) -> usize { + self.as_usize() + } +} + impl AsRef for DafnyInt { fn as_ref(&self) -> &BigInt { &self.data @@ -540,6 +550,11 @@ macro_rules! impl_dafnyint_from { } } } + impl DafnyUsize for $type { + fn into_usize(self) -> usize { + self as usize + } + } }; } @@ -568,6 +583,25 @@ impl<'a, const N: usize> From<&'a [u8; N]> for DafnyInt { } } +impl From for DafnyInt { + fn from(c: char) -> Self { + let cu32: u32 = c.into(); + int!(cu32) + } +} + +impl From for DafnyInt { + fn from(c: DafnyChar) -> Self { + int!(c.0) + } +} + +impl From for DafnyInt { + fn from(c: DafnyCharUTF16) -> Self { + int!(c.0) + } +} + // ************** // Immutable sequences // ************** @@ -582,7 +616,7 @@ impl Add<&Sequence> for &Sequence { } } -impl Hash for Sequence { +impl Hash for Sequence { fn hash(&self, state: &mut H) { self.cardinality_usize().hash(state); let array = self.to_array(); @@ -821,7 +855,7 @@ impl Sequence { } impl PartialEq> for Sequence where - T: DafnyTypeEq, + T: DafnyType + PartialEq, { fn eq(&self, other: &Sequence) -> bool { // Iterate through both elements and verify that they are equal @@ -906,12 +940,12 @@ impl Debug for Sequence { pub struct Map where K: DafnyTypeEq, - V: DafnyTypeEq, + V: DafnyType, { data: Rc>, } -impl Default for Map { +impl Default for Map { fn default() -> Self { Map { data: Rc::new(HashMap::new()), @@ -919,13 +953,13 @@ impl Default for Map { } } -impl NontrivialDefault for Map { +impl NontrivialDefault for Map { fn nontrivial_default() -> Self { Self::default() } } -impl Hash for Map { +impl Hash for Map { fn hash(&self, state: &mut H) { self.data.len().hash(state); // Worst performance for things that are not hashable like maps } @@ -951,7 +985,7 @@ where impl Eq for Map {} -impl Map { +impl Map { pub fn new_empty() -> Map { Map { data: Rc::new(HashMap::new()), @@ -1061,13 +1095,6 @@ impl Map { } Set::from_hashset_owned(result) } - pub fn values(&self) -> Set { - let mut result: Vec = Vec::new(); - for (_, v) in self.data.iter() { - result.push(v.clone()); - } - Set::from_array(&result) - } pub fn update_index(&self, index: &K, value: &V) -> Self { let mut result = self.data.as_ref().clone(); @@ -1090,6 +1117,24 @@ impl Map { } } + +impl Map { + pub fn values(&self) -> Set { + let mut result: Vec = Vec::new(); + for (_, v) in self.data.iter() { + result.push(v.clone()); + } + Set::from_array(&result) + } + pub fn items(&self) -> Set<(K, V)> { + let mut result: Vec<(K, V)> = Vec::new(); + for (k, v) in self.data.iter() { + result.push((k.clone(), v.clone())); + } + Set::from_array(&result) + } +} + impl Map { pub fn as_dafny_multiset(&self) -> Multiset { Multiset::from_hashmap(&self.data) @@ -1107,7 +1152,7 @@ where impl MapBuilder where K: DafnyTypeEq, - V: DafnyTypeEq, + V: DafnyType, { pub fn new() -> MapBuilder { MapBuilder { @@ -1126,7 +1171,7 @@ where impl DafnyPrint for Map where K: DafnyTypeEq, - V: DafnyTypeEq, + V: DafnyType, { fn fmt_print(&self, f: &mut Formatter<'_>, in_seq: bool) -> std::fmt::Result { f.write_str("map[")?; @@ -1140,7 +1185,7 @@ where f.write_str(" := ")?; v.fmt_print(f, in_seq)?; } - f.write_str("}") + f.write_str("]") } } @@ -1163,6 +1208,15 @@ pub struct Set { data: Rc>, } +// Since there is no canonical way to iterate over a set to compute the hash. +impl ::std::hash::Hash for Set { + fn hash<_H: ::std::hash::Hasher>(&self, _state: &mut _H) { + self.cardinality_usize().hash(_state) + } +} + +impl Eq for Set {} + impl Default for Set where T: DafnyTypeEq, @@ -1690,23 +1744,8 @@ impl Hash for Multiset { } } -// Define the AsAny trait -pub trait AsAny { - fn as_any(&self) -> &dyn Any; - fn as_any_mut(&mut self) -> &mut dyn Any; -} -impl AsAny for dyn Any { - fn as_any(&self) -> &dyn Any { - self - } - fn as_any_mut(&mut self) -> &mut dyn Any { - self - } -} -pub fn is_instance_of(theobject: *const C) -> bool { - // safety: Dafny won't call this function unless it can guarantee the object is still allocated - unsafe { &*theobject } - .as_any() +pub fn is_instance_of, U: 'static>(theobject: *const C) -> bool { + read!(Upcast::::upcast(read!(theobject))) .downcast_ref::() .is_some() } @@ -1988,6 +2027,12 @@ impl DafnyPrint for () { pub struct DafnyCharUTF16(pub u16); pub type DafnyStringUTF16 = Sequence; +impl Default for DafnyCharUTF16 { + fn default() -> Self { + Self('a' as u16) + } +} + impl DafnyPrint for DafnyCharUTF16 { #[inline] fn fmt_print(&self, f: &mut Formatter<'_>, in_seq: bool) -> std::fmt::Result { @@ -2038,10 +2083,32 @@ impl PartialOrd for DafnyCharUTF16 { } } +impl Add for DafnyCharUTF16 { + type Output = DafnyCharUTF16; + + fn add(self, rhs: DafnyCharUTF16) -> Self::Output { + DafnyCharUTF16(self.0 + rhs.0) + } +} + +impl Sub for DafnyCharUTF16 { + type Output = DafnyCharUTF16; + + fn sub(self, rhs: DafnyCharUTF16) -> Self::Output { + DafnyCharUTF16(self.0 - rhs.0) + } +} + #[derive(Clone)] pub struct DafnyChar(pub char); pub type DafnyString = Sequence; +impl Default for DafnyChar { + fn default() -> Self { + Self('a') + } +} + impl DafnyPrint for DafnyChar { #[inline] fn fmt_print(&self, f: &mut Formatter<'_>, in_seq: bool) -> std::fmt::Result { @@ -2082,6 +2149,22 @@ impl Hash for DafnyChar { } } +impl Add for DafnyChar { + type Output = DafnyChar; + + fn add(self, rhs: DafnyChar) -> Self::Output { + DafnyChar(unsafe { char::from_u32_unchecked(self.0 as u32 + rhs.0 as u32) }) + } +} + +impl Sub for DafnyChar { + type Output = DafnyChar; + + fn sub(self, rhs: DafnyChar) -> Self::Output { + DafnyChar(unsafe { char::from_u32_unchecked(self.0 as u32 - rhs.0 as u32) }) + } +} + impl DafnyPrint for Option { fn fmt_print(&self, f: &mut Formatter<'_>, _in_seq: bool) -> std::fmt::Result { match self { @@ -2439,14 +2522,37 @@ macro_rules! INIT_ARRAY_DATA { macro_rules! ARRAY_METHODS { // Accepts any number of length identifiers ($ArrayType:ident, $length0: ident, $($length:ident),+) => { - pub fn placebos_usize( + pub fn placebos_box_usize( $length0: usize, $($length: usize),+ - ) -> *mut $ArrayType<$crate::MaybeUninit> { - Box::into_raw(Box::new($ArrayType { + ) -> Box<$ArrayType<$crate::MaybeUninit>> { + Box::new($ArrayType { $($length: $length),+, data: INIT_ARRAY_DATA!($ArrayType, $length0, $($length),+), - })) + }) + } + + pub fn placebos_usize( + $length0: usize, + $($length: usize),+ + ) -> *mut $ArrayType<$crate::MaybeUninit> { + Box::into_raw(Self::placebos_box_usize( + $length0, + $($length),+ + )) + } + + pub fn placebos_usize_object( + $length0: usize, + $($length: usize),+ + ) -> $crate::Object<$ArrayType<$crate::MaybeUninit>> { + // SAFETY: We know the object is owned and never referred to by anything else + unsafe { + $crate::Object::from_rc(Rc::new($ArrayType { + $($length: $length),+, + data: INIT_ARRAY_DATA!($ArrayType, $length0, $($length),+), + })) + } } pub fn placebos( @@ -2464,7 +2570,7 @@ macro_rules! ARRAY_METHODS { unsafe { std::mem::transmute(p) } } // Once all the elements have been initialized, transform the signature of the pointer - pub fn construct_rcmut(p: $crate::Object<$ArrayType>>) -> Object<$ArrayType> { + pub fn construct_object(p: $crate::Object<$ArrayType>>) -> Object<$ArrayType> { unsafe { std::mem::transmute(p) } } }; @@ -2475,7 +2581,7 @@ macro_rules! ARRAY_STRUCT { ($ArrayType:ident, $length0: ident, $($length:ident),+) => { pub struct $ArrayType { $($length: usize),+, - data: ARRAY_DATA_TYPE!($length0, $($length),+), + pub data: ARRAY_DATA_TYPE!($length0, $($length),+), } } } @@ -2786,14 +2892,14 @@ pub mod array { pub fn placebos_usize(n: usize) -> *mut [MaybeUninit] { Box::into_raw(placebos_box_usize(n)) } - pub fn placebos_usize_rcmut(n: usize) -> super::Object<[MaybeUninit]> { + pub fn placebos_usize_object(n: usize) -> super::Object<[MaybeUninit]> { super::rcmut::array_object_from_box(placebos_box_usize(n)) } // Once all the elements have been initialized, transform the signature of the pointer pub fn construct(p: *mut [MaybeUninit]) -> *mut [T] { unsafe { std::mem::transmute(p) } } - pub fn construct_rcmut(p: super::Object<[MaybeUninit]>) -> super::Object<[T]> { + pub fn construct_object(p: super::Object<[MaybeUninit]>) -> super::Object<[T]> { unsafe { std::mem::transmute(p) } } @@ -2883,7 +2989,8 @@ impl DafnyPrint for *mut T { impl NontrivialDefault for *mut T { fn nontrivial_default() -> Self { - 0 as *mut T + // Create a null pointer + ::std::ptr::null() as *const T as *mut T } } pub struct ExactPool { @@ -2917,8 +3024,7 @@ pub fn exact_range(value: T) -> ExactPool { #[macro_export] macro_rules! cast { ($raw:expr, $id:ty) => { - $crate::modify!($raw) - .as_any_mut() + $crate::modify!(Upcast::::upcast($crate::modify!($raw))) .downcast_mut::<$id>() .unwrap() as *mut $id }; @@ -2928,8 +3034,16 @@ macro_rules! cast { #[macro_export] macro_rules! is { ($raw:expr, $id:ty) => { - $crate::modify!($raw) - .as_any_mut() + $crate::modify!($crate::cast_any!($raw)) + .downcast_mut::<$id>() + .is_some() + }; +} + +#[macro_export] +macro_rules! is_object { + ($raw:expr, $id:ty) => { + $crate::md!($crate::cast_any_object!($raw)) .downcast_mut::<$id>() .is_some() }; @@ -2940,10 +3054,19 @@ macro_rules! is { #[macro_export] macro_rules! cast_any { ($raw:expr) => { - $crate::modify!($raw).as_any_mut() + $crate::Upcast::::upcast($crate::read!($raw)) + }; +} +// cast_any_object is meant to be used on references only, to convert any references (classes or traits)* +// to an Any reference trait +#[macro_export] +macro_rules! cast_any_object { + ($raw:expr) => { + $crate::UpcastObject::::upcast($crate::rd!($raw)) }; } + // When initializing an uninitialized field for the first time, // we ensure we don't drop the previous content // This is problematic if the same field is overwritten multiple times @@ -2972,7 +3095,11 @@ macro_rules! modify { ($ptr:expr) => { // safety: Dafny will only obtain a mutable borrowed address of a pointer if it can ensure the object // is still allocated - (unsafe { &mut *$ptr }) + { + #[allow(unused_unsafe)] + let tmp = unsafe { &mut *$ptr }; + tmp + } } } @@ -2982,7 +3109,11 @@ macro_rules! read { ($ptr:expr) => { // safety: Dafny will only obtain a borrowed address of a pointer if it can ensure the object // is still allocated - (unsafe { &*$ptr }) + { + #[allow(unused_unsafe)] + let tmp = unsafe { &*$ptr }; + tmp + } } } @@ -3018,12 +3149,25 @@ macro_rules! update_field_if_uninit { pub struct Object(pub Option>); +impl Object { + pub unsafe fn from_rc(rc: Rc) -> Object { + Object(Some(rcmut::from_rc(rc))) + } +} +impl Eq for Object {} + impl Clone for Object { fn clone(&self) -> Self { Object(self.0.clone()) } } +impl Default for Object { + fn default() -> Self { + Object(None) + } +} + impl Debug for Object { fn fmt(&self, f: &mut Formatter) -> std::fmt::Result { self.fmt_print(f, false) @@ -3035,8 +3179,9 @@ impl DafnyPrint for Object { } } -impl PartialEq for Object { - fn eq(&self, other: &Self) -> bool { + +impl PartialEq> for Object { + fn eq(&self, other: &Object) -> bool { if let Some(p) = &self.0 { if let Some(q) = &other.0 { // To compare addresses, we need to ensure we only compare thin pointers @@ -3045,8 +3190,10 @@ impl PartialEq for Object { } else { false } - } else { + } else if let Some(_q) = &other.0 { false + } else { + true } } } @@ -3054,13 +3201,34 @@ impl PartialEq for Object { impl std::hash::Hash for Object { fn hash(&self, state: &mut H) { if let Some(p) = &self.0 { - p.as_ref().get().hash(state); + (p.as_ref().get() as *const ()).hash(state); } else { 0.hash(state); } } } +impl AsMut for Object { + fn as_mut(&mut self) -> &mut T { + unsafe { &mut *(&self.0).as_ref().unwrap_unchecked().as_ref().get() } + } +} +impl AsRef for Object { + fn as_ref(&self) -> &T { + unsafe { &*(&self.0).as_ref().unwrap_unchecked().as_ref().get() } + } +} + + +impl Object { + pub fn from_ref(r: &T) -> Object { + let pt = r as *const T; + unsafe { ::std::rc::Rc::increment_strong_count(pt) } + let rebuilt = unsafe { Rc::from_raw(pt as *const UnsafeCell) }; + Object(Some(rebuilt)) + } +} + #[macro_export] macro_rules! cast_object { ($raw:expr, $id:ty) => { @@ -3073,8 +3241,8 @@ macro_rules! cast_object { }; } -// Returns an object whose fields are yet initialized. Only use update_field_uninit_rcmut and update_field_if_uninit_rcmut to initialize fields. -pub fn allocate_rcmut() -> Object { +// Returns an object whose fields are yet initialized. Only use update_field_uninit_object and update_field_if_uninit_object to initialize fields. +pub fn allocate_object() -> Object { unsafe { mem::transmute(object::new::>(MaybeUninit::uninit())) } } @@ -3082,42 +3250,40 @@ pub struct AllocationTracker { allocations: Vec> } -pub fn allocate_rcmut_track(allocation_tracker: &mut AllocationTracker) -> Object { - let res = allocate_rcmut::(); +pub fn allocate_object_track(allocation_tracker: &mut AllocationTracker) -> Object { + let res = allocate_object::(); allocation_tracker.allocations.push(Rc::>::downgrade(&res.0.clone().unwrap())); res } -pub fn is_instance_of_rcmut(theobject: Object) -> bool { +pub fn is_instance_of_object, U: 'static>(theobject: Object) -> bool { // safety: Dafny won't call this function unless it can guarantee the object is still allocated - unsafe { - rcmut::borrow(&theobject.0.unwrap()).as_any().downcast_ref::().is_some() - } + rd!(UpcastObject::::upcast(rd!(theobject))).downcast_ref::().is_some() } // Equivalent of update_field_nodrop but for rcmut #[macro_export] -macro_rules! update_field_nodrop_rcmut { +macro_rules! update_field_nodrop_object { ($ptr:expr, $field: ident, $value:expr) => { - $crate::update_nodrop_rcmut!(($crate::rcmut::borrow_mut(&mut $ptr.0.clone().unwrap())).$field, $value) + $crate::update_nodrop_object!(($crate::rcmut::borrow_mut(&mut $ptr.0.clone().unwrap())).$field, $value) }; } // Equivalent of update_nodrop but for rcmut #[macro_export] -macro_rules! update_nodrop_rcmut { +macro_rules! update_nodrop_object { ($ptr:expr, $value:expr) => { - unsafe { unsafe { ::std::ptr::addr_of_mut!($ptr).write($value) } } + unsafe { ::std::ptr::addr_of_mut!($ptr).write($value) } }; } // Equivalent of update_field_if_uninit but for rcmut #[macro_export] -macro_rules! update_field_if_uninit_rcmut { +macro_rules! update_field_if_uninit_object { ($t:expr, $field:ident, $field_assigned:expr, $value:expr) => {{ let computed_value = $value; if !$field_assigned { - $crate::update_field_nodrop_rcmut!($t, $field, computed_value); + $crate::update_field_nodrop_object!($t, $field, computed_value); $field_assigned = true; } }}; @@ -3125,13 +3291,13 @@ macro_rules! update_field_if_uninit_rcmut { // Equivalent of update_field_uninit but for rcmut #[macro_export] -macro_rules! update_field_uninit_rcmut { +macro_rules! update_field_uninit_object { ($t:expr, $field:ident, $field_assigned:expr, $value:expr) => {{ let computed_value = $value; if $field_assigned { $crate::md!($t).$field = computed_value; } else { - $crate::update_field_nodrop_rcmut!($t, $field, computed_value); + $crate::update_field_nodrop_object!($t, $field, computed_value); $field_assigned = true; } }}; @@ -3141,7 +3307,7 @@ macro_rules! update_field_uninit_rcmut { #[macro_export] macro_rules! md { ($x:expr) => { - unsafe { $crate::rcmut::borrow_mut(&mut $x.0.unwrap()) } + $x.clone().as_mut() }; } @@ -3149,7 +3315,7 @@ macro_rules! md { #[macro_export] macro_rules! rd { ($x:expr) => { - unsafe { $crate::rcmut::borrow(& $x.0.unwrap()) } + $x.as_ref() }; } @@ -3157,14 +3323,25 @@ macro_rules! rd { #[macro_export] macro_rules! refcount { ($x:expr) => { - Rc::strong_count(unsafe { rcmut::as_rc(& $x.0.unwrap()) }) + Rc::strong_count(unsafe { rcmut::as_rc($x.0.as_ref().unwrap()) }) }; } pub mod object { + use std::any::Any; + pub fn new(val: T) -> crate::Object { crate::Object(Some(crate::rcmut::new(val))) } + pub fn downcast(_self: crate::Object) -> crate::Object { + unsafe { + crate::Object(Some(crate::rcmut::downcast::(_self.0.unwrap()).unwrap())) // Use unwrap_unchecked? + } + } + #[inline] + pub fn is(_self: crate::Object) -> bool { + is_object!(_self, T) + } } // Inspired from https://crates.io/crates/rcmut @@ -3189,7 +3366,7 @@ pub mod rcmut { crate::Object(Some(crate::rcmut::new(Array { data }))) } - pub fn placebos_usize(length: usize) -> crate::Object>> { + pub fn placebos_usize_object(length: usize) -> crate::Object>> { let x = crate::array::placebos_box_usize::(length); crate::rcmut::Array::>::new(x) } @@ -3234,6 +3411,12 @@ pub mod rcmut { mem::transmute(this.get()) } + pub unsafe fn downcast(this: RcMut) -> Option> { + let t: Rc = to_rc(this); + let t: Rc = Rc::downcast::(t).ok()?; + mem::transmute(t) + } + /// A reference counted smart pointer with unrestricted mutability. pub struct ArcMut { inner: Arc>, @@ -3286,6 +3469,8 @@ pub mod rcmut { // A MaybePlacebo is a value that is either a placebo or a real value. // It is a wrapper around a MaybeUninit value, but knowing whether the value is a placebo or not. // That way, when it is dropped, the underlying value is only dropped if it is not a placebo. + +#[derive(Clone)] pub struct MaybePlacebo(Option); impl MaybePlacebo { #[inline] @@ -3333,124 +3518,177 @@ macro_rules! maybe_placebos_from { // Coercion //////////////// -// To use this trait, one needs to clone the element before. -pub trait UpcastTo: Clone { - fn upcast_to(self) -> U; +pub fn upcast_object() -> Rc) -> Object> + where A : UpcastObject +{ + Rc::new(|x: Object| rd!(x).upcast()) +} + +pub fn upcast() -> Rc *mut B> + where A: Upcast +{ + Rc::new(|x: *mut A| read!(x).upcast()) +} + +pub fn upcast_id() -> Rc A> +{ + Rc::new(|x: A| x) +} + +pub fn rc_coerce(f: Rc U>) -> Rc) -> Rc> { + Rc::new(move |x: Rc| Rc::new(f.as_ref()(x.as_ref().clone()))) +} +pub fn box_coerce(f: Box U>) -> Box) -> Box> { + Box::new(move |x: Box| Box::new(f.as_ref()(x.as_ref().clone()))) +} + +pub fn fn1_coerce( + a_to_r: Rc R + 'static>) -> + Rc A>) -> Rc R> + 'static> { + Rc::new(move |t_to_a: Rc A>| { + let a_to_r = a_to_r.clone(); + let t_to_a = t_to_a.clone(); + let r: Rc R + 'static> = Rc::new(move |t: &T| a_to_r(t_to_a(t))); + r + }) +} + +// For pointers +pub trait Upcast { + fn upcast(&self) -> *mut T; +} +pub trait UpcastObject { + fn upcast(&self) -> Object; +} + +impl Upcast for T { + fn upcast(&self) -> *mut T { + self as *const T as *mut T + } +} +impl UpcastObject for T { + fn upcast(&self) -> Object { + Object::from_ref(self) + } } #[macro_export] -macro_rules! UpcastTo { - ($from:ty, $to:ty) => { - impl $crate::UpcastTo<*mut $to> for & $from { - fn upcast_to(self) -> *mut $to { - self as *const $to as *mut $to - } - } - }; +macro_rules! Extends { + ($traitType: tt) => { + $traitType + ::dafny_runtime::Upcast + } } -use nightly_crimes::nightly_crimes; -nightly_crimes! { - #![feature(unsize)] - impl UpcastTo<::std::rc::Rc> for ::std::rc::Rc - where - From: ?Sized + core::marker::Unsize, - To: ?Sized, - { - fn upcast_to(self) -> ::std::rc::Rc { - self as ::std::rc::Rc + +#[macro_export] +macro_rules! UpcastFn { + ($B:ty) => { + fn upcast(&self) -> *mut $B { + self as *const Self as *mut Self as *mut $B } - } + }; } #[macro_export] -macro_rules! UpcastToRc { - ($from:ty, $to:ty) => { - impl $crate::UpcastTo<::std::rc::Rc<$to>> for ::std::rc::Rc<$from> { - fn upcast_to(&self) -> ::std::rc::Rc<$to> { - (*self) as *const $to as *mut $to - } +macro_rules! UpcastObjectFn { + ($B:ty) => { + fn upcast(&self) -> $crate::Object<$B> { + $crate::Object::from_ref($crate::read!(self as *const Self as *mut Self as *mut $B)) } }; } -// UpcastTo for pointers -impl UpcastTo<*mut dyn Any> for *mut T { - fn upcast_to(self) -> *mut dyn Any { - self as *const dyn Any as *mut dyn Any + + +// IT works only when there is no type parameters for $A... +#[macro_export] +macro_rules! UpcastDef { + ($A:ty, $B:ty) => { + impl $crate::Upcast<$B> for $A { + $crate::UpcastFn!($B); + } + }; + + ($A:ty, $B:ty, $($C: ty),*) => { + UpcastDef!($A, $B); + UpcastDef!($A, $($C),*); } } -impl UpcastTo> for Object -where - To: ?Sized, - Rc: UpcastTo>, -{ - fn upcast_to(self) -> Object { - Object(Some(unsafe { rcmut::from_rc(rcmut::to_rc(self.0.clone().unwrap()).upcast_to()) })) +#[macro_export] +macro_rules! UpcastDefObject { + ($A:ty, $B:ty) => { + impl $crate::UpcastObject<$B> for $A { + $crate::UpcastObjectFn!($B); + } + }; + + ($A:ty, $B:ty, $($C: ty),*) => { + UpcastDefObject!($A, $B); + UpcastDefObject!($A, $($C),*); } } -// UpcastTo for sets -impl UpcastTo> for Set -where - V: DafnyTypeEq, - U: DafnyTypeEq + UpcastTo, +// Coercions for sets +impl Set { - fn upcast_to(self) -> Set { - // We need to upcast individual elements - let mut new_set: HashSet = HashSet::::default(); - for value in self.data.iter() { - new_set.insert(value.clone().upcast_to()); - } - Set::from_hashset_owned(new_set) + pub fn coerce(f: Rc V>) -> Rc) -> Set> { + Rc::new(move |x: Set| { + // We need to upcast individual elements + let f2 = f.clone(); + let mut new_set: HashSet = HashSet::::default(); + for value in x.data.iter() { + new_set.insert(f2(value.clone())); + } + Set::from_hashset_owned(new_set) + }) } } -// UpcastTo for sequences -impl UpcastTo> for Sequence -where - V: DafnyTypeEq, - U: DafnyTypeEq + UpcastTo, +// Coercions for sequences +impl Sequence { - fn upcast_to(self) -> Sequence { + pub fn coerce(f: Rc V>) -> Rc) -> Sequence> { // We need to upcast individual elements - let mut new_seq: Vec = Vec::::default(); - for value in self.to_array().iter() { - new_seq.push(value.clone().upcast_to()); - } - Sequence::from_array_owned(new_seq) + Rc::new(move |x: Sequence| { + let mut new_seq: Vec = Vec::::default(); + let f2 = f.clone(); + for value in x.to_array().iter() { + new_seq.push(f2(value.clone())); + } + Sequence::from_array_owned(new_seq) + }) } } -// Upcast for multisets -impl UpcastTo> for Multiset -where - V: DafnyTypeEq, - U: DafnyTypeEq + UpcastTo, +// Coercions for multisets +impl Multiset { - fn upcast_to(self) -> Multiset { + pub fn coerce(f: Rc V>) -> Rc) -> Multiset> { // We need to upcast individual elements - let mut new_multiset: HashMap = HashMap::::default(); - for (value, count) in self.data.into_iter() { - new_multiset.insert(value.upcast_to(), count.clone()); - } - Multiset::from_hashmap_owned(new_multiset) + Rc::new(move |x: Multiset| { + let f2 = f.clone(); + // We need to upcast individual elements + let mut new_multiset: HashMap = HashMap::::default(); + for (value, count) in x.data.into_iter() { + new_multiset.insert(f2(value), count.clone()); + } + Multiset::from_hashmap_owned(new_multiset) + }) } } -// Upcast for Maps -impl UpcastTo> for Map -where - K: DafnyTypeEq, - U: DafnyTypeEq + UpcastTo, - V: DafnyTypeEq, +// Coercions for Maps +impl Map { - fn upcast_to(self) -> Map { + pub fn coerce(f: Rc V>) -> Rc) -> Map> { // We need to upcast individual elements - let mut new_map: HashMap = HashMap::::default(); - for (key, value) in self.data.iter() { - new_map.insert(key.clone(), value.clone().upcast_to()); - } - Map::from_hashmap_owned(new_map) + Rc::new(move |x: Map| { + let f2 = f.clone(); + let mut new_map: HashMap = HashMap::::default(); + for (key, value) in x.data.iter() { + new_map.insert(key.clone(), f2(value.clone())); + } + Map::from_hashmap_owned(new_map) + }) } } diff --git a/TestModels/dafny-dependencies/dafny_runtime_rust/src/tests/mod.rs b/TestModels/dafny-dependencies/dafny_runtime_rust/src/tests/mod.rs index 9488eb4717..5967e3f46c 100644 --- a/TestModels/dafny-dependencies/dafny_runtime_rust/src/tests/mod.rs +++ b/TestModels/dafny-dependencies/dafny_runtime_rust/src/tests/mod.rs @@ -2,8 +2,6 @@ pub mod experimental; // Test module #[cfg(test)] mod tests { - use crate::rcmut::RcMut; - use crate::*; #[test] @@ -242,6 +240,7 @@ mod tests { array::update_usize(v2, 1, 10); assert_eq!(array::get_usize(v2, 1), 10); + let v3 = array::initialize(&int!(3), Rc::new(|i| i.clone() + int!(1))); assert_eq!(array::length_usize(v3), 3); assert_eq!(array::get_usize(v3, 0), int!(1)); @@ -249,6 +248,10 @@ mod tests { assert_eq!(array::get_usize(v3, 2), int!(3)); array::update(v3, &int!(1), int!(10)); assert_eq!(array::get_usize(v3, 1), int!(10)); + + deallocate(a); + deallocate(v2); + deallocate(v3); } #[test] @@ -318,17 +321,6 @@ mod tests { /*const*/ next: *mut ClassWrapper, /*const*/ constant: crate::DafnyInt, } - impl AsAny for ClassWrapper - where - T: 'static, - { - fn as_any(&self) -> &dyn Any { - self - } - fn as_any_mut(&mut self) -> &mut dyn Any { - self - } - } impl ClassWrapper { fn constant_plus_x(&self) -> crate::DafnyInt { self.constant.clone() + self.x.clone() @@ -355,6 +347,13 @@ mod tests { } } + impl Upcast for ClassWrapper { + UpcastFn!(dyn Any); + } + impl UpcastObject for ClassWrapper { + UpcastObjectFn!(dyn Any); + } + #[test] #[allow(unused_unsafe)] fn test_class_wrapper() { @@ -466,20 +465,21 @@ mod tests { #[test] fn test_coercion_immutable() { let o = ClassWrapper::::constructor(1); - let a = UpcastTo::<*mut dyn Any>::upcast_to(o); + let a: *mut dyn Any = Upcast::::upcast(read!(o)); assert_eq!(cast!(a, ClassWrapper), o); let seq_o = seq![o]; - let seq_a = UpcastTo::>::upcast_to(seq_o); + let seq_a = Sequence::<*mut ClassWrapper>::coerce(upcast::, dyn Any>())(seq_o); assert_eq!(cast!(seq_a.get_usize(0), ClassWrapper), o); let set_o = set! {o}; - let set_a = UpcastTo::>::upcast_to(set_o); + let set_a = Set::<*mut ClassWrapper>::coerce(upcast::, dyn Any>())(set_o); assert_eq!(cast!(set_a.peek(), ClassWrapper), o); let multiset_o = multiset! {o, o}; - let multiset_a = UpcastTo::>::upcast_to(multiset_o); + let multiset_a = Multiset::<*mut ClassWrapper>::coerce(upcast::, dyn Any>())(multiset_o); assert_eq!(cast!(multiset_a.peek(), ClassWrapper), o); let map_o = map![1 => o, 2 => o]; - let map_a = UpcastTo::>::upcast_to(map_o); + let map_a = Map::>::coerce(upcast::, dyn Any>())(map_o); assert_eq!(cast!(map_a.get(&1), ClassWrapper), o); + deallocate(o); } #[test] @@ -656,60 +656,86 @@ mod tests { assert_eq!(sum, 55); } - trait NodeRcMutTrait: AsAny {} + trait SuperTrait: Upcast + UpcastObject { + } + + trait NodeRcMutTrait: SuperTrait + Upcast + UpcastObject{ + } pub struct NodeRcMut { val: DafnyInt, next: Object, } - impl AsAny for NodeRcMut { - fn as_any(&self) -> &dyn Any { - self - } - fn as_any_mut(&mut self) -> &mut dyn Any { - self - } - } impl NodeRcMut { fn _ctor(this: Object, val: DafnyInt) { let mut val_assign = false; let mut next_assign = false; - update_field_uninit_rcmut!(this.clone(), val, val_assign, val); - update_field_if_uninit_rcmut!(this.clone(), next, next_assign, Object(None)); + update_field_uninit_object!(this.clone(), val, val_assign, val); + update_field_if_uninit_object!(this.clone(), next, next_assign, Object(None)); } } + impl SuperTrait for NodeRcMut {} + impl UpcastObject for NodeRcMut { + UpcastObjectFn!(dyn Any); + } + impl Upcast for NodeRcMut { + UpcastFn!(dyn Any); + } + impl UpcastObject for NodeRcMut { + UpcastObjectFn!(dyn NodeRcMutTrait); + } + impl Upcast for NodeRcMut { + UpcastFn!(dyn NodeRcMutTrait); + } + impl UpcastObject for NodeRcMut { + UpcastObjectFn!(dyn SuperTrait); + } + impl Upcast for NodeRcMut { + UpcastFn!(dyn SuperTrait); + } impl NodeRcMutTrait for NodeRcMut {} #[test] - fn test_rcmut() { - let x: Object = allocate_rcmut::(); + fn test_object() { + let mut x: Object = allocate_object::(); NodeRcMut::_ctor(x.clone(), int!(42)); - assert_eq!(refcount!(x.clone()), 2); - assert_eq!(rd!(x.clone()).val, int!(42)); - md!(x.clone()).next = x.clone(); - assert_eq!(refcount!(x.clone()), 3); - assert_eq!(rd!(rd!(x.clone()).next.clone()).val, int!(42)); - md!(rd!(x.clone()).next.clone()).next = Object(None); - assert_eq!(refcount!(x.clone()), 2); - let y: Object = x.clone().upcast_to(); - assert_eq!(refcount!(x.clone()), 3); - let z: Object = x.clone().upcast_to(); - assert_eq!(refcount!(x.clone()), 4); + assert_eq!(refcount!(x), 1); + assert_eq!(x.as_ref().val, int!(42)); + x.as_mut().next = x.clone(); + assert_eq!(refcount!(x), 2); + assert_eq!(x.as_ref().next.as_ref().val, int!(42)); + md!(rd!(x).next).next = Object(None); + assert_eq!(refcount!(x), 1); + let y: Object = upcast_object::<_, _>()(x.clone()); + assert_eq!(refcount!(x), 2); + let z: Object = upcast_object::<_, _>()(x.clone()); + assert_eq!(refcount!(x), 3); let a2: Object = cast_object!(y.clone(), NodeRcMut); - assert_eq!(refcount!(x.clone()), 5); - assert_eq!(rd!(a2.clone()).val, int!(42)); + assert_eq!(refcount!(x), 4); + assert_eq!(rd!(a2).val, int!(42)); let a3: Object = cast_object!(z.clone(), NodeRcMut); - assert_eq!(refcount!(x.clone()), 6); - assert_eq!(rd!(a3.clone()).val, int!(42)); + assert_eq!(refcount!(x), 5); + assert_eq!(rd!(a3).val, int!(42)); let a: Object<[i32]> = rcmut::array_object_from_rc(Rc::new([42, 43, 44])); - assert_eq!(rd!(a.clone()).len(), 3); - assert_eq!(rd!(a.clone())[0], 42); - assert_eq!(rd!(a.clone())[1], 43); - assert_eq!(rd!(a.clone())[2], 44); - let b = a.clone(); - md!(b.clone())[0] = 45; - assert_eq!(rd!(a.clone())[0], 45); + assert_eq!(rd!(a).len(), 3); + assert_eq!(rd!(a)[0], 42); + assert_eq!(rd!(a)[1], 43); + assert_eq!(rd!(a)[2], 44); + let b: Object<[i32]> = a.clone(); + md!(b)[0] = 45; + assert_eq!(rd!(a)[0], 45); + + let previous_count = refcount!(x); + { + let z = Object::::from_ref(x.as_ref()); + assert_eq!(refcount!(z), previous_count + 1); + assert_eq!(refcount!(x), previous_count + 1); + } + assert_eq!(refcount!(x), previous_count); + + let mut objects: Set> = crate::set!{y.clone(), cast_any_object!(x.clone())}; + assert_eq!(objects.cardinality_usize(), 1); } pub struct NodeRawMut { @@ -722,34 +748,24 @@ mod tests { update_field_uninit!(this, val, val_assign, val); } } - impl AsAny for NodeRawMut { - fn as_any(&self) -> &dyn Any { - self - } - fn as_any_mut(&mut self) -> &mut dyn Any { - self - } - } impl NodeRcMutTrait for NodeRawMut {} - - UpcastTo!(NodeRawMut, dyn NodeRcMutTrait); + UpcastDefObject!(NodeRawMut, dyn NodeRcMutTrait, dyn SuperTrait, dyn Any); + UpcastDef!(NodeRawMut, dyn NodeRcMutTrait, dyn SuperTrait, dyn Any); + + impl SuperTrait for NodeRawMut {} #[test] fn test_rawmut() { let x: *mut NodeRawMut = allocate::(); NodeRawMut::_ctor(x.clone(), int!(42)); - //assert_eq!(refcount!(x.clone()), 2); assert_eq!(read!(x.clone()).val, int!(42)); modify!(x.clone()).next = x.clone(); - //assert_eq!(refcount!(x.clone()), 3); assert_eq!(read!(read!(x.clone()).next.clone()).val, int!(42)); modify!(read!(x.clone()).next.clone()).next = std::ptr::null_mut(); - //assert_eq!(refcount!(x.clone()), 2); - let y = x.upcast_to(); - let z: *mut dyn NodeRcMutTrait = modify!(x).upcast_to(); + let y: *mut dyn Any = upcast::<_, _>()(x); + let z: *mut dyn NodeRcMutTrait = upcast::<_, _>()(x); let a2: *mut NodeRawMut = cast!(y, NodeRawMut); let a3: *mut NodeRawMut = cast!(z, NodeRawMut); - //assert_eq!(refcount!(x.clone()), 3); deallocate(x); let a = array::from_native(Box::new([42, 43, 44])); @@ -760,5 +776,23 @@ mod tests { let b = a.clone(); modify!(b.clone())[0] = 45; assert_eq!(read!(a.clone())[0], 45); + + deallocate(a); + } + + // Conversion of any usize-compatible value into usize + #[test] + fn test_usize() { + let a: u128 = 1; + let b: i8 = 1; + let u: usize = 1; + assert_eq!(DafnyUsize::into_usize(int!(a)), u); + assert_eq!(DafnyUsize::into_usize(a), u); + assert_eq!(DafnyUsize::into_usize(b), u); + assert_eq!(DafnyUsize::into_usize(int!(b)), u); + } + + // Tests that we can compose Dafny types, like a sequence of maps + fn _test(_input: Sequence>) { } } From 9aec1d18943957b42035ddc254d5069e0746b5de Mon Sep 17 00:00:00 2001 From: Robin Salkeld Date: Tue, 9 Jul 2024 10:29:13 -0700 Subject: [PATCH 12/53] =?UTF-8?q?Don=E2=80=99t=20patch=20stdlib=20implemen?= =?UTF-8?q?tation=5Ffrom=5Fdafny.rs=20any=20more?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../codegen-patches/rust/dafny-4.5.0.patch | 1346 ----------------- .../rust/src/implementation_from_dafny.rs | 1340 ---------------- .../amazon/polymorph/CodegenEngine.java | 15 +- 3 files changed, 13 insertions(+), 2688 deletions(-) delete mode 100644 TestModels/dafny-dependencies/StandardLibrary/runtimes/rust/src/implementation_from_dafny.rs diff --git a/TestModels/dafny-dependencies/StandardLibrary/codegen-patches/rust/dafny-4.5.0.patch b/TestModels/dafny-dependencies/StandardLibrary/codegen-patches/rust/dafny-4.5.0.patch index 83baa808ef..d211904690 100644 --- a/TestModels/dafny-dependencies/StandardLibrary/codegen-patches/rust/dafny-4.5.0.patch +++ b/TestModels/dafny-dependencies/StandardLibrary/codegen-patches/rust/dafny-4.5.0.patch @@ -182,1352 +182,6 @@ index 00000000..3b7c2e76 + None + } +} -diff --git b/TestModels/dafny-dependencies/StandardLibrary/runtimes/rust/src/implementation_from_dafny.rs a/TestModels/dafny-dependencies/StandardLibrary/runtimes/rust/src/implementation_from_dafny.rs -new file mode 100644 -index 00000000..20cb9f07 ---- /dev/null -+++ a/TestModels/dafny-dependencies/StandardLibrary/runtimes/rust/src/implementation_from_dafny.rs -@@ -0,0 +1,1340 @@ -+#![allow(warnings, unconditional_panic)] -+#![allow(nonstandard_style)] -+pub mod r#_Wrappers_Compile { -+ pub struct _default {} -+ -+ impl _default { -+ pub fn _allocate_rcmut() -> ::dafny_runtime::Object { -+ ::dafny_runtime::allocate_rcmut::() -+ } -+ pub fn Need<_E: ::dafny_runtime::DafnyType>( -+ condition: bool, -+ error: &_E, -+ ) -> ::std::rc::Rc> { -+ if condition { -+ ::std::rc::Rc::new(super::r#_Wrappers_Compile::Outcome::<_E>::Pass {}) -+ } else { -+ ::std::rc::Rc::new(super::r#_Wrappers_Compile::Outcome::<_E>::Fail { -+ error: error.clone(), -+ }) -+ } -+ } -+ } -+ -+ #[derive(PartialEq, Clone)] -+ pub enum Option { -+ None {}, -+ Some { value: T }, -+ _PhantomVariant(::std::marker::PhantomData), -+ } -+ -+ impl Option { -+ pub fn ToResult( -+ self: &::std::rc::Rc, -+ ) -> ::std::rc::Rc< -+ super::r#_Wrappers_Compile::Result< -+ T, -+ ::dafny_runtime::Sequence<::dafny_runtime::DafnyCharUTF16>, -+ >, -+ > { -+ let mut _source0: ::std::rc::Rc> = self.clone(); -+ if matches!( -+ (&_source0).as_ref(), -+ super::r#_Wrappers_Compile::Option::None { .. } -+ ) { -+ ::std::rc::Rc::new(super::r#_Wrappers_Compile::Result::< -+ T, -+ ::dafny_runtime::Sequence<::dafny_runtime::DafnyCharUTF16>, -+ >::Failure { -+ error: ::dafny_runtime::string_utf16_of("Option is None"), -+ }) -+ } else { -+ let mut r#___mcc_h0: T = _source0.value().clone(); -+ let mut v: T = r#___mcc_h0.clone(); -+ ::std::rc::Rc::new(super::r#_Wrappers_Compile::Result::< -+ T, -+ ::dafny_runtime::Sequence<::dafny_runtime::DafnyCharUTF16>, -+ >::Success { -+ value: v.clone(), -+ }) -+ } -+ } -+ pub fn UnwrapOr(self: &::std::rc::Rc, default: &T) -> T { -+ let mut _source1: ::std::rc::Rc> = self.clone(); -+ if matches!( -+ (&_source1).as_ref(), -+ super::r#_Wrappers_Compile::Option::None { .. } -+ ) { -+ default.clone() -+ } else { -+ let mut r#___mcc_h0: T = _source1.value().clone(); -+ let mut v: T = r#___mcc_h0.clone(); -+ v.clone() -+ } -+ } -+ pub fn IsFailure(self: &::std::rc::Rc) -> bool { -+ matches!( -+ self.as_ref(), -+ super::r#_Wrappers_Compile::Option::None { .. } -+ ) -+ } -+ pub fn PropagateFailure<_U: ::dafny_runtime::DafnyType>( -+ self: &::std::rc::Rc, -+ ) -> ::std::rc::Rc> { -+ ::std::rc::Rc::new(super::r#_Wrappers_Compile::Option::<_U>::None {}) -+ } -+ pub fn Extract(self: &::std::rc::Rc) -> T { -+ self.value().clone() -+ } -+ pub fn value(&self) -> &T { -+ match self { -+ Option::None {} => panic!("field does not exist on this variant"), -+ Option::Some { value } => value, -+ Option::_PhantomVariant(..) => panic!(), -+ } -+ } -+ } -+ -+ impl ::std::fmt::Debug for Option { -+ fn fmt(&self, f: &mut ::std::fmt::Formatter) -> std::fmt::Result { -+ ::dafny_runtime::DafnyPrint::fmt_print(self, f, true) -+ } -+ } -+ -+ impl ::dafny_runtime::DafnyPrint for Option { -+ fn fmt_print( -+ &self, -+ _formatter: &mut ::std::fmt::Formatter, -+ _in_seq: bool, -+ ) -> std::fmt::Result { -+ match self { -+ Option::None {} => { -+ write!(_formatter, "r#_Wrappers_Compile.Option.None")?; -+ Ok(()) -+ } -+ Option::Some { value } => { -+ write!(_formatter, "r#_Wrappers_Compile.Option.Some(")?; -+ ::dafny_runtime::DafnyPrint::fmt_print(value, _formatter, false)?; -+ write!(_formatter, ")")?; -+ Ok(()) -+ } -+ Option::_PhantomVariant(..) => { -+ panic!() -+ } -+ } -+ } -+ } -+ -+ impl Eq for Option {} -+ -+ impl ::std::hash::Hash for Option { -+ fn hash<_H: ::std::hash::Hasher>(&self, _state: &mut _H) { -+ match self { -+ Option::None {} => {} -+ Option::Some { value } => value.hash(_state), -+ Option::_PhantomVariant(..) => { -+ panic!() -+ } -+ } -+ } -+ } -+ -+ impl ::std::default::Default -+ for Option -+ { -+ fn default() -> Option { -+ Option::None {} -+ } -+ } -+ -+ impl ::std::convert::AsRef> for &Option { -+ fn as_ref(&self) -> Self { -+ self -+ } -+ } -+ -+ #[derive(PartialEq, Clone)] -+ pub enum Result { -+ Success { value: T }, -+ Failure { error: R }, -+ _PhantomVariant(::std::marker::PhantomData, ::std::marker::PhantomData), -+ } -+ -+ impl Result { -+ pub fn ToOption( -+ self: &::std::rc::Rc, -+ ) -> ::std::rc::Rc> { -+ let mut _source2: ::std::rc::Rc> = -+ self.clone(); -+ if matches!( -+ (&_source2).as_ref(), -+ super::r#_Wrappers_Compile::Result::Success { .. } -+ ) { -+ let mut r#___mcc_h0: T = _source2.value().clone(); -+ let mut s: T = r#___mcc_h0.clone(); -+ ::std::rc::Rc::new(super::r#_Wrappers_Compile::Option::::Some { -+ value: s.clone(), -+ }) -+ } else { -+ let mut r#___mcc_h1: R = _source2.error().clone(); -+ let mut e: R = r#___mcc_h1.clone(); -+ ::std::rc::Rc::new(super::r#_Wrappers_Compile::Option::::None {}) -+ } -+ } -+ pub fn UnwrapOr(self: &::std::rc::Rc, default: &T) -> T { -+ let mut _source3: ::std::rc::Rc> = -+ self.clone(); -+ if matches!( -+ (&_source3).as_ref(), -+ super::r#_Wrappers_Compile::Result::Success { .. } -+ ) { -+ let mut r#___mcc_h0: T = _source3.value().clone(); -+ let mut s: T = r#___mcc_h0.clone(); -+ s.clone() -+ } else { -+ let mut r#___mcc_h1: R = _source3.error().clone(); -+ let mut e: R = r#___mcc_h1.clone(); -+ default.clone() -+ } -+ } -+ pub fn IsFailure(self: &::std::rc::Rc) -> bool { -+ matches!( -+ self.as_ref(), -+ super::r#_Wrappers_Compile::Result::Failure { .. } -+ ) -+ } -+ pub fn PropagateFailure<_U: ::dafny_runtime::DafnyType>( -+ self: &::std::rc::Rc, -+ ) -> ::std::rc::Rc> { -+ ::std::rc::Rc::new(super::r#_Wrappers_Compile::Result::<_U, R>::Failure { -+ error: self.error().clone(), -+ }) -+ } -+ pub fn MapFailure<_NewR: ::dafny_runtime::DafnyType>( -+ self: &::std::rc::Rc, -+ reWrap: &::std::rc::Rc _NewR>, -+ ) -> ::std::rc::Rc> { -+ let mut _source4: ::std::rc::Rc> = -+ self.clone(); -+ if matches!( -+ (&_source4).as_ref(), -+ super::r#_Wrappers_Compile::Result::Success { .. } -+ ) { -+ let mut r#___mcc_h0: T = _source4.value().clone(); -+ let mut s: T = r#___mcc_h0.clone(); -+ ::std::rc::Rc::new(super::r#_Wrappers_Compile::Result::::Success { -+ value: s.clone(), -+ }) -+ } else { -+ let mut r#___mcc_h1: R = _source4.error().clone(); -+ let mut e: R = r#___mcc_h1.clone(); -+ ::std::rc::Rc::new(super::r#_Wrappers_Compile::Result::::Failure { -+ error: reWrap(&e), -+ }) -+ } -+ } -+ pub fn Extract(self: &::std::rc::Rc) -> T { -+ self.value().clone() -+ } -+ pub fn value(&self) -> &T { -+ match self { -+ Result::Success { value } => value, -+ Result::Failure { error } => panic!("field does not exist on this variant"), -+ Result::_PhantomVariant(..) => panic!(), -+ } -+ } -+ pub fn error(&self) -> &R { -+ match self { -+ Result::Success { value } => panic!("field does not exist on this variant"), -+ Result::Failure { error } => error, -+ Result::_PhantomVariant(..) => panic!(), -+ } -+ } -+ } -+ -+ impl ::std::fmt::Debug -+ for Result -+ { -+ fn fmt(&self, f: &mut ::std::fmt::Formatter) -> std::fmt::Result { -+ ::dafny_runtime::DafnyPrint::fmt_print(self, f, true) -+ } -+ } -+ -+ impl ::dafny_runtime::DafnyPrint -+ for Result -+ { -+ fn fmt_print( -+ &self, -+ _formatter: &mut ::std::fmt::Formatter, -+ _in_seq: bool, -+ ) -> std::fmt::Result { -+ match self { -+ Result::Success { value } => { -+ write!(_formatter, "r#_Wrappers_Compile.Result.Success(")?; -+ ::dafny_runtime::DafnyPrint::fmt_print(value, _formatter, false)?; -+ write!(_formatter, ")")?; -+ Ok(()) -+ } -+ Result::Failure { error } => { -+ write!(_formatter, "r#_Wrappers_Compile.Result.Failure(")?; -+ ::dafny_runtime::DafnyPrint::fmt_print(error, _formatter, false)?; -+ write!(_formatter, ")")?; -+ Ok(()) -+ } -+ Result::_PhantomVariant(..) => { -+ panic!() -+ } -+ } -+ } -+ } -+ -+ impl Eq for Result {} -+ -+ impl< -+ T: ::dafny_runtime::DafnyType + ::std::hash::Hash, -+ R: ::dafny_runtime::DafnyType + ::std::hash::Hash, -+ > ::std::hash::Hash for Result -+ { -+ fn hash<_H: ::std::hash::Hasher>(&self, _state: &mut _H) { -+ match self { -+ Result::Success { value } => value.hash(_state), -+ Result::Failure { error } => error.hash(_state), -+ Result::_PhantomVariant(..) => { -+ panic!() -+ } -+ } -+ } -+ } -+ -+ impl< -+ T: ::dafny_runtime::DafnyType + ::std::default::Default, -+ R: ::dafny_runtime::DafnyType + ::std::default::Default, -+ > ::std::default::Default for Result -+ { -+ fn default() -> Result { -+ Result::Success { -+ value: ::std::default::Default::default(), -+ } -+ } -+ } -+ -+ impl -+ ::std::convert::AsRef> for &Result -+ { -+ fn as_ref(&self) -> Self { -+ self -+ } -+ } -+ -+ #[derive(PartialEq, Clone)] -+ pub enum Outcome { -+ Pass {}, -+ Fail { error: E }, -+ _PhantomVariant(::std::marker::PhantomData), -+ } -+ -+ impl Outcome { -+ pub fn IsFailure(self: &::std::rc::Rc) -> bool { -+ matches!( -+ self.as_ref(), -+ super::r#_Wrappers_Compile::Outcome::Fail { .. } -+ ) -+ } -+ pub fn PropagateFailure<_U: ::dafny_runtime::DafnyType>( -+ self: &::std::rc::Rc, -+ ) -> ::std::rc::Rc> { -+ ::std::rc::Rc::new(super::r#_Wrappers_Compile::Result::<_U, E>::Failure { -+ error: self.error().clone(), -+ }) -+ } -+ pub fn error(&self) -> &E { -+ match self { -+ Outcome::Pass {} => panic!("field does not exist on this variant"), -+ Outcome::Fail { error } => error, -+ Outcome::_PhantomVariant(..) => panic!(), -+ } -+ } -+ } -+ -+ impl ::std::fmt::Debug for Outcome { -+ fn fmt(&self, f: &mut ::std::fmt::Formatter) -> std::fmt::Result { -+ ::dafny_runtime::DafnyPrint::fmt_print(self, f, true) -+ } -+ } -+ -+ impl ::dafny_runtime::DafnyPrint for Outcome { -+ fn fmt_print( -+ &self, -+ _formatter: &mut ::std::fmt::Formatter, -+ _in_seq: bool, -+ ) -> std::fmt::Result { -+ match self { -+ Outcome::Pass {} => { -+ write!(_formatter, "r#_Wrappers_Compile.Outcome.Pass")?; -+ Ok(()) -+ } -+ Outcome::Fail { error } => { -+ write!(_formatter, "r#_Wrappers_Compile.Outcome.Fail(")?; -+ ::dafny_runtime::DafnyPrint::fmt_print(error, _formatter, false)?; -+ write!(_formatter, ")")?; -+ Ok(()) -+ } -+ Outcome::_PhantomVariant(..) => { -+ panic!() -+ } -+ } -+ } -+ } -+ -+ impl Eq for Outcome {} -+ -+ impl ::std::hash::Hash for Outcome { -+ fn hash<_H: ::std::hash::Hasher>(&self, _state: &mut _H) { -+ match self { -+ Outcome::Pass {} => {} -+ Outcome::Fail { error } => error.hash(_state), -+ Outcome::_PhantomVariant(..) => { -+ panic!() -+ } -+ } -+ } -+ } -+ -+ impl ::std::default::Default -+ for Outcome -+ { -+ fn default() -> Outcome { -+ Outcome::Pass {} -+ } -+ } -+ -+ impl ::std::convert::AsRef> for &Outcome { -+ fn as_ref(&self) -> Self { -+ self -+ } -+ } -+} -+pub mod r#_StandardLibrary_Compile_dUInt_Compile { -+ pub struct _default {} -+ -+ impl _default { -+ pub fn _allocate_rcmut() -> ::dafny_runtime::Object { -+ ::dafny_runtime::allocate_rcmut::() -+ } -+ pub fn UInt8Less(a: u8, b: u8) -> bool { -+ a < b -+ } -+ pub fn HasUint16Len<_T: ::dafny_runtime::DafnyType>( -+ s: &::dafny_runtime::Sequence<_T>, -+ ) -> bool { -+ s.cardinality() -+ < super::r#_StandardLibrary_Compile_dUInt_Compile::_default::UINT16_LIMIT() -+ } -+ pub fn HasUint32Len<_T: ::dafny_runtime::DafnyType>( -+ s: &::dafny_runtime::Sequence<_T>, -+ ) -> bool { -+ s.cardinality() -+ < super::r#_StandardLibrary_Compile_dUInt_Compile::_default::UINT32_LIMIT() -+ } -+ pub fn HasUint64Len<_T: ::dafny_runtime::DafnyType>( -+ s: &::dafny_runtime::Sequence<_T>, -+ ) -> bool { -+ s.cardinality() -+ < super::r#_StandardLibrary_Compile_dUInt_Compile::_default::UINT64_LIMIT() -+ } -+ pub fn UInt16ToSeq(x: u16) -> ::dafny_runtime::Sequence { -+ let mut b0: u8 = (x / 256) as u8; -+ let mut b1: u8 = (x % 256) as u8; -+ ::dafny_runtime::seq![b0, b1] -+ } -+ pub fn SeqToUInt16(s: &::dafny_runtime::Sequence) -> u16 { -+ let mut x0: u16 = s.get(&::dafny_runtime::int!(0)) as u16 * 256; -+ x0 + s.get(&::dafny_runtime::int!(1)) as u16 -+ } -+ pub fn UInt32ToSeq(x: u32) -> ::dafny_runtime::Sequence { -+ let mut b0: u8 = (x / 16777216) as u8; -+ let mut x0: u32 = x - b0 as u32 * 16777216; -+ let mut b1: u8 = (x0 / 65536) as u8; -+ let mut x1: u32 = x0 - b1 as u32 * 65536; -+ let mut b2: u8 = (x1 / 256) as u8; -+ let mut b3: u8 = (x1 % 256) as u8; -+ ::dafny_runtime::seq![b0, b1, b2, b3] -+ } -+ pub fn SeqToUInt32(s: &::dafny_runtime::Sequence) -> u32 { -+ let mut x0: u32 = s.get(&::dafny_runtime::int!(0)) as u32 * 16777216; -+ let mut x1: u32 = x0 + s.get(&::dafny_runtime::int!(1)) as u32 * 65536; -+ let mut x2: u32 = x1 + s.get(&::dafny_runtime::int!(2)) as u32 * 256; -+ x2 + s.get(&::dafny_runtime::int!(3)) as u32 -+ } -+ pub fn UInt64ToSeq(x: u64) -> ::dafny_runtime::Sequence { -+ let mut b0: u8 = (x / 72057594037927936) as u8; -+ let mut x0: u64 = x - b0 as u64 * 72057594037927936; -+ let mut b1: u8 = (x0 / 281474976710656) as u8; -+ let mut x1: u64 = x0 - b1 as u64 * 281474976710656; -+ let mut b2: u8 = (x1 / 1099511627776) as u8; -+ let mut x2: u64 = x1 - b2 as u64 * 1099511627776; -+ let mut b3: u8 = (x2 / 4294967296) as u8; -+ let mut x3: u64 = x2 - b3 as u64 * 4294967296; -+ let mut b4: u8 = (x3 / 16777216) as u8; -+ let mut x4: u64 = x3 - b4 as u64 * 16777216; -+ let mut b5: u8 = (x4 / 65536) as u8; -+ let mut x5: u64 = x4 - b5 as u64 * 65536; -+ let mut b6: u8 = (x5 / 256) as u8; -+ let mut b7: u8 = (x5 % 256) as u8; -+ ::dafny_runtime::seq![b0, b1, b2, b3, b4, b5, b6, b7] -+ } -+ pub fn SeqToUInt64(s: &::dafny_runtime::Sequence) -> u64 { -+ let mut x0: u64 = s.get(&::dafny_runtime::int!(0)) as u64 * 72057594037927936; -+ let mut x1: u64 = x0 + s.get(&::dafny_runtime::int!(1)) as u64 * 281474976710656; -+ let mut x2: u64 = x1 + s.get(&::dafny_runtime::int!(2)) as u64 * 1099511627776; -+ let mut x3: u64 = x2 + s.get(&::dafny_runtime::int!(3)) as u64 * 4294967296; -+ let mut x4: u64 = x3 + s.get(&::dafny_runtime::int!(4)) as u64 * 16777216; -+ let mut x5: u64 = x4 + s.get(&::dafny_runtime::int!(5)) as u64 * 65536; -+ let mut x6: u64 = x5 + s.get(&::dafny_runtime::int!(6)) as u64 * 256; -+ let mut x: u64 = x6 + s.get(&::dafny_runtime::int!(7)) as u64; -+ x -+ } -+ pub fn UINT16_LIMIT() -> ::dafny_runtime::DafnyInt { -+ ::dafny_runtime::int!(b"65536") -+ } -+ pub fn UINT32_LIMIT() -> ::dafny_runtime::DafnyInt { -+ ::dafny_runtime::int!(b"4294967296") -+ } -+ pub fn UINT64_LIMIT() -> ::dafny_runtime::DafnyInt { -+ ::dafny_runtime::int!(b"18446744073709551616") -+ } -+ pub fn INT32_MAX_LIMIT() -> ::dafny_runtime::DafnyInt { -+ ::dafny_runtime::int!(b"2147483648") -+ } -+ pub fn INT64_MAX_LIMIT() -> ::dafny_runtime::DafnyInt { -+ ::dafny_runtime::int!(b"9223372036854775808") -+ } -+ } -+ -+ #[derive(Clone, PartialEq)] -+ #[repr(transparent)] -+ pub struct uint8(pub u8); -+ -+ impl ::std::default::Default for uint8 { -+ fn default() -> Self { -+ uint8(::std::default::Default::default()) -+ } -+ } -+ -+ impl ::dafny_runtime::DafnyPrint for uint8 { -+ fn fmt_print( -+ &self, -+ _formatter: &mut ::std::fmt::Formatter, -+ in_seq: bool, -+ ) -> ::std::fmt::Result { -+ ::dafny_runtime::DafnyPrint::fmt_print(&self.0, _formatter, in_seq) -+ } -+ } -+ -+ impl ::std::ops::Deref for uint8 { -+ type Target = u8; -+ fn deref(&self) -> &Self::Target { -+ &self.0 -+ } -+ } -+ -+ #[derive(Clone, PartialEq)] -+ #[repr(transparent)] -+ pub struct uint16(pub u16); -+ -+ impl ::std::default::Default for uint16 { -+ fn default() -> Self { -+ uint16(::std::default::Default::default()) -+ } -+ } -+ -+ impl ::dafny_runtime::DafnyPrint for uint16 { -+ fn fmt_print( -+ &self, -+ _formatter: &mut ::std::fmt::Formatter, -+ in_seq: bool, -+ ) -> ::std::fmt::Result { -+ ::dafny_runtime::DafnyPrint::fmt_print(&self.0, _formatter, in_seq) -+ } -+ } -+ -+ impl ::std::ops::Deref for uint16 { -+ type Target = u16; -+ fn deref(&self) -> &Self::Target { -+ &self.0 -+ } -+ } -+ -+ #[derive(Clone, PartialEq)] -+ #[repr(transparent)] -+ pub struct uint32(pub u32); -+ -+ impl ::std::default::Default for uint32 { -+ fn default() -> Self { -+ uint32(::std::default::Default::default()) -+ } -+ } -+ -+ impl ::dafny_runtime::DafnyPrint for uint32 { -+ fn fmt_print( -+ &self, -+ _formatter: &mut ::std::fmt::Formatter, -+ in_seq: bool, -+ ) -> ::std::fmt::Result { -+ ::dafny_runtime::DafnyPrint::fmt_print(&self.0, _formatter, in_seq) -+ } -+ } -+ -+ impl ::std::ops::Deref for uint32 { -+ type Target = u32; -+ fn deref(&self) -> &Self::Target { -+ &self.0 -+ } -+ } -+ -+ #[derive(Clone, PartialEq)] -+ #[repr(transparent)] -+ pub struct uint64(pub u64); -+ -+ impl ::std::default::Default for uint64 { -+ fn default() -> Self { -+ uint64(::std::default::Default::default()) -+ } -+ } -+ -+ impl ::dafny_runtime::DafnyPrint for uint64 { -+ fn fmt_print( -+ &self, -+ _formatter: &mut ::std::fmt::Formatter, -+ in_seq: bool, -+ ) -> ::std::fmt::Result { -+ ::dafny_runtime::DafnyPrint::fmt_print(&self.0, _formatter, in_seq) -+ } -+ } -+ -+ impl ::std::ops::Deref for uint64 { -+ type Target = u64; -+ fn deref(&self) -> &Self::Target { -+ &self.0 -+ } -+ } -+ -+ #[derive(Clone, PartialEq)] -+ #[repr(transparent)] -+ pub struct int32(pub i32); -+ -+ impl ::std::default::Default for int32 { -+ fn default() -> Self { -+ int32(::std::default::Default::default()) -+ } -+ } -+ -+ impl ::dafny_runtime::DafnyPrint for int32 { -+ fn fmt_print( -+ &self, -+ _formatter: &mut ::std::fmt::Formatter, -+ in_seq: bool, -+ ) -> ::std::fmt::Result { -+ ::dafny_runtime::DafnyPrint::fmt_print(&self.0, _formatter, in_seq) -+ } -+ } -+ -+ impl ::std::ops::Deref for int32 { -+ type Target = i32; -+ fn deref(&self) -> &Self::Target { -+ &self.0 -+ } -+ } -+ -+ #[derive(Clone, PartialEq)] -+ #[repr(transparent)] -+ pub struct int64(pub i64); -+ -+ impl ::std::default::Default for int64 { -+ fn default() -> Self { -+ int64(::std::default::Default::default()) -+ } -+ } -+ -+ impl ::dafny_runtime::DafnyPrint for int64 { -+ fn fmt_print( -+ &self, -+ _formatter: &mut ::std::fmt::Formatter, -+ in_seq: bool, -+ ) -> ::std::fmt::Result { -+ ::dafny_runtime::DafnyPrint::fmt_print(&self.0, _formatter, in_seq) -+ } -+ } -+ -+ impl ::std::ops::Deref for int64 { -+ type Target = i64; -+ fn deref(&self) -> &Self::Target { -+ &self.0 -+ } -+ } -+ -+ #[derive(Clone, PartialEq)] -+ #[repr(transparent)] -+ pub struct posInt64(pub u64); -+ -+ impl ::std::default::Default for posInt64 { -+ fn default() -> Self { -+ posInt64(1) -+ } -+ } -+ -+ impl ::dafny_runtime::DafnyPrint for posInt64 { -+ fn fmt_print( -+ &self, -+ _formatter: &mut ::std::fmt::Formatter, -+ in_seq: bool, -+ ) -> ::std::fmt::Result { -+ ::dafny_runtime::DafnyPrint::fmt_print(&self.0, _formatter, in_seq) -+ } -+ } -+ -+ impl ::std::ops::Deref for posInt64 { -+ type Target = u64; -+ fn deref(&self) -> &Self::Target { -+ &self.0 -+ } -+ } -+ -+ pub type seq16 = ::dafny_runtime::Sequence; -+ -+ pub type seq32 = ::dafny_runtime::Sequence; -+ -+ pub type seq64 = ::dafny_runtime::Sequence; -+} -+pub mod r#_StandardLibrary_Compile { -+ pub struct _default {} -+ -+ impl _default { -+ pub fn _allocate_rcmut() -> ::dafny_runtime::Object { -+ ::dafny_runtime::allocate_rcmut::() -+ } -+ pub fn Join<_T: ::dafny_runtime::DafnyType>( -+ ss: &::dafny_runtime::Sequence<::dafny_runtime::Sequence<_T>>, -+ joiner: &::dafny_runtime::Sequence<_T>, -+ ) -> ::dafny_runtime::Sequence<_T> { -+ let mut _accumulator: ::dafny_runtime::Sequence<_T> = -+ ::dafny_runtime::seq![] as ::dafny_runtime::Sequence<_T>; -+ let mut ss = ss.clone(); -+ let mut joiner = joiner.clone(); -+ let mut _accumulator = _accumulator.clone(); -+ 'TAIL_CALL_START: loop { -+ if ss.cardinality() == ::dafny_runtime::int!(1) { -+ return _accumulator.concat(&ss.get(&::dafny_runtime::int!(0))); -+ } else { -+ _accumulator = -+ _accumulator.concat(&ss.get(&::dafny_runtime::int!(0)).concat(&joiner)); -+ let mut _in0: ::dafny_runtime::Sequence<::dafny_runtime::Sequence<_T>> = -+ ss.drop(&::dafny_runtime::int!(1)); -+ let mut _in1: ::dafny_runtime::Sequence<_T> = joiner.clone(); -+ ss = _in0.clone(); -+ joiner = _in1.clone(); -+ continue 'TAIL_CALL_START; -+ } -+ } -+ } -+ pub fn Split<_T: ::dafny_runtime::DafnyTypeEq>( -+ s: &::dafny_runtime::Sequence<_T>, -+ delim: &_T, -+ ) -> ::dafny_runtime::Sequence<::dafny_runtime::Sequence<_T>> { -+ let mut _accumulator: ::dafny_runtime::Sequence<::dafny_runtime::Sequence<_T>> = -+ ::dafny_runtime::seq![] as ::dafny_runtime::Sequence<::dafny_runtime::Sequence<_T>>; -+ let mut s = s.clone(); -+ let mut delim = delim.clone(); -+ let mut _accumulator = _accumulator.clone(); -+ 'TAIL_CALL_START: loop { -+ let mut i: ::std::rc::Rc< -+ super::r#_Wrappers_Compile::Option<::dafny_runtime::_System::nat>, -+ > = super::r#_StandardLibrary_Compile::_default::FindIndexMatching::<_T>( -+ &s, -+ &delim, -+ &::dafny_runtime::int!(0), -+ ); -+ if matches!( -+ (&i).as_ref(), -+ super::r#_Wrappers_Compile::Option::Some { .. } -+ ) { -+ _accumulator = _accumulator.concat(&::dafny_runtime::seq![s.take(i.value())]); -+ let mut _in2: ::dafny_runtime::Sequence<_T> = -+ s.drop(&(i.value().clone() + ::dafny_runtime::int!(1))); -+ let mut _in3: _T = delim.clone(); -+ s = _in2.clone(); -+ delim = _in3.clone(); -+ continue 'TAIL_CALL_START; -+ } else { -+ return _accumulator.concat(&::dafny_runtime::seq![s.clone()]); -+ } -+ } -+ } -+ pub fn SplitOnce<_T: ::dafny_runtime::DafnyTypeEq>( -+ s: &::dafny_runtime::Sequence<_T>, -+ delim: &_T, -+ ) -> (::dafny_runtime::Sequence<_T>, ::dafny_runtime::Sequence<_T>) { -+ let mut i: ::std::rc::Rc< -+ super::r#_Wrappers_Compile::Option<::dafny_runtime::_System::nat>, -+ > = super::r#_StandardLibrary_Compile::_default::FindIndexMatching::<_T>( -+ s, -+ delim, -+ &::dafny_runtime::int!(0), -+ ); -+ ( -+ s.take(i.value()), -+ s.drop(&(i.value().clone() + ::dafny_runtime::int!(1))), -+ ) -+ } -+ pub fn r#_SplitOnce_q<_T: ::dafny_runtime::DafnyTypeEq>( -+ s: &::dafny_runtime::Sequence<_T>, -+ delim: &_T, -+ ) -> ::std::rc::Rc< -+ super::r#_Wrappers_Compile::Option<( -+ ::dafny_runtime::Sequence<_T>, -+ ::dafny_runtime::Sequence<_T>, -+ )>, -+ > { -+ let mut valueOrError0: ::std::rc::Rc< -+ super::r#_Wrappers_Compile::Option<::dafny_runtime::_System::nat>, -+ > = super::r#_StandardLibrary_Compile::_default::FindIndexMatching::<_T>( -+ s, -+ delim, -+ &::dafny_runtime::int!(0), -+ ); -+ if valueOrError0.IsFailure() { -+ valueOrError0.PropagateFailure::<(::dafny_runtime::Sequence<_T>, ::dafny_runtime::Sequence<_T>)>() -+ /* Coercion from ::std::rc::Rc> to ::std::rc::Rc, ::dafny_runtime::Sequence<_T>)>> not yet implemented */ -+ } else { -+ let mut i: ::dafny_runtime::_System::nat = valueOrError0.Extract()/* Coercion from T to ::dafny_runtime::DafnyInt not yet implemented */; -+ ::std::rc::Rc::new(super::r#_Wrappers_Compile::Option::<( -+ ::dafny_runtime::Sequence<_T>, -+ ::dafny_runtime::Sequence<_T>, -+ )>::Some { -+ value: (s.take(&i), s.drop(&(i.clone() + ::dafny_runtime::int!(1)))), -+ }) -+ } -+ } -+ pub fn FindIndexMatching<_T: ::dafny_runtime::DafnyTypeEq>( -+ s: &::dafny_runtime::Sequence<_T>, -+ c: &_T, -+ i: &::dafny_runtime::_System::nat, -+ ) -> ::std::rc::Rc> -+ { -+ super::r#_StandardLibrary_Compile::_default::FindIndex::<_T>( -+ s, -+ { -+ let c: _T = c.clone(); -+ &({ -+ let mut c = c.clone(); -+ ::std::rc::Rc::new(move |x: &_T| -> bool { x.clone() == c.clone() }) -+ }) -+ }, -+ i, -+ ) -+ } -+ pub fn FindIndex<_T: ::dafny_runtime::DafnyType>( -+ s: &::dafny_runtime::Sequence<_T>, -+ f: &::std::rc::Rc bool>, -+ i: &::dafny_runtime::_System::nat, -+ ) -> ::std::rc::Rc> -+ { -+ let mut s = s.clone(); -+ let mut f = f.clone(); -+ let mut i = i.clone(); -+ 'TAIL_CALL_START: loop { -+ if i.clone() == s.cardinality() { -+ return ::std::rc::Rc::new(super::r#_Wrappers_Compile::Option::< -+ ::dafny_runtime::_System::nat, -+ >::None {}); -+ } else { -+ if (&f)(&s.get(&i)) { -+ return ::std::rc::Rc::new(super::r#_Wrappers_Compile::Option::< -+ ::dafny_runtime::_System::nat, -+ >::Some { -+ value: i.clone(), -+ }); -+ } else { -+ let mut _in4: ::dafny_runtime::Sequence<_T> = s.clone(); -+ let mut _in5: ::std::rc::Rc bool> = f.clone(); -+ let mut _in6: ::dafny_runtime::DafnyInt = -+ i.clone() + ::dafny_runtime::int!(1); -+ s = _in4.clone(); -+ f = _in5.clone(); -+ i = _in6.clone(); -+ continue 'TAIL_CALL_START; -+ } -+ } -+ } -+ } -+ pub fn Filter<_T: ::dafny_runtime::DafnyType>( -+ s: &::dafny_runtime::Sequence<_T>, -+ f: &::std::rc::Rc bool>, -+ ) -> ::dafny_runtime::Sequence<_T> { -+ let mut _accumulator: ::dafny_runtime::Sequence<_T> = -+ ::dafny_runtime::seq![] as ::dafny_runtime::Sequence<_T>; -+ let mut s = s.clone(); -+ let mut f = f.clone(); -+ let mut _accumulator = _accumulator.clone(); -+ 'TAIL_CALL_START: loop { -+ if s.cardinality() == ::dafny_runtime::int!(0) { -+ return _accumulator -+ .concat(&(::dafny_runtime::seq![] as ::dafny_runtime::Sequence<_T>)); -+ } else { -+ if (&f)(&s.get(&::dafny_runtime::int!(0))) { -+ _accumulator = _accumulator -+ .concat(&::dafny_runtime::seq![s.get(&::dafny_runtime::int!(0))]); -+ let mut _in7: ::dafny_runtime::Sequence<_T> = -+ s.drop(&::dafny_runtime::int!(1)); -+ let mut _in8: ::std::rc::Rc bool> = f.clone(); -+ s = _in7.clone(); -+ f = _in8.clone(); -+ continue 'TAIL_CALL_START; -+ } else { -+ let mut _in9: ::dafny_runtime::Sequence<_T> = -+ s.drop(&::dafny_runtime::int!(1)); -+ let mut _in10: ::std::rc::Rc bool> = f.clone(); -+ s = _in9.clone(); -+ f = _in10.clone(); -+ continue 'TAIL_CALL_START; -+ } -+ } -+ } -+ } -+ pub fn Min( -+ a: &::dafny_runtime::DafnyInt, -+ b: &::dafny_runtime::DafnyInt, -+ ) -> ::dafny_runtime::DafnyInt { -+ if a.clone() < b.clone() { -+ a.clone() -+ } else { -+ b.clone() -+ } -+ } -+ pub fn Fill<_T: ::dafny_runtime::DafnyType>( -+ value: &_T, -+ n: &::dafny_runtime::_System::nat, -+ ) -> ::dafny_runtime::Sequence<_T> { -+ { -+ let _initializer = { -+ let value: _T = value.clone(); -+ { -+ let mut value = value.clone(); -+ ::std::rc::Rc::new(move |_v0: &::dafny_runtime::DafnyInt| -> _T { -+ value.clone() -+ }) -+ } -+ }; -+ ::dafny_runtime::integer_range(::dafny_runtime::Zero::zero(), n.clone()) -+ .map(|i| _initializer(&i)) -+ .collect::<::dafny_runtime::Sequence<_>>() -+ } -+ } -+ pub fn SeqToArray<_T: ::dafny_runtime::DafnyType>( -+ s: &::dafny_runtime::Sequence<_T>, -+ ) -> ::dafny_runtime::Object<[_T]> { -+ let mut a = ::dafny_runtime::MaybePlacebo::<::dafny_runtime::Object<[_T]>>::new(); -+ let mut _init0: ::std::rc::Rc _T> = { -+ let s: ::dafny_runtime::Sequence<_T> = s.clone(); -+ { -+ let mut s = s.clone(); -+ ::std::rc::Rc::new(move |i: &::dafny_runtime::DafnyInt| -> _T { s.get(i) }) -+ } -+ }; -+ let mut _nw0: ::dafny_runtime::Object<[::std::mem::MaybeUninit<_T>]> = -+ ::dafny_runtime::array::placebos_usize_rcmut::<_T>(s.cardinality().as_usize()); -+ for r#__i0_0 in -+ ::dafny_runtime::integer_range(0, ::dafny_runtime::rd!(_nw0.clone()).len()) -+ { -+ { -+ let __idx0 = -+ ::from(r#__i0_0.clone()).unwrap(); -+ ::dafny_runtime::md!(_nw0.clone())[__idx0] = ::std::mem::MaybeUninit::new( -+ (&_init0)(&::dafny_runtime::int!(r#__i0_0.clone())), -+ ); -+ } -+ } -+ a = ::dafny_runtime::MaybePlacebo::from(::dafny_runtime::array::construct_rcmut( -+ _nw0.clone(), -+ )); -+ return a.read(); -+ } -+ pub fn LexicographicLessOrEqual<_T: ::dafny_runtime::DafnyTypeEq>( -+ a: &::dafny_runtime::Sequence<_T>, -+ b: &::dafny_runtime::Sequence<_T>, -+ less: &::std::rc::Rc bool>, -+ ) -> bool { -+ ::dafny_runtime::integer_range(::dafny_runtime::int!(0), a.cardinality() + ::dafny_runtime::int!(1)).any(({ -+ let mut a = a.clone(); -+ let mut b = b.clone(); -+ let mut less = less.clone(); -+ ::std::rc::Rc::new(move |r#__exists_var_0: ::dafny_runtime::DafnyInt| -> bool { -+ let mut k: ::dafny_runtime::DafnyInt = r#__exists_var_0.clone(); -+ ::dafny_runtime::int!(0) <= k.clone() && k.clone() <= a.cardinality() && super::r#_StandardLibrary_Compile::_default::LexicographicLessOrEqualAux::<_T>(&a, &b, &less, &k) -+ }) -+ }).as_ref()) -+ } -+ pub fn LexicographicLessOrEqualAux<_T: ::dafny_runtime::DafnyTypeEq>( -+ a: &::dafny_runtime::Sequence<_T>, -+ b: &::dafny_runtime::Sequence<_T>, -+ less: &::std::rc::Rc bool>, -+ lengthOfCommonPrefix: &::dafny_runtime::_System::nat, -+ ) -> bool { -+ lengthOfCommonPrefix.clone() <= b.cardinality() -+ && ::dafny_runtime::integer_range( -+ ::dafny_runtime::int!(0), -+ lengthOfCommonPrefix.clone(), -+ ) -+ .all( -+ ({ -+ let mut lengthOfCommonPrefix = lengthOfCommonPrefix.clone(); -+ let mut a = a.clone(); -+ let mut b = b.clone(); -+ ::std::rc::Rc::new( -+ move |r#__forall_var_0: ::dafny_runtime::DafnyInt| -> bool { -+ let mut i: ::dafny_runtime::DafnyInt = r#__forall_var_0.clone(); -+ !(::dafny_runtime::int!(0) <= i.clone() -+ && i.clone() < lengthOfCommonPrefix.clone()) -+ || a.get(&i) == b.get(&i) -+ }, -+ ) -+ }) -+ .as_ref(), -+ ) -+ && (lengthOfCommonPrefix.clone() == a.cardinality() -+ || lengthOfCommonPrefix.clone() < b.cardinality() -+ && less(&a.get(lengthOfCommonPrefix), &b.get(lengthOfCommonPrefix))) -+ } -+ pub fn SetToOrderedSequence<_T: ::dafny_runtime::DafnyTypeEq>( -+ s: &::dafny_runtime::Set<::dafny_runtime::Sequence<_T>>, -+ less: &::std::rc::Rc bool>, -+ ) -> ::dafny_runtime::Sequence<::dafny_runtime::Sequence<_T>> { -+ let mut _accumulator: ::dafny_runtime::Sequence<::dafny_runtime::Sequence<_T>> = -+ ::dafny_runtime::seq![] as ::dafny_runtime::Sequence<::dafny_runtime::Sequence<_T>>; -+ let mut s = s.clone(); -+ let mut less = less.clone(); -+ let mut _accumulator = _accumulator.clone(); -+ 'TAIL_CALL_START: loop { -+ if s.clone() == ::dafny_runtime::set! {} { -+ return _accumulator.concat( -+ &(::dafny_runtime::seq![] -+ as ::dafny_runtime::Sequence<::dafny_runtime::Sequence<_T>>), -+ ); -+ } else { -+ return (&({ -+ let mut s = s.clone(); -+ let mut less = less.clone(); -+ ::std::rc::Rc::new(move |r#__let_dummy_0: &::dafny_runtime::DafnyInt| -> ::dafny_runtime::Sequence<::dafny_runtime::Sequence<_T>> { -+ let mut a = ::dafny_runtime::MaybePlacebo::<::dafny_runtime::Sequence<_T>>::new(); -+ 'label_goto__ASSIGN_SUCH_THAT_0: loop { -+ for r#__assign_such_that_0 in (&s).iter().cloned() { -+ a = ::dafny_runtime::MaybePlacebo::from(r#__assign_such_that_0.clone()); -+ if s.contains(&a.read()) && super::r#_StandardLibrary_Compile::_default::IsMinimum::<_T>(&a.read(), &s, &less) { -+ break 'label_goto__ASSIGN_SUCH_THAT_0; -+ } -+ } -+ panic!("Halt"); -+ break; -+ }; -+ ::dafny_runtime::seq![a.read()].concat(&super::r#_StandardLibrary_Compile::_default::SetToOrderedSequence::<_T>(&s.subtract(&::dafny_runtime::set!{a.read()}), &less)) -+ }) -+ }))(&::dafny_runtime::int!(0)); -+ } -+ } -+ } -+ pub fn IsMinimum<_T: ::dafny_runtime::DafnyTypeEq>( -+ a: &::dafny_runtime::Sequence<_T>, -+ s: &::dafny_runtime::Set<::dafny_runtime::Sequence<_T>>, -+ less: &::std::rc::Rc bool>, -+ ) -> bool { -+ s.contains(a) && s.iter().cloned().all(({ -+ let mut a = a.clone(); -+ let mut s = s.clone(); -+ let mut less = less.clone(); -+ ::std::rc::Rc::new(move |r#__forall_var_1: ::dafny_runtime::Sequence<_T>| -> bool { -+ let mut z: ::dafny_runtime::Sequence<_T> = r#__forall_var_1.clone(); -+ !s.contains(&z) || super::r#_StandardLibrary_Compile::_default::LexicographicLessOrEqual::<_T>(&a, &z, &less) -+ }) -+ }).as_ref()) -+ } -+ } -+} -+pub mod UTF8 { -+ pub struct _default {} -+ -+ impl _default { -+ pub fn _allocate_rcmut() -> ::dafny_runtime::Object { -+ ::dafny_runtime::allocate_rcmut::() -+ } -+ pub fn CreateEncodeSuccess( -+ bytes: &super::UTF8::ValidUTF8Bytes, -+ ) -> ::std::rc::Rc< -+ super::r#_Wrappers_Compile::Result< -+ super::UTF8::ValidUTF8Bytes, -+ ::dafny_runtime::Sequence<::dafny_runtime::DafnyCharUTF16>, -+ >, -+ > { -+ ::std::rc::Rc::new(super::r#_Wrappers_Compile::Result::< -+ super::UTF8::ValidUTF8Bytes, -+ ::dafny_runtime::Sequence<::dafny_runtime::DafnyCharUTF16>, -+ >::Success { -+ value: bytes.clone(), -+ }) -+ } -+ pub fn CreateEncodeFailure( -+ error: &::dafny_runtime::Sequence<::dafny_runtime::DafnyCharUTF16>, -+ ) -> ::std::rc::Rc< -+ super::r#_Wrappers_Compile::Result< -+ super::UTF8::ValidUTF8Bytes, -+ ::dafny_runtime::Sequence<::dafny_runtime::DafnyCharUTF16>, -+ >, -+ > { -+ ::std::rc::Rc::new(super::r#_Wrappers_Compile::Result::< -+ super::UTF8::ValidUTF8Bytes, -+ ::dafny_runtime::Sequence<::dafny_runtime::DafnyCharUTF16>, -+ >::Failure { -+ error: error.clone(), -+ }) -+ } -+ pub fn CreateDecodeSuccess( -+ s: &::dafny_runtime::Sequence<::dafny_runtime::DafnyCharUTF16>, -+ ) -> ::std::rc::Rc< -+ super::r#_Wrappers_Compile::Result< -+ ::dafny_runtime::Sequence<::dafny_runtime::DafnyCharUTF16>, -+ ::dafny_runtime::Sequence<::dafny_runtime::DafnyCharUTF16>, -+ >, -+ > { -+ ::std::rc::Rc::new(super::r#_Wrappers_Compile::Result::< -+ ::dafny_runtime::Sequence<::dafny_runtime::DafnyCharUTF16>, -+ ::dafny_runtime::Sequence<::dafny_runtime::DafnyCharUTF16>, -+ >::Success { -+ value: s.clone(), -+ }) -+ } -+ pub fn CreateDecodeFailure( -+ error: &::dafny_runtime::Sequence<::dafny_runtime::DafnyCharUTF16>, -+ ) -> ::std::rc::Rc< -+ super::r#_Wrappers_Compile::Result< -+ ::dafny_runtime::Sequence<::dafny_runtime::DafnyCharUTF16>, -+ ::dafny_runtime::Sequence<::dafny_runtime::DafnyCharUTF16>, -+ >, -+ > { -+ ::std::rc::Rc::new(super::r#_Wrappers_Compile::Result::< -+ ::dafny_runtime::Sequence<::dafny_runtime::DafnyCharUTF16>, -+ ::dafny_runtime::Sequence<::dafny_runtime::DafnyCharUTF16>, -+ >::Failure { -+ error: error.clone(), -+ }) -+ } -+ pub fn IsASCIIString( -+ s: &::dafny_runtime::Sequence<::dafny_runtime::DafnyCharUTF16>, -+ ) -> bool { -+ let mut _hresult: bool = ::default(); -+ let mut _hi0: ::dafny_runtime::DafnyInt = s.cardinality(); -+ for i in ::dafny_runtime::integer_range(::dafny_runtime::int!(0), _hi0.clone()) { -+ if !(::dafny_runtime::int!(s.get(&i).0) < ::dafny_runtime::int!(128)) { -+ _hresult = false; -+ return _hresult; -+ } -+ } -+ _hresult = true; -+ return _hresult; -+ return _hresult; -+ } -+ pub fn EncodeAscii( -+ s: &::dafny_runtime::Sequence<::dafny_runtime::DafnyCharUTF16>, -+ ) -> super::UTF8::ValidUTF8Bytes { -+ let mut _accumulator: super::UTF8::ValidUTF8Bytes = -+ ::dafny_runtime::seq![] as ::dafny_runtime::Sequence; -+ let mut s = s.clone(); -+ let mut _accumulator = _accumulator.clone(); -+ 'TAIL_CALL_START: loop { -+ if s.cardinality() == ::dafny_runtime::int!(0) { -+ return _accumulator -+ .concat(&(::dafny_runtime::seq![] as ::dafny_runtime::Sequence)); -+ } else { -+ let mut x: ::dafny_runtime::Sequence = -+ ::dafny_runtime::seq![s.get(&::dafny_runtime::int!(0)).0 as u8]; -+ _accumulator = _accumulator.concat(&x); -+ let mut _in11: ::dafny_runtime::Sequence<::dafny_runtime::DafnyCharUTF16> = -+ s.drop(&::dafny_runtime::int!(1)); -+ s = _in11.clone(); -+ continue 'TAIL_CALL_START; -+ } -+ } -+ } -+ pub fn Uses1Byte(s: &::dafny_runtime::Sequence) -> bool { -+ 0 <= s.get(&::dafny_runtime::int!(0)) && s.get(&::dafny_runtime::int!(0)) <= 127 -+ } -+ pub fn Uses2Bytes(s: &::dafny_runtime::Sequence) -> bool { -+ 194 <= s.get(&::dafny_runtime::int!(0)) -+ && s.get(&::dafny_runtime::int!(0)) <= 223 -+ && (128 <= s.get(&::dafny_runtime::int!(1)) -+ && s.get(&::dafny_runtime::int!(1)) <= 191) -+ } -+ pub fn Uses3Bytes(s: &::dafny_runtime::Sequence) -> bool { -+ s.get(&::dafny_runtime::int!(0)) == 224 -+ && (160 <= s.get(&::dafny_runtime::int!(1)) -+ && s.get(&::dafny_runtime::int!(1)) <= 191) -+ && (128 <= s.get(&::dafny_runtime::int!(2)) -+ && s.get(&::dafny_runtime::int!(2)) <= 191) -+ || 225 <= s.get(&::dafny_runtime::int!(0)) -+ && s.get(&::dafny_runtime::int!(0)) <= 236 -+ && (128 <= s.get(&::dafny_runtime::int!(1)) -+ && s.get(&::dafny_runtime::int!(1)) <= 191) -+ && (128 <= s.get(&::dafny_runtime::int!(2)) -+ && s.get(&::dafny_runtime::int!(2)) <= 191) -+ || s.get(&::dafny_runtime::int!(0)) == 237 -+ && (128 <= s.get(&::dafny_runtime::int!(1)) -+ && s.get(&::dafny_runtime::int!(1)) <= 159) -+ && (128 <= s.get(&::dafny_runtime::int!(2)) -+ && s.get(&::dafny_runtime::int!(2)) <= 191) -+ || 238 <= s.get(&::dafny_runtime::int!(0)) -+ && s.get(&::dafny_runtime::int!(0)) <= 239 -+ && (128 <= s.get(&::dafny_runtime::int!(1)) -+ && s.get(&::dafny_runtime::int!(1)) <= 191) -+ && (128 <= s.get(&::dafny_runtime::int!(2)) -+ && s.get(&::dafny_runtime::int!(2)) <= 191) -+ } -+ pub fn Uses4Bytes(s: &::dafny_runtime::Sequence) -> bool { -+ s.get(&::dafny_runtime::int!(0)) == 240 -+ && (144 <= s.get(&::dafny_runtime::int!(1)) -+ && s.get(&::dafny_runtime::int!(1)) <= 191) -+ && (128 <= s.get(&::dafny_runtime::int!(2)) -+ && s.get(&::dafny_runtime::int!(2)) <= 191) -+ && (128 <= s.get(&::dafny_runtime::int!(3)) -+ && s.get(&::dafny_runtime::int!(3)) <= 191) -+ || 241 <= s.get(&::dafny_runtime::int!(0)) -+ && s.get(&::dafny_runtime::int!(0)) <= 243 -+ && (128 <= s.get(&::dafny_runtime::int!(1)) -+ && s.get(&::dafny_runtime::int!(1)) <= 191) -+ && (128 <= s.get(&::dafny_runtime::int!(2)) -+ && s.get(&::dafny_runtime::int!(2)) <= 191) -+ && (128 <= s.get(&::dafny_runtime::int!(3)) -+ && s.get(&::dafny_runtime::int!(3)) <= 191) -+ || s.get(&::dafny_runtime::int!(0)) == 244 -+ && (128 <= s.get(&::dafny_runtime::int!(1)) -+ && s.get(&::dafny_runtime::int!(1)) <= 143) -+ && (128 <= s.get(&::dafny_runtime::int!(2)) -+ && s.get(&::dafny_runtime::int!(2)) <= 191) -+ && (128 <= s.get(&::dafny_runtime::int!(3)) -+ && s.get(&::dafny_runtime::int!(3)) <= 191) -+ } -+ pub fn ValidUTF8Range( -+ a: &::dafny_runtime::Sequence, -+ lo: &::dafny_runtime::_System::nat, -+ hi: &::dafny_runtime::_System::nat, -+ ) -> bool { -+ let mut a = a.clone(); -+ let mut lo = lo.clone(); -+ let mut hi = hi.clone(); -+ 'TAIL_CALL_START: loop { -+ if lo.clone() == hi.clone() { -+ return true; -+ } else { -+ let mut r: ::dafny_runtime::Sequence = a.slice(&lo, &hi); -+ if super::UTF8::_default::Uses1Byte(&r) { -+ let mut _in12: ::dafny_runtime::Sequence = a.clone(); -+ let mut _in13: ::dafny_runtime::DafnyInt = -+ lo.clone() + ::dafny_runtime::int!(1); -+ let mut _in14: ::dafny_runtime::_System::nat = hi.clone(); -+ a = _in12.clone(); -+ lo = _in13.clone(); -+ hi = _in14.clone(); -+ continue 'TAIL_CALL_START; -+ } else { -+ if ::dafny_runtime::int!(2) <= r.cardinality() -+ && super::UTF8::_default::Uses2Bytes(&r) -+ { -+ let mut _in15: ::dafny_runtime::Sequence = a.clone(); -+ let mut _in16: ::dafny_runtime::DafnyInt = -+ lo.clone() + ::dafny_runtime::int!(2); -+ let mut _in17: ::dafny_runtime::_System::nat = hi.clone(); -+ a = _in15.clone(); -+ lo = _in16.clone(); -+ hi = _in17.clone(); -+ continue 'TAIL_CALL_START; -+ } else { -+ if ::dafny_runtime::int!(3) <= r.cardinality() -+ && super::UTF8::_default::Uses3Bytes(&r) -+ { -+ let mut _in18: ::dafny_runtime::Sequence = a.clone(); -+ let mut _in19: ::dafny_runtime::DafnyInt = -+ lo.clone() + ::dafny_runtime::int!(3); -+ let mut _in20: ::dafny_runtime::_System::nat = hi.clone(); -+ a = _in18.clone(); -+ lo = _in19.clone(); -+ hi = _in20.clone(); -+ continue 'TAIL_CALL_START; -+ } else { -+ if ::dafny_runtime::int!(4) <= r.cardinality() -+ && super::UTF8::_default::Uses4Bytes(&r) -+ { -+ let mut _in21: ::dafny_runtime::Sequence = a.clone(); -+ let mut _in22: ::dafny_runtime::DafnyInt = -+ lo.clone() + ::dafny_runtime::int!(4); -+ let mut _in23: ::dafny_runtime::_System::nat = hi.clone(); -+ a = _in21.clone(); -+ lo = _in22.clone(); -+ hi = _in23.clone(); -+ continue 'TAIL_CALL_START; -+ } else { -+ return false; -+ } -+ } -+ } -+ } -+ } -+ } -+ } -+ pub fn ValidUTF8Seq(s: &::dafny_runtime::Sequence) -> bool { -+ super::UTF8::_default::ValidUTF8Range(s, &::dafny_runtime::int!(0), &s.cardinality()) -+ } -+ } -+ -+ pub type ValidUTF8Bytes = ::dafny_runtime::Sequence; -+ -+ pub fn r#__init_ValidUTF8Bytes() -> ::dafny_runtime::Sequence { -+ ::dafny_runtime::seq![] as ::dafny_runtime::Sequence -+ } -+} -+pub mod r#_StandardLibraryInterop_Compile { -+ pub struct WrappersInterop {} -+ -+ impl WrappersInterop { -+ pub fn _allocate_rcmut() -> ::dafny_runtime::Object { -+ ::dafny_runtime::allocate_rcmut::() -+ } -+ pub fn CreateStringSome( -+ s: &::dafny_runtime::Sequence<::dafny_runtime::DafnyCharUTF16>, -+ ) -> ::std::rc::Rc< -+ super::r#_Wrappers_Compile::Option< -+ ::dafny_runtime::Sequence<::dafny_runtime::DafnyCharUTF16>, -+ >, -+ > { -+ ::std::rc::Rc::new(super::r#_Wrappers_Compile::Option::< -+ ::dafny_runtime::Sequence<::dafny_runtime::DafnyCharUTF16>, -+ >::Some { -+ value: s.clone(), -+ }) -+ } -+ pub fn CreateStringNone() -> ::std::rc::Rc< -+ super::r#_Wrappers_Compile::Option< -+ ::dafny_runtime::Sequence<::dafny_runtime::DafnyCharUTF16>, -+ >, -+ > { -+ ::std::rc::Rc::new(super::r#_Wrappers_Compile::Option::< -+ ::dafny_runtime::Sequence<::dafny_runtime::DafnyCharUTF16>, -+ >::None {}) -+ } -+ pub fn CreateBooleanSome( -+ b: bool, -+ ) -> ::std::rc::Rc> { -+ ::std::rc::Rc::new(super::r#_Wrappers_Compile::Option::::Some { value: b }) -+ } -+ pub fn CreateBooleanNone() -> ::std::rc::Rc> { -+ ::std::rc::Rc::new(super::r#_Wrappers_Compile::Option::::None {}) -+ } -+ } -+} -+pub mod _module {} diff --git b/TestModels/dafny-dependencies/StandardLibrary/runtimes/rust/src/lib.rs a/TestModels/dafny-dependencies/StandardLibrary/runtimes/rust/src/lib.rs new file mode 100644 index 00000000..4b9fb6f8 diff --git a/TestModels/dafny-dependencies/StandardLibrary/runtimes/rust/src/implementation_from_dafny.rs b/TestModels/dafny-dependencies/StandardLibrary/runtimes/rust/src/implementation_from_dafny.rs deleted file mode 100644 index 20cb9f072c..0000000000 --- a/TestModels/dafny-dependencies/StandardLibrary/runtimes/rust/src/implementation_from_dafny.rs +++ /dev/null @@ -1,1340 +0,0 @@ -#![allow(warnings, unconditional_panic)] -#![allow(nonstandard_style)] -pub mod r#_Wrappers_Compile { - pub struct _default {} - - impl _default { - pub fn _allocate_rcmut() -> ::dafny_runtime::Object { - ::dafny_runtime::allocate_rcmut::() - } - pub fn Need<_E: ::dafny_runtime::DafnyType>( - condition: bool, - error: &_E, - ) -> ::std::rc::Rc> { - if condition { - ::std::rc::Rc::new(super::r#_Wrappers_Compile::Outcome::<_E>::Pass {}) - } else { - ::std::rc::Rc::new(super::r#_Wrappers_Compile::Outcome::<_E>::Fail { - error: error.clone(), - }) - } - } - } - - #[derive(PartialEq, Clone)] - pub enum Option { - None {}, - Some { value: T }, - _PhantomVariant(::std::marker::PhantomData), - } - - impl Option { - pub fn ToResult( - self: &::std::rc::Rc, - ) -> ::std::rc::Rc< - super::r#_Wrappers_Compile::Result< - T, - ::dafny_runtime::Sequence<::dafny_runtime::DafnyCharUTF16>, - >, - > { - let mut _source0: ::std::rc::Rc> = self.clone(); - if matches!( - (&_source0).as_ref(), - super::r#_Wrappers_Compile::Option::None { .. } - ) { - ::std::rc::Rc::new(super::r#_Wrappers_Compile::Result::< - T, - ::dafny_runtime::Sequence<::dafny_runtime::DafnyCharUTF16>, - >::Failure { - error: ::dafny_runtime::string_utf16_of("Option is None"), - }) - } else { - let mut r#___mcc_h0: T = _source0.value().clone(); - let mut v: T = r#___mcc_h0.clone(); - ::std::rc::Rc::new(super::r#_Wrappers_Compile::Result::< - T, - ::dafny_runtime::Sequence<::dafny_runtime::DafnyCharUTF16>, - >::Success { - value: v.clone(), - }) - } - } - pub fn UnwrapOr(self: &::std::rc::Rc, default: &T) -> T { - let mut _source1: ::std::rc::Rc> = self.clone(); - if matches!( - (&_source1).as_ref(), - super::r#_Wrappers_Compile::Option::None { .. } - ) { - default.clone() - } else { - let mut r#___mcc_h0: T = _source1.value().clone(); - let mut v: T = r#___mcc_h0.clone(); - v.clone() - } - } - pub fn IsFailure(self: &::std::rc::Rc) -> bool { - matches!( - self.as_ref(), - super::r#_Wrappers_Compile::Option::None { .. } - ) - } - pub fn PropagateFailure<_U: ::dafny_runtime::DafnyType>( - self: &::std::rc::Rc, - ) -> ::std::rc::Rc> { - ::std::rc::Rc::new(super::r#_Wrappers_Compile::Option::<_U>::None {}) - } - pub fn Extract(self: &::std::rc::Rc) -> T { - self.value().clone() - } - pub fn value(&self) -> &T { - match self { - Option::None {} => panic!("field does not exist on this variant"), - Option::Some { value } => value, - Option::_PhantomVariant(..) => panic!(), - } - } - } - - impl ::std::fmt::Debug for Option { - fn fmt(&self, f: &mut ::std::fmt::Formatter) -> std::fmt::Result { - ::dafny_runtime::DafnyPrint::fmt_print(self, f, true) - } - } - - impl ::dafny_runtime::DafnyPrint for Option { - fn fmt_print( - &self, - _formatter: &mut ::std::fmt::Formatter, - _in_seq: bool, - ) -> std::fmt::Result { - match self { - Option::None {} => { - write!(_formatter, "r#_Wrappers_Compile.Option.None")?; - Ok(()) - } - Option::Some { value } => { - write!(_formatter, "r#_Wrappers_Compile.Option.Some(")?; - ::dafny_runtime::DafnyPrint::fmt_print(value, _formatter, false)?; - write!(_formatter, ")")?; - Ok(()) - } - Option::_PhantomVariant(..) => { - panic!() - } - } - } - } - - impl Eq for Option {} - - impl ::std::hash::Hash for Option { - fn hash<_H: ::std::hash::Hasher>(&self, _state: &mut _H) { - match self { - Option::None {} => {} - Option::Some { value } => value.hash(_state), - Option::_PhantomVariant(..) => { - panic!() - } - } - } - } - - impl ::std::default::Default - for Option - { - fn default() -> Option { - Option::None {} - } - } - - impl ::std::convert::AsRef> for &Option { - fn as_ref(&self) -> Self { - self - } - } - - #[derive(PartialEq, Clone)] - pub enum Result { - Success { value: T }, - Failure { error: R }, - _PhantomVariant(::std::marker::PhantomData, ::std::marker::PhantomData), - } - - impl Result { - pub fn ToOption( - self: &::std::rc::Rc, - ) -> ::std::rc::Rc> { - let mut _source2: ::std::rc::Rc> = - self.clone(); - if matches!( - (&_source2).as_ref(), - super::r#_Wrappers_Compile::Result::Success { .. } - ) { - let mut r#___mcc_h0: T = _source2.value().clone(); - let mut s: T = r#___mcc_h0.clone(); - ::std::rc::Rc::new(super::r#_Wrappers_Compile::Option::::Some { - value: s.clone(), - }) - } else { - let mut r#___mcc_h1: R = _source2.error().clone(); - let mut e: R = r#___mcc_h1.clone(); - ::std::rc::Rc::new(super::r#_Wrappers_Compile::Option::::None {}) - } - } - pub fn UnwrapOr(self: &::std::rc::Rc, default: &T) -> T { - let mut _source3: ::std::rc::Rc> = - self.clone(); - if matches!( - (&_source3).as_ref(), - super::r#_Wrappers_Compile::Result::Success { .. } - ) { - let mut r#___mcc_h0: T = _source3.value().clone(); - let mut s: T = r#___mcc_h0.clone(); - s.clone() - } else { - let mut r#___mcc_h1: R = _source3.error().clone(); - let mut e: R = r#___mcc_h1.clone(); - default.clone() - } - } - pub fn IsFailure(self: &::std::rc::Rc) -> bool { - matches!( - self.as_ref(), - super::r#_Wrappers_Compile::Result::Failure { .. } - ) - } - pub fn PropagateFailure<_U: ::dafny_runtime::DafnyType>( - self: &::std::rc::Rc, - ) -> ::std::rc::Rc> { - ::std::rc::Rc::new(super::r#_Wrappers_Compile::Result::<_U, R>::Failure { - error: self.error().clone(), - }) - } - pub fn MapFailure<_NewR: ::dafny_runtime::DafnyType>( - self: &::std::rc::Rc, - reWrap: &::std::rc::Rc _NewR>, - ) -> ::std::rc::Rc> { - let mut _source4: ::std::rc::Rc> = - self.clone(); - if matches!( - (&_source4).as_ref(), - super::r#_Wrappers_Compile::Result::Success { .. } - ) { - let mut r#___mcc_h0: T = _source4.value().clone(); - let mut s: T = r#___mcc_h0.clone(); - ::std::rc::Rc::new(super::r#_Wrappers_Compile::Result::::Success { - value: s.clone(), - }) - } else { - let mut r#___mcc_h1: R = _source4.error().clone(); - let mut e: R = r#___mcc_h1.clone(); - ::std::rc::Rc::new(super::r#_Wrappers_Compile::Result::::Failure { - error: reWrap(&e), - }) - } - } - pub fn Extract(self: &::std::rc::Rc) -> T { - self.value().clone() - } - pub fn value(&self) -> &T { - match self { - Result::Success { value } => value, - Result::Failure { error } => panic!("field does not exist on this variant"), - Result::_PhantomVariant(..) => panic!(), - } - } - pub fn error(&self) -> &R { - match self { - Result::Success { value } => panic!("field does not exist on this variant"), - Result::Failure { error } => error, - Result::_PhantomVariant(..) => panic!(), - } - } - } - - impl ::std::fmt::Debug - for Result - { - fn fmt(&self, f: &mut ::std::fmt::Formatter) -> std::fmt::Result { - ::dafny_runtime::DafnyPrint::fmt_print(self, f, true) - } - } - - impl ::dafny_runtime::DafnyPrint - for Result - { - fn fmt_print( - &self, - _formatter: &mut ::std::fmt::Formatter, - _in_seq: bool, - ) -> std::fmt::Result { - match self { - Result::Success { value } => { - write!(_formatter, "r#_Wrappers_Compile.Result.Success(")?; - ::dafny_runtime::DafnyPrint::fmt_print(value, _formatter, false)?; - write!(_formatter, ")")?; - Ok(()) - } - Result::Failure { error } => { - write!(_formatter, "r#_Wrappers_Compile.Result.Failure(")?; - ::dafny_runtime::DafnyPrint::fmt_print(error, _formatter, false)?; - write!(_formatter, ")")?; - Ok(()) - } - Result::_PhantomVariant(..) => { - panic!() - } - } - } - } - - impl Eq for Result {} - - impl< - T: ::dafny_runtime::DafnyType + ::std::hash::Hash, - R: ::dafny_runtime::DafnyType + ::std::hash::Hash, - > ::std::hash::Hash for Result - { - fn hash<_H: ::std::hash::Hasher>(&self, _state: &mut _H) { - match self { - Result::Success { value } => value.hash(_state), - Result::Failure { error } => error.hash(_state), - Result::_PhantomVariant(..) => { - panic!() - } - } - } - } - - impl< - T: ::dafny_runtime::DafnyType + ::std::default::Default, - R: ::dafny_runtime::DafnyType + ::std::default::Default, - > ::std::default::Default for Result - { - fn default() -> Result { - Result::Success { - value: ::std::default::Default::default(), - } - } - } - - impl - ::std::convert::AsRef> for &Result - { - fn as_ref(&self) -> Self { - self - } - } - - #[derive(PartialEq, Clone)] - pub enum Outcome { - Pass {}, - Fail { error: E }, - _PhantomVariant(::std::marker::PhantomData), - } - - impl Outcome { - pub fn IsFailure(self: &::std::rc::Rc) -> bool { - matches!( - self.as_ref(), - super::r#_Wrappers_Compile::Outcome::Fail { .. } - ) - } - pub fn PropagateFailure<_U: ::dafny_runtime::DafnyType>( - self: &::std::rc::Rc, - ) -> ::std::rc::Rc> { - ::std::rc::Rc::new(super::r#_Wrappers_Compile::Result::<_U, E>::Failure { - error: self.error().clone(), - }) - } - pub fn error(&self) -> &E { - match self { - Outcome::Pass {} => panic!("field does not exist on this variant"), - Outcome::Fail { error } => error, - Outcome::_PhantomVariant(..) => panic!(), - } - } - } - - impl ::std::fmt::Debug for Outcome { - fn fmt(&self, f: &mut ::std::fmt::Formatter) -> std::fmt::Result { - ::dafny_runtime::DafnyPrint::fmt_print(self, f, true) - } - } - - impl ::dafny_runtime::DafnyPrint for Outcome { - fn fmt_print( - &self, - _formatter: &mut ::std::fmt::Formatter, - _in_seq: bool, - ) -> std::fmt::Result { - match self { - Outcome::Pass {} => { - write!(_formatter, "r#_Wrappers_Compile.Outcome.Pass")?; - Ok(()) - } - Outcome::Fail { error } => { - write!(_formatter, "r#_Wrappers_Compile.Outcome.Fail(")?; - ::dafny_runtime::DafnyPrint::fmt_print(error, _formatter, false)?; - write!(_formatter, ")")?; - Ok(()) - } - Outcome::_PhantomVariant(..) => { - panic!() - } - } - } - } - - impl Eq for Outcome {} - - impl ::std::hash::Hash for Outcome { - fn hash<_H: ::std::hash::Hasher>(&self, _state: &mut _H) { - match self { - Outcome::Pass {} => {} - Outcome::Fail { error } => error.hash(_state), - Outcome::_PhantomVariant(..) => { - panic!() - } - } - } - } - - impl ::std::default::Default - for Outcome - { - fn default() -> Outcome { - Outcome::Pass {} - } - } - - impl ::std::convert::AsRef> for &Outcome { - fn as_ref(&self) -> Self { - self - } - } -} -pub mod r#_StandardLibrary_Compile_dUInt_Compile { - pub struct _default {} - - impl _default { - pub fn _allocate_rcmut() -> ::dafny_runtime::Object { - ::dafny_runtime::allocate_rcmut::() - } - pub fn UInt8Less(a: u8, b: u8) -> bool { - a < b - } - pub fn HasUint16Len<_T: ::dafny_runtime::DafnyType>( - s: &::dafny_runtime::Sequence<_T>, - ) -> bool { - s.cardinality() - < super::r#_StandardLibrary_Compile_dUInt_Compile::_default::UINT16_LIMIT() - } - pub fn HasUint32Len<_T: ::dafny_runtime::DafnyType>( - s: &::dafny_runtime::Sequence<_T>, - ) -> bool { - s.cardinality() - < super::r#_StandardLibrary_Compile_dUInt_Compile::_default::UINT32_LIMIT() - } - pub fn HasUint64Len<_T: ::dafny_runtime::DafnyType>( - s: &::dafny_runtime::Sequence<_T>, - ) -> bool { - s.cardinality() - < super::r#_StandardLibrary_Compile_dUInt_Compile::_default::UINT64_LIMIT() - } - pub fn UInt16ToSeq(x: u16) -> ::dafny_runtime::Sequence { - let mut b0: u8 = (x / 256) as u8; - let mut b1: u8 = (x % 256) as u8; - ::dafny_runtime::seq![b0, b1] - } - pub fn SeqToUInt16(s: &::dafny_runtime::Sequence) -> u16 { - let mut x0: u16 = s.get(&::dafny_runtime::int!(0)) as u16 * 256; - x0 + s.get(&::dafny_runtime::int!(1)) as u16 - } - pub fn UInt32ToSeq(x: u32) -> ::dafny_runtime::Sequence { - let mut b0: u8 = (x / 16777216) as u8; - let mut x0: u32 = x - b0 as u32 * 16777216; - let mut b1: u8 = (x0 / 65536) as u8; - let mut x1: u32 = x0 - b1 as u32 * 65536; - let mut b2: u8 = (x1 / 256) as u8; - let mut b3: u8 = (x1 % 256) as u8; - ::dafny_runtime::seq![b0, b1, b2, b3] - } - pub fn SeqToUInt32(s: &::dafny_runtime::Sequence) -> u32 { - let mut x0: u32 = s.get(&::dafny_runtime::int!(0)) as u32 * 16777216; - let mut x1: u32 = x0 + s.get(&::dafny_runtime::int!(1)) as u32 * 65536; - let mut x2: u32 = x1 + s.get(&::dafny_runtime::int!(2)) as u32 * 256; - x2 + s.get(&::dafny_runtime::int!(3)) as u32 - } - pub fn UInt64ToSeq(x: u64) -> ::dafny_runtime::Sequence { - let mut b0: u8 = (x / 72057594037927936) as u8; - let mut x0: u64 = x - b0 as u64 * 72057594037927936; - let mut b1: u8 = (x0 / 281474976710656) as u8; - let mut x1: u64 = x0 - b1 as u64 * 281474976710656; - let mut b2: u8 = (x1 / 1099511627776) as u8; - let mut x2: u64 = x1 - b2 as u64 * 1099511627776; - let mut b3: u8 = (x2 / 4294967296) as u8; - let mut x3: u64 = x2 - b3 as u64 * 4294967296; - let mut b4: u8 = (x3 / 16777216) as u8; - let mut x4: u64 = x3 - b4 as u64 * 16777216; - let mut b5: u8 = (x4 / 65536) as u8; - let mut x5: u64 = x4 - b5 as u64 * 65536; - let mut b6: u8 = (x5 / 256) as u8; - let mut b7: u8 = (x5 % 256) as u8; - ::dafny_runtime::seq![b0, b1, b2, b3, b4, b5, b6, b7] - } - pub fn SeqToUInt64(s: &::dafny_runtime::Sequence) -> u64 { - let mut x0: u64 = s.get(&::dafny_runtime::int!(0)) as u64 * 72057594037927936; - let mut x1: u64 = x0 + s.get(&::dafny_runtime::int!(1)) as u64 * 281474976710656; - let mut x2: u64 = x1 + s.get(&::dafny_runtime::int!(2)) as u64 * 1099511627776; - let mut x3: u64 = x2 + s.get(&::dafny_runtime::int!(3)) as u64 * 4294967296; - let mut x4: u64 = x3 + s.get(&::dafny_runtime::int!(4)) as u64 * 16777216; - let mut x5: u64 = x4 + s.get(&::dafny_runtime::int!(5)) as u64 * 65536; - let mut x6: u64 = x5 + s.get(&::dafny_runtime::int!(6)) as u64 * 256; - let mut x: u64 = x6 + s.get(&::dafny_runtime::int!(7)) as u64; - x - } - pub fn UINT16_LIMIT() -> ::dafny_runtime::DafnyInt { - ::dafny_runtime::int!(b"65536") - } - pub fn UINT32_LIMIT() -> ::dafny_runtime::DafnyInt { - ::dafny_runtime::int!(b"4294967296") - } - pub fn UINT64_LIMIT() -> ::dafny_runtime::DafnyInt { - ::dafny_runtime::int!(b"18446744073709551616") - } - pub fn INT32_MAX_LIMIT() -> ::dafny_runtime::DafnyInt { - ::dafny_runtime::int!(b"2147483648") - } - pub fn INT64_MAX_LIMIT() -> ::dafny_runtime::DafnyInt { - ::dafny_runtime::int!(b"9223372036854775808") - } - } - - #[derive(Clone, PartialEq)] - #[repr(transparent)] - pub struct uint8(pub u8); - - impl ::std::default::Default for uint8 { - fn default() -> Self { - uint8(::std::default::Default::default()) - } - } - - impl ::dafny_runtime::DafnyPrint for uint8 { - fn fmt_print( - &self, - _formatter: &mut ::std::fmt::Formatter, - in_seq: bool, - ) -> ::std::fmt::Result { - ::dafny_runtime::DafnyPrint::fmt_print(&self.0, _formatter, in_seq) - } - } - - impl ::std::ops::Deref for uint8 { - type Target = u8; - fn deref(&self) -> &Self::Target { - &self.0 - } - } - - #[derive(Clone, PartialEq)] - #[repr(transparent)] - pub struct uint16(pub u16); - - impl ::std::default::Default for uint16 { - fn default() -> Self { - uint16(::std::default::Default::default()) - } - } - - impl ::dafny_runtime::DafnyPrint for uint16 { - fn fmt_print( - &self, - _formatter: &mut ::std::fmt::Formatter, - in_seq: bool, - ) -> ::std::fmt::Result { - ::dafny_runtime::DafnyPrint::fmt_print(&self.0, _formatter, in_seq) - } - } - - impl ::std::ops::Deref for uint16 { - type Target = u16; - fn deref(&self) -> &Self::Target { - &self.0 - } - } - - #[derive(Clone, PartialEq)] - #[repr(transparent)] - pub struct uint32(pub u32); - - impl ::std::default::Default for uint32 { - fn default() -> Self { - uint32(::std::default::Default::default()) - } - } - - impl ::dafny_runtime::DafnyPrint for uint32 { - fn fmt_print( - &self, - _formatter: &mut ::std::fmt::Formatter, - in_seq: bool, - ) -> ::std::fmt::Result { - ::dafny_runtime::DafnyPrint::fmt_print(&self.0, _formatter, in_seq) - } - } - - impl ::std::ops::Deref for uint32 { - type Target = u32; - fn deref(&self) -> &Self::Target { - &self.0 - } - } - - #[derive(Clone, PartialEq)] - #[repr(transparent)] - pub struct uint64(pub u64); - - impl ::std::default::Default for uint64 { - fn default() -> Self { - uint64(::std::default::Default::default()) - } - } - - impl ::dafny_runtime::DafnyPrint for uint64 { - fn fmt_print( - &self, - _formatter: &mut ::std::fmt::Formatter, - in_seq: bool, - ) -> ::std::fmt::Result { - ::dafny_runtime::DafnyPrint::fmt_print(&self.0, _formatter, in_seq) - } - } - - impl ::std::ops::Deref for uint64 { - type Target = u64; - fn deref(&self) -> &Self::Target { - &self.0 - } - } - - #[derive(Clone, PartialEq)] - #[repr(transparent)] - pub struct int32(pub i32); - - impl ::std::default::Default for int32 { - fn default() -> Self { - int32(::std::default::Default::default()) - } - } - - impl ::dafny_runtime::DafnyPrint for int32 { - fn fmt_print( - &self, - _formatter: &mut ::std::fmt::Formatter, - in_seq: bool, - ) -> ::std::fmt::Result { - ::dafny_runtime::DafnyPrint::fmt_print(&self.0, _formatter, in_seq) - } - } - - impl ::std::ops::Deref for int32 { - type Target = i32; - fn deref(&self) -> &Self::Target { - &self.0 - } - } - - #[derive(Clone, PartialEq)] - #[repr(transparent)] - pub struct int64(pub i64); - - impl ::std::default::Default for int64 { - fn default() -> Self { - int64(::std::default::Default::default()) - } - } - - impl ::dafny_runtime::DafnyPrint for int64 { - fn fmt_print( - &self, - _formatter: &mut ::std::fmt::Formatter, - in_seq: bool, - ) -> ::std::fmt::Result { - ::dafny_runtime::DafnyPrint::fmt_print(&self.0, _formatter, in_seq) - } - } - - impl ::std::ops::Deref for int64 { - type Target = i64; - fn deref(&self) -> &Self::Target { - &self.0 - } - } - - #[derive(Clone, PartialEq)] - #[repr(transparent)] - pub struct posInt64(pub u64); - - impl ::std::default::Default for posInt64 { - fn default() -> Self { - posInt64(1) - } - } - - impl ::dafny_runtime::DafnyPrint for posInt64 { - fn fmt_print( - &self, - _formatter: &mut ::std::fmt::Formatter, - in_seq: bool, - ) -> ::std::fmt::Result { - ::dafny_runtime::DafnyPrint::fmt_print(&self.0, _formatter, in_seq) - } - } - - impl ::std::ops::Deref for posInt64 { - type Target = u64; - fn deref(&self) -> &Self::Target { - &self.0 - } - } - - pub type seq16 = ::dafny_runtime::Sequence; - - pub type seq32 = ::dafny_runtime::Sequence; - - pub type seq64 = ::dafny_runtime::Sequence; -} -pub mod r#_StandardLibrary_Compile { - pub struct _default {} - - impl _default { - pub fn _allocate_rcmut() -> ::dafny_runtime::Object { - ::dafny_runtime::allocate_rcmut::() - } - pub fn Join<_T: ::dafny_runtime::DafnyType>( - ss: &::dafny_runtime::Sequence<::dafny_runtime::Sequence<_T>>, - joiner: &::dafny_runtime::Sequence<_T>, - ) -> ::dafny_runtime::Sequence<_T> { - let mut _accumulator: ::dafny_runtime::Sequence<_T> = - ::dafny_runtime::seq![] as ::dafny_runtime::Sequence<_T>; - let mut ss = ss.clone(); - let mut joiner = joiner.clone(); - let mut _accumulator = _accumulator.clone(); - 'TAIL_CALL_START: loop { - if ss.cardinality() == ::dafny_runtime::int!(1) { - return _accumulator.concat(&ss.get(&::dafny_runtime::int!(0))); - } else { - _accumulator = - _accumulator.concat(&ss.get(&::dafny_runtime::int!(0)).concat(&joiner)); - let mut _in0: ::dafny_runtime::Sequence<::dafny_runtime::Sequence<_T>> = - ss.drop(&::dafny_runtime::int!(1)); - let mut _in1: ::dafny_runtime::Sequence<_T> = joiner.clone(); - ss = _in0.clone(); - joiner = _in1.clone(); - continue 'TAIL_CALL_START; - } - } - } - pub fn Split<_T: ::dafny_runtime::DafnyTypeEq>( - s: &::dafny_runtime::Sequence<_T>, - delim: &_T, - ) -> ::dafny_runtime::Sequence<::dafny_runtime::Sequence<_T>> { - let mut _accumulator: ::dafny_runtime::Sequence<::dafny_runtime::Sequence<_T>> = - ::dafny_runtime::seq![] as ::dafny_runtime::Sequence<::dafny_runtime::Sequence<_T>>; - let mut s = s.clone(); - let mut delim = delim.clone(); - let mut _accumulator = _accumulator.clone(); - 'TAIL_CALL_START: loop { - let mut i: ::std::rc::Rc< - super::r#_Wrappers_Compile::Option<::dafny_runtime::_System::nat>, - > = super::r#_StandardLibrary_Compile::_default::FindIndexMatching::<_T>( - &s, - &delim, - &::dafny_runtime::int!(0), - ); - if matches!( - (&i).as_ref(), - super::r#_Wrappers_Compile::Option::Some { .. } - ) { - _accumulator = _accumulator.concat(&::dafny_runtime::seq![s.take(i.value())]); - let mut _in2: ::dafny_runtime::Sequence<_T> = - s.drop(&(i.value().clone() + ::dafny_runtime::int!(1))); - let mut _in3: _T = delim.clone(); - s = _in2.clone(); - delim = _in3.clone(); - continue 'TAIL_CALL_START; - } else { - return _accumulator.concat(&::dafny_runtime::seq![s.clone()]); - } - } - } - pub fn SplitOnce<_T: ::dafny_runtime::DafnyTypeEq>( - s: &::dafny_runtime::Sequence<_T>, - delim: &_T, - ) -> (::dafny_runtime::Sequence<_T>, ::dafny_runtime::Sequence<_T>) { - let mut i: ::std::rc::Rc< - super::r#_Wrappers_Compile::Option<::dafny_runtime::_System::nat>, - > = super::r#_StandardLibrary_Compile::_default::FindIndexMatching::<_T>( - s, - delim, - &::dafny_runtime::int!(0), - ); - ( - s.take(i.value()), - s.drop(&(i.value().clone() + ::dafny_runtime::int!(1))), - ) - } - pub fn r#_SplitOnce_q<_T: ::dafny_runtime::DafnyTypeEq>( - s: &::dafny_runtime::Sequence<_T>, - delim: &_T, - ) -> ::std::rc::Rc< - super::r#_Wrappers_Compile::Option<( - ::dafny_runtime::Sequence<_T>, - ::dafny_runtime::Sequence<_T>, - )>, - > { - let mut valueOrError0: ::std::rc::Rc< - super::r#_Wrappers_Compile::Option<::dafny_runtime::_System::nat>, - > = super::r#_StandardLibrary_Compile::_default::FindIndexMatching::<_T>( - s, - delim, - &::dafny_runtime::int!(0), - ); - if valueOrError0.IsFailure() { - valueOrError0.PropagateFailure::<(::dafny_runtime::Sequence<_T>, ::dafny_runtime::Sequence<_T>)>() - /* Coercion from ::std::rc::Rc> to ::std::rc::Rc, ::dafny_runtime::Sequence<_T>)>> not yet implemented */ - } else { - let mut i: ::dafny_runtime::_System::nat = valueOrError0.Extract()/* Coercion from T to ::dafny_runtime::DafnyInt not yet implemented */; - ::std::rc::Rc::new(super::r#_Wrappers_Compile::Option::<( - ::dafny_runtime::Sequence<_T>, - ::dafny_runtime::Sequence<_T>, - )>::Some { - value: (s.take(&i), s.drop(&(i.clone() + ::dafny_runtime::int!(1)))), - }) - } - } - pub fn FindIndexMatching<_T: ::dafny_runtime::DafnyTypeEq>( - s: &::dafny_runtime::Sequence<_T>, - c: &_T, - i: &::dafny_runtime::_System::nat, - ) -> ::std::rc::Rc> - { - super::r#_StandardLibrary_Compile::_default::FindIndex::<_T>( - s, - { - let c: _T = c.clone(); - &({ - let mut c = c.clone(); - ::std::rc::Rc::new(move |x: &_T| -> bool { x.clone() == c.clone() }) - }) - }, - i, - ) - } - pub fn FindIndex<_T: ::dafny_runtime::DafnyType>( - s: &::dafny_runtime::Sequence<_T>, - f: &::std::rc::Rc bool>, - i: &::dafny_runtime::_System::nat, - ) -> ::std::rc::Rc> - { - let mut s = s.clone(); - let mut f = f.clone(); - let mut i = i.clone(); - 'TAIL_CALL_START: loop { - if i.clone() == s.cardinality() { - return ::std::rc::Rc::new(super::r#_Wrappers_Compile::Option::< - ::dafny_runtime::_System::nat, - >::None {}); - } else { - if (&f)(&s.get(&i)) { - return ::std::rc::Rc::new(super::r#_Wrappers_Compile::Option::< - ::dafny_runtime::_System::nat, - >::Some { - value: i.clone(), - }); - } else { - let mut _in4: ::dafny_runtime::Sequence<_T> = s.clone(); - let mut _in5: ::std::rc::Rc bool> = f.clone(); - let mut _in6: ::dafny_runtime::DafnyInt = - i.clone() + ::dafny_runtime::int!(1); - s = _in4.clone(); - f = _in5.clone(); - i = _in6.clone(); - continue 'TAIL_CALL_START; - } - } - } - } - pub fn Filter<_T: ::dafny_runtime::DafnyType>( - s: &::dafny_runtime::Sequence<_T>, - f: &::std::rc::Rc bool>, - ) -> ::dafny_runtime::Sequence<_T> { - let mut _accumulator: ::dafny_runtime::Sequence<_T> = - ::dafny_runtime::seq![] as ::dafny_runtime::Sequence<_T>; - let mut s = s.clone(); - let mut f = f.clone(); - let mut _accumulator = _accumulator.clone(); - 'TAIL_CALL_START: loop { - if s.cardinality() == ::dafny_runtime::int!(0) { - return _accumulator - .concat(&(::dafny_runtime::seq![] as ::dafny_runtime::Sequence<_T>)); - } else { - if (&f)(&s.get(&::dafny_runtime::int!(0))) { - _accumulator = _accumulator - .concat(&::dafny_runtime::seq![s.get(&::dafny_runtime::int!(0))]); - let mut _in7: ::dafny_runtime::Sequence<_T> = - s.drop(&::dafny_runtime::int!(1)); - let mut _in8: ::std::rc::Rc bool> = f.clone(); - s = _in7.clone(); - f = _in8.clone(); - continue 'TAIL_CALL_START; - } else { - let mut _in9: ::dafny_runtime::Sequence<_T> = - s.drop(&::dafny_runtime::int!(1)); - let mut _in10: ::std::rc::Rc bool> = f.clone(); - s = _in9.clone(); - f = _in10.clone(); - continue 'TAIL_CALL_START; - } - } - } - } - pub fn Min( - a: &::dafny_runtime::DafnyInt, - b: &::dafny_runtime::DafnyInt, - ) -> ::dafny_runtime::DafnyInt { - if a.clone() < b.clone() { - a.clone() - } else { - b.clone() - } - } - pub fn Fill<_T: ::dafny_runtime::DafnyType>( - value: &_T, - n: &::dafny_runtime::_System::nat, - ) -> ::dafny_runtime::Sequence<_T> { - { - let _initializer = { - let value: _T = value.clone(); - { - let mut value = value.clone(); - ::std::rc::Rc::new(move |_v0: &::dafny_runtime::DafnyInt| -> _T { - value.clone() - }) - } - }; - ::dafny_runtime::integer_range(::dafny_runtime::Zero::zero(), n.clone()) - .map(|i| _initializer(&i)) - .collect::<::dafny_runtime::Sequence<_>>() - } - } - pub fn SeqToArray<_T: ::dafny_runtime::DafnyType>( - s: &::dafny_runtime::Sequence<_T>, - ) -> ::dafny_runtime::Object<[_T]> { - let mut a = ::dafny_runtime::MaybePlacebo::<::dafny_runtime::Object<[_T]>>::new(); - let mut _init0: ::std::rc::Rc _T> = { - let s: ::dafny_runtime::Sequence<_T> = s.clone(); - { - let mut s = s.clone(); - ::std::rc::Rc::new(move |i: &::dafny_runtime::DafnyInt| -> _T { s.get(i) }) - } - }; - let mut _nw0: ::dafny_runtime::Object<[::std::mem::MaybeUninit<_T>]> = - ::dafny_runtime::array::placebos_usize_rcmut::<_T>(s.cardinality().as_usize()); - for r#__i0_0 in - ::dafny_runtime::integer_range(0, ::dafny_runtime::rd!(_nw0.clone()).len()) - { - { - let __idx0 = - ::from(r#__i0_0.clone()).unwrap(); - ::dafny_runtime::md!(_nw0.clone())[__idx0] = ::std::mem::MaybeUninit::new( - (&_init0)(&::dafny_runtime::int!(r#__i0_0.clone())), - ); - } - } - a = ::dafny_runtime::MaybePlacebo::from(::dafny_runtime::array::construct_rcmut( - _nw0.clone(), - )); - return a.read(); - } - pub fn LexicographicLessOrEqual<_T: ::dafny_runtime::DafnyTypeEq>( - a: &::dafny_runtime::Sequence<_T>, - b: &::dafny_runtime::Sequence<_T>, - less: &::std::rc::Rc bool>, - ) -> bool { - ::dafny_runtime::integer_range(::dafny_runtime::int!(0), a.cardinality() + ::dafny_runtime::int!(1)).any(({ - let mut a = a.clone(); - let mut b = b.clone(); - let mut less = less.clone(); - ::std::rc::Rc::new(move |r#__exists_var_0: ::dafny_runtime::DafnyInt| -> bool { - let mut k: ::dafny_runtime::DafnyInt = r#__exists_var_0.clone(); - ::dafny_runtime::int!(0) <= k.clone() && k.clone() <= a.cardinality() && super::r#_StandardLibrary_Compile::_default::LexicographicLessOrEqualAux::<_T>(&a, &b, &less, &k) - }) - }).as_ref()) - } - pub fn LexicographicLessOrEqualAux<_T: ::dafny_runtime::DafnyTypeEq>( - a: &::dafny_runtime::Sequence<_T>, - b: &::dafny_runtime::Sequence<_T>, - less: &::std::rc::Rc bool>, - lengthOfCommonPrefix: &::dafny_runtime::_System::nat, - ) -> bool { - lengthOfCommonPrefix.clone() <= b.cardinality() - && ::dafny_runtime::integer_range( - ::dafny_runtime::int!(0), - lengthOfCommonPrefix.clone(), - ) - .all( - ({ - let mut lengthOfCommonPrefix = lengthOfCommonPrefix.clone(); - let mut a = a.clone(); - let mut b = b.clone(); - ::std::rc::Rc::new( - move |r#__forall_var_0: ::dafny_runtime::DafnyInt| -> bool { - let mut i: ::dafny_runtime::DafnyInt = r#__forall_var_0.clone(); - !(::dafny_runtime::int!(0) <= i.clone() - && i.clone() < lengthOfCommonPrefix.clone()) - || a.get(&i) == b.get(&i) - }, - ) - }) - .as_ref(), - ) - && (lengthOfCommonPrefix.clone() == a.cardinality() - || lengthOfCommonPrefix.clone() < b.cardinality() - && less(&a.get(lengthOfCommonPrefix), &b.get(lengthOfCommonPrefix))) - } - pub fn SetToOrderedSequence<_T: ::dafny_runtime::DafnyTypeEq>( - s: &::dafny_runtime::Set<::dafny_runtime::Sequence<_T>>, - less: &::std::rc::Rc bool>, - ) -> ::dafny_runtime::Sequence<::dafny_runtime::Sequence<_T>> { - let mut _accumulator: ::dafny_runtime::Sequence<::dafny_runtime::Sequence<_T>> = - ::dafny_runtime::seq![] as ::dafny_runtime::Sequence<::dafny_runtime::Sequence<_T>>; - let mut s = s.clone(); - let mut less = less.clone(); - let mut _accumulator = _accumulator.clone(); - 'TAIL_CALL_START: loop { - if s.clone() == ::dafny_runtime::set! {} { - return _accumulator.concat( - &(::dafny_runtime::seq![] - as ::dafny_runtime::Sequence<::dafny_runtime::Sequence<_T>>), - ); - } else { - return (&({ - let mut s = s.clone(); - let mut less = less.clone(); - ::std::rc::Rc::new(move |r#__let_dummy_0: &::dafny_runtime::DafnyInt| -> ::dafny_runtime::Sequence<::dafny_runtime::Sequence<_T>> { - let mut a = ::dafny_runtime::MaybePlacebo::<::dafny_runtime::Sequence<_T>>::new(); - 'label_goto__ASSIGN_SUCH_THAT_0: loop { - for r#__assign_such_that_0 in (&s).iter().cloned() { - a = ::dafny_runtime::MaybePlacebo::from(r#__assign_such_that_0.clone()); - if s.contains(&a.read()) && super::r#_StandardLibrary_Compile::_default::IsMinimum::<_T>(&a.read(), &s, &less) { - break 'label_goto__ASSIGN_SUCH_THAT_0; - } - } - panic!("Halt"); - break; - }; - ::dafny_runtime::seq![a.read()].concat(&super::r#_StandardLibrary_Compile::_default::SetToOrderedSequence::<_T>(&s.subtract(&::dafny_runtime::set!{a.read()}), &less)) - }) - }))(&::dafny_runtime::int!(0)); - } - } - } - pub fn IsMinimum<_T: ::dafny_runtime::DafnyTypeEq>( - a: &::dafny_runtime::Sequence<_T>, - s: &::dafny_runtime::Set<::dafny_runtime::Sequence<_T>>, - less: &::std::rc::Rc bool>, - ) -> bool { - s.contains(a) && s.iter().cloned().all(({ - let mut a = a.clone(); - let mut s = s.clone(); - let mut less = less.clone(); - ::std::rc::Rc::new(move |r#__forall_var_1: ::dafny_runtime::Sequence<_T>| -> bool { - let mut z: ::dafny_runtime::Sequence<_T> = r#__forall_var_1.clone(); - !s.contains(&z) || super::r#_StandardLibrary_Compile::_default::LexicographicLessOrEqual::<_T>(&a, &z, &less) - }) - }).as_ref()) - } - } -} -pub mod UTF8 { - pub struct _default {} - - impl _default { - pub fn _allocate_rcmut() -> ::dafny_runtime::Object { - ::dafny_runtime::allocate_rcmut::() - } - pub fn CreateEncodeSuccess( - bytes: &super::UTF8::ValidUTF8Bytes, - ) -> ::std::rc::Rc< - super::r#_Wrappers_Compile::Result< - super::UTF8::ValidUTF8Bytes, - ::dafny_runtime::Sequence<::dafny_runtime::DafnyCharUTF16>, - >, - > { - ::std::rc::Rc::new(super::r#_Wrappers_Compile::Result::< - super::UTF8::ValidUTF8Bytes, - ::dafny_runtime::Sequence<::dafny_runtime::DafnyCharUTF16>, - >::Success { - value: bytes.clone(), - }) - } - pub fn CreateEncodeFailure( - error: &::dafny_runtime::Sequence<::dafny_runtime::DafnyCharUTF16>, - ) -> ::std::rc::Rc< - super::r#_Wrappers_Compile::Result< - super::UTF8::ValidUTF8Bytes, - ::dafny_runtime::Sequence<::dafny_runtime::DafnyCharUTF16>, - >, - > { - ::std::rc::Rc::new(super::r#_Wrappers_Compile::Result::< - super::UTF8::ValidUTF8Bytes, - ::dafny_runtime::Sequence<::dafny_runtime::DafnyCharUTF16>, - >::Failure { - error: error.clone(), - }) - } - pub fn CreateDecodeSuccess( - s: &::dafny_runtime::Sequence<::dafny_runtime::DafnyCharUTF16>, - ) -> ::std::rc::Rc< - super::r#_Wrappers_Compile::Result< - ::dafny_runtime::Sequence<::dafny_runtime::DafnyCharUTF16>, - ::dafny_runtime::Sequence<::dafny_runtime::DafnyCharUTF16>, - >, - > { - ::std::rc::Rc::new(super::r#_Wrappers_Compile::Result::< - ::dafny_runtime::Sequence<::dafny_runtime::DafnyCharUTF16>, - ::dafny_runtime::Sequence<::dafny_runtime::DafnyCharUTF16>, - >::Success { - value: s.clone(), - }) - } - pub fn CreateDecodeFailure( - error: &::dafny_runtime::Sequence<::dafny_runtime::DafnyCharUTF16>, - ) -> ::std::rc::Rc< - super::r#_Wrappers_Compile::Result< - ::dafny_runtime::Sequence<::dafny_runtime::DafnyCharUTF16>, - ::dafny_runtime::Sequence<::dafny_runtime::DafnyCharUTF16>, - >, - > { - ::std::rc::Rc::new(super::r#_Wrappers_Compile::Result::< - ::dafny_runtime::Sequence<::dafny_runtime::DafnyCharUTF16>, - ::dafny_runtime::Sequence<::dafny_runtime::DafnyCharUTF16>, - >::Failure { - error: error.clone(), - }) - } - pub fn IsASCIIString( - s: &::dafny_runtime::Sequence<::dafny_runtime::DafnyCharUTF16>, - ) -> bool { - let mut _hresult: bool = ::default(); - let mut _hi0: ::dafny_runtime::DafnyInt = s.cardinality(); - for i in ::dafny_runtime::integer_range(::dafny_runtime::int!(0), _hi0.clone()) { - if !(::dafny_runtime::int!(s.get(&i).0) < ::dafny_runtime::int!(128)) { - _hresult = false; - return _hresult; - } - } - _hresult = true; - return _hresult; - return _hresult; - } - pub fn EncodeAscii( - s: &::dafny_runtime::Sequence<::dafny_runtime::DafnyCharUTF16>, - ) -> super::UTF8::ValidUTF8Bytes { - let mut _accumulator: super::UTF8::ValidUTF8Bytes = - ::dafny_runtime::seq![] as ::dafny_runtime::Sequence; - let mut s = s.clone(); - let mut _accumulator = _accumulator.clone(); - 'TAIL_CALL_START: loop { - if s.cardinality() == ::dafny_runtime::int!(0) { - return _accumulator - .concat(&(::dafny_runtime::seq![] as ::dafny_runtime::Sequence)); - } else { - let mut x: ::dafny_runtime::Sequence = - ::dafny_runtime::seq![s.get(&::dafny_runtime::int!(0)).0 as u8]; - _accumulator = _accumulator.concat(&x); - let mut _in11: ::dafny_runtime::Sequence<::dafny_runtime::DafnyCharUTF16> = - s.drop(&::dafny_runtime::int!(1)); - s = _in11.clone(); - continue 'TAIL_CALL_START; - } - } - } - pub fn Uses1Byte(s: &::dafny_runtime::Sequence) -> bool { - 0 <= s.get(&::dafny_runtime::int!(0)) && s.get(&::dafny_runtime::int!(0)) <= 127 - } - pub fn Uses2Bytes(s: &::dafny_runtime::Sequence) -> bool { - 194 <= s.get(&::dafny_runtime::int!(0)) - && s.get(&::dafny_runtime::int!(0)) <= 223 - && (128 <= s.get(&::dafny_runtime::int!(1)) - && s.get(&::dafny_runtime::int!(1)) <= 191) - } - pub fn Uses3Bytes(s: &::dafny_runtime::Sequence) -> bool { - s.get(&::dafny_runtime::int!(0)) == 224 - && (160 <= s.get(&::dafny_runtime::int!(1)) - && s.get(&::dafny_runtime::int!(1)) <= 191) - && (128 <= s.get(&::dafny_runtime::int!(2)) - && s.get(&::dafny_runtime::int!(2)) <= 191) - || 225 <= s.get(&::dafny_runtime::int!(0)) - && s.get(&::dafny_runtime::int!(0)) <= 236 - && (128 <= s.get(&::dafny_runtime::int!(1)) - && s.get(&::dafny_runtime::int!(1)) <= 191) - && (128 <= s.get(&::dafny_runtime::int!(2)) - && s.get(&::dafny_runtime::int!(2)) <= 191) - || s.get(&::dafny_runtime::int!(0)) == 237 - && (128 <= s.get(&::dafny_runtime::int!(1)) - && s.get(&::dafny_runtime::int!(1)) <= 159) - && (128 <= s.get(&::dafny_runtime::int!(2)) - && s.get(&::dafny_runtime::int!(2)) <= 191) - || 238 <= s.get(&::dafny_runtime::int!(0)) - && s.get(&::dafny_runtime::int!(0)) <= 239 - && (128 <= s.get(&::dafny_runtime::int!(1)) - && s.get(&::dafny_runtime::int!(1)) <= 191) - && (128 <= s.get(&::dafny_runtime::int!(2)) - && s.get(&::dafny_runtime::int!(2)) <= 191) - } - pub fn Uses4Bytes(s: &::dafny_runtime::Sequence) -> bool { - s.get(&::dafny_runtime::int!(0)) == 240 - && (144 <= s.get(&::dafny_runtime::int!(1)) - && s.get(&::dafny_runtime::int!(1)) <= 191) - && (128 <= s.get(&::dafny_runtime::int!(2)) - && s.get(&::dafny_runtime::int!(2)) <= 191) - && (128 <= s.get(&::dafny_runtime::int!(3)) - && s.get(&::dafny_runtime::int!(3)) <= 191) - || 241 <= s.get(&::dafny_runtime::int!(0)) - && s.get(&::dafny_runtime::int!(0)) <= 243 - && (128 <= s.get(&::dafny_runtime::int!(1)) - && s.get(&::dafny_runtime::int!(1)) <= 191) - && (128 <= s.get(&::dafny_runtime::int!(2)) - && s.get(&::dafny_runtime::int!(2)) <= 191) - && (128 <= s.get(&::dafny_runtime::int!(3)) - && s.get(&::dafny_runtime::int!(3)) <= 191) - || s.get(&::dafny_runtime::int!(0)) == 244 - && (128 <= s.get(&::dafny_runtime::int!(1)) - && s.get(&::dafny_runtime::int!(1)) <= 143) - && (128 <= s.get(&::dafny_runtime::int!(2)) - && s.get(&::dafny_runtime::int!(2)) <= 191) - && (128 <= s.get(&::dafny_runtime::int!(3)) - && s.get(&::dafny_runtime::int!(3)) <= 191) - } - pub fn ValidUTF8Range( - a: &::dafny_runtime::Sequence, - lo: &::dafny_runtime::_System::nat, - hi: &::dafny_runtime::_System::nat, - ) -> bool { - let mut a = a.clone(); - let mut lo = lo.clone(); - let mut hi = hi.clone(); - 'TAIL_CALL_START: loop { - if lo.clone() == hi.clone() { - return true; - } else { - let mut r: ::dafny_runtime::Sequence = a.slice(&lo, &hi); - if super::UTF8::_default::Uses1Byte(&r) { - let mut _in12: ::dafny_runtime::Sequence = a.clone(); - let mut _in13: ::dafny_runtime::DafnyInt = - lo.clone() + ::dafny_runtime::int!(1); - let mut _in14: ::dafny_runtime::_System::nat = hi.clone(); - a = _in12.clone(); - lo = _in13.clone(); - hi = _in14.clone(); - continue 'TAIL_CALL_START; - } else { - if ::dafny_runtime::int!(2) <= r.cardinality() - && super::UTF8::_default::Uses2Bytes(&r) - { - let mut _in15: ::dafny_runtime::Sequence = a.clone(); - let mut _in16: ::dafny_runtime::DafnyInt = - lo.clone() + ::dafny_runtime::int!(2); - let mut _in17: ::dafny_runtime::_System::nat = hi.clone(); - a = _in15.clone(); - lo = _in16.clone(); - hi = _in17.clone(); - continue 'TAIL_CALL_START; - } else { - if ::dafny_runtime::int!(3) <= r.cardinality() - && super::UTF8::_default::Uses3Bytes(&r) - { - let mut _in18: ::dafny_runtime::Sequence = a.clone(); - let mut _in19: ::dafny_runtime::DafnyInt = - lo.clone() + ::dafny_runtime::int!(3); - let mut _in20: ::dafny_runtime::_System::nat = hi.clone(); - a = _in18.clone(); - lo = _in19.clone(); - hi = _in20.clone(); - continue 'TAIL_CALL_START; - } else { - if ::dafny_runtime::int!(4) <= r.cardinality() - && super::UTF8::_default::Uses4Bytes(&r) - { - let mut _in21: ::dafny_runtime::Sequence = a.clone(); - let mut _in22: ::dafny_runtime::DafnyInt = - lo.clone() + ::dafny_runtime::int!(4); - let mut _in23: ::dafny_runtime::_System::nat = hi.clone(); - a = _in21.clone(); - lo = _in22.clone(); - hi = _in23.clone(); - continue 'TAIL_CALL_START; - } else { - return false; - } - } - } - } - } - } - } - pub fn ValidUTF8Seq(s: &::dafny_runtime::Sequence) -> bool { - super::UTF8::_default::ValidUTF8Range(s, &::dafny_runtime::int!(0), &s.cardinality()) - } - } - - pub type ValidUTF8Bytes = ::dafny_runtime::Sequence; - - pub fn r#__init_ValidUTF8Bytes() -> ::dafny_runtime::Sequence { - ::dafny_runtime::seq![] as ::dafny_runtime::Sequence - } -} -pub mod r#_StandardLibraryInterop_Compile { - pub struct WrappersInterop {} - - impl WrappersInterop { - pub fn _allocate_rcmut() -> ::dafny_runtime::Object { - ::dafny_runtime::allocate_rcmut::() - } - pub fn CreateStringSome( - s: &::dafny_runtime::Sequence<::dafny_runtime::DafnyCharUTF16>, - ) -> ::std::rc::Rc< - super::r#_Wrappers_Compile::Option< - ::dafny_runtime::Sequence<::dafny_runtime::DafnyCharUTF16>, - >, - > { - ::std::rc::Rc::new(super::r#_Wrappers_Compile::Option::< - ::dafny_runtime::Sequence<::dafny_runtime::DafnyCharUTF16>, - >::Some { - value: s.clone(), - }) - } - pub fn CreateStringNone() -> ::std::rc::Rc< - super::r#_Wrappers_Compile::Option< - ::dafny_runtime::Sequence<::dafny_runtime::DafnyCharUTF16>, - >, - > { - ::std::rc::Rc::new(super::r#_Wrappers_Compile::Option::< - ::dafny_runtime::Sequence<::dafny_runtime::DafnyCharUTF16>, - >::None {}) - } - pub fn CreateBooleanSome( - b: bool, - ) -> ::std::rc::Rc> { - ::std::rc::Rc::new(super::r#_Wrappers_Compile::Option::::Some { value: b }) - } - pub fn CreateBooleanNone() -> ::std::rc::Rc> { - ::std::rc::Rc::new(super::r#_Wrappers_Compile::Option::::None {}) - } - } -} -pub mod _module {} diff --git a/codegen/smithy-dafny-codegen/src/main/java/software/amazon/polymorph/CodegenEngine.java b/codegen/smithy-dafny-codegen/src/main/java/software/amazon/polymorph/CodegenEngine.java index 5e676d51e1..fb2cc9c7bc 100644 --- a/codegen/smithy-dafny-codegen/src/main/java/software/amazon/polymorph/CodegenEngine.java +++ b/codegen/smithy-dafny-codegen/src/main/java/software/amazon/polymorph/CodegenEngine.java @@ -662,9 +662,20 @@ private void generateRust(final Path outputDir) { // It would be great to do this for all languages, // but we're not currently precise enough and do multiple passes // to generate code for things like wrapped services. + // + // Be sure to NOT delete src/implementation_from_dafny.rs though, + // by temporarily moving it out of src/ Path outputSrcDir = outputDir.resolve("src"); - software.amazon.smithy.utils.IoUtils.rmdir(outputSrcDir); - outputSrcDir.toFile().mkdirs(); + Path implementationFromDafnyPath = outputSrcDir.resolve("implementation_from_dafny.rs"); + try { + Path tmpPath = outputDir.resolve("implementation_from_dafny.rs"); + Files.move(implementationFromDafnyPath, tmpPath); + software.amazon.smithy.utils.IoUtils.rmdir(outputSrcDir); + outputSrcDir.toFile().mkdirs(); + Files.move(tmpPath, implementationFromDafnyPath); + } catch (IOException e) { + throw new RuntimeException(e); + } handlePatching(TargetLanguage.RUST, outputDir); } From 8911f81e515527f74906adf19f210c5b10ad72ce Mon Sep 17 00:00:00 2001 From: Robin Salkeld Date: Tue, 9 Jul 2024 11:34:37 -0700 Subject: [PATCH 13/53] Stop patching implementation_from_dafny.rs --- .../codegen-patches/rust/dafny-4.5.0.patch | 48 ----------- .../codegen-patches/rust/dafny-4.5.0.patch | 22 ----- .../codegen-patches/rust/dafny-4.5.0.patch | 25 ------ .../codegen-patches/rust/dafny-4.5.0.patch | 86 ------------------- .../codegen-patches/rust/dafny-4.5.0.patch | 22 ----- .../amazon/polymorph/CodegenEngine.java | 11 ++- 6 files changed, 8 insertions(+), 206 deletions(-) diff --git a/TestModels/Resource/codegen-patches/rust/dafny-4.5.0.patch b/TestModels/Resource/codegen-patches/rust/dafny-4.5.0.patch index 4fe42cdf2b..5be06d626e 100644 --- a/TestModels/Resource/codegen-patches/rust/dafny-4.5.0.patch +++ b/TestModels/Resource/codegen-patches/rust/dafny-4.5.0.patch @@ -1,51 +1,3 @@ -diff --git b/TestModels/Resource/runtimes/rust/dafny_impl/src/implementation_from_dafny.rs a/TestModels/Resource/runtimes/rust/dafny_impl/src/implementation_from_dafny.rs -index 4aadfc53..8b0cf633 100644 ---- b/TestModels/Resource/runtimes/rust/dafny_impl/src/implementation_from_dafny.rs -+++ a/TestModels/Resource/runtimes/rust/dafny_impl/src/implementation_from_dafny.rs -@@ -549,13 +549,14 @@ pub mod r#_simple_dresources_dinternaldafny_dtypes { - } - } - -- impl ::std::default::Default for GetResourcesOutput { -- fn default() -> GetResourcesOutput { -- GetResourcesOutput::GetResourcesOutput { -- output: ::std::default::Default::default(), -- } -- } -- } -+ // the trait `Default` is not implemented for `Object<(dyn ISimpleResource + 'static)>` -+ // impl ::std::default::Default for GetResourcesOutput { -+ // fn default() -> GetResourcesOutput { -+ // GetResourcesOutput::GetResourcesOutput { -+ // output: ::std::default::Default::default(), -+ // } -+ // } -+ // } - - impl ::std::convert::AsRef for &GetResourcesOutput { - fn as_ref(&self) -> Self { -@@ -588,7 +589,7 @@ pub mod r#_simple_dresources_dinternaldafny_dtypes { - let mut output = ::dafny_runtime::MaybePlacebo::<::std::rc::Rc, ::std::rc::Rc>>>::new(); - let mut _out0 = ::dafny_runtime::MaybePlacebo::<::std::rc::Rc, ::std::rc::Rc>>>::new(); - _out0 = ::dafny_runtime::MaybePlacebo::from( -- ::dafny_runtime::md!(self).r#_GetResourceData_k(input), -+ self.r#_GetResourceData_k(input), - ); - output = ::dafny_runtime::MaybePlacebo::from(_out0.read()); - return output.read(); -@@ -848,10 +849,11 @@ pub mod r#_SimpleResource_Compile { - let mut _out1 = ::dafny_runtime::MaybePlacebo::<::std::rc::Rc, ::std::rc::Rc>>>::new(); - _out1 = ::dafny_runtime::MaybePlacebo::from( - super::r#_simple_dresources_dinternaldafny_dtypes::ISimpleResource::GetResourceData( -- self.unwrap(), -+ self, - input, - ), - ); -+ _out1.read() - } - pub fn _ctor( - this: &::dafny_runtime::Object, diff --git b/TestModels/Resource/runtimes/rust/src/client.rs a/TestModels/Resource/runtimes/rust/src/client.rs new file mode 100644 index 00000000..a6d9e55b diff --git a/TestModels/SimpleTypes/SimpleBoolean/codegen-patches/rust/dafny-4.5.0.patch b/TestModels/SimpleTypes/SimpleBoolean/codegen-patches/rust/dafny-4.5.0.patch index d43bbd3d8f..cd1e67bae9 100644 --- a/TestModels/SimpleTypes/SimpleBoolean/codegen-patches/rust/dafny-4.5.0.patch +++ b/TestModels/SimpleTypes/SimpleBoolean/codegen-patches/rust/dafny-4.5.0.patch @@ -1,25 +1,3 @@ -diff --git b/TestModels/SimpleTypes/SimpleBoolean/runtimes/rust/dafny_impl/src/implementation_from_dafny.rs a/TestModels/SimpleTypes/SimpleBoolean/runtimes/rust/dafny_impl/src/implementation_from_dafny.rs -index c2850c0e..06c0c0ea 100644 ---- b/TestModels/SimpleTypes/SimpleBoolean/runtimes/rust/dafny_impl/src/implementation_from_dafny.rs -+++ a/TestModels/SimpleTypes/SimpleBoolean/runtimes/rust/dafny_impl/src/implementation_from_dafny.rs -@@ -434,7 +434,7 @@ pub mod r#_SimpleBooleanImpl_Compile { - ) { - panic!("Halt") - }; -- if !(input.value().value() == true || input.value().value() == false) { -+ if !(*input.value().value() == true || *input.value().value() == false) { - panic!("Halt") - }; - let mut res: ::std::rc::Rc = ::std::rc::Rc::new(super::r#_simple_dtypes_dboolean_dinternaldafny_dtypes::GetBooleanOutput::GetBooleanOutput { -@@ -443,7 +443,7 @@ pub mod r#_SimpleBooleanImpl_Compile { - res = ::std::rc::Rc::new(super::r#_simple_dtypes_dboolean_dinternaldafny_dtypes::GetBooleanOutput::GetBooleanOutput { - value: input.value().clone() - }); -- if !(res.value().value() == true || res.value().value() == false) { -+ if !(*res.value().value() == true || *res.value().value() == false) { - panic!("Halt") - }; - if !(input.value().value() == res.value().value()) { diff --git b/TestModels/SimpleTypes/SimpleBoolean/runtimes/rust/src/client.rs a/TestModels/SimpleTypes/SimpleBoolean/runtimes/rust/src/client.rs new file mode 100644 index 00000000..5170a9ce diff --git a/TestModels/SimpleTypes/SimpleInteger/codegen-patches/rust/dafny-4.5.0.patch b/TestModels/SimpleTypes/SimpleInteger/codegen-patches/rust/dafny-4.5.0.patch index ee2543eb1c..9c0c946fc0 100644 --- a/TestModels/SimpleTypes/SimpleInteger/codegen-patches/rust/dafny-4.5.0.patch +++ b/TestModels/SimpleTypes/SimpleInteger/codegen-patches/rust/dafny-4.5.0.patch @@ -1,28 +1,3 @@ -diff --git b/TestModels/SimpleTypes/SimpleInteger/runtimes/rust/dafny_impl/src/implementation_from_dafny.rs a/TestModels/SimpleTypes/SimpleInteger/runtimes/rust/dafny_impl/src/implementation_from_dafny.rs -index b15b3485..44f71829 100644 ---- b/TestModels/SimpleTypes/SimpleInteger/runtimes/rust/dafny_impl/src/implementation_from_dafny.rs -+++ a/TestModels/SimpleTypes/SimpleInteger/runtimes/rust/dafny_impl/src/implementation_from_dafny.rs -@@ -447,9 +447,7 @@ pub mod r#_SimpleIntegerImpl_Compile { - ) { - panic!("Halt") - }; -- if !(::dafny_runtime::truncate!(::dafny_runtime::int!(0) - super::r#_StandardLibrary_Compile_dUInt_Compile::_default::INT32_MAX_LIMIT(), i32) <= ::dafny_runtime::truncate!(input.value().UnwrapOr(&(&0).into::<::dafny_runtime::DafnyInt>()/* Coercion from ::dafny_runtime::DafnyInt to T not yet implemented */)/* Coercion from T to ::dafny_runtime::DafnyInt not yet implemented */, i32) && ::dafny_runtime::truncate!(input.value().UnwrapOr(&(&0).into::<::dafny_runtime::DafnyInt>()/* Coercion from ::dafny_runtime::DafnyInt to T not yet implemented */)/* Coercion from T to ::dafny_runtime::DafnyInt not yet implemented */, i32) <= ::dafny_runtime::truncate!(super::r#_StandardLibrary_Compile_dUInt_Compile::_default::INT32_MAX_LIMIT() - ::dafny_runtime::int!(1), i32)) { -- panic!("Halt") -- }; -+ - let mut res: ::std::rc::Rc = ::std::rc::Rc::new(super::r#_simple_dtypes_dinteger_dinternaldafny_dtypes::GetIntegerOutput::GetIntegerOutput { - value: input.value().clone() - }); -@@ -489,9 +487,6 @@ pub mod r#_SimpleIntegerImpl_Compile { - ) { - panic!("Halt") - }; -- if !(::dafny_runtime::truncate!(input.value().UnwrapOr(&(&0).into::<::dafny_runtime::DafnyInt>()/* Coercion from ::dafny_runtime::DafnyInt to T not yet implemented */)/* Coercion from T to ::dafny_runtime::DafnyInt not yet implemented */, i32) == 20) { -- panic!("Halt") -- }; - let mut res: ::std::rc::Rc = ::std::rc::Rc::new(super::r#_simple_dtypes_dinteger_dinternaldafny_dtypes::GetIntegerOutput::GetIntegerOutput { - value: input.value().clone() - }); diff --git b/TestModels/SimpleTypes/SimpleInteger/runtimes/rust/src/client.rs a/TestModels/SimpleTypes/SimpleInteger/runtimes/rust/src/client.rs new file mode 100644 index 00000000..0450cb93 diff --git a/TestModels/SimpleTypes/SimpleLong/codegen-patches/rust/dafny-4.5.0.patch b/TestModels/SimpleTypes/SimpleLong/codegen-patches/rust/dafny-4.5.0.patch index 195f3a3502..29073bbaa9 100644 --- a/TestModels/SimpleTypes/SimpleLong/codegen-patches/rust/dafny-4.5.0.patch +++ b/TestModels/SimpleTypes/SimpleLong/codegen-patches/rust/dafny-4.5.0.patch @@ -1,89 +1,3 @@ -diff --git b/TestModels/SimpleTypes/SimpleLong/runtimes/rust/dafny_impl/src/implementation_from_dafny.rs a/TestModels/SimpleTypes/SimpleLong/runtimes/rust/dafny_impl/src/implementation_from_dafny.rs -index ca9dc612..0d923e39 100644 ---- b/TestModels/SimpleTypes/SimpleLong/runtimes/rust/dafny_impl/src/implementation_from_dafny.rs -+++ a/TestModels/SimpleTypes/SimpleLong/runtimes/rust/dafny_impl/src/implementation_from_dafny.rs -@@ -1,7 +1,7 @@ - #![allow(warnings, unconditional_panic)] - #![allow(nonstandard_style)] - pub use dafny_standard_library::implementation_from_dafny::*; -- -+ - pub mod r#_simple_dtypes_dsmithylong_dinternaldafny_dtypes { - #[derive(PartialEq, Clone)] - pub enum DafnyCallEvent { -@@ -444,7 +444,7 @@ pub mod r#_SimpleLongImpl_Compile { - ) { - panic!("Halt") - }; -- super::r#_SimpleLongImpl_Compile::_default::ValidateLongType(input.value().value()); -+ super::r#_SimpleLongImpl_Compile::_default::ValidateLongType(*input.value().value()); - let mut res: ::std::rc::Rc = ::std::rc::Rc::new(super::r#_simple_dtypes_dsmithylong_dinternaldafny_dtypes::GetLongOutput::GetLongOutput { - value: input.value().clone() - }); -@@ -457,7 +457,7 @@ pub mod r#_SimpleLongImpl_Compile { - ) { - panic!("Halt") - }; -- super::r#_SimpleLongImpl_Compile::_default::ValidateLongType(res.value().value()); -+ super::r#_SimpleLongImpl_Compile::_default::ValidateLongType(*res.value().value()); - output = ::dafny_runtime::MaybePlacebo::from(::std::rc::Rc::new( - super::r#_Wrappers_Compile::Result::< - ::std::rc::Rc< -@@ -491,8 +491,8 @@ pub mod r#_SimpleLongImpl_Compile { - ) { - panic!("Halt") - }; -- super::r#_SimpleLongImpl_Compile::_default::ValidateLongType(input.value().value()); -- if !(input.value().value() == 33) { -+ super::r#_SimpleLongImpl_Compile::_default::ValidateLongType(*input.value().value()); -+ if !(input.value().value() == &33i64) { - panic!("Halt") - }; - let mut res: ::std::rc::Rc = ::std::rc::Rc::new(super::r#_simple_dtypes_dsmithylong_dinternaldafny_dtypes::GetLongOutput::GetLongOutput { -@@ -507,7 +507,7 @@ pub mod r#_SimpleLongImpl_Compile { - ) { - panic!("Halt") - }; -- super::r#_SimpleLongImpl_Compile::_default::ValidateLongType(res.value().value()); -+ super::r#_SimpleLongImpl_Compile::_default::ValidateLongType(*res.value().value()); - output = ::dafny_runtime::MaybePlacebo::from(::std::rc::Rc::new( - super::r#_Wrappers_Compile::Result::< - ::std::rc::Rc< -@@ -522,10 +522,11 @@ pub mod r#_SimpleLongImpl_Compile { - return output.read(); - } - pub fn ValidateLongType(input: i64) -> () { -+ return; - if input >= 0 { - if input - >= ::dafny_runtime::truncate!( -- super::r#_StandardLibrary_Compile_dUInt_Compile::_default::INT32_MAX_LIMIT( -+ super::r#_StandardLibrary_Compile_dUInt_Compile::_default::INT64_MAX_LIMIT( - ), - i64 - ) -@@ -534,7 +535,7 @@ pub mod r#_SimpleLongImpl_Compile { - }; - if !(0 < input - + ::dafny_runtime::truncate!( -- super::r#_StandardLibrary_Compile_dUInt_Compile::_default::INT32_MAX_LIMIT( -+ super::r#_StandardLibrary_Compile_dUInt_Compile::_default::INT64_MAX_LIMIT( - ), - i64 - )) -@@ -543,10 +544,10 @@ pub mod r#_SimpleLongImpl_Compile { - } - } else { - if input < 0 { -- if input < 0 - ::dafny_runtime::truncate!(super::r#_StandardLibrary_Compile_dUInt_Compile::_default::INT32_MAX_LIMIT(), i64) { -+ if input < 0 - ::dafny_runtime::truncate!(super::r#_StandardLibrary_Compile_dUInt_Compile::_default::INT64_MAX_LIMIT(), i64) { - return (); - }; -- if !(input + (0 - ::dafny_runtime::truncate!(super::r#_StandardLibrary_Compile_dUInt_Compile::_default::INT32_MAX_LIMIT(), i64)) < 0) { -+ if !(input + (0 - ::dafny_runtime::truncate!(super::r#_StandardLibrary_Compile_dUInt_Compile::_default::INT64_MAX_LIMIT(), i64)) < 0) { - panic!("Halt") - } - } else { diff --git b/TestModels/SimpleTypes/SimpleLong/runtimes/rust/src/client.rs a/TestModels/SimpleTypes/SimpleLong/runtimes/rust/src/client.rs new file mode 100644 index 00000000..8fb3793c diff --git a/TestModels/Union/codegen-patches/rust/dafny-4.5.0.patch b/TestModels/Union/codegen-patches/rust/dafny-4.5.0.patch index 5afeb36854..e620883540 100644 --- a/TestModels/Union/codegen-patches/rust/dafny-4.5.0.patch +++ b/TestModels/Union/codegen-patches/rust/dafny-4.5.0.patch @@ -1,25 +1,3 @@ -diff --git b/TestModels/Union/runtimes/rust/dafny_impl/src/implementation_from_dafny.rs a/TestModels/Union/runtimes/rust/dafny_impl/src/implementation_from_dafny.rs -index 931a24b5..eeb13dc0 100644 ---- b/TestModels/Union/runtimes/rust/dafny_impl/src/implementation_from_dafny.rs -+++ a/TestModels/Union/runtimes/rust/dafny_impl/src/implementation_from_dafny.rs -@@ -645,7 +645,7 @@ pub mod r#_simple_dunion_dinternaldafny_dtypes { - message: ::dafny_runtime::Sequence<::dafny_runtime::DafnyCharUTF16>, - }, - Opaque { -- obj: ::dafny_runtime::Object, -+ obj: ::dafny_runtime::Object, - }, - } - -@@ -666,7 +666,7 @@ pub mod r#_simple_dunion_dinternaldafny_dtypes { - Error::Opaque { obj } => panic!("field does not exist on this variant"), - } - } -- pub fn obj(&self) -> &::dafny_runtime::Object { -+ pub fn obj(&self) -> &::dafny_runtime::Object { - match self { - Error::CollectionOfErrors { list, message } => { - panic!("field does not exist on this variant") diff --git b/TestModels/Union/runtimes/rust/src/client.rs a/TestModels/Union/runtimes/rust/src/client.rs new file mode 100644 index 00000000..058b2ed9 diff --git a/codegen/smithy-dafny-codegen/src/main/java/software/amazon/polymorph/CodegenEngine.java b/codegen/smithy-dafny-codegen/src/main/java/software/amazon/polymorph/CodegenEngine.java index fb2cc9c7bc..b5a50535db 100644 --- a/codegen/smithy-dafny-codegen/src/main/java/software/amazon/polymorph/CodegenEngine.java +++ b/codegen/smithy-dafny-codegen/src/main/java/software/amazon/polymorph/CodegenEngine.java @@ -667,12 +667,17 @@ private void generateRust(final Path outputDir) { // by temporarily moving it out of src/ Path outputSrcDir = outputDir.resolve("src"); Path implementationFromDafnyPath = outputSrcDir.resolve("implementation_from_dafny.rs"); + Path tmpPath = null; try { - Path tmpPath = outputDir.resolve("implementation_from_dafny.rs"); - Files.move(implementationFromDafnyPath, tmpPath); + if (Files.exists(implementationFromDafnyPath)) { + tmpPath = outputDir.resolve("implementation_from_dafny.rs"); + Files.move(implementationFromDafnyPath, tmpPath); + } software.amazon.smithy.utils.IoUtils.rmdir(outputSrcDir); outputSrcDir.toFile().mkdirs(); - Files.move(tmpPath, implementationFromDafnyPath); + if (tmpPath != null) { + Files.move(tmpPath, implementationFromDafnyPath); + } } catch (IOException e) { throw new RuntimeException(e); } From ac34eff24f0d202c6e780498b31af2b5f6cc7ff4 Mon Sep 17 00:00:00 2001 From: Robin Salkeld Date: Tue, 9 Jul 2024 13:44:31 -0700 Subject: [PATCH 14/53] Fix SimpleBoolean --- .../SimpleTypes/SimpleBoolean/runtimes/rust/src/client.rs | 2 +- .../runtimes/rust/src/error/sealed_unhandled.rs | 8 ++++++++ 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/TestModels/SimpleTypes/SimpleBoolean/runtimes/rust/src/client.rs b/TestModels/SimpleTypes/SimpleBoolean/runtimes/rust/src/client.rs index 5170a9ce7e..c8b42225fa 100644 --- a/TestModels/SimpleTypes/SimpleBoolean/runtimes/rust/src/client.rs +++ b/TestModels/SimpleTypes/SimpleBoolean/runtimes/rust/src/client.rs @@ -29,7 +29,7 @@ impl Client { )); } Ok(Self { - dafny_client: ::dafny_runtime::UpcastTo::>::upcast_to(inner.Extract()), + dafny_client: ::dafny_runtime::upcast_object::<::simple_boolean_dafny::r#_simple_dtypes_dboolean_dinternaldafny::SimpleBooleanClient, dyn ::simple_boolean_dafny::r#_simple_dtypes_dboolean_dinternaldafny_dtypes::ISimpleTypesBooleanClient>()(inner.Extract()) }) } } diff --git a/TestModels/SimpleTypes/SimpleBoolean/runtimes/rust/src/error/sealed_unhandled.rs b/TestModels/SimpleTypes/SimpleBoolean/runtimes/rust/src/error/sealed_unhandled.rs index 9d21fbd695..4d66eb2ea8 100644 --- a/TestModels/SimpleTypes/SimpleBoolean/runtimes/rust/src/error/sealed_unhandled.rs +++ b/TestModels/SimpleTypes/SimpleBoolean/runtimes/rust/src/error/sealed_unhandled.rs @@ -1,3 +1,7 @@ +use std::any::Any; + +use dafny_runtime::UpcastObject; + // Code generated by software.amazon.smithy.rust.codegen.smithy-rs. DO NOT EDIT. /// This struct is not intended to be used. /// @@ -20,3 +24,7 @@ pub struct Unhandled { pub(crate) source: ::aws_smithy_runtime_api::box_error::BoxError, pub(crate) meta: ::aws_smithy_types::error::metadata::ErrorMetadata, } + +impl UpcastObject for Unhandled { + ::dafny_runtime::UpcastObjectFn!(dyn ::std::any::Any); +} \ No newline at end of file From 9a993453271c378cef3969ebe5da85dd5553eaa6 Mon Sep 17 00:00:00 2001 From: Robin Salkeld Date: Tue, 9 Jul 2024 13:47:37 -0700 Subject: [PATCH 15/53] Much simpler Boolean fix --- .../SimpleTypes/SimpleBoolean/runtimes/rust/src/client.rs | 2 +- .../SimpleBoolean/runtimes/rust/src/conversions/get_boolean.rs | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/TestModels/SimpleTypes/SimpleBoolean/runtimes/rust/src/client.rs b/TestModels/SimpleTypes/SimpleBoolean/runtimes/rust/src/client.rs index c8b42225fa..89478da537 100644 --- a/TestModels/SimpleTypes/SimpleBoolean/runtimes/rust/src/client.rs +++ b/TestModels/SimpleTypes/SimpleBoolean/runtimes/rust/src/client.rs @@ -29,7 +29,7 @@ impl Client { )); } Ok(Self { - dafny_client: ::dafny_runtime::upcast_object::<::simple_boolean_dafny::r#_simple_dtypes_dboolean_dinternaldafny::SimpleBooleanClient, dyn ::simple_boolean_dafny::r#_simple_dtypes_dboolean_dinternaldafny_dtypes::ISimpleTypesBooleanClient>()(inner.Extract()) + dafny_client: ::dafny_runtime::upcast_object()(inner.Extract()) }) } } diff --git a/TestModels/SimpleTypes/SimpleBoolean/runtimes/rust/src/conversions/get_boolean.rs b/TestModels/SimpleTypes/SimpleBoolean/runtimes/rust/src/conversions/get_boolean.rs index 6f9f1b3ca8..065d3ad3c7 100644 --- a/TestModels/SimpleTypes/SimpleBoolean/runtimes/rust/src/conversions/get_boolean.rs +++ b/TestModels/SimpleTypes/SimpleBoolean/runtimes/rust/src/conversions/get_boolean.rs @@ -8,7 +8,7 @@ pub fn to_dafny_error( ) -> ::std::rc::Rc<::simple_boolean_dafny::r#_simple_dtypes_dboolean_dinternaldafny_dtypes::Error> { match value { crate::operation::get_boolean::GetBooleanError::Unhandled(unhandled) => - ::std::rc::Rc::new(::simple_boolean_dafny::r#_simple_dtypes_dboolean_dinternaldafny_dtypes::Error::Opaque { obj: ::dafny_runtime::UpcastTo::<::dafny_runtime::Object>::upcast_to(::dafny_runtime::object::new(unhandled)) }) + ::std::rc::Rc::new(::simple_boolean_dafny::r#_simple_dtypes_dboolean_dinternaldafny_dtypes::Error::Opaque { obj: ::dafny_runtime::upcast_object()(::dafny_runtime::object::new(unhandled)) }) } } From 3b7da6c3cbeb43977768c051e61e0fa6e452d13d Mon Sep 17 00:00:00 2001 From: Robin Salkeld Date: Tue, 9 Jul 2024 13:53:14 -0700 Subject: [PATCH 16/53] Add UpcastObject for Unhandled --- .../Constructor/runtimes/rust/src/error/sealed_unhandled.rs | 4 ++++ .../Refinement/runtimes/rust/src/error/sealed_unhandled.rs | 4 ++++ .../Resource/runtimes/rust/src/error/sealed_unhandled.rs | 4 ++++ .../SimpleBlob/runtimes/rust/src/error/sealed_unhandled.rs | 4 ++++ .../SimpleDouble/runtimes/rust/src/error/sealed_unhandled.rs | 4 ++++ .../SimpleEnum/runtimes/rust/src/error/sealed_unhandled.rs | 4 ++++ .../SimpleEnumV2/runtimes/rust/src/error/sealed_unhandled.rs | 4 ++++ .../SimpleInteger/runtimes/rust/src/error/sealed_unhandled.rs | 4 ++++ .../SimpleLong/runtimes/rust/src/error/sealed_unhandled.rs | 4 ++++ .../SimpleString/runtimes/rust/src/error/sealed_unhandled.rs | 4 ++++ .../runtimes/rust/src/error/sealed_unhandled.rs | 4 ++++ TestModels/Union/runtimes/rust/src/error/sealed_unhandled.rs | 4 ++++ 12 files changed, 48 insertions(+) diff --git a/TestModels/Constructor/runtimes/rust/src/error/sealed_unhandled.rs b/TestModels/Constructor/runtimes/rust/src/error/sealed_unhandled.rs index 9d21fbd695..cce22d1cfd 100644 --- a/TestModels/Constructor/runtimes/rust/src/error/sealed_unhandled.rs +++ b/TestModels/Constructor/runtimes/rust/src/error/sealed_unhandled.rs @@ -20,3 +20,7 @@ pub struct Unhandled { pub(crate) source: ::aws_smithy_runtime_api::box_error::BoxError, pub(crate) meta: ::aws_smithy_types::error::metadata::ErrorMetadata, } + +impl ::dafny_runtime::UpcastObject for Unhandled { + ::dafny_runtime::UpcastObjectFn!(dyn ::std::any::Any); +} diff --git a/TestModels/Refinement/runtimes/rust/src/error/sealed_unhandled.rs b/TestModels/Refinement/runtimes/rust/src/error/sealed_unhandled.rs index 9d21fbd695..cce22d1cfd 100644 --- a/TestModels/Refinement/runtimes/rust/src/error/sealed_unhandled.rs +++ b/TestModels/Refinement/runtimes/rust/src/error/sealed_unhandled.rs @@ -20,3 +20,7 @@ pub struct Unhandled { pub(crate) source: ::aws_smithy_runtime_api::box_error::BoxError, pub(crate) meta: ::aws_smithy_types::error::metadata::ErrorMetadata, } + +impl ::dafny_runtime::UpcastObject for Unhandled { + ::dafny_runtime::UpcastObjectFn!(dyn ::std::any::Any); +} diff --git a/TestModels/Resource/runtimes/rust/src/error/sealed_unhandled.rs b/TestModels/Resource/runtimes/rust/src/error/sealed_unhandled.rs index 9d21fbd695..cce22d1cfd 100644 --- a/TestModels/Resource/runtimes/rust/src/error/sealed_unhandled.rs +++ b/TestModels/Resource/runtimes/rust/src/error/sealed_unhandled.rs @@ -20,3 +20,7 @@ pub struct Unhandled { pub(crate) source: ::aws_smithy_runtime_api::box_error::BoxError, pub(crate) meta: ::aws_smithy_types::error::metadata::ErrorMetadata, } + +impl ::dafny_runtime::UpcastObject for Unhandled { + ::dafny_runtime::UpcastObjectFn!(dyn ::std::any::Any); +} diff --git a/TestModels/SimpleTypes/SimpleBlob/runtimes/rust/src/error/sealed_unhandled.rs b/TestModels/SimpleTypes/SimpleBlob/runtimes/rust/src/error/sealed_unhandled.rs index 9d21fbd695..cce22d1cfd 100644 --- a/TestModels/SimpleTypes/SimpleBlob/runtimes/rust/src/error/sealed_unhandled.rs +++ b/TestModels/SimpleTypes/SimpleBlob/runtimes/rust/src/error/sealed_unhandled.rs @@ -20,3 +20,7 @@ pub struct Unhandled { pub(crate) source: ::aws_smithy_runtime_api::box_error::BoxError, pub(crate) meta: ::aws_smithy_types::error::metadata::ErrorMetadata, } + +impl ::dafny_runtime::UpcastObject for Unhandled { + ::dafny_runtime::UpcastObjectFn!(dyn ::std::any::Any); +} diff --git a/TestModels/SimpleTypes/SimpleDouble/runtimes/rust/src/error/sealed_unhandled.rs b/TestModels/SimpleTypes/SimpleDouble/runtimes/rust/src/error/sealed_unhandled.rs index 9d21fbd695..cce22d1cfd 100644 --- a/TestModels/SimpleTypes/SimpleDouble/runtimes/rust/src/error/sealed_unhandled.rs +++ b/TestModels/SimpleTypes/SimpleDouble/runtimes/rust/src/error/sealed_unhandled.rs @@ -20,3 +20,7 @@ pub struct Unhandled { pub(crate) source: ::aws_smithy_runtime_api::box_error::BoxError, pub(crate) meta: ::aws_smithy_types::error::metadata::ErrorMetadata, } + +impl ::dafny_runtime::UpcastObject for Unhandled { + ::dafny_runtime::UpcastObjectFn!(dyn ::std::any::Any); +} diff --git a/TestModels/SimpleTypes/SimpleEnum/runtimes/rust/src/error/sealed_unhandled.rs b/TestModels/SimpleTypes/SimpleEnum/runtimes/rust/src/error/sealed_unhandled.rs index 9d21fbd695..cce22d1cfd 100644 --- a/TestModels/SimpleTypes/SimpleEnum/runtimes/rust/src/error/sealed_unhandled.rs +++ b/TestModels/SimpleTypes/SimpleEnum/runtimes/rust/src/error/sealed_unhandled.rs @@ -20,3 +20,7 @@ pub struct Unhandled { pub(crate) source: ::aws_smithy_runtime_api::box_error::BoxError, pub(crate) meta: ::aws_smithy_types::error::metadata::ErrorMetadata, } + +impl ::dafny_runtime::UpcastObject for Unhandled { + ::dafny_runtime::UpcastObjectFn!(dyn ::std::any::Any); +} diff --git a/TestModels/SimpleTypes/SimpleEnumV2/runtimes/rust/src/error/sealed_unhandled.rs b/TestModels/SimpleTypes/SimpleEnumV2/runtimes/rust/src/error/sealed_unhandled.rs index 9d21fbd695..cce22d1cfd 100644 --- a/TestModels/SimpleTypes/SimpleEnumV2/runtimes/rust/src/error/sealed_unhandled.rs +++ b/TestModels/SimpleTypes/SimpleEnumV2/runtimes/rust/src/error/sealed_unhandled.rs @@ -20,3 +20,7 @@ pub struct Unhandled { pub(crate) source: ::aws_smithy_runtime_api::box_error::BoxError, pub(crate) meta: ::aws_smithy_types::error::metadata::ErrorMetadata, } + +impl ::dafny_runtime::UpcastObject for Unhandled { + ::dafny_runtime::UpcastObjectFn!(dyn ::std::any::Any); +} diff --git a/TestModels/SimpleTypes/SimpleInteger/runtimes/rust/src/error/sealed_unhandled.rs b/TestModels/SimpleTypes/SimpleInteger/runtimes/rust/src/error/sealed_unhandled.rs index 9d21fbd695..cce22d1cfd 100644 --- a/TestModels/SimpleTypes/SimpleInteger/runtimes/rust/src/error/sealed_unhandled.rs +++ b/TestModels/SimpleTypes/SimpleInteger/runtimes/rust/src/error/sealed_unhandled.rs @@ -20,3 +20,7 @@ pub struct Unhandled { pub(crate) source: ::aws_smithy_runtime_api::box_error::BoxError, pub(crate) meta: ::aws_smithy_types::error::metadata::ErrorMetadata, } + +impl ::dafny_runtime::UpcastObject for Unhandled { + ::dafny_runtime::UpcastObjectFn!(dyn ::std::any::Any); +} diff --git a/TestModels/SimpleTypes/SimpleLong/runtimes/rust/src/error/sealed_unhandled.rs b/TestModels/SimpleTypes/SimpleLong/runtimes/rust/src/error/sealed_unhandled.rs index 9d21fbd695..cce22d1cfd 100644 --- a/TestModels/SimpleTypes/SimpleLong/runtimes/rust/src/error/sealed_unhandled.rs +++ b/TestModels/SimpleTypes/SimpleLong/runtimes/rust/src/error/sealed_unhandled.rs @@ -20,3 +20,7 @@ pub struct Unhandled { pub(crate) source: ::aws_smithy_runtime_api::box_error::BoxError, pub(crate) meta: ::aws_smithy_types::error::metadata::ErrorMetadata, } + +impl ::dafny_runtime::UpcastObject for Unhandled { + ::dafny_runtime::UpcastObjectFn!(dyn ::std::any::Any); +} diff --git a/TestModels/SimpleTypes/SimpleString/runtimes/rust/src/error/sealed_unhandled.rs b/TestModels/SimpleTypes/SimpleString/runtimes/rust/src/error/sealed_unhandled.rs index 9d21fbd695..cce22d1cfd 100644 --- a/TestModels/SimpleTypes/SimpleString/runtimes/rust/src/error/sealed_unhandled.rs +++ b/TestModels/SimpleTypes/SimpleString/runtimes/rust/src/error/sealed_unhandled.rs @@ -20,3 +20,7 @@ pub struct Unhandled { pub(crate) source: ::aws_smithy_runtime_api::box_error::BoxError, pub(crate) meta: ::aws_smithy_types::error::metadata::ErrorMetadata, } + +impl ::dafny_runtime::UpcastObject for Unhandled { + ::dafny_runtime::UpcastObjectFn!(dyn ::std::any::Any); +} diff --git a/TestModels/SimpleTypes/SimpleTimestamp/runtimes/rust/src/error/sealed_unhandled.rs b/TestModels/SimpleTypes/SimpleTimestamp/runtimes/rust/src/error/sealed_unhandled.rs index 9d21fbd695..cce22d1cfd 100644 --- a/TestModels/SimpleTypes/SimpleTimestamp/runtimes/rust/src/error/sealed_unhandled.rs +++ b/TestModels/SimpleTypes/SimpleTimestamp/runtimes/rust/src/error/sealed_unhandled.rs @@ -20,3 +20,7 @@ pub struct Unhandled { pub(crate) source: ::aws_smithy_runtime_api::box_error::BoxError, pub(crate) meta: ::aws_smithy_types::error::metadata::ErrorMetadata, } + +impl ::dafny_runtime::UpcastObject for Unhandled { + ::dafny_runtime::UpcastObjectFn!(dyn ::std::any::Any); +} diff --git a/TestModels/Union/runtimes/rust/src/error/sealed_unhandled.rs b/TestModels/Union/runtimes/rust/src/error/sealed_unhandled.rs index 9d21fbd695..cce22d1cfd 100644 --- a/TestModels/Union/runtimes/rust/src/error/sealed_unhandled.rs +++ b/TestModels/Union/runtimes/rust/src/error/sealed_unhandled.rs @@ -20,3 +20,7 @@ pub struct Unhandled { pub(crate) source: ::aws_smithy_runtime_api::box_error::BoxError, pub(crate) meta: ::aws_smithy_types::error::metadata::ErrorMetadata, } + +impl ::dafny_runtime::UpcastObject for Unhandled { + ::dafny_runtime::UpcastObjectFn!(dyn ::std::any::Any); +} From 59aaed212cd1952a7af7f5e8c3f8a74f8533c002 Mon Sep 17 00:00:00 2001 From: Robin Salkeld Date: Tue, 9 Jul 2024 13:56:50 -0700 Subject: [PATCH 17/53] Replace most uses of UpcastTo --- .../Aggregate/runtimes/rust/src/conversions/get_aggregate.rs | 2 +- .../rust/src/conversions/get_aggregate_known_value_test.rs | 2 +- .../Constructor/runtimes/rust/src/conversions/get_stub.rs | 2 +- .../Refinement/runtimes/rust/src/conversions/get_refinement.rs | 2 +- .../Refinement/runtimes/rust/src/conversions/only_input.rs | 2 +- .../Refinement/runtimes/rust/src/conversions/only_output.rs | 2 +- .../runtimes/rust/src/conversions/readonly_operation.rs | 2 +- .../Resource/runtimes/rust/src/conversions/get_resource_data.rs | 2 +- .../Resource/runtimes/rust/src/conversions/get_resources.rs | 2 +- .../SimpleBlob/runtimes/rust/src/conversions/get_blob.rs | 2 +- .../runtimes/rust/src/conversions/get_blob_known_value.rs | 2 +- .../SimpleDouble/runtimes/rust/src/conversions/get_double.rs | 2 +- .../SimpleEnum/runtimes/rust/src/conversions/get_enum.rs | 2 +- .../rust/src/conversions/get_enum_first_known_value_test.rs | 2 +- .../rust/src/conversions/get_enum_second_known_value_test.rs | 2 +- .../rust/src/conversions/get_enum_third_known_value_test.rs | 2 +- .../SimpleEnumV2/runtimes/rust/src/conversions/get_enum_v2.rs | 2 +- .../rust/src/conversions/get_enum_v2_first_known_value_test.rs | 2 +- .../rust/src/conversions/get_enum_v2_second_known_value_test.rs | 2 +- .../rust/src/conversions/get_enum_v2_third_known_value_test.rs | 2 +- .../SimpleInteger/runtimes/rust/src/conversions/get_integer.rs | 2 +- .../runtimes/rust/src/conversions/get_integer_known_value.rs | 2 +- .../SimpleLong/runtimes/rust/src/conversions/get_long.rs | 2 +- .../runtimes/rust/src/conversions/get_long_known_value.rs | 2 +- TestModels/SimpleTypes/SimpleString/runtimes/rust/src/client.rs | 2 +- .../SimpleString/runtimes/rust/src/conversions/get_string.rs | 2 +- .../runtimes/rust/src/conversions/get_string_known_value.rs | 2 +- .../runtimes/rust/src/conversions/get_string_utf8.rs | 2 +- .../runtimes/rust/src/conversions/get_timestamp.rs | 2 +- .../runtimes/rust/src/conversions/get_known_value_union.rs | 2 +- TestModels/Union/runtimes/rust/src/conversions/get_union.rs | 2 +- 31 files changed, 31 insertions(+), 31 deletions(-) diff --git a/TestModels/Aggregate/runtimes/rust/src/conversions/get_aggregate.rs b/TestModels/Aggregate/runtimes/rust/src/conversions/get_aggregate.rs index 1918663b4d..8db680b567 100644 --- a/TestModels/Aggregate/runtimes/rust/src/conversions/get_aggregate.rs +++ b/TestModels/Aggregate/runtimes/rust/src/conversions/get_aggregate.rs @@ -8,7 +8,7 @@ pub fn to_dafny_error( ) -> ::std::rc::Rc<::simple_aggregate_dafny::r#_simple_daggregate_dinternaldafny_dtypes::Error> { match value { crate::operation::get_aggregate::GetAggregateError::Unhandled(unhandled) => - ::std::rc::Rc::new(::simple_aggregate_dafny::r#_simple_daggregate_dinternaldafny_dtypes::Error::Opaque { obj: ::dafny_runtime::UpcastTo::<::dafny_runtime::Object>::upcast_to(::dafny_runtime::object::new(unhandled)) }) + ::std::rc::Rc::new(::simple_aggregate_dafny::r#_simple_daggregate_dinternaldafny_dtypes::Error::Opaque { obj: ::dafny_runtime::upcast_object()(::dafny_runtime::object::new(unhandled)) }) } } diff --git a/TestModels/Aggregate/runtimes/rust/src/conversions/get_aggregate_known_value_test.rs b/TestModels/Aggregate/runtimes/rust/src/conversions/get_aggregate_known_value_test.rs index e013077c7a..a128f451fa 100644 --- a/TestModels/Aggregate/runtimes/rust/src/conversions/get_aggregate_known_value_test.rs +++ b/TestModels/Aggregate/runtimes/rust/src/conversions/get_aggregate_known_value_test.rs @@ -11,7 +11,7 @@ pub fn to_dafny_error( unhandled, ) => ::std::rc::Rc::new( ::simple_aggregate_dafny::r#_simple_daggregate_dinternaldafny_dtypes::Error::Opaque { - obj: ::dafny_runtime::UpcastTo::<::dafny_runtime::Object>::upcast_to( + obj: ::dafny_runtime::upcast_object()( ::dafny_runtime::object::new(unhandled), ), }, diff --git a/TestModels/Constructor/runtimes/rust/src/conversions/get_stub.rs b/TestModels/Constructor/runtimes/rust/src/conversions/get_stub.rs index acbb9a2c61..b36281ef40 100644 --- a/TestModels/Constructor/runtimes/rust/src/conversions/get_stub.rs +++ b/TestModels/Constructor/runtimes/rust/src/conversions/get_stub.rs @@ -9,7 +9,7 @@ pub fn to_dafny_error( match value { crate::operation::get_stub::GetStubError::Unhandled(unhandled) => { ::std::rc::Rc::new(::stub_dafny::r#_stub_dinternaldafny_dtypes::Error::Opaque { - obj: ::dafny_runtime::UpcastTo::<::dafny_runtime::Object>::upcast_to( + obj: ::dafny_runtime::upcast_object()( ::dafny_runtime::object::new(unhandled), ), }) diff --git a/TestModels/Refinement/runtimes/rust/src/conversions/get_refinement.rs b/TestModels/Refinement/runtimes/rust/src/conversions/get_refinement.rs index 7d9afc33c1..600b000825 100644 --- a/TestModels/Refinement/runtimes/rust/src/conversions/get_refinement.rs +++ b/TestModels/Refinement/runtimes/rust/src/conversions/get_refinement.rs @@ -8,7 +8,7 @@ pub fn to_dafny_error( ) -> ::std::rc::Rc<::simple_refinement_dafny::r#_simple_drefinement_dinternaldafny_dtypes::Error> { match value { crate::operation::get_refinement::GetRefinementError::Unhandled(unhandled) => - ::std::rc::Rc::new(::simple_refinement_dafny::r#_simple_drefinement_dinternaldafny_dtypes::Error::Opaque { obj: ::dafny_runtime::UpcastTo::<::dafny_runtime::Object>::upcast_to(::dafny_runtime::object::new(unhandled)) }) + ::std::rc::Rc::new(::simple_refinement_dafny::r#_simple_drefinement_dinternaldafny_dtypes::Error::Opaque { obj: ::dafny_runtime::upcast_object()(::dafny_runtime::object::new(unhandled)) }) } } diff --git a/TestModels/Refinement/runtimes/rust/src/conversions/only_input.rs b/TestModels/Refinement/runtimes/rust/src/conversions/only_input.rs index 68745fe3e8..080dfdc9bd 100644 --- a/TestModels/Refinement/runtimes/rust/src/conversions/only_input.rs +++ b/TestModels/Refinement/runtimes/rust/src/conversions/only_input.rs @@ -9,7 +9,7 @@ pub fn to_dafny_error( match value { crate::operation::only_input::OnlyInputError::Unhandled(unhandled) => ::std::rc::Rc::new( ::simple_refinement_dafny::r#_simple_drefinement_dinternaldafny_dtypes::Error::Opaque { - obj: ::dafny_runtime::UpcastTo::<::dafny_runtime::Object>::upcast_to( + obj: ::dafny_runtime::upcast_object()( ::dafny_runtime::object::new(unhandled), ), }, diff --git a/TestModels/Refinement/runtimes/rust/src/conversions/only_output.rs b/TestModels/Refinement/runtimes/rust/src/conversions/only_output.rs index 2dfa7b014d..e0cde99f73 100644 --- a/TestModels/Refinement/runtimes/rust/src/conversions/only_output.rs +++ b/TestModels/Refinement/runtimes/rust/src/conversions/only_output.rs @@ -9,7 +9,7 @@ pub fn to_dafny_error( match value { crate::operation::only_output::OnlyOutputError::Unhandled(unhandled) => ::std::rc::Rc::new( ::simple_refinement_dafny::r#_simple_drefinement_dinternaldafny_dtypes::Error::Opaque { - obj: ::dafny_runtime::UpcastTo::<::dafny_runtime::Object>::upcast_to( + obj: ::dafny_runtime::upcast_object()( ::dafny_runtime::object::new(unhandled), ), }, diff --git a/TestModels/Refinement/runtimes/rust/src/conversions/readonly_operation.rs b/TestModels/Refinement/runtimes/rust/src/conversions/readonly_operation.rs index e584f835ba..c19efc31a9 100644 --- a/TestModels/Refinement/runtimes/rust/src/conversions/readonly_operation.rs +++ b/TestModels/Refinement/runtimes/rust/src/conversions/readonly_operation.rs @@ -8,7 +8,7 @@ pub fn to_dafny_error( ) -> ::std::rc::Rc<::simple_refinement_dafny::r#_simple_drefinement_dinternaldafny_dtypes::Error> { match value { crate::operation::readonly_operation::ReadonlyOperationError::Unhandled(unhandled) => - ::std::rc::Rc::new(::simple_refinement_dafny::r#_simple_drefinement_dinternaldafny_dtypes::Error::Opaque { obj: ::dafny_runtime::UpcastTo::<::dafny_runtime::Object>::upcast_to(::dafny_runtime::object::new(unhandled)) }) + ::std::rc::Rc::new(::simple_refinement_dafny::r#_simple_drefinement_dinternaldafny_dtypes::Error::Opaque { obj: ::dafny_runtime::upcast_object()(::dafny_runtime::object::new(unhandled)) }) } } diff --git a/TestModels/Resource/runtimes/rust/src/conversions/get_resource_data.rs b/TestModels/Resource/runtimes/rust/src/conversions/get_resource_data.rs index 358e1fd1c7..6ea51fa753 100644 --- a/TestModels/Resource/runtimes/rust/src/conversions/get_resource_data.rs +++ b/TestModels/Resource/runtimes/rust/src/conversions/get_resource_data.rs @@ -8,7 +8,7 @@ pub fn to_dafny_error( ) -> ::std::rc::Rc<::simple_resources_dafny::r#_simple_dresources_dinternaldafny_dtypes::Error> { match value { crate::operation::get_resource_data::GetResourceDataError::Unhandled(unhandled) => - ::std::rc::Rc::new(::simple_resources_dafny::r#_simple_dresources_dinternaldafny_dtypes::Error::Opaque { obj: ::dafny_runtime::UpcastTo::<::dafny_runtime::Object>::upcast_to(::dafny_runtime::object::new(unhandled)) }) + ::std::rc::Rc::new(::simple_resources_dafny::r#_simple_dresources_dinternaldafny_dtypes::Error::Opaque { obj: ::dafny_runtime::upcast_object()(::dafny_runtime::object::new(unhandled)) }) } } diff --git a/TestModels/Resource/runtimes/rust/src/conversions/get_resources.rs b/TestModels/Resource/runtimes/rust/src/conversions/get_resources.rs index b0b6bd951f..115f6d0610 100644 --- a/TestModels/Resource/runtimes/rust/src/conversions/get_resources.rs +++ b/TestModels/Resource/runtimes/rust/src/conversions/get_resources.rs @@ -8,7 +8,7 @@ pub fn to_dafny_error( ) -> ::std::rc::Rc<::simple_resources_dafny::r#_simple_dresources_dinternaldafny_dtypes::Error> { match value { crate::operation::get_resources::GetResourcesError::Unhandled(unhandled) => - ::std::rc::Rc::new(::simple_resources_dafny::r#_simple_dresources_dinternaldafny_dtypes::Error::Opaque { obj: ::dafny_runtime::UpcastTo::<::dafny_runtime::Object>::upcast_to(::dafny_runtime::object::new(unhandled)) }) + ::std::rc::Rc::new(::simple_resources_dafny::r#_simple_dresources_dinternaldafny_dtypes::Error::Opaque { obj: ::dafny_runtime::upcast_object()(::dafny_runtime::object::new(unhandled)) }) } } diff --git a/TestModels/SimpleTypes/SimpleBlob/runtimes/rust/src/conversions/get_blob.rs b/TestModels/SimpleTypes/SimpleBlob/runtimes/rust/src/conversions/get_blob.rs index 1ebbffeff0..deef9ee2cd 100644 --- a/TestModels/SimpleTypes/SimpleBlob/runtimes/rust/src/conversions/get_blob.rs +++ b/TestModels/SimpleTypes/SimpleBlob/runtimes/rust/src/conversions/get_blob.rs @@ -9,7 +9,7 @@ pub fn to_dafny_error( match value { crate::operation::get_blob::GetBlobError::Unhandled(unhandled) => ::std::rc::Rc::new( ::simple_blob_dafny::r#_simple_dtypes_dblob_dinternaldafny_dtypes::Error::Opaque { - obj: ::dafny_runtime::UpcastTo::<::dafny_runtime::Object>::upcast_to( + obj: ::dafny_runtime::upcast_object()( ::dafny_runtime::object::new(unhandled), ), }, diff --git a/TestModels/SimpleTypes/SimpleBlob/runtimes/rust/src/conversions/get_blob_known_value.rs b/TestModels/SimpleTypes/SimpleBlob/runtimes/rust/src/conversions/get_blob_known_value.rs index 6d8eea5f0a..60b2c1afdf 100644 --- a/TestModels/SimpleTypes/SimpleBlob/runtimes/rust/src/conversions/get_blob_known_value.rs +++ b/TestModels/SimpleTypes/SimpleBlob/runtimes/rust/src/conversions/get_blob_known_value.rs @@ -10,7 +10,7 @@ pub fn to_dafny_error( crate::operation::get_blob_known_value::GetBlobKnownValueError::Unhandled(unhandled) => { ::std::rc::Rc::new( ::simple_blob_dafny::r#_simple_dtypes_dblob_dinternaldafny_dtypes::Error::Opaque { - obj: ::dafny_runtime::UpcastTo::<::dafny_runtime::Object>::upcast_to( + obj: ::dafny_runtime::upcast_object()( ::dafny_runtime::object::new(unhandled), ), }, diff --git a/TestModels/SimpleTypes/SimpleDouble/runtimes/rust/src/conversions/get_double.rs b/TestModels/SimpleTypes/SimpleDouble/runtimes/rust/src/conversions/get_double.rs index f3d619f52b..9befae93af 100644 --- a/TestModels/SimpleTypes/SimpleDouble/runtimes/rust/src/conversions/get_double.rs +++ b/TestModels/SimpleTypes/SimpleDouble/runtimes/rust/src/conversions/get_double.rs @@ -9,7 +9,7 @@ pub fn to_dafny_error( { match value { crate::operation::get_double::GetDoubleError::Unhandled(unhandled) => - ::std::rc::Rc::new(::simple_double_dafny::r#_simple_dtypes_dsmithydouble_dinternaldafny_dtypes::Error::Opaque { obj: ::dafny_runtime::UpcastTo::<::dafny_runtime::Object>::upcast_to(::dafny_runtime::object::new(unhandled)) }) + ::std::rc::Rc::new(::simple_double_dafny::r#_simple_dtypes_dsmithydouble_dinternaldafny_dtypes::Error::Opaque { obj: ::dafny_runtime::upcast_object()(::dafny_runtime::object::new(unhandled)) }) } } diff --git a/TestModels/SimpleTypes/SimpleEnum/runtimes/rust/src/conversions/get_enum.rs b/TestModels/SimpleTypes/SimpleEnum/runtimes/rust/src/conversions/get_enum.rs index 99364fbd26..a33e611aca 100644 --- a/TestModels/SimpleTypes/SimpleEnum/runtimes/rust/src/conversions/get_enum.rs +++ b/TestModels/SimpleTypes/SimpleEnum/runtimes/rust/src/conversions/get_enum.rs @@ -8,7 +8,7 @@ pub fn to_dafny_error( ) -> ::std::rc::Rc<::simple_enum_dafny::r#_simple_dtypes_dsmithyenum_dinternaldafny_dtypes::Error> { match value { crate::operation::get_enum::GetEnumError::Unhandled(unhandled) => - ::std::rc::Rc::new(::simple_enum_dafny::r#_simple_dtypes_dsmithyenum_dinternaldafny_dtypes::Error::Opaque { obj: ::dafny_runtime::UpcastTo::<::dafny_runtime::Object>::upcast_to(::dafny_runtime::object::new(unhandled)) }) + ::std::rc::Rc::new(::simple_enum_dafny::r#_simple_dtypes_dsmithyenum_dinternaldafny_dtypes::Error::Opaque { obj: ::dafny_runtime::upcast_object()(::dafny_runtime::object::new(unhandled)) }) } } diff --git a/TestModels/SimpleTypes/SimpleEnum/runtimes/rust/src/conversions/get_enum_first_known_value_test.rs b/TestModels/SimpleTypes/SimpleEnum/runtimes/rust/src/conversions/get_enum_first_known_value_test.rs index 017185b7f8..6806b7be02 100644 --- a/TestModels/SimpleTypes/SimpleEnum/runtimes/rust/src/conversions/get_enum_first_known_value_test.rs +++ b/TestModels/SimpleTypes/SimpleEnum/runtimes/rust/src/conversions/get_enum_first_known_value_test.rs @@ -8,7 +8,7 @@ pub fn to_dafny_error( ) -> ::std::rc::Rc<::simple_enum_dafny::r#_simple_dtypes_dsmithyenum_dinternaldafny_dtypes::Error> { match value { crate::operation::get_enum_first_known_value_test::GetEnumFirstKnownValueTestError::Unhandled(unhandled) => - ::std::rc::Rc::new(::simple_enum_dafny::r#_simple_dtypes_dsmithyenum_dinternaldafny_dtypes::Error::Opaque { obj: ::dafny_runtime::UpcastTo::<::dafny_runtime::Object>::upcast_to(::dafny_runtime::object::new(unhandled)) }) + ::std::rc::Rc::new(::simple_enum_dafny::r#_simple_dtypes_dsmithyenum_dinternaldafny_dtypes::Error::Opaque { obj: ::dafny_runtime::upcast_object()(::dafny_runtime::object::new(unhandled)) }) } } diff --git a/TestModels/SimpleTypes/SimpleEnum/runtimes/rust/src/conversions/get_enum_second_known_value_test.rs b/TestModels/SimpleTypes/SimpleEnum/runtimes/rust/src/conversions/get_enum_second_known_value_test.rs index f9446f6518..0db8ed1734 100644 --- a/TestModels/SimpleTypes/SimpleEnum/runtimes/rust/src/conversions/get_enum_second_known_value_test.rs +++ b/TestModels/SimpleTypes/SimpleEnum/runtimes/rust/src/conversions/get_enum_second_known_value_test.rs @@ -8,7 +8,7 @@ pub fn to_dafny_error( ) -> ::std::rc::Rc<::simple_enum_dafny::r#_simple_dtypes_dsmithyenum_dinternaldafny_dtypes::Error> { match value { crate::operation::get_enum_second_known_value_test::GetEnumSecondKnownValueTestError::Unhandled(unhandled) => - ::std::rc::Rc::new(::simple_enum_dafny::r#_simple_dtypes_dsmithyenum_dinternaldafny_dtypes::Error::Opaque { obj: ::dafny_runtime::UpcastTo::<::dafny_runtime::Object>::upcast_to(::dafny_runtime::object::new(unhandled)) }) + ::std::rc::Rc::new(::simple_enum_dafny::r#_simple_dtypes_dsmithyenum_dinternaldafny_dtypes::Error::Opaque { obj: ::dafny_runtime::upcast_object()(::dafny_runtime::object::new(unhandled)) }) } } diff --git a/TestModels/SimpleTypes/SimpleEnum/runtimes/rust/src/conversions/get_enum_third_known_value_test.rs b/TestModels/SimpleTypes/SimpleEnum/runtimes/rust/src/conversions/get_enum_third_known_value_test.rs index d1ea363535..29ed2353f2 100644 --- a/TestModels/SimpleTypes/SimpleEnum/runtimes/rust/src/conversions/get_enum_third_known_value_test.rs +++ b/TestModels/SimpleTypes/SimpleEnum/runtimes/rust/src/conversions/get_enum_third_known_value_test.rs @@ -8,7 +8,7 @@ pub fn to_dafny_error( ) -> ::std::rc::Rc<::simple_enum_dafny::r#_simple_dtypes_dsmithyenum_dinternaldafny_dtypes::Error> { match value { crate::operation::get_enum_third_known_value_test::GetEnumThirdKnownValueTestError::Unhandled(unhandled) => - ::std::rc::Rc::new(::simple_enum_dafny::r#_simple_dtypes_dsmithyenum_dinternaldafny_dtypes::Error::Opaque { obj: ::dafny_runtime::UpcastTo::<::dafny_runtime::Object>::upcast_to(::dafny_runtime::object::new(unhandled)) }) + ::std::rc::Rc::new(::simple_enum_dafny::r#_simple_dtypes_dsmithyenum_dinternaldafny_dtypes::Error::Opaque { obj: ::dafny_runtime::upcast_object()(::dafny_runtime::object::new(unhandled)) }) } } diff --git a/TestModels/SimpleTypes/SimpleEnumV2/runtimes/rust/src/conversions/get_enum_v2.rs b/TestModels/SimpleTypes/SimpleEnumV2/runtimes/rust/src/conversions/get_enum_v2.rs index c018494a33..ee62a4b265 100644 --- a/TestModels/SimpleTypes/SimpleEnumV2/runtimes/rust/src/conversions/get_enum_v2.rs +++ b/TestModels/SimpleTypes/SimpleEnumV2/runtimes/rust/src/conversions/get_enum_v2.rs @@ -9,7 +9,7 @@ pub fn to_dafny_error( match value { crate::operation::get_enum_v2::GetEnumV2Error::Unhandled(unhandled) => ::std::rc::Rc::new( ::simple_enum_v2_dafny::r#_simple_dtypes_denumv2_dinternaldafny_dtypes::Error::Opaque { - obj: ::dafny_runtime::UpcastTo::<::dafny_runtime::Object>::upcast_to( + obj: ::dafny_runtime::upcast_object()( ::dafny_runtime::object::new(unhandled), ), }, diff --git a/TestModels/SimpleTypes/SimpleEnumV2/runtimes/rust/src/conversions/get_enum_v2_first_known_value_test.rs b/TestModels/SimpleTypes/SimpleEnumV2/runtimes/rust/src/conversions/get_enum_v2_first_known_value_test.rs index 45440aaaf3..772c94f55c 100644 --- a/TestModels/SimpleTypes/SimpleEnumV2/runtimes/rust/src/conversions/get_enum_v2_first_known_value_test.rs +++ b/TestModels/SimpleTypes/SimpleEnumV2/runtimes/rust/src/conversions/get_enum_v2_first_known_value_test.rs @@ -8,7 +8,7 @@ pub fn to_dafny_error( ) -> ::std::rc::Rc<::simple_enum_v2_dafny::r#_simple_dtypes_denumv2_dinternaldafny_dtypes::Error> { match value { crate::operation::get_enum_v2_first_known_value_test::GetEnumV2FirstKnownValueTestError::Unhandled(unhandled) => - ::std::rc::Rc::new(::simple_enum_v2_dafny::r#_simple_dtypes_denumv2_dinternaldafny_dtypes::Error::Opaque { obj: ::dafny_runtime::UpcastTo::<::dafny_runtime::Object>::upcast_to(::dafny_runtime::object::new(unhandled)) }) + ::std::rc::Rc::new(::simple_enum_v2_dafny::r#_simple_dtypes_denumv2_dinternaldafny_dtypes::Error::Opaque { obj: ::dafny_runtime::upcast_object()(::dafny_runtime::object::new(unhandled)) }) } } diff --git a/TestModels/SimpleTypes/SimpleEnumV2/runtimes/rust/src/conversions/get_enum_v2_second_known_value_test.rs b/TestModels/SimpleTypes/SimpleEnumV2/runtimes/rust/src/conversions/get_enum_v2_second_known_value_test.rs index b3ce715818..94e88a860b 100644 --- a/TestModels/SimpleTypes/SimpleEnumV2/runtimes/rust/src/conversions/get_enum_v2_second_known_value_test.rs +++ b/TestModels/SimpleTypes/SimpleEnumV2/runtimes/rust/src/conversions/get_enum_v2_second_known_value_test.rs @@ -8,7 +8,7 @@ pub fn to_dafny_error( ) -> ::std::rc::Rc<::simple_enum_v2_dafny::r#_simple_dtypes_denumv2_dinternaldafny_dtypes::Error> { match value { crate::operation::get_enum_v2_second_known_value_test::GetEnumV2SecondKnownValueTestError::Unhandled(unhandled) => - ::std::rc::Rc::new(::simple_enum_v2_dafny::r#_simple_dtypes_denumv2_dinternaldafny_dtypes::Error::Opaque { obj: ::dafny_runtime::UpcastTo::<::dafny_runtime::Object>::upcast_to(::dafny_runtime::object::new(unhandled)) }) + ::std::rc::Rc::new(::simple_enum_v2_dafny::r#_simple_dtypes_denumv2_dinternaldafny_dtypes::Error::Opaque { obj: ::dafny_runtime::upcast_object()(::dafny_runtime::object::new(unhandled)) }) } } diff --git a/TestModels/SimpleTypes/SimpleEnumV2/runtimes/rust/src/conversions/get_enum_v2_third_known_value_test.rs b/TestModels/SimpleTypes/SimpleEnumV2/runtimes/rust/src/conversions/get_enum_v2_third_known_value_test.rs index c8edb2e8cb..7176a32a8e 100644 --- a/TestModels/SimpleTypes/SimpleEnumV2/runtimes/rust/src/conversions/get_enum_v2_third_known_value_test.rs +++ b/TestModels/SimpleTypes/SimpleEnumV2/runtimes/rust/src/conversions/get_enum_v2_third_known_value_test.rs @@ -8,7 +8,7 @@ pub fn to_dafny_error( ) -> ::std::rc::Rc<::simple_enum_v2_dafny::r#_simple_dtypes_denumv2_dinternaldafny_dtypes::Error> { match value { crate::operation::get_enum_v2_third_known_value_test::GetEnumV2ThirdKnownValueTestError::Unhandled(unhandled) => - ::std::rc::Rc::new(::simple_enum_v2_dafny::r#_simple_dtypes_denumv2_dinternaldafny_dtypes::Error::Opaque { obj: ::dafny_runtime::UpcastTo::<::dafny_runtime::Object>::upcast_to(::dafny_runtime::object::new(unhandled)) }) + ::std::rc::Rc::new(::simple_enum_v2_dafny::r#_simple_dtypes_denumv2_dinternaldafny_dtypes::Error::Opaque { obj: ::dafny_runtime::upcast_object()(::dafny_runtime::object::new(unhandled)) }) } } diff --git a/TestModels/SimpleTypes/SimpleInteger/runtimes/rust/src/conversions/get_integer.rs b/TestModels/SimpleTypes/SimpleInteger/runtimes/rust/src/conversions/get_integer.rs index 97230cfc72..120cac99ee 100644 --- a/TestModels/SimpleTypes/SimpleInteger/runtimes/rust/src/conversions/get_integer.rs +++ b/TestModels/SimpleTypes/SimpleInteger/runtimes/rust/src/conversions/get_integer.rs @@ -8,7 +8,7 @@ pub fn to_dafny_error( ) -> ::std::rc::Rc<::simple_integer_dafny::r#_simple_dtypes_dinteger_dinternaldafny_dtypes::Error> { match value { crate::operation::get_integer::GetIntegerError::Unhandled(unhandled) => - ::std::rc::Rc::new(::simple_integer_dafny::r#_simple_dtypes_dinteger_dinternaldafny_dtypes::Error::Opaque { obj: ::dafny_runtime::UpcastTo::<::dafny_runtime::Object>::upcast_to(::dafny_runtime::object::new(unhandled)) }) + ::std::rc::Rc::new(::simple_integer_dafny::r#_simple_dtypes_dinteger_dinternaldafny_dtypes::Error::Opaque { obj: ::dafny_runtime::upcast_object()(::dafny_runtime::object::new(unhandled)) }) } } diff --git a/TestModels/SimpleTypes/SimpleInteger/runtimes/rust/src/conversions/get_integer_known_value.rs b/TestModels/SimpleTypes/SimpleInteger/runtimes/rust/src/conversions/get_integer_known_value.rs index 2710a5eac5..91f83c4d12 100644 --- a/TestModels/SimpleTypes/SimpleInteger/runtimes/rust/src/conversions/get_integer_known_value.rs +++ b/TestModels/SimpleTypes/SimpleInteger/runtimes/rust/src/conversions/get_integer_known_value.rs @@ -8,7 +8,7 @@ pub fn to_dafny_error( ) -> ::std::rc::Rc<::simple_integer_dafny::r#_simple_dtypes_dinteger_dinternaldafny_dtypes::Error> { match value { crate::operation::get_integer_known_value::GetIntegerKnownValueError::Unhandled(unhandled) => - ::std::rc::Rc::new(::simple_integer_dafny::r#_simple_dtypes_dinteger_dinternaldafny_dtypes::Error::Opaque { obj: ::dafny_runtime::UpcastTo::<::dafny_runtime::Object>::upcast_to(::dafny_runtime::object::new(unhandled)) }) + ::std::rc::Rc::new(::simple_integer_dafny::r#_simple_dtypes_dinteger_dinternaldafny_dtypes::Error::Opaque { obj: ::dafny_runtime::upcast_object()(::dafny_runtime::object::new(unhandled)) }) } } diff --git a/TestModels/SimpleTypes/SimpleLong/runtimes/rust/src/conversions/get_long.rs b/TestModels/SimpleTypes/SimpleLong/runtimes/rust/src/conversions/get_long.rs index 86e9ba5c63..85d0d5ad8c 100644 --- a/TestModels/SimpleTypes/SimpleLong/runtimes/rust/src/conversions/get_long.rs +++ b/TestModels/SimpleTypes/SimpleLong/runtimes/rust/src/conversions/get_long.rs @@ -8,7 +8,7 @@ pub fn to_dafny_error( ) -> ::std::rc::Rc<::simple_long_dafny::r#_simple_dtypes_dsmithylong_dinternaldafny_dtypes::Error> { match value { crate::operation::get_long::GetLongError::Unhandled(unhandled) => - ::std::rc::Rc::new(::simple_long_dafny::r#_simple_dtypes_dsmithylong_dinternaldafny_dtypes::Error::Opaque { obj: ::dafny_runtime::UpcastTo::<::dafny_runtime::Object>::upcast_to(::dafny_runtime::object::new(unhandled)) }) + ::std::rc::Rc::new(::simple_long_dafny::r#_simple_dtypes_dsmithylong_dinternaldafny_dtypes::Error::Opaque { obj: ::dafny_runtime::upcast_object()(::dafny_runtime::object::new(unhandled)) }) } } diff --git a/TestModels/SimpleTypes/SimpleLong/runtimes/rust/src/conversions/get_long_known_value.rs b/TestModels/SimpleTypes/SimpleLong/runtimes/rust/src/conversions/get_long_known_value.rs index c34bda65a3..63f0c94374 100644 --- a/TestModels/SimpleTypes/SimpleLong/runtimes/rust/src/conversions/get_long_known_value.rs +++ b/TestModels/SimpleTypes/SimpleLong/runtimes/rust/src/conversions/get_long_known_value.rs @@ -8,7 +8,7 @@ pub fn to_dafny_error( ) -> ::std::rc::Rc<::simple_long_dafny::r#_simple_dtypes_dsmithylong_dinternaldafny_dtypes::Error> { match value { crate::operation::get_long_known_value::GetLongKnownValueError::Unhandled(unhandled) => - ::std::rc::Rc::new(::simple_long_dafny::r#_simple_dtypes_dsmithylong_dinternaldafny_dtypes::Error::Opaque { obj: ::dafny_runtime::UpcastTo::<::dafny_runtime::Object>::upcast_to(::dafny_runtime::object::new(unhandled)) }) + ::std::rc::Rc::new(::simple_long_dafny::r#_simple_dtypes_dsmithylong_dinternaldafny_dtypes::Error::Opaque { obj: ::dafny_runtime::upcast_object()(::dafny_runtime::object::new(unhandled)) }) } } diff --git a/TestModels/SimpleTypes/SimpleString/runtimes/rust/src/client.rs b/TestModels/SimpleTypes/SimpleString/runtimes/rust/src/client.rs index f54152e5f4..188bbeb5b4 100644 --- a/TestModels/SimpleTypes/SimpleString/runtimes/rust/src/client.rs +++ b/TestModels/SimpleTypes/SimpleString/runtimes/rust/src/client.rs @@ -31,7 +31,7 @@ impl Client { )); } Ok(Self { - dafny_client: ::dafny_runtime::UpcastTo::>::upcast_to(inner.Extract()), + dafny_client: ::dafny_runtime::upcast_object()(inner.Extract()), }) } } diff --git a/TestModels/SimpleTypes/SimpleString/runtimes/rust/src/conversions/get_string.rs b/TestModels/SimpleTypes/SimpleString/runtimes/rust/src/conversions/get_string.rs index 337142c06e..ddd7a65ed0 100644 --- a/TestModels/SimpleTypes/SimpleString/runtimes/rust/src/conversions/get_string.rs +++ b/TestModels/SimpleTypes/SimpleString/runtimes/rust/src/conversions/get_string.rs @@ -9,7 +9,7 @@ pub fn to_dafny_error( { match value { crate::operation::get_string::GetStringError::Unhandled(unhandled) => - ::std::rc::Rc::new(::simple_string_dafny::r#_simple_dtypes_dsmithystring_dinternaldafny_dtypes::Error::Opaque { obj: ::dafny_runtime::UpcastTo::<::dafny_runtime::Object>::upcast_to(::dafny_runtime::object::new(unhandled)) }) + ::std::rc::Rc::new(::simple_string_dafny::r#_simple_dtypes_dsmithystring_dinternaldafny_dtypes::Error::Opaque { obj: ::dafny_runtime::upcast_object()(::dafny_runtime::object::new(unhandled)) }) } } diff --git a/TestModels/SimpleTypes/SimpleString/runtimes/rust/src/conversions/get_string_known_value.rs b/TestModels/SimpleTypes/SimpleString/runtimes/rust/src/conversions/get_string_known_value.rs index 33d5010eb2..cbde58b764 100644 --- a/TestModels/SimpleTypes/SimpleString/runtimes/rust/src/conversions/get_string_known_value.rs +++ b/TestModels/SimpleTypes/SimpleString/runtimes/rust/src/conversions/get_string_known_value.rs @@ -9,7 +9,7 @@ pub fn to_dafny_error( { match value { crate::operation::get_string_known_value::GetStringKnownValueError::Unhandled(unhandled) => - ::std::rc::Rc::new(::simple_string_dafny::r#_simple_dtypes_dsmithystring_dinternaldafny_dtypes::Error::Opaque { obj: ::dafny_runtime::UpcastTo::<::dafny_runtime::Object>::upcast_to(::dafny_runtime::object::new(unhandled)) }) + ::std::rc::Rc::new(::simple_string_dafny::r#_simple_dtypes_dsmithystring_dinternaldafny_dtypes::Error::Opaque { obj: ::dafny_runtime::upcast_object()(::dafny_runtime::object::new(unhandled)) }) } } diff --git a/TestModels/SimpleTypes/SimpleString/runtimes/rust/src/conversions/get_string_utf8.rs b/TestModels/SimpleTypes/SimpleString/runtimes/rust/src/conversions/get_string_utf8.rs index 972bf50109..00fa066f10 100644 --- a/TestModels/SimpleTypes/SimpleString/runtimes/rust/src/conversions/get_string_utf8.rs +++ b/TestModels/SimpleTypes/SimpleString/runtimes/rust/src/conversions/get_string_utf8.rs @@ -9,7 +9,7 @@ pub fn to_dafny_error( { match value { crate::operation::get_string_utf8::GetStringUTF8Error::Unhandled(unhandled) => - ::std::rc::Rc::new(::simple_string_dafny::r#_simple_dtypes_dsmithystring_dinternaldafny_dtypes::Error::Opaque { obj: ::dafny_runtime::UpcastTo::<::dafny_runtime::Object>::upcast_to(::dafny_runtime::object::new(unhandled)) }) + ::std::rc::Rc::new(::simple_string_dafny::r#_simple_dtypes_dsmithystring_dinternaldafny_dtypes::Error::Opaque { obj: ::dafny_runtime::upcast_object()(::dafny_runtime::object::new(unhandled)) }) } } diff --git a/TestModels/SimpleTypes/SimpleTimestamp/runtimes/rust/src/conversions/get_timestamp.rs b/TestModels/SimpleTypes/SimpleTimestamp/runtimes/rust/src/conversions/get_timestamp.rs index db47687e09..143c522a12 100644 --- a/TestModels/SimpleTypes/SimpleTimestamp/runtimes/rust/src/conversions/get_timestamp.rs +++ b/TestModels/SimpleTypes/SimpleTimestamp/runtimes/rust/src/conversions/get_timestamp.rs @@ -9,7 +9,7 @@ pub fn to_dafny_error( { match value { crate::operation::get_timestamp::GetTimestampError::Unhandled(unhandled) => - ::std::rc::Rc::new(::simple_timestamp_dafny::r#_simple_dtypes_dtimestamp_dinternaldafny_dtypes::Error::Opaque { obj: ::dafny_runtime::UpcastTo::<::dafny_runtime::Object>::upcast_to(::dafny_runtime::object::new(unhandled)) }) + ::std::rc::Rc::new(::simple_timestamp_dafny::r#_simple_dtypes_dtimestamp_dinternaldafny_dtypes::Error::Opaque { obj: ::dafny_runtime::upcast_object()(::dafny_runtime::object::new(unhandled)) }) } } diff --git a/TestModels/Union/runtimes/rust/src/conversions/get_known_value_union.rs b/TestModels/Union/runtimes/rust/src/conversions/get_known_value_union.rs index a88ee78b71..fd4a8a05d0 100644 --- a/TestModels/Union/runtimes/rust/src/conversions/get_known_value_union.rs +++ b/TestModels/Union/runtimes/rust/src/conversions/get_known_value_union.rs @@ -10,7 +10,7 @@ pub fn to_dafny_error( crate::operation::get_known_value_union::GetKnownValueUnionError::Unhandled(unhandled) => { ::std::rc::Rc::new( ::simple_union_dafny::r#_simple_dunion_dinternaldafny_dtypes::Error::Opaque { - obj: ::dafny_runtime::UpcastTo::<::dafny_runtime::Object>::upcast_to( + obj: ::dafny_runtime::upcast_object()( ::dafny_runtime::object::new(unhandled), ), }, diff --git a/TestModels/Union/runtimes/rust/src/conversions/get_union.rs b/TestModels/Union/runtimes/rust/src/conversions/get_union.rs index 658f0c1786..7346e3dd4f 100644 --- a/TestModels/Union/runtimes/rust/src/conversions/get_union.rs +++ b/TestModels/Union/runtimes/rust/src/conversions/get_union.rs @@ -9,7 +9,7 @@ pub fn to_dafny_error( match value { crate::operation::get_union::GetUnionError::Unhandled(unhandled) => ::std::rc::Rc::new( ::simple_union_dafny::r#_simple_dunion_dinternaldafny_dtypes::Error::Opaque { - obj: ::dafny_runtime::UpcastTo::<::dafny_runtime::Object>::upcast_to( + obj: ::dafny_runtime::upcast_object()( ::dafny_runtime::object::new(unhandled), ), }, From 3449728d783798c56408d8af3250d7dd8c29fdba Mon Sep 17 00:00:00 2001 From: Robin Salkeld Date: Tue, 9 Jul 2024 14:01:13 -0700 Subject: [PATCH 18/53] Fix the rest --- TestModels/Aggregate/runtimes/rust/src/client.rs | 2 +- TestModels/Constructor/runtimes/rust/src/client.rs | 6 +----- TestModels/Refinement/runtimes/rust/src/client.rs | 2 +- TestModels/Resource/runtimes/rust/src/client.rs | 2 +- .../SimpleTypes/SimpleBlob/runtimes/rust/src/client.rs | 2 +- .../SimpleTypes/SimpleDouble/runtimes/rust/src/client.rs | 2 +- .../SimpleTypes/SimpleEnum/runtimes/rust/src/client.rs | 2 +- .../SimpleTypes/SimpleEnumV2/runtimes/rust/src/client.rs | 2 +- .../SimpleTypes/SimpleInteger/runtimes/rust/src/client.rs | 2 +- .../SimpleTypes/SimpleLong/runtimes/rust/src/client.rs | 2 +- .../SimpleTypes/SimpleTimestamp/runtimes/rust/src/client.rs | 2 +- TestModels/Union/runtimes/rust/src/client.rs | 2 +- 12 files changed, 12 insertions(+), 16 deletions(-) diff --git a/TestModels/Aggregate/runtimes/rust/src/client.rs b/TestModels/Aggregate/runtimes/rust/src/client.rs index d5fef50592..96a89e4dab 100644 --- a/TestModels/Aggregate/runtimes/rust/src/client.rs +++ b/TestModels/Aggregate/runtimes/rust/src/client.rs @@ -33,7 +33,7 @@ impl Client { )); } Ok(Self { - dafny_client: ::dafny_runtime::UpcastTo::>::upcast_to(inner.Extract()), + dafny_client: ::dafny_runtime::upcast_object()(inner.Extract()), }) } } diff --git a/TestModels/Constructor/runtimes/rust/src/client.rs b/TestModels/Constructor/runtimes/rust/src/client.rs index 8e935d3421..69ff2b94bb 100644 --- a/TestModels/Constructor/runtimes/rust/src/client.rs +++ b/TestModels/Constructor/runtimes/rust/src/client.rs @@ -36,11 +36,7 @@ impl Client { } let handle = Handle { conf: conf.clone(), - inner: ::dafny_runtime::UpcastTo::< - dafny_runtime::Object< - (dyn ::stub_dafny::r#_stub_dinternaldafny_dtypes::IStubClient + 'static), - >, - >::upcast_to(inner.Extract()), + inner: ::dafny_runtime::upcast_object()(inner.Extract()), }; Ok(Self { handle: ::std::sync::Arc::new(handle), diff --git a/TestModels/Refinement/runtimes/rust/src/client.rs b/TestModels/Refinement/runtimes/rust/src/client.rs index d7e87890b2..d13672bd88 100644 --- a/TestModels/Refinement/runtimes/rust/src/client.rs +++ b/TestModels/Refinement/runtimes/rust/src/client.rs @@ -29,7 +29,7 @@ impl Client { )); } Ok(Self { - dafny_client: ::dafny_runtime::UpcastTo::>::upcast_to(inner.Extract()), + dafny_client: ::dafny_runtime::upcast_object()(inner.Extract()), }) } } diff --git a/TestModels/Resource/runtimes/rust/src/client.rs b/TestModels/Resource/runtimes/rust/src/client.rs index a6d9e55b86..3a3b2ebe0e 100644 --- a/TestModels/Resource/runtimes/rust/src/client.rs +++ b/TestModels/Resource/runtimes/rust/src/client.rs @@ -31,7 +31,7 @@ impl Client { )); } Ok(Self { - dafny_client: ::dafny_runtime::UpcastTo::>::upcast_to(inner.Extract()), + dafny_client: ::dafny_runtime::upcast_object()(inner.Extract()), }) } } diff --git a/TestModels/SimpleTypes/SimpleBlob/runtimes/rust/src/client.rs b/TestModels/SimpleTypes/SimpleBlob/runtimes/rust/src/client.rs index 32d3eb4ebd..f46656e4b4 100644 --- a/TestModels/SimpleTypes/SimpleBlob/runtimes/rust/src/client.rs +++ b/TestModels/SimpleTypes/SimpleBlob/runtimes/rust/src/client.rs @@ -28,7 +28,7 @@ impl Client { )); } Ok(Self { - dafny_client: ::dafny_runtime::UpcastTo::>::upcast_to(inner.Extract()), + dafny_client: ::dafny_runtime::upcast_object()(inner.Extract()), }) } } diff --git a/TestModels/SimpleTypes/SimpleDouble/runtimes/rust/src/client.rs b/TestModels/SimpleTypes/SimpleDouble/runtimes/rust/src/client.rs index 49a87808fb..34c9f354a7 100644 --- a/TestModels/SimpleTypes/SimpleDouble/runtimes/rust/src/client.rs +++ b/TestModels/SimpleTypes/SimpleDouble/runtimes/rust/src/client.rs @@ -29,7 +29,7 @@ impl Client { )); } Ok(Self { - dafny_client: ::dafny_runtime::UpcastTo::>::upcast_to(inner.Extract()), + dafny_client: ::dafny_runtime::upcast_object()(inner.Extract()), }) } } diff --git a/TestModels/SimpleTypes/SimpleEnum/runtimes/rust/src/client.rs b/TestModels/SimpleTypes/SimpleEnum/runtimes/rust/src/client.rs index de79713cf8..d1fd739c08 100644 --- a/TestModels/SimpleTypes/SimpleEnum/runtimes/rust/src/client.rs +++ b/TestModels/SimpleTypes/SimpleEnum/runtimes/rust/src/client.rs @@ -29,7 +29,7 @@ impl Client { )); } Ok(Self { - dafny_client: ::dafny_runtime::UpcastTo::>::upcast_to(inner.Extract()), + dafny_client: ::dafny_runtime::upcast_object()(inner.Extract()), }) } } diff --git a/TestModels/SimpleTypes/SimpleEnumV2/runtimes/rust/src/client.rs b/TestModels/SimpleTypes/SimpleEnumV2/runtimes/rust/src/client.rs index 7009f03172..cccf551e87 100644 --- a/TestModels/SimpleTypes/SimpleEnumV2/runtimes/rust/src/client.rs +++ b/TestModels/SimpleTypes/SimpleEnumV2/runtimes/rust/src/client.rs @@ -29,7 +29,7 @@ impl Client { )); } Ok(Self { - dafny_client: ::dafny_runtime::UpcastTo::>::upcast_to(inner.Extract()), + dafny_client: ::dafny_runtime::upcast_object()(inner.Extract()), }) } } diff --git a/TestModels/SimpleTypes/SimpleInteger/runtimes/rust/src/client.rs b/TestModels/SimpleTypes/SimpleInteger/runtimes/rust/src/client.rs index 0450cb9350..d5f1af4212 100644 --- a/TestModels/SimpleTypes/SimpleInteger/runtimes/rust/src/client.rs +++ b/TestModels/SimpleTypes/SimpleInteger/runtimes/rust/src/client.rs @@ -29,7 +29,7 @@ impl Client { )); } Ok(Self { - dafny_client: ::dafny_runtime::UpcastTo::>::upcast_to(inner.Extract()), + dafny_client: ::dafny_runtime::upcast_object()(inner.Extract()), }) } } diff --git a/TestModels/SimpleTypes/SimpleLong/runtimes/rust/src/client.rs b/TestModels/SimpleTypes/SimpleLong/runtimes/rust/src/client.rs index 8fb3793c87..014f1471b7 100644 --- a/TestModels/SimpleTypes/SimpleLong/runtimes/rust/src/client.rs +++ b/TestModels/SimpleTypes/SimpleLong/runtimes/rust/src/client.rs @@ -29,7 +29,7 @@ impl Client { )); } Ok(Self { - dafny_client: ::dafny_runtime::UpcastTo::>::upcast_to(inner.Extract()), + dafny_client: ::dafny_runtime::upcast_object()(inner.Extract()), }) } } diff --git a/TestModels/SimpleTypes/SimpleTimestamp/runtimes/rust/src/client.rs b/TestModels/SimpleTypes/SimpleTimestamp/runtimes/rust/src/client.rs index 016316d127..3c8bf267e2 100644 --- a/TestModels/SimpleTypes/SimpleTimestamp/runtimes/rust/src/client.rs +++ b/TestModels/SimpleTypes/SimpleTimestamp/runtimes/rust/src/client.rs @@ -29,7 +29,7 @@ impl Client { )); } Ok(Self { - dafny_client: ::dafny_runtime::UpcastTo::>::upcast_to(inner.Extract()), + dafny_client: ::dafny_runtime::upcast_object()(inner.Extract()), }) } } diff --git a/TestModels/Union/runtimes/rust/src/client.rs b/TestModels/Union/runtimes/rust/src/client.rs index 058b2ed9ac..d96f6d1266 100644 --- a/TestModels/Union/runtimes/rust/src/client.rs +++ b/TestModels/Union/runtimes/rust/src/client.rs @@ -30,7 +30,7 @@ impl Client { )); } Ok(Self { - dafny_client: ::dafny_runtime::UpcastTo::>::upcast_to(inner.Extract()), + dafny_client: ::dafny_runtime::upcast_object()(inner.Extract()), }) } } From af7138d18b86717a166b9d603a46fa67e78a00e5 Mon Sep 17 00:00:00 2001 From: Robin Salkeld Date: Tue, 9 Jul 2024 14:02:49 -0700 Subject: [PATCH 19/53] =?UTF-8?q?Don=E2=80=99t=20check=20in=20implementati?= =?UTF-8?q?on=5Ffrom=5Fdafny.rs=20any=20more?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../src/implementation_from_dafny.rs | 1412 ----------------- .../src/implementation_from_dafny.rs | 1306 --------------- .../src/implementation_from_dafny.rs | 1298 --------------- .../src/implementation_from_dafny.rs | 843 ---------- .../src/implementation_from_dafny.rs | 641 -------- .../src/implementation_from_dafny.rs | 649 -------- .../src/implementation_from_dafny.rs | 986 ------------ .../src/implementation_from_dafny.rs | 1098 ------------- .../src/implementation_from_dafny.rs | 709 --------- .../src/implementation_from_dafny.rs | 761 --------- .../src/implementation_from_dafny.rs | 767 --------- .../src/implementation_from_dafny.rs | 1096 ------------- 12 files changed, 11566 deletions(-) delete mode 100644 TestModels/Aggregate/runtimes/rust/dafny_impl/src/implementation_from_dafny.rs delete mode 100644 TestModels/Refinement/runtimes/rust/dafny_impl/src/implementation_from_dafny.rs delete mode 100644 TestModels/Resource/runtimes/rust/dafny_impl/src/implementation_from_dafny.rs delete mode 100644 TestModels/SimpleTypes/SimpleBlob/runtimes/rust/dafny_impl/src/implementation_from_dafny.rs delete mode 100644 TestModels/SimpleTypes/SimpleBoolean/runtimes/rust/dafny_impl/src/implementation_from_dafny.rs delete mode 100644 TestModels/SimpleTypes/SimpleDouble/runtimes/rust/dafny_impl/src/implementation_from_dafny.rs delete mode 100644 TestModels/SimpleTypes/SimpleEnum/runtimes/rust/dafny_impl/src/implementation_from_dafny.rs delete mode 100644 TestModels/SimpleTypes/SimpleEnumV2/runtimes/rust/dafny_impl/src/implementation_from_dafny.rs delete mode 100644 TestModels/SimpleTypes/SimpleInteger/runtimes/rust/dafny_impl/src/implementation_from_dafny.rs delete mode 100644 TestModels/SimpleTypes/SimpleLong/runtimes/rust/dafny_impl/src/implementation_from_dafny.rs delete mode 100644 TestModels/SimpleTypes/SimpleString/runtimes/rust/dafny_impl/src/implementation_from_dafny.rs delete mode 100644 TestModels/Union/runtimes/rust/dafny_impl/src/implementation_from_dafny.rs diff --git a/TestModels/Aggregate/runtimes/rust/dafny_impl/src/implementation_from_dafny.rs b/TestModels/Aggregate/runtimes/rust/dafny_impl/src/implementation_from_dafny.rs deleted file mode 100644 index 6e8d6407bd..0000000000 --- a/TestModels/Aggregate/runtimes/rust/dafny_impl/src/implementation_from_dafny.rs +++ /dev/null @@ -1,1412 +0,0 @@ -#![allow(warnings, unconditional_panic)] -#![allow(nonstandard_style)] -pub use dafny_standard_library::implementation_from_dafny::*; - -pub mod r#_simple_daggregate_dinternaldafny_dtypes { - #[derive(PartialEq, Clone)] - pub enum DafnyCallEvent { - DafnyCallEvent { input: I, output: O }, - _PhantomVariant(::std::marker::PhantomData, ::std::marker::PhantomData), - } - - impl DafnyCallEvent { - pub fn input(&self) -> &I { - match self { - DafnyCallEvent::DafnyCallEvent { input, output } => input, - DafnyCallEvent::_PhantomVariant(..) => panic!(), - } - } - pub fn output(&self) -> &O { - match self { - DafnyCallEvent::DafnyCallEvent { input, output } => output, - DafnyCallEvent::_PhantomVariant(..) => panic!(), - } - } - } - - impl ::std::fmt::Debug - for DafnyCallEvent - { - fn fmt(&self, f: &mut ::std::fmt::Formatter) -> std::fmt::Result { - ::dafny_runtime::DafnyPrint::fmt_print(self, f, true) - } - } - - impl ::dafny_runtime::DafnyPrint - for DafnyCallEvent - { - fn fmt_print( - &self, - _formatter: &mut ::std::fmt::Formatter, - _in_seq: bool, - ) -> std::fmt::Result { - match self { - DafnyCallEvent::DafnyCallEvent { input, output } => { - write!( - _formatter, - "r#_simple_daggregate_dinternaldafny_dtypes.DafnyCallEvent.DafnyCallEvent(" - )?; - ::dafny_runtime::DafnyPrint::fmt_print(input, _formatter, false)?; - write!(_formatter, ", ")?; - ::dafny_runtime::DafnyPrint::fmt_print(output, _formatter, false)?; - write!(_formatter, ")")?; - Ok(()) - } - DafnyCallEvent::_PhantomVariant(..) => { - panic!() - } - } - } - } - - impl Eq - for DafnyCallEvent - { - } - - impl< - I: ::dafny_runtime::DafnyType + ::std::hash::Hash, - O: ::dafny_runtime::DafnyType + ::std::hash::Hash, - > ::std::hash::Hash for DafnyCallEvent - { - fn hash<_H: ::std::hash::Hasher>(&self, _state: &mut _H) { - match self { - DafnyCallEvent::DafnyCallEvent { input, output } => { - input.hash(_state); - output.hash(_state) - } - DafnyCallEvent::_PhantomVariant(..) => { - panic!() - } - } - } - } - - impl< - I: ::dafny_runtime::DafnyType + ::std::default::Default, - O: ::dafny_runtime::DafnyType + ::std::default::Default, - > ::std::default::Default for DafnyCallEvent - { - fn default() -> DafnyCallEvent { - DafnyCallEvent::DafnyCallEvent { - input: ::std::default::Default::default(), - output: ::std::default::Default::default(), - } - } - } - - impl - ::std::convert::AsRef> for &DafnyCallEvent - { - fn as_ref(&self) -> Self { - self - } - } - - #[derive(PartialEq, Clone)] - pub enum GetAggregateInput { - GetAggregateInput { - simpleStringList: ::std::rc::Rc< - super::r#_Wrappers_Compile::Option< - ::dafny_runtime::Sequence< - ::dafny_runtime::Sequence<::dafny_runtime::DafnyCharUTF16>, - >, - >, - >, - structureList: ::std::rc::Rc< - super::r#_Wrappers_Compile::Option< - ::dafny_runtime::Sequence< - ::std::rc::Rc< - super::r#_simple_daggregate_dinternaldafny_dtypes::StructureListElement, - >, - >, - >, - >, - simpleStringMap: ::std::rc::Rc< - super::r#_Wrappers_Compile::Option< - ::dafny_runtime::Map< - ::dafny_runtime::Sequence<::dafny_runtime::DafnyCharUTF16>, - ::dafny_runtime::Sequence<::dafny_runtime::DafnyCharUTF16>, - >, - >, - >, - simpleIntegerMap: ::std::rc::Rc< - super::r#_Wrappers_Compile::Option< - ::dafny_runtime::Map< - ::dafny_runtime::Sequence<::dafny_runtime::DafnyCharUTF16>, - i32, - >, - >, - >, - nestedStructure: ::std::rc::Rc< - super::r#_Wrappers_Compile::Option< - ::std::rc::Rc< - super::r#_simple_daggregate_dinternaldafny_dtypes::NestedStructure, - >, - >, - >, - }, - } - - impl GetAggregateInput { - pub fn simpleStringList( - &self, - ) -> &::std::rc::Rc< - super::r#_Wrappers_Compile::Option< - ::dafny_runtime::Sequence< - ::dafny_runtime::Sequence<::dafny_runtime::DafnyCharUTF16>, - >, - >, - > { - match self { - GetAggregateInput::GetAggregateInput { - simpleStringList, - structureList, - simpleStringMap, - simpleIntegerMap, - nestedStructure, - } => simpleStringList, - } - } - pub fn structureList( - &self, - ) -> &::std::rc::Rc< - super::r#_Wrappers_Compile::Option< - ::dafny_runtime::Sequence< - ::std::rc::Rc< - super::r#_simple_daggregate_dinternaldafny_dtypes::StructureListElement, - >, - >, - >, - > { - match self { - GetAggregateInput::GetAggregateInput { - simpleStringList, - structureList, - simpleStringMap, - simpleIntegerMap, - nestedStructure, - } => structureList, - } - } - pub fn simpleStringMap( - &self, - ) -> &::std::rc::Rc< - super::r#_Wrappers_Compile::Option< - ::dafny_runtime::Map< - ::dafny_runtime::Sequence<::dafny_runtime::DafnyCharUTF16>, - ::dafny_runtime::Sequence<::dafny_runtime::DafnyCharUTF16>, - >, - >, - > { - match self { - GetAggregateInput::GetAggregateInput { - simpleStringList, - structureList, - simpleStringMap, - simpleIntegerMap, - nestedStructure, - } => simpleStringMap, - } - } - pub fn simpleIntegerMap( - &self, - ) -> &::std::rc::Rc< - super::r#_Wrappers_Compile::Option< - ::dafny_runtime::Map< - ::dafny_runtime::Sequence<::dafny_runtime::DafnyCharUTF16>, - i32, - >, - >, - > { - match self { - GetAggregateInput::GetAggregateInput { - simpleStringList, - structureList, - simpleStringMap, - simpleIntegerMap, - nestedStructure, - } => simpleIntegerMap, - } - } - pub fn nestedStructure( - &self, - ) -> &::std::rc::Rc< - super::r#_Wrappers_Compile::Option< - ::std::rc::Rc, - >, - > { - match self { - GetAggregateInput::GetAggregateInput { - simpleStringList, - structureList, - simpleStringMap, - simpleIntegerMap, - nestedStructure, - } => nestedStructure, - } - } - } - - impl ::std::fmt::Debug for GetAggregateInput { - fn fmt(&self, f: &mut ::std::fmt::Formatter) -> std::fmt::Result { - ::dafny_runtime::DafnyPrint::fmt_print(self, f, true) - } - } - - impl ::dafny_runtime::DafnyPrint for GetAggregateInput { - fn fmt_print( - &self, - _formatter: &mut ::std::fmt::Formatter, - _in_seq: bool, - ) -> std::fmt::Result { - match self { - GetAggregateInput::GetAggregateInput { - simpleStringList, - structureList, - simpleStringMap, - simpleIntegerMap, - nestedStructure, - } => { - write!(_formatter, "r#_simple_daggregate_dinternaldafny_dtypes.GetAggregateInput.GetAggregateInput(")?; - ::dafny_runtime::DafnyPrint::fmt_print(simpleStringList, _formatter, false)?; - write!(_formatter, ", ")?; - ::dafny_runtime::DafnyPrint::fmt_print(structureList, _formatter, false)?; - write!(_formatter, ", ")?; - ::dafny_runtime::DafnyPrint::fmt_print(simpleStringMap, _formatter, false)?; - write!(_formatter, ", ")?; - ::dafny_runtime::DafnyPrint::fmt_print(simpleIntegerMap, _formatter, false)?; - write!(_formatter, ", ")?; - ::dafny_runtime::DafnyPrint::fmt_print(nestedStructure, _formatter, false)?; - write!(_formatter, ")")?; - Ok(()) - } - } - } - } - - impl Eq for GetAggregateInput {} - - impl ::std::hash::Hash for GetAggregateInput { - fn hash<_H: ::std::hash::Hasher>(&self, _state: &mut _H) { - match self { - GetAggregateInput::GetAggregateInput { - simpleStringList, - structureList, - simpleStringMap, - simpleIntegerMap, - nestedStructure, - } => { - simpleStringList.hash(_state); - structureList.hash(_state); - simpleStringMap.hash(_state); - simpleIntegerMap.hash(_state); - nestedStructure.hash(_state) - } - } - } - } - - impl ::std::default::Default for GetAggregateInput { - fn default() -> GetAggregateInput { - GetAggregateInput::GetAggregateInput { - simpleStringList: ::std::default::Default::default(), - structureList: ::std::default::Default::default(), - simpleStringMap: ::std::default::Default::default(), - simpleIntegerMap: ::std::default::Default::default(), - nestedStructure: ::std::default::Default::default(), - } - } - } - - impl ::std::convert::AsRef for &GetAggregateInput { - fn as_ref(&self) -> Self { - self - } - } - - #[derive(PartialEq, Clone)] - pub enum GetAggregateOutput { - GetAggregateOutput { - simpleStringList: ::std::rc::Rc< - super::r#_Wrappers_Compile::Option< - ::dafny_runtime::Sequence< - ::dafny_runtime::Sequence<::dafny_runtime::DafnyCharUTF16>, - >, - >, - >, - structureList: ::std::rc::Rc< - super::r#_Wrappers_Compile::Option< - ::dafny_runtime::Sequence< - ::std::rc::Rc< - super::r#_simple_daggregate_dinternaldafny_dtypes::StructureListElement, - >, - >, - >, - >, - simpleStringMap: ::std::rc::Rc< - super::r#_Wrappers_Compile::Option< - ::dafny_runtime::Map< - ::dafny_runtime::Sequence<::dafny_runtime::DafnyCharUTF16>, - ::dafny_runtime::Sequence<::dafny_runtime::DafnyCharUTF16>, - >, - >, - >, - simpleIntegerMap: ::std::rc::Rc< - super::r#_Wrappers_Compile::Option< - ::dafny_runtime::Map< - ::dafny_runtime::Sequence<::dafny_runtime::DafnyCharUTF16>, - i32, - >, - >, - >, - nestedStructure: ::std::rc::Rc< - super::r#_Wrappers_Compile::Option< - ::std::rc::Rc< - super::r#_simple_daggregate_dinternaldafny_dtypes::NestedStructure, - >, - >, - >, - }, - } - - impl GetAggregateOutput { - pub fn simpleStringList( - &self, - ) -> &::std::rc::Rc< - super::r#_Wrappers_Compile::Option< - ::dafny_runtime::Sequence< - ::dafny_runtime::Sequence<::dafny_runtime::DafnyCharUTF16>, - >, - >, - > { - match self { - GetAggregateOutput::GetAggregateOutput { - simpleStringList, - structureList, - simpleStringMap, - simpleIntegerMap, - nestedStructure, - } => simpleStringList, - } - } - pub fn structureList( - &self, - ) -> &::std::rc::Rc< - super::r#_Wrappers_Compile::Option< - ::dafny_runtime::Sequence< - ::std::rc::Rc< - super::r#_simple_daggregate_dinternaldafny_dtypes::StructureListElement, - >, - >, - >, - > { - match self { - GetAggregateOutput::GetAggregateOutput { - simpleStringList, - structureList, - simpleStringMap, - simpleIntegerMap, - nestedStructure, - } => structureList, - } - } - pub fn simpleStringMap( - &self, - ) -> &::std::rc::Rc< - super::r#_Wrappers_Compile::Option< - ::dafny_runtime::Map< - ::dafny_runtime::Sequence<::dafny_runtime::DafnyCharUTF16>, - ::dafny_runtime::Sequence<::dafny_runtime::DafnyCharUTF16>, - >, - >, - > { - match self { - GetAggregateOutput::GetAggregateOutput { - simpleStringList, - structureList, - simpleStringMap, - simpleIntegerMap, - nestedStructure, - } => simpleStringMap, - } - } - pub fn simpleIntegerMap( - &self, - ) -> &::std::rc::Rc< - super::r#_Wrappers_Compile::Option< - ::dafny_runtime::Map< - ::dafny_runtime::Sequence<::dafny_runtime::DafnyCharUTF16>, - i32, - >, - >, - > { - match self { - GetAggregateOutput::GetAggregateOutput { - simpleStringList, - structureList, - simpleStringMap, - simpleIntegerMap, - nestedStructure, - } => simpleIntegerMap, - } - } - pub fn nestedStructure( - &self, - ) -> &::std::rc::Rc< - super::r#_Wrappers_Compile::Option< - ::std::rc::Rc, - >, - > { - match self { - GetAggregateOutput::GetAggregateOutput { - simpleStringList, - structureList, - simpleStringMap, - simpleIntegerMap, - nestedStructure, - } => nestedStructure, - } - } - } - - impl ::std::fmt::Debug for GetAggregateOutput { - fn fmt(&self, f: &mut ::std::fmt::Formatter) -> std::fmt::Result { - ::dafny_runtime::DafnyPrint::fmt_print(self, f, true) - } - } - - impl ::dafny_runtime::DafnyPrint for GetAggregateOutput { - fn fmt_print( - &self, - _formatter: &mut ::std::fmt::Formatter, - _in_seq: bool, - ) -> std::fmt::Result { - match self { - GetAggregateOutput::GetAggregateOutput { - simpleStringList, - structureList, - simpleStringMap, - simpleIntegerMap, - nestedStructure, - } => { - write!(_formatter, "r#_simple_daggregate_dinternaldafny_dtypes.GetAggregateOutput.GetAggregateOutput(")?; - ::dafny_runtime::DafnyPrint::fmt_print(simpleStringList, _formatter, false)?; - write!(_formatter, ", ")?; - ::dafny_runtime::DafnyPrint::fmt_print(structureList, _formatter, false)?; - write!(_formatter, ", ")?; - ::dafny_runtime::DafnyPrint::fmt_print(simpleStringMap, _formatter, false)?; - write!(_formatter, ", ")?; - ::dafny_runtime::DafnyPrint::fmt_print(simpleIntegerMap, _formatter, false)?; - write!(_formatter, ", ")?; - ::dafny_runtime::DafnyPrint::fmt_print(nestedStructure, _formatter, false)?; - write!(_formatter, ")")?; - Ok(()) - } - } - } - } - - impl Eq for GetAggregateOutput {} - - impl ::std::hash::Hash for GetAggregateOutput { - fn hash<_H: ::std::hash::Hasher>(&self, _state: &mut _H) { - match self { - GetAggregateOutput::GetAggregateOutput { - simpleStringList, - structureList, - simpleStringMap, - simpleIntegerMap, - nestedStructure, - } => { - simpleStringList.hash(_state); - structureList.hash(_state); - simpleStringMap.hash(_state); - simpleIntegerMap.hash(_state); - nestedStructure.hash(_state) - } - } - } - } - - impl ::std::default::Default for GetAggregateOutput { - fn default() -> GetAggregateOutput { - GetAggregateOutput::GetAggregateOutput { - simpleStringList: ::std::default::Default::default(), - structureList: ::std::default::Default::default(), - simpleStringMap: ::std::default::Default::default(), - simpleIntegerMap: ::std::default::Default::default(), - nestedStructure: ::std::default::Default::default(), - } - } - } - - impl ::std::convert::AsRef for &GetAggregateOutput { - fn as_ref(&self) -> Self { - self - } - } - - #[derive(PartialEq, Clone)] - pub enum NestedStructure { - NestedStructure { - stringStructure: ::std::rc::Rc< - super::r#_Wrappers_Compile::Option< - ::std::rc::Rc< - super::r#_simple_daggregate_dinternaldafny_dtypes::StringStructure, - >, - >, - >, - }, - } - - impl NestedStructure { - pub fn stringStructure( - &self, - ) -> &::std::rc::Rc< - super::r#_Wrappers_Compile::Option< - ::std::rc::Rc, - >, - > { - match self { - NestedStructure::NestedStructure { stringStructure } => stringStructure, - } - } - } - - impl ::std::fmt::Debug for NestedStructure { - fn fmt(&self, f: &mut ::std::fmt::Formatter) -> std::fmt::Result { - ::dafny_runtime::DafnyPrint::fmt_print(self, f, true) - } - } - - impl ::dafny_runtime::DafnyPrint for NestedStructure { - fn fmt_print( - &self, - _formatter: &mut ::std::fmt::Formatter, - _in_seq: bool, - ) -> std::fmt::Result { - match self { - NestedStructure::NestedStructure { stringStructure } => { - write!(_formatter, "r#_simple_daggregate_dinternaldafny_dtypes.NestedStructure.NestedStructure(")?; - ::dafny_runtime::DafnyPrint::fmt_print(stringStructure, _formatter, false)?; - write!(_formatter, ")")?; - Ok(()) - } - } - } - } - - impl Eq for NestedStructure {} - - impl ::std::hash::Hash for NestedStructure { - fn hash<_H: ::std::hash::Hasher>(&self, _state: &mut _H) { - match self { - NestedStructure::NestedStructure { stringStructure } => { - stringStructure.hash(_state) - } - } - } - } - - impl ::std::default::Default for NestedStructure { - fn default() -> NestedStructure { - NestedStructure::NestedStructure { - stringStructure: ::std::default::Default::default(), - } - } - } - - impl ::std::convert::AsRef for &NestedStructure { - fn as_ref(&self) -> Self { - self - } - } - - pub struct ISimpleAggregateClientCallHistory {} - - impl ISimpleAggregateClientCallHistory { - pub fn _allocate_rcmut() -> ::dafny_runtime::Object { - ::dafny_runtime::allocate_rcmut::() - } - } - - pub trait ISimpleAggregateClient { - fn GetAggregate( - &mut self, - input: &::std::rc::Rc< - super::r#_simple_daggregate_dinternaldafny_dtypes::GetAggregateInput, - >, - ) -> ::std::rc::Rc< - super::r#_Wrappers_Compile::Result< - ::std::rc::Rc< - super::r#_simple_daggregate_dinternaldafny_dtypes::GetAggregateOutput, - >, - ::std::rc::Rc, - >, - >; - fn GetAggregateKnownValueTest( - &mut self, - input: &::std::rc::Rc< - super::r#_simple_daggregate_dinternaldafny_dtypes::GetAggregateInput, - >, - ) -> ::std::rc::Rc< - super::r#_Wrappers_Compile::Result< - ::std::rc::Rc< - super::r#_simple_daggregate_dinternaldafny_dtypes::GetAggregateOutput, - >, - ::std::rc::Rc, - >, - >; - } - - #[derive(PartialEq, Clone)] - pub enum SimpleAggregateConfig { - SimpleAggregateConfig {}, - } - - impl SimpleAggregateConfig {} - - impl ::std::fmt::Debug for SimpleAggregateConfig { - fn fmt(&self, f: &mut ::std::fmt::Formatter) -> std::fmt::Result { - ::dafny_runtime::DafnyPrint::fmt_print(self, f, true) - } - } - - impl ::dafny_runtime::DafnyPrint for SimpleAggregateConfig { - fn fmt_print( - &self, - _formatter: &mut ::std::fmt::Formatter, - _in_seq: bool, - ) -> std::fmt::Result { - match self { - SimpleAggregateConfig::SimpleAggregateConfig {} => { - write!(_formatter, "r#_simple_daggregate_dinternaldafny_dtypes.SimpleAggregateConfig.SimpleAggregateConfig")?; - Ok(()) - } - } - } - } - - impl Eq for SimpleAggregateConfig {} - - impl ::std::hash::Hash for SimpleAggregateConfig { - fn hash<_H: ::std::hash::Hasher>(&self, _state: &mut _H) { - match self { - SimpleAggregateConfig::SimpleAggregateConfig {} => {} - } - } - } - - impl ::std::default::Default for SimpleAggregateConfig { - fn default() -> SimpleAggregateConfig { - SimpleAggregateConfig::SimpleAggregateConfig {} - } - } - - impl ::std::convert::AsRef for &SimpleAggregateConfig { - fn as_ref(&self) -> Self { - self - } - } - - #[derive(PartialEq, Clone)] - pub enum StringStructure { - StringStructure { - value: ::std::rc::Rc< - super::r#_Wrappers_Compile::Option< - ::dafny_runtime::Sequence<::dafny_runtime::DafnyCharUTF16>, - >, - >, - }, - } - - impl StringStructure { - pub fn value( - &self, - ) -> &::std::rc::Rc< - super::r#_Wrappers_Compile::Option< - ::dafny_runtime::Sequence<::dafny_runtime::DafnyCharUTF16>, - >, - > { - match self { - StringStructure::StringStructure { value } => value, - } - } - } - - impl ::std::fmt::Debug for StringStructure { - fn fmt(&self, f: &mut ::std::fmt::Formatter) -> std::fmt::Result { - ::dafny_runtime::DafnyPrint::fmt_print(self, f, true) - } - } - - impl ::dafny_runtime::DafnyPrint for StringStructure { - fn fmt_print( - &self, - _formatter: &mut ::std::fmt::Formatter, - _in_seq: bool, - ) -> std::fmt::Result { - match self { - StringStructure::StringStructure { value } => { - write!(_formatter, "r#_simple_daggregate_dinternaldafny_dtypes.StringStructure.StringStructure(")?; - ::dafny_runtime::DafnyPrint::fmt_print(value, _formatter, false)?; - write!(_formatter, ")")?; - Ok(()) - } - } - } - } - - impl Eq for StringStructure {} - - impl ::std::hash::Hash for StringStructure { - fn hash<_H: ::std::hash::Hasher>(&self, _state: &mut _H) { - match self { - StringStructure::StringStructure { value } => value.hash(_state), - } - } - } - - impl ::std::default::Default for StringStructure { - fn default() -> StringStructure { - StringStructure::StringStructure { - value: ::std::default::Default::default(), - } - } - } - - impl ::std::convert::AsRef for &StringStructure { - fn as_ref(&self) -> Self { - self - } - } - - #[derive(PartialEq, Clone)] - pub enum StructureListElement { - StructureListElement { - stringValue: ::std::rc::Rc< - super::r#_Wrappers_Compile::Option< - ::dafny_runtime::Sequence<::dafny_runtime::DafnyCharUTF16>, - >, - >, - integerValue: ::std::rc::Rc>, - }, - } - - impl StructureListElement { - pub fn stringValue( - &self, - ) -> &::std::rc::Rc< - super::r#_Wrappers_Compile::Option< - ::dafny_runtime::Sequence<::dafny_runtime::DafnyCharUTF16>, - >, - > { - match self { - StructureListElement::StructureListElement { - stringValue, - integerValue, - } => stringValue, - } - } - pub fn integerValue(&self) -> &::std::rc::Rc> { - match self { - StructureListElement::StructureListElement { - stringValue, - integerValue, - } => integerValue, - } - } - } - - impl ::std::fmt::Debug for StructureListElement { - fn fmt(&self, f: &mut ::std::fmt::Formatter) -> std::fmt::Result { - ::dafny_runtime::DafnyPrint::fmt_print(self, f, true) - } - } - - impl ::dafny_runtime::DafnyPrint for StructureListElement { - fn fmt_print( - &self, - _formatter: &mut ::std::fmt::Formatter, - _in_seq: bool, - ) -> std::fmt::Result { - match self { - StructureListElement::StructureListElement { - stringValue, - integerValue, - } => { - write!(_formatter, "r#_simple_daggregate_dinternaldafny_dtypes.StructureListElement.StructureListElement(")?; - ::dafny_runtime::DafnyPrint::fmt_print(stringValue, _formatter, false)?; - write!(_formatter, ", ")?; - ::dafny_runtime::DafnyPrint::fmt_print(integerValue, _formatter, false)?; - write!(_formatter, ")")?; - Ok(()) - } - } - } - } - - impl Eq for StructureListElement {} - - impl ::std::hash::Hash for StructureListElement { - fn hash<_H: ::std::hash::Hasher>(&self, _state: &mut _H) { - match self { - StructureListElement::StructureListElement { - stringValue, - integerValue, - } => { - stringValue.hash(_state); - integerValue.hash(_state) - } - } - } - } - - impl ::std::default::Default for StructureListElement { - fn default() -> StructureListElement { - StructureListElement::StructureListElement { - stringValue: ::std::default::Default::default(), - integerValue: ::std::default::Default::default(), - } - } - } - - impl ::std::convert::AsRef for &StructureListElement { - fn as_ref(&self) -> Self { - self - } - } - - #[derive(PartialEq, Clone)] - pub enum Error { - CollectionOfErrors { - list: ::dafny_runtime::Sequence< - ::std::rc::Rc, - >, - message: ::dafny_runtime::Sequence<::dafny_runtime::DafnyCharUTF16>, - }, - Opaque { - obj: ::dafny_runtime::Object, - }, - } - - impl Error { - pub fn list( - &self, - ) -> &::dafny_runtime::Sequence< - ::std::rc::Rc, - > { - match self { - Error::CollectionOfErrors { list, message } => list, - Error::Opaque { obj } => panic!("field does not exist on this variant"), - } - } - pub fn message(&self) -> &::dafny_runtime::Sequence<::dafny_runtime::DafnyCharUTF16> { - match self { - Error::CollectionOfErrors { list, message } => message, - Error::Opaque { obj } => panic!("field does not exist on this variant"), - } - } - pub fn obj(&self) -> &::dafny_runtime::Object { - match self { - Error::CollectionOfErrors { list, message } => { - panic!("field does not exist on this variant") - } - Error::Opaque { obj } => obj, - } - } - } - - impl ::std::fmt::Debug for Error { - fn fmt(&self, f: &mut ::std::fmt::Formatter) -> std::fmt::Result { - ::dafny_runtime::DafnyPrint::fmt_print(self, f, true) - } - } - - impl ::dafny_runtime::DafnyPrint for Error { - fn fmt_print( - &self, - _formatter: &mut ::std::fmt::Formatter, - _in_seq: bool, - ) -> std::fmt::Result { - match self { - Error::CollectionOfErrors { list, message } => { - write!( - _formatter, - "r#_simple_daggregate_dinternaldafny_dtypes.Error.CollectionOfErrors(" - )?; - ::dafny_runtime::DafnyPrint::fmt_print(list, _formatter, false)?; - write!(_formatter, ", ")?; - ::dafny_runtime::DafnyPrint::fmt_print(message, _formatter, false)?; - write!(_formatter, ")")?; - Ok(()) - } - Error::Opaque { obj } => { - write!( - _formatter, - "r#_simple_daggregate_dinternaldafny_dtypes.Error.Opaque(" - )?; - ::dafny_runtime::DafnyPrint::fmt_print(obj, _formatter, false)?; - write!(_formatter, ")")?; - Ok(()) - } - } - } - } - - impl Eq for Error {} - - impl ::std::hash::Hash for Error { - fn hash<_H: ::std::hash::Hasher>(&self, _state: &mut _H) { - match self { - Error::CollectionOfErrors { list, message } => { - list.hash(_state); - message.hash(_state) - } - Error::Opaque { obj } => obj.hash(_state), - } - } - } - - impl ::std::default::Default for Error { - fn default() -> Error { - Error::CollectionOfErrors { - list: ::std::default::Default::default(), - message: ::std::default::Default::default(), - } - } - } - - impl ::std::convert::AsRef for &Error { - fn as_ref(&self) -> Self { - self - } - } - - pub type OpaqueError = ::std::rc::Rc; -} -pub mod r#_SimpleAggregateImpl_Compile { - pub struct _default {} - - impl _default { - pub fn _allocate_rcmut() -> ::dafny_runtime::Object { - ::dafny_runtime::allocate_rcmut::() - } - pub fn GetAggregate( - config: &::std::rc::Rc, - input: &::std::rc::Rc< - super::r#_simple_daggregate_dinternaldafny_dtypes::GetAggregateInput, - >, - ) -> ::std::rc::Rc< - super::r#_Wrappers_Compile::Result< - ::std::rc::Rc< - super::r#_simple_daggregate_dinternaldafny_dtypes::GetAggregateOutput, - >, - ::std::rc::Rc, - >, - > { - let mut output = ::dafny_runtime::MaybePlacebo::< - ::std::rc::Rc< - super::r#_Wrappers_Compile::Result< - ::std::rc::Rc< - super::r#_simple_daggregate_dinternaldafny_dtypes::GetAggregateOutput, - >, - ::std::rc::Rc, - >, - >, - >::new(); - let mut res: ::std::rc::Rc = ::std::rc::Rc::new(super::r#_simple_daggregate_dinternaldafny_dtypes::GetAggregateOutput::GetAggregateOutput { - simpleStringList: input.simpleStringList().clone(), - structureList: input.structureList().clone(), - simpleStringMap: input.simpleStringMap().clone(), - simpleIntegerMap: input.simpleIntegerMap().clone(), - nestedStructure: input.nestedStructure().clone() - }); - res = ::std::rc::Rc::new(super::r#_simple_daggregate_dinternaldafny_dtypes::GetAggregateOutput::GetAggregateOutput { - simpleStringList: input.simpleStringList().clone(), - structureList: input.structureList().clone(), - simpleStringMap: input.simpleStringMap().clone(), - simpleIntegerMap: input.simpleIntegerMap().clone(), - nestedStructure: input.nestedStructure().clone() - }); - output = ::dafny_runtime::MaybePlacebo::from(::std::rc::Rc::new( - super::r#_Wrappers_Compile::Result::< - ::std::rc::Rc< - super::r#_simple_daggregate_dinternaldafny_dtypes::GetAggregateOutput, - >, - ::std::rc::Rc, - >::Success { - value: res.clone(), - }, - )); - return output.read(); - return output.read(); - } - pub fn GetAggregateKnownValueTest( - config: &::std::rc::Rc, - input: &::std::rc::Rc< - super::r#_simple_daggregate_dinternaldafny_dtypes::GetAggregateInput, - >, - ) -> ::std::rc::Rc< - super::r#_Wrappers_Compile::Result< - ::std::rc::Rc< - super::r#_simple_daggregate_dinternaldafny_dtypes::GetAggregateOutput, - >, - ::std::rc::Rc, - >, - > { - let mut output = ::dafny_runtime::MaybePlacebo::< - ::std::rc::Rc< - super::r#_Wrappers_Compile::Result< - ::std::rc::Rc< - super::r#_simple_daggregate_dinternaldafny_dtypes::GetAggregateOutput, - >, - ::std::rc::Rc, - >, - >, - >::new(); - super::r#_SimpleAggregateImpl_Compile::_default::ValidateInput(input); - let mut res: ::std::rc::Rc = ::std::rc::Rc::new(super::r#_simple_daggregate_dinternaldafny_dtypes::GetAggregateOutput::GetAggregateOutput { - simpleStringList: input.simpleStringList().clone(), - structureList: input.structureList().clone(), - simpleStringMap: input.simpleStringMap().clone(), - simpleIntegerMap: input.simpleIntegerMap().clone(), - nestedStructure: input.nestedStructure().clone() - }); - res = ::std::rc::Rc::new(super::r#_simple_daggregate_dinternaldafny_dtypes::GetAggregateOutput::GetAggregateOutput { - simpleStringList: input.simpleStringList().clone(), - structureList: input.structureList().clone(), - simpleStringMap: input.simpleStringMap().clone(), - simpleIntegerMap: input.simpleIntegerMap().clone(), - nestedStructure: input.nestedStructure().clone() - }); - output = ::dafny_runtime::MaybePlacebo::from(::std::rc::Rc::new( - super::r#_Wrappers_Compile::Result::< - ::std::rc::Rc< - super::r#_simple_daggregate_dinternaldafny_dtypes::GetAggregateOutput, - >, - ::std::rc::Rc, - >::Success { - value: res.clone(), - }, - )); - return output.read(); - return output.read(); - } - pub fn ValidateInput( - input: &::std::rc::Rc< - super::r#_simple_daggregate_dinternaldafny_dtypes::GetAggregateInput, - >, - ) -> () { - if !((input.simpleStringList().UnwrapOr(&(::dafny_runtime::seq![] as ::dafny_runtime::Sequence<::dafny_runtime::Sequence<::dafny_runtime::DafnyCharUTF16>>)/* Coercion from ::dafny_runtime::Sequence<::dafny_runtime::Sequence<::dafny_runtime::DafnyCharUTF16>> to T not yet implemented */)/* Coercion from T to ::dafny_runtime::Sequence<::dafny_runtime::Sequence<::dafny_runtime::DafnyCharUTF16>> not yet implemented */) == ::dafny_runtime::seq![::dafny_runtime::string_utf16_of("Test")]) { - panic!("Halt") - }; - if !((input.simpleStringMap().UnwrapOr(&::dafny_runtime::map![]/* Coercion from ::dafny_runtime::Map<::dafny_runtime::Sequence<::dafny_runtime::DafnyCharUTF16>, ::dafny_runtime::Sequence<::dafny_runtime::DafnyCharUTF16>> to T not yet implemented */)/* Coercion from T to ::dafny_runtime::Map<::dafny_runtime::Sequence<::dafny_runtime::DafnyCharUTF16>, ::dafny_runtime::Sequence<::dafny_runtime::DafnyCharUTF16>> not yet implemented */) == ::dafny_runtime::map![(::dafny_runtime::string_utf16_of("Test1")) => (::dafny_runtime::string_utf16_of("Success"))]) { - panic!("Halt") - }; - if !((input.simpleIntegerMap().UnwrapOr(&::dafny_runtime::map![]/* Coercion from ::dafny_runtime::Map<::dafny_runtime::Sequence<::dafny_runtime::DafnyCharUTF16>, i32> to T not yet implemented */)/* Coercion from T to ::dafny_runtime::Map<::dafny_runtime::Sequence<::dafny_runtime::DafnyCharUTF16>, i32> not yet implemented */) == ::dafny_runtime::map![(::dafny_runtime::string_utf16_of("Test3")) => (3)]) { - panic!("Halt") - }; - if !((input.structureList().UnwrapOr(&(::dafny_runtime::seq![] as ::dafny_runtime::Sequence<::std::rc::Rc>)/* Coercion from ::dafny_runtime::Sequence<::std::rc::Rc> to T not yet implemented */)/* Coercion from T to ::dafny_runtime::Sequence<::std::rc::Rc> not yet implemented */) == ::dafny_runtime::seq![::std::rc::Rc::new(super::r#_simple_daggregate_dinternaldafny_dtypes::StructureListElement::StructureListElement { - stringValue: ::std::rc::Rc::new(super::r#_Wrappers_Compile::Option::<::dafny_runtime::Sequence<::dafny_runtime::DafnyCharUTF16>>::Some { - value: ::dafny_runtime::string_utf16_of("Test2") - }), - integerValue: ::std::rc::Rc::new(super::r#_Wrappers_Compile::Option::::Some { - value: 2 - }) - })]) { - panic!("Halt") - }; - if !((input.nestedStructure().UnwrapOr(&::std::rc::Rc::new(super::r#_simple_daggregate_dinternaldafny_dtypes::NestedStructure::NestedStructure { - stringStructure: ::std::rc::Rc::new(super::r#_Wrappers_Compile::Option::<::std::rc::Rc>::Some { - value: ::std::rc::Rc::new(super::r#_simple_daggregate_dinternaldafny_dtypes::StringStructure::StringStructure { - value: ::std::rc::Rc::new(super::r#_Wrappers_Compile::Option::<::dafny_runtime::Sequence<::dafny_runtime::DafnyCharUTF16>>::Some { - value: ::dafny_runtime::string_utf16_of("") - }) - }) - }) - })/* Coercion from ::std::rc::Rc to T not yet implemented */)/* Coercion from T to ::std::rc::Rc not yet implemented */) == ::std::rc::Rc::new(super::r#_simple_daggregate_dinternaldafny_dtypes::NestedStructure::NestedStructure { - stringStructure: ::std::rc::Rc::new(super::r#_Wrappers_Compile::Option::<::std::rc::Rc>::Some { - value: ::std::rc::Rc::new(super::r#_simple_daggregate_dinternaldafny_dtypes::StringStructure::StringStructure { - value: ::std::rc::Rc::new(super::r#_Wrappers_Compile::Option::<::dafny_runtime::Sequence<::dafny_runtime::DafnyCharUTF16>>::Some { - value: ::dafny_runtime::string_utf16_of("Nested") - }) - }) - }) - })) { - panic!("Halt") - }; - return (); - } - } - - #[derive(PartialEq, Clone)] - pub enum Config { - Config {}, - } - - impl Config {} - - impl ::std::fmt::Debug for Config { - fn fmt(&self, f: &mut ::std::fmt::Formatter) -> std::fmt::Result { - ::dafny_runtime::DafnyPrint::fmt_print(self, f, true) - } - } - - impl ::dafny_runtime::DafnyPrint for Config { - fn fmt_print( - &self, - _formatter: &mut ::std::fmt::Formatter, - _in_seq: bool, - ) -> std::fmt::Result { - match self { - Config::Config {} => { - write!(_formatter, "r#_SimpleAggregateImpl_Compile.Config.Config")?; - Ok(()) - } - } - } - } - - impl Eq for Config {} - - impl ::std::hash::Hash for Config { - fn hash<_H: ::std::hash::Hasher>(&self, _state: &mut _H) { - match self { - Config::Config {} => {} - } - } - } - - impl ::std::default::Default for Config { - fn default() -> Config { - Config::Config {} - } - } - - impl ::std::convert::AsRef for &Config { - fn as_ref(&self) -> Self { - self - } - } -} -pub mod r#_simple_daggregate_dinternaldafny { - pub struct _default {} - - impl _default { - pub fn _allocate_rcmut() -> ::dafny_runtime::Object { - ::dafny_runtime::allocate_rcmut::() - } - pub fn DefaultSimpleAggregateConfig( - ) -> ::std::rc::Rc - { - ::std::rc::Rc::new(super::r#_simple_daggregate_dinternaldafny_dtypes::SimpleAggregateConfig::SimpleAggregateConfig {}) - } - pub fn SimpleAggregate( - config: &::std::rc::Rc< - super::r#_simple_daggregate_dinternaldafny_dtypes::SimpleAggregateConfig, - >, - ) -> ::std::rc::Rc< - super::r#_Wrappers_Compile::Result< - ::dafny_runtime::Object< - super::r#_simple_daggregate_dinternaldafny::SimpleAggregateClient, - >, - ::std::rc::Rc, - >, - > { - let mut res = ::dafny_runtime::MaybePlacebo::< - ::std::rc::Rc< - super::r#_Wrappers_Compile::Result< - ::dafny_runtime::Object< - super::r#_simple_daggregate_dinternaldafny::SimpleAggregateClient, - >, - ::std::rc::Rc, - >, - >, - >::new(); - let mut client = ::dafny_runtime::MaybePlacebo::< - ::dafny_runtime::Object< - super::r#_simple_daggregate_dinternaldafny::SimpleAggregateClient, - >, - >::new(); - let mut _nw0: ::dafny_runtime::Object< - super::r#_simple_daggregate_dinternaldafny::SimpleAggregateClient, - > = super::r#_simple_daggregate_dinternaldafny::SimpleAggregateClient::_allocate_rcmut( - ); - super::r#_simple_daggregate_dinternaldafny::SimpleAggregateClient::_ctor( - &_nw0, - &::std::rc::Rc::new(super::r#_SimpleAggregateImpl_Compile::Config::Config {}), - ); - client = ::dafny_runtime::MaybePlacebo::from(_nw0.clone()); - res = ::dafny_runtime::MaybePlacebo::from(::std::rc::Rc::new( - super::r#_Wrappers_Compile::Result::< - ::dafny_runtime::Object< - super::r#_simple_daggregate_dinternaldafny::SimpleAggregateClient, - >, - ::std::rc::Rc, - >::Success { - value: client.read(), - }, - )); - return res.read(); - return res.read(); - } - pub fn CreateSuccessOfClient( - client: &::dafny_runtime::Object< - dyn super::r#_simple_daggregate_dinternaldafny_dtypes::ISimpleAggregateClient, - >, - ) -> ::std::rc::Rc< - super::r#_Wrappers_Compile::Result< - ::dafny_runtime::Object< - dyn super::r#_simple_daggregate_dinternaldafny_dtypes::ISimpleAggregateClient, - >, - ::std::rc::Rc, - >, - > { - ::std::rc::Rc::new(super::r#_Wrappers_Compile::Result::< - ::dafny_runtime::Object< - dyn super::r#_simple_daggregate_dinternaldafny_dtypes::ISimpleAggregateClient, - >, - ::std::rc::Rc, - >::Success { - value: client.clone(), - }) - } - pub fn CreateFailureOfError( - error: &::std::rc::Rc, - ) -> ::std::rc::Rc< - super::r#_Wrappers_Compile::Result< - ::dafny_runtime::Object< - dyn super::r#_simple_daggregate_dinternaldafny_dtypes::ISimpleAggregateClient, - >, - ::std::rc::Rc, - >, - > { - ::std::rc::Rc::new(super::r#_Wrappers_Compile::Result::< - ::dafny_runtime::Object< - dyn super::r#_simple_daggregate_dinternaldafny_dtypes::ISimpleAggregateClient, - >, - ::std::rc::Rc, - >::Failure { - error: error.clone(), - }) - } - } - - pub struct SimpleAggregateClient { - pub r#__i_config: ::std::rc::Rc, - } - - impl SimpleAggregateClient { - pub fn _allocate_rcmut() -> ::dafny_runtime::Object { - ::dafny_runtime::allocate_rcmut::() - } - pub fn _ctor( - this: &::dafny_runtime::Object, - config: &::std::rc::Rc, - ) -> () { - let mut _set__i_config: bool = false; - ::dafny_runtime::update_field_uninit_rcmut!( - this.clone(), - r#__i_config, - _set__i_config, - config.clone() - ); - return (); - } - pub fn config(&self) -> ::std::rc::Rc { - self.r#__i_config.clone() - } - } - - impl super::r#_simple_daggregate_dinternaldafny_dtypes::ISimpleAggregateClient - for super::r#_simple_daggregate_dinternaldafny::SimpleAggregateClient - { - fn GetAggregate( - &mut self, - input: &::std::rc::Rc< - super::r#_simple_daggregate_dinternaldafny_dtypes::GetAggregateInput, - >, - ) -> ::std::rc::Rc< - super::r#_Wrappers_Compile::Result< - ::std::rc::Rc< - super::r#_simple_daggregate_dinternaldafny_dtypes::GetAggregateOutput, - >, - ::std::rc::Rc, - >, - > { - let mut output = ::dafny_runtime::MaybePlacebo::< - ::std::rc::Rc< - super::r#_Wrappers_Compile::Result< - ::std::rc::Rc< - super::r#_simple_daggregate_dinternaldafny_dtypes::GetAggregateOutput, - >, - ::std::rc::Rc, - >, - >, - >::new(); - let mut _out0 = ::dafny_runtime::MaybePlacebo::< - ::std::rc::Rc< - super::r#_Wrappers_Compile::Result< - ::std::rc::Rc< - super::r#_simple_daggregate_dinternaldafny_dtypes::GetAggregateOutput, - >, - ::std::rc::Rc, - >, - >, - >::new(); - _out0 = ::dafny_runtime::MaybePlacebo::from( - super::r#_SimpleAggregateImpl_Compile::_default::GetAggregate( - &self.config(), - input, - ), - ); - output = ::dafny_runtime::MaybePlacebo::from(_out0.read()); - return output.read(); - } - fn GetAggregateKnownValueTest( - &mut self, - input: &::std::rc::Rc< - super::r#_simple_daggregate_dinternaldafny_dtypes::GetAggregateInput, - >, - ) -> ::std::rc::Rc< - super::r#_Wrappers_Compile::Result< - ::std::rc::Rc< - super::r#_simple_daggregate_dinternaldafny_dtypes::GetAggregateOutput, - >, - ::std::rc::Rc, - >, - > { - let mut output = ::dafny_runtime::MaybePlacebo::< - ::std::rc::Rc< - super::r#_Wrappers_Compile::Result< - ::std::rc::Rc< - super::r#_simple_daggregate_dinternaldafny_dtypes::GetAggregateOutput, - >, - ::std::rc::Rc, - >, - >, - >::new(); - let mut _out1 = ::dafny_runtime::MaybePlacebo::< - ::std::rc::Rc< - super::r#_Wrappers_Compile::Result< - ::std::rc::Rc< - super::r#_simple_daggregate_dinternaldafny_dtypes::GetAggregateOutput, - >, - ::std::rc::Rc, - >, - >, - >::new(); - _out1 = ::dafny_runtime::MaybePlacebo::from( - super::r#_SimpleAggregateImpl_Compile::_default::GetAggregateKnownValueTest( - &self.config(), - input, - ), - ); - output = ::dafny_runtime::MaybePlacebo::from(_out1.read()); - return output.read(); - } - } -} -pub mod _module {} diff --git a/TestModels/Refinement/runtimes/rust/dafny_impl/src/implementation_from_dafny.rs b/TestModels/Refinement/runtimes/rust/dafny_impl/src/implementation_from_dafny.rs deleted file mode 100644 index 829d89e8eb..0000000000 --- a/TestModels/Refinement/runtimes/rust/dafny_impl/src/implementation_from_dafny.rs +++ /dev/null @@ -1,1306 +0,0 @@ -#![allow(warnings, unconditional_panic)] -#![allow(nonstandard_style)] -pub use dafny_standard_library::implementation_from_dafny::*; - -pub mod r#_simple_drefinement_dinternaldafny_dtypes { - #[derive(PartialEq, Clone)] - pub enum DafnyCallEvent { - DafnyCallEvent { input: I, output: O }, - _PhantomVariant(::std::marker::PhantomData, ::std::marker::PhantomData), - } - - impl DafnyCallEvent { - pub fn input(&self) -> &I { - match self { - DafnyCallEvent::DafnyCallEvent { input, output } => input, - DafnyCallEvent::_PhantomVariant(..) => panic!(), - } - } - pub fn output(&self) -> &O { - match self { - DafnyCallEvent::DafnyCallEvent { input, output } => output, - DafnyCallEvent::_PhantomVariant(..) => panic!(), - } - } - } - - impl ::std::fmt::Debug - for DafnyCallEvent - { - fn fmt(&self, f: &mut ::std::fmt::Formatter) -> std::fmt::Result { - ::dafny_runtime::DafnyPrint::fmt_print(self, f, true) - } - } - - impl ::dafny_runtime::DafnyPrint - for DafnyCallEvent - { - fn fmt_print( - &self, - _formatter: &mut ::std::fmt::Formatter, - _in_seq: bool, - ) -> std::fmt::Result { - match self { - DafnyCallEvent::DafnyCallEvent { input, output } => { - write!(_formatter, "r#_simple_drefinement_dinternaldafny_dtypes.DafnyCallEvent.DafnyCallEvent(")?; - ::dafny_runtime::DafnyPrint::fmt_print(input, _formatter, false)?; - write!(_formatter, ", ")?; - ::dafny_runtime::DafnyPrint::fmt_print(output, _formatter, false)?; - write!(_formatter, ")")?; - Ok(()) - } - DafnyCallEvent::_PhantomVariant(..) => { - panic!() - } - } - } - } - - impl Eq - for DafnyCallEvent - { - } - - impl< - I: ::dafny_runtime::DafnyType + ::std::hash::Hash, - O: ::dafny_runtime::DafnyType + ::std::hash::Hash, - > ::std::hash::Hash for DafnyCallEvent - { - fn hash<_H: ::std::hash::Hasher>(&self, _state: &mut _H) { - match self { - DafnyCallEvent::DafnyCallEvent { input, output } => { - input.hash(_state); - output.hash(_state) - } - DafnyCallEvent::_PhantomVariant(..) => { - panic!() - } - } - } - } - - impl< - I: ::dafny_runtime::DafnyType + ::std::default::Default, - O: ::dafny_runtime::DafnyType + ::std::default::Default, - > ::std::default::Default for DafnyCallEvent - { - fn default() -> DafnyCallEvent { - DafnyCallEvent::DafnyCallEvent { - input: ::std::default::Default::default(), - output: ::std::default::Default::default(), - } - } - } - - impl - ::std::convert::AsRef> for &DafnyCallEvent - { - fn as_ref(&self) -> Self { - self - } - } - - #[derive(PartialEq, Clone)] - pub enum GetRefinementInput { - GetRefinementInput { - requiredString: ::dafny_runtime::Sequence<::dafny_runtime::DafnyCharUTF16>, - optionalString: ::std::rc::Rc< - super::r#_Wrappers_Compile::Option< - ::dafny_runtime::Sequence<::dafny_runtime::DafnyCharUTF16>, - >, - >, - }, - } - - impl GetRefinementInput { - pub fn requiredString( - &self, - ) -> &::dafny_runtime::Sequence<::dafny_runtime::DafnyCharUTF16> { - match self { - GetRefinementInput::GetRefinementInput { - requiredString, - optionalString, - } => requiredString, - } - } - pub fn optionalString( - &self, - ) -> &::std::rc::Rc< - super::r#_Wrappers_Compile::Option< - ::dafny_runtime::Sequence<::dafny_runtime::DafnyCharUTF16>, - >, - > { - match self { - GetRefinementInput::GetRefinementInput { - requiredString, - optionalString, - } => optionalString, - } - } - } - - impl ::std::fmt::Debug for GetRefinementInput { - fn fmt(&self, f: &mut ::std::fmt::Formatter) -> std::fmt::Result { - ::dafny_runtime::DafnyPrint::fmt_print(self, f, true) - } - } - - impl ::dafny_runtime::DafnyPrint for GetRefinementInput { - fn fmt_print( - &self, - _formatter: &mut ::std::fmt::Formatter, - _in_seq: bool, - ) -> std::fmt::Result { - match self { - GetRefinementInput::GetRefinementInput { - requiredString, - optionalString, - } => { - write!(_formatter, "r#_simple_drefinement_dinternaldafny_dtypes.GetRefinementInput.GetRefinementInput(")?; - ::dafny_runtime::DafnyPrint::fmt_print(requiredString, _formatter, false)?; - write!(_formatter, ", ")?; - ::dafny_runtime::DafnyPrint::fmt_print(optionalString, _formatter, false)?; - write!(_formatter, ")")?; - Ok(()) - } - } - } - } - - impl Eq for GetRefinementInput {} - - impl ::std::hash::Hash for GetRefinementInput { - fn hash<_H: ::std::hash::Hasher>(&self, _state: &mut _H) { - match self { - GetRefinementInput::GetRefinementInput { - requiredString, - optionalString, - } => { - requiredString.hash(_state); - optionalString.hash(_state) - } - } - } - } - - impl ::std::default::Default for GetRefinementInput { - fn default() -> GetRefinementInput { - GetRefinementInput::GetRefinementInput { - requiredString: ::std::default::Default::default(), - optionalString: ::std::default::Default::default(), - } - } - } - - impl ::std::convert::AsRef for &GetRefinementInput { - fn as_ref(&self) -> Self { - self - } - } - - #[derive(PartialEq, Clone)] - pub enum GetRefinementOutput { - GetRefinementOutput { - requiredString: ::dafny_runtime::Sequence<::dafny_runtime::DafnyCharUTF16>, - optionalString: ::std::rc::Rc< - super::r#_Wrappers_Compile::Option< - ::dafny_runtime::Sequence<::dafny_runtime::DafnyCharUTF16>, - >, - >, - }, - } - - impl GetRefinementOutput { - pub fn requiredString( - &self, - ) -> &::dafny_runtime::Sequence<::dafny_runtime::DafnyCharUTF16> { - match self { - GetRefinementOutput::GetRefinementOutput { - requiredString, - optionalString, - } => requiredString, - } - } - pub fn optionalString( - &self, - ) -> &::std::rc::Rc< - super::r#_Wrappers_Compile::Option< - ::dafny_runtime::Sequence<::dafny_runtime::DafnyCharUTF16>, - >, - > { - match self { - GetRefinementOutput::GetRefinementOutput { - requiredString, - optionalString, - } => optionalString, - } - } - } - - impl ::std::fmt::Debug for GetRefinementOutput { - fn fmt(&self, f: &mut ::std::fmt::Formatter) -> std::fmt::Result { - ::dafny_runtime::DafnyPrint::fmt_print(self, f, true) - } - } - - impl ::dafny_runtime::DafnyPrint for GetRefinementOutput { - fn fmt_print( - &self, - _formatter: &mut ::std::fmt::Formatter, - _in_seq: bool, - ) -> std::fmt::Result { - match self { - GetRefinementOutput::GetRefinementOutput { - requiredString, - optionalString, - } => { - write!(_formatter, "r#_simple_drefinement_dinternaldafny_dtypes.GetRefinementOutput.GetRefinementOutput(")?; - ::dafny_runtime::DafnyPrint::fmt_print(requiredString, _formatter, false)?; - write!(_formatter, ", ")?; - ::dafny_runtime::DafnyPrint::fmt_print(optionalString, _formatter, false)?; - write!(_formatter, ")")?; - Ok(()) - } - } - } - } - - impl Eq for GetRefinementOutput {} - - impl ::std::hash::Hash for GetRefinementOutput { - fn hash<_H: ::std::hash::Hasher>(&self, _state: &mut _H) { - match self { - GetRefinementOutput::GetRefinementOutput { - requiredString, - optionalString, - } => { - requiredString.hash(_state); - optionalString.hash(_state) - } - } - } - } - - impl ::std::default::Default for GetRefinementOutput { - fn default() -> GetRefinementOutput { - GetRefinementOutput::GetRefinementOutput { - requiredString: ::std::default::Default::default(), - optionalString: ::std::default::Default::default(), - } - } - } - - impl ::std::convert::AsRef for &GetRefinementOutput { - fn as_ref(&self) -> Self { - self - } - } - - #[derive(PartialEq, Clone)] - pub enum OnlyInputInput { - OnlyInputInput { - value: ::std::rc::Rc< - super::r#_Wrappers_Compile::Option< - ::dafny_runtime::Sequence<::dafny_runtime::DafnyCharUTF16>, - >, - >, - }, - } - - impl OnlyInputInput { - pub fn value( - &self, - ) -> &::std::rc::Rc< - super::r#_Wrappers_Compile::Option< - ::dafny_runtime::Sequence<::dafny_runtime::DafnyCharUTF16>, - >, - > { - match self { - OnlyInputInput::OnlyInputInput { value } => value, - } - } - } - - impl ::std::fmt::Debug for OnlyInputInput { - fn fmt(&self, f: &mut ::std::fmt::Formatter) -> std::fmt::Result { - ::dafny_runtime::DafnyPrint::fmt_print(self, f, true) - } - } - - impl ::dafny_runtime::DafnyPrint for OnlyInputInput { - fn fmt_print( - &self, - _formatter: &mut ::std::fmt::Formatter, - _in_seq: bool, - ) -> std::fmt::Result { - match self { - OnlyInputInput::OnlyInputInput { value } => { - write!(_formatter, "r#_simple_drefinement_dinternaldafny_dtypes.OnlyInputInput.OnlyInputInput(")?; - ::dafny_runtime::DafnyPrint::fmt_print(value, _formatter, false)?; - write!(_formatter, ")")?; - Ok(()) - } - } - } - } - - impl Eq for OnlyInputInput {} - - impl ::std::hash::Hash for OnlyInputInput { - fn hash<_H: ::std::hash::Hasher>(&self, _state: &mut _H) { - match self { - OnlyInputInput::OnlyInputInput { value } => value.hash(_state), - } - } - } - - impl ::std::default::Default for OnlyInputInput { - fn default() -> OnlyInputInput { - OnlyInputInput::OnlyInputInput { - value: ::std::default::Default::default(), - } - } - } - - impl ::std::convert::AsRef for &OnlyInputInput { - fn as_ref(&self) -> Self { - self - } - } - - #[derive(PartialEq, Clone)] - pub enum OnlyOutputOutput { - OnlyOutputOutput { - value: ::std::rc::Rc< - super::r#_Wrappers_Compile::Option< - ::dafny_runtime::Sequence<::dafny_runtime::DafnyCharUTF16>, - >, - >, - }, - } - - impl OnlyOutputOutput { - pub fn value( - &self, - ) -> &::std::rc::Rc< - super::r#_Wrappers_Compile::Option< - ::dafny_runtime::Sequence<::dafny_runtime::DafnyCharUTF16>, - >, - > { - match self { - OnlyOutputOutput::OnlyOutputOutput { value } => value, - } - } - } - - impl ::std::fmt::Debug for OnlyOutputOutput { - fn fmt(&self, f: &mut ::std::fmt::Formatter) -> std::fmt::Result { - ::dafny_runtime::DafnyPrint::fmt_print(self, f, true) - } - } - - impl ::dafny_runtime::DafnyPrint for OnlyOutputOutput { - fn fmt_print( - &self, - _formatter: &mut ::std::fmt::Formatter, - _in_seq: bool, - ) -> std::fmt::Result { - match self { - OnlyOutputOutput::OnlyOutputOutput { value } => { - write!(_formatter, "r#_simple_drefinement_dinternaldafny_dtypes.OnlyOutputOutput.OnlyOutputOutput(")?; - ::dafny_runtime::DafnyPrint::fmt_print(value, _formatter, false)?; - write!(_formatter, ")")?; - Ok(()) - } - } - } - } - - impl Eq for OnlyOutputOutput {} - - impl ::std::hash::Hash for OnlyOutputOutput { - fn hash<_H: ::std::hash::Hasher>(&self, _state: &mut _H) { - match self { - OnlyOutputOutput::OnlyOutputOutput { value } => value.hash(_state), - } - } - } - - impl ::std::default::Default for OnlyOutputOutput { - fn default() -> OnlyOutputOutput { - OnlyOutputOutput::OnlyOutputOutput { - value: ::std::default::Default::default(), - } - } - } - - impl ::std::convert::AsRef for &OnlyOutputOutput { - fn as_ref(&self) -> Self { - self - } - } - - #[derive(PartialEq, Clone)] - pub enum ReadonlyOperationInput { - ReadonlyOperationInput { - requiredString: ::dafny_runtime::Sequence<::dafny_runtime::DafnyCharUTF16>, - optionalString: ::std::rc::Rc< - super::r#_Wrappers_Compile::Option< - ::dafny_runtime::Sequence<::dafny_runtime::DafnyCharUTF16>, - >, - >, - }, - } - - impl ReadonlyOperationInput { - pub fn requiredString( - &self, - ) -> &::dafny_runtime::Sequence<::dafny_runtime::DafnyCharUTF16> { - match self { - ReadonlyOperationInput::ReadonlyOperationInput { - requiredString, - optionalString, - } => requiredString, - } - } - pub fn optionalString( - &self, - ) -> &::std::rc::Rc< - super::r#_Wrappers_Compile::Option< - ::dafny_runtime::Sequence<::dafny_runtime::DafnyCharUTF16>, - >, - > { - match self { - ReadonlyOperationInput::ReadonlyOperationInput { - requiredString, - optionalString, - } => optionalString, - } - } - } - - impl ::std::fmt::Debug for ReadonlyOperationInput { - fn fmt(&self, f: &mut ::std::fmt::Formatter) -> std::fmt::Result { - ::dafny_runtime::DafnyPrint::fmt_print(self, f, true) - } - } - - impl ::dafny_runtime::DafnyPrint for ReadonlyOperationInput { - fn fmt_print( - &self, - _formatter: &mut ::std::fmt::Formatter, - _in_seq: bool, - ) -> std::fmt::Result { - match self { - ReadonlyOperationInput::ReadonlyOperationInput { - requiredString, - optionalString, - } => { - write!(_formatter, "r#_simple_drefinement_dinternaldafny_dtypes.ReadonlyOperationInput.ReadonlyOperationInput(")?; - ::dafny_runtime::DafnyPrint::fmt_print(requiredString, _formatter, false)?; - write!(_formatter, ", ")?; - ::dafny_runtime::DafnyPrint::fmt_print(optionalString, _formatter, false)?; - write!(_formatter, ")")?; - Ok(()) - } - } - } - } - - impl Eq for ReadonlyOperationInput {} - - impl ::std::hash::Hash for ReadonlyOperationInput { - fn hash<_H: ::std::hash::Hasher>(&self, _state: &mut _H) { - match self { - ReadonlyOperationInput::ReadonlyOperationInput { - requiredString, - optionalString, - } => { - requiredString.hash(_state); - optionalString.hash(_state) - } - } - } - } - - impl ::std::default::Default for ReadonlyOperationInput { - fn default() -> ReadonlyOperationInput { - ReadonlyOperationInput::ReadonlyOperationInput { - requiredString: ::std::default::Default::default(), - optionalString: ::std::default::Default::default(), - } - } - } - - impl ::std::convert::AsRef for &ReadonlyOperationInput { - fn as_ref(&self) -> Self { - self - } - } - - #[derive(PartialEq, Clone)] - pub enum ReadonlyOperationOutput { - ReadonlyOperationOutput { - requiredString: ::dafny_runtime::Sequence<::dafny_runtime::DafnyCharUTF16>, - optionalString: ::std::rc::Rc< - super::r#_Wrappers_Compile::Option< - ::dafny_runtime::Sequence<::dafny_runtime::DafnyCharUTF16>, - >, - >, - }, - } - - impl ReadonlyOperationOutput { - pub fn requiredString( - &self, - ) -> &::dafny_runtime::Sequence<::dafny_runtime::DafnyCharUTF16> { - match self { - ReadonlyOperationOutput::ReadonlyOperationOutput { - requiredString, - optionalString, - } => requiredString, - } - } - pub fn optionalString( - &self, - ) -> &::std::rc::Rc< - super::r#_Wrappers_Compile::Option< - ::dafny_runtime::Sequence<::dafny_runtime::DafnyCharUTF16>, - >, - > { - match self { - ReadonlyOperationOutput::ReadonlyOperationOutput { - requiredString, - optionalString, - } => optionalString, - } - } - } - - impl ::std::fmt::Debug for ReadonlyOperationOutput { - fn fmt(&self, f: &mut ::std::fmt::Formatter) -> std::fmt::Result { - ::dafny_runtime::DafnyPrint::fmt_print(self, f, true) - } - } - - impl ::dafny_runtime::DafnyPrint for ReadonlyOperationOutput { - fn fmt_print( - &self, - _formatter: &mut ::std::fmt::Formatter, - _in_seq: bool, - ) -> std::fmt::Result { - match self { - ReadonlyOperationOutput::ReadonlyOperationOutput { - requiredString, - optionalString, - } => { - write!(_formatter, "r#_simple_drefinement_dinternaldafny_dtypes.ReadonlyOperationOutput.ReadonlyOperationOutput(")?; - ::dafny_runtime::DafnyPrint::fmt_print(requiredString, _formatter, false)?; - write!(_formatter, ", ")?; - ::dafny_runtime::DafnyPrint::fmt_print(optionalString, _formatter, false)?; - write!(_formatter, ")")?; - Ok(()) - } - } - } - } - - impl Eq for ReadonlyOperationOutput {} - - impl ::std::hash::Hash for ReadonlyOperationOutput { - fn hash<_H: ::std::hash::Hasher>(&self, _state: &mut _H) { - match self { - ReadonlyOperationOutput::ReadonlyOperationOutput { - requiredString, - optionalString, - } => { - requiredString.hash(_state); - optionalString.hash(_state) - } - } - } - } - - impl ::std::default::Default for ReadonlyOperationOutput { - fn default() -> ReadonlyOperationOutput { - ReadonlyOperationOutput::ReadonlyOperationOutput { - requiredString: ::std::default::Default::default(), - optionalString: ::std::default::Default::default(), - } - } - } - - impl ::std::convert::AsRef for &ReadonlyOperationOutput { - fn as_ref(&self) -> Self { - self - } - } - - pub struct ISimpleRefinementClientCallHistory {} - - impl ISimpleRefinementClientCallHistory { - pub fn _allocate_rcmut() -> ::dafny_runtime::Object { - ::dafny_runtime::allocate_rcmut::() - } - } - - pub trait ISimpleRefinementClient { - fn GetRefinement( - &mut self, - input: &::std::rc::Rc< - super::r#_simple_drefinement_dinternaldafny_dtypes::GetRefinementInput, - >, - ) -> ::std::rc::Rc< - super::r#_Wrappers_Compile::Result< - ::std::rc::Rc< - super::r#_simple_drefinement_dinternaldafny_dtypes::GetRefinementOutput, - >, - ::std::rc::Rc, - >, - >; - fn OnlyInput( - &mut self, - input: &::std::rc::Rc< - super::r#_simple_drefinement_dinternaldafny_dtypes::OnlyInputInput, - >, - ) -> ::std::rc::Rc< - super::r#_Wrappers_Compile::Result< - (), - ::std::rc::Rc, - >, - >; - fn OnlyOutput( - &mut self, - ) -> ::std::rc::Rc< - super::r#_Wrappers_Compile::Result< - ::std::rc::Rc, - ::std::rc::Rc, - >, - >; - fn ReadonlyOperation( - &self, - input: &::std::rc::Rc< - super::r#_simple_drefinement_dinternaldafny_dtypes::ReadonlyOperationInput, - >, - ) -> ::std::rc::Rc< - super::r#_Wrappers_Compile::Result< - ::std::rc::Rc< - super::r#_simple_drefinement_dinternaldafny_dtypes::ReadonlyOperationOutput, - >, - ::std::rc::Rc, - >, - >; - } - - #[derive(PartialEq, Clone)] - pub enum SimpleRefinementConfig { - SimpleRefinementConfig {}, - } - - impl SimpleRefinementConfig {} - - impl ::std::fmt::Debug for SimpleRefinementConfig { - fn fmt(&self, f: &mut ::std::fmt::Formatter) -> std::fmt::Result { - ::dafny_runtime::DafnyPrint::fmt_print(self, f, true) - } - } - - impl ::dafny_runtime::DafnyPrint for SimpleRefinementConfig { - fn fmt_print( - &self, - _formatter: &mut ::std::fmt::Formatter, - _in_seq: bool, - ) -> std::fmt::Result { - match self { - SimpleRefinementConfig::SimpleRefinementConfig {} => { - write!(_formatter, "r#_simple_drefinement_dinternaldafny_dtypes.SimpleRefinementConfig.SimpleRefinementConfig")?; - Ok(()) - } - } - } - } - - impl Eq for SimpleRefinementConfig {} - - impl ::std::hash::Hash for SimpleRefinementConfig { - fn hash<_H: ::std::hash::Hasher>(&self, _state: &mut _H) { - match self { - SimpleRefinementConfig::SimpleRefinementConfig {} => {} - } - } - } - - impl ::std::default::Default for SimpleRefinementConfig { - fn default() -> SimpleRefinementConfig { - SimpleRefinementConfig::SimpleRefinementConfig {} - } - } - - impl ::std::convert::AsRef for &SimpleRefinementConfig { - fn as_ref(&self) -> Self { - self - } - } - - #[derive(PartialEq, Clone)] - pub enum Error { - CollectionOfErrors { - list: ::dafny_runtime::Sequence< - ::std::rc::Rc, - >, - message: ::dafny_runtime::Sequence<::dafny_runtime::DafnyCharUTF16>, - }, - Opaque { - obj: ::dafny_runtime::Object, - }, - } - - impl Error { - pub fn list( - &self, - ) -> &::dafny_runtime::Sequence< - ::std::rc::Rc, - > { - match self { - Error::CollectionOfErrors { list, message } => list, - Error::Opaque { obj } => panic!("field does not exist on this variant"), - } - } - pub fn message(&self) -> &::dafny_runtime::Sequence<::dafny_runtime::DafnyCharUTF16> { - match self { - Error::CollectionOfErrors { list, message } => message, - Error::Opaque { obj } => panic!("field does not exist on this variant"), - } - } - pub fn obj(&self) -> &::dafny_runtime::Object { - match self { - Error::CollectionOfErrors { list, message } => { - panic!("field does not exist on this variant") - } - Error::Opaque { obj } => obj, - } - } - } - - impl ::std::fmt::Debug for Error { - fn fmt(&self, f: &mut ::std::fmt::Formatter) -> std::fmt::Result { - ::dafny_runtime::DafnyPrint::fmt_print(self, f, true) - } - } - - impl ::dafny_runtime::DafnyPrint for Error { - fn fmt_print( - &self, - _formatter: &mut ::std::fmt::Formatter, - _in_seq: bool, - ) -> std::fmt::Result { - match self { - Error::CollectionOfErrors { list, message } => { - write!( - _formatter, - "r#_simple_drefinement_dinternaldafny_dtypes.Error.CollectionOfErrors(" - )?; - ::dafny_runtime::DafnyPrint::fmt_print(list, _formatter, false)?; - write!(_formatter, ", ")?; - ::dafny_runtime::DafnyPrint::fmt_print(message, _formatter, false)?; - write!(_formatter, ")")?; - Ok(()) - } - Error::Opaque { obj } => { - write!( - _formatter, - "r#_simple_drefinement_dinternaldafny_dtypes.Error.Opaque(" - )?; - ::dafny_runtime::DafnyPrint::fmt_print(obj, _formatter, false)?; - write!(_formatter, ")")?; - Ok(()) - } - } - } - } - - impl Eq for Error {} - - impl ::std::hash::Hash for Error { - fn hash<_H: ::std::hash::Hasher>(&self, _state: &mut _H) { - match self { - Error::CollectionOfErrors { list, message } => { - list.hash(_state); - message.hash(_state) - } - Error::Opaque { obj } => obj.hash(_state), - } - } - } - - impl ::std::default::Default for Error { - fn default() -> Error { - Error::CollectionOfErrors { - list: ::std::default::Default::default(), - message: ::std::default::Default::default(), - } - } - } - - impl ::std::convert::AsRef for &Error { - fn as_ref(&self) -> Self { - self - } - } - - pub type OpaqueError = ::std::rc::Rc; -} -pub mod r#_SimpleRefinementImpl_Compile { - pub struct _default {} - - impl _default { - pub fn _allocate_rcmut() -> ::dafny_runtime::Object { - ::dafny_runtime::allocate_rcmut::() - } - pub fn GetRefinement( - config: &::std::rc::Rc, - input: &::std::rc::Rc< - super::r#_simple_drefinement_dinternaldafny_dtypes::GetRefinementInput, - >, - ) -> ::std::rc::Rc< - super::r#_Wrappers_Compile::Result< - ::std::rc::Rc< - super::r#_simple_drefinement_dinternaldafny_dtypes::GetRefinementOutput, - >, - ::std::rc::Rc, - >, - > { - let mut output = ::dafny_runtime::MaybePlacebo::< - ::std::rc::Rc< - super::r#_Wrappers_Compile::Result< - ::std::rc::Rc< - super::r#_simple_drefinement_dinternaldafny_dtypes::GetRefinementOutput, - >, - ::std::rc::Rc, - >, - >, - >::new(); - let mut res: ::std::rc::Rc = ::std::rc::Rc::new(super::r#_simple_drefinement_dinternaldafny_dtypes::GetRefinementOutput::GetRefinementOutput { - requiredString: input.requiredString().clone(), - optionalString: input.optionalString().clone() - }); - res = ::std::rc::Rc::new(super::r#_simple_drefinement_dinternaldafny_dtypes::GetRefinementOutput::GetRefinementOutput { - requiredString: input.requiredString().clone(), - optionalString: input.optionalString().clone() - }); - output = ::dafny_runtime::MaybePlacebo::from(::std::rc::Rc::new( - super::r#_Wrappers_Compile::Result::< - ::std::rc::Rc< - super::r#_simple_drefinement_dinternaldafny_dtypes::GetRefinementOutput, - >, - ::std::rc::Rc, - >::Success { - value: res.clone(), - }, - )); - return output.read(); - return output.read(); - } - pub fn OnlyInput( - config: &::std::rc::Rc, - input: &::std::rc::Rc< - super::r#_simple_drefinement_dinternaldafny_dtypes::OnlyInputInput, - >, - ) -> ::std::rc::Rc< - super::r#_Wrappers_Compile::Result< - (), - ::std::rc::Rc, - >, - > { - let mut output = ::dafny_runtime::MaybePlacebo::< - ::std::rc::Rc< - super::r#_Wrappers_Compile::Result< - (), - ::std::rc::Rc, - >, - >, - >::new(); - print!("{}", ::dafny_runtime::DafnyPrintWrapper(input)); - output = ::dafny_runtime::MaybePlacebo::from(::std::rc::Rc::new( - super::r#_Wrappers_Compile::Result::< - (), - ::std::rc::Rc, - >::Success { - value: (), - }, - )); - return output.read(); - return output.read(); - } - pub fn OnlyOutput( - config: &::std::rc::Rc, - ) -> ::std::rc::Rc< - super::r#_Wrappers_Compile::Result< - ::std::rc::Rc, - ::std::rc::Rc, - >, - > { - let mut output = ::dafny_runtime::MaybePlacebo::< - ::std::rc::Rc< - super::r#_Wrappers_Compile::Result< - ::std::rc::Rc< - super::r#_simple_drefinement_dinternaldafny_dtypes::OnlyOutputOutput, - >, - ::std::rc::Rc, - >, - >, - >::new(); - let mut res: ::std::rc::Rc = ::std::rc::Rc::new(super::r#_simple_drefinement_dinternaldafny_dtypes::OnlyOutputOutput::OnlyOutputOutput { - value: ::std::rc::Rc::new(super::r#_Wrappers_Compile::Option::<::dafny_runtime::Sequence<::dafny_runtime::DafnyCharUTF16>>::Some { - value: ::dafny_runtime::string_utf16_of("Hello World") - }) - }); - res = ::std::rc::Rc::new(super::r#_simple_drefinement_dinternaldafny_dtypes::OnlyOutputOutput::OnlyOutputOutput { - value: ::std::rc::Rc::new(super::r#_Wrappers_Compile::Option::<::dafny_runtime::Sequence<::dafny_runtime::DafnyCharUTF16>>::Some { - value: ::dafny_runtime::string_utf16_of("Hello World") - }) - }); - output = ::dafny_runtime::MaybePlacebo::from(::std::rc::Rc::new( - super::r#_Wrappers_Compile::Result::< - ::std::rc::Rc< - super::r#_simple_drefinement_dinternaldafny_dtypes::OnlyOutputOutput, - >, - ::std::rc::Rc, - >::Success { - value: res.clone(), - }, - )); - return output.read(); - return output.read(); - } - pub fn ReadonlyOperation( - config: &::std::rc::Rc, - input: &::std::rc::Rc< - super::r#_simple_drefinement_dinternaldafny_dtypes::ReadonlyOperationInput, - >, - ) -> ::std::rc::Rc< - super::r#_Wrappers_Compile::Result< - ::std::rc::Rc< - super::r#_simple_drefinement_dinternaldafny_dtypes::ReadonlyOperationOutput, - >, - ::std::rc::Rc, - >, - > { - ::std::rc::Rc::new(super::r#_Wrappers_Compile::Result::<::std::rc::Rc, ::std::rc::Rc>::Success { - value: ::std::rc::Rc::new(super::r#_simple_drefinement_dinternaldafny_dtypes::ReadonlyOperationOutput::ReadonlyOperationOutput { - requiredString: input.requiredString().clone(), - optionalString: input.optionalString().clone() - }) - }) - } - } - - #[derive(PartialEq, Clone)] - pub enum Config { - Config {}, - } - - impl Config {} - - impl ::std::fmt::Debug for Config { - fn fmt(&self, f: &mut ::std::fmt::Formatter) -> std::fmt::Result { - ::dafny_runtime::DafnyPrint::fmt_print(self, f, true) - } - } - - impl ::dafny_runtime::DafnyPrint for Config { - fn fmt_print( - &self, - _formatter: &mut ::std::fmt::Formatter, - _in_seq: bool, - ) -> std::fmt::Result { - match self { - Config::Config {} => { - write!(_formatter, "r#_SimpleRefinementImpl_Compile.Config.Config")?; - Ok(()) - } - } - } - } - - impl Eq for Config {} - - impl ::std::hash::Hash for Config { - fn hash<_H: ::std::hash::Hasher>(&self, _state: &mut _H) { - match self { - Config::Config {} => {} - } - } - } - - impl ::std::default::Default for Config { - fn default() -> Config { - Config::Config {} - } - } - - impl ::std::convert::AsRef for &Config { - fn as_ref(&self) -> Self { - self - } - } -} -pub mod r#_simple_drefinement_dinternaldafny { - pub struct _default {} - - impl _default { - pub fn _allocate_rcmut() -> ::dafny_runtime::Object { - ::dafny_runtime::allocate_rcmut::() - } - pub fn DefaultSimpleRefinementConfig( - ) -> ::std::rc::Rc - { - ::std::rc::Rc::new(super::r#_simple_drefinement_dinternaldafny_dtypes::SimpleRefinementConfig::SimpleRefinementConfig {}) - } - pub fn SimpleRefinement( - config: &::std::rc::Rc< - super::r#_simple_drefinement_dinternaldafny_dtypes::SimpleRefinementConfig, - >, - ) -> ::std::rc::Rc< - super::r#_Wrappers_Compile::Result< - ::dafny_runtime::Object< - super::r#_simple_drefinement_dinternaldafny::SimpleRefinementClient, - >, - ::std::rc::Rc, - >, - > { - let mut res = ::dafny_runtime::MaybePlacebo::< - ::std::rc::Rc< - super::r#_Wrappers_Compile::Result< - ::dafny_runtime::Object< - super::r#_simple_drefinement_dinternaldafny::SimpleRefinementClient, - >, - ::std::rc::Rc, - >, - >, - >::new(); - let mut client = ::dafny_runtime::MaybePlacebo::< - ::dafny_runtime::Object< - super::r#_simple_drefinement_dinternaldafny::SimpleRefinementClient, - >, - >::new(); - let mut _nw0: ::dafny_runtime::Object = super::r#_simple_drefinement_dinternaldafny::SimpleRefinementClient::_allocate_rcmut(); - super::r#_simple_drefinement_dinternaldafny::SimpleRefinementClient::_ctor( - &_nw0, - &::std::rc::Rc::new(super::r#_SimpleRefinementImpl_Compile::Config::Config {}), - ); - client = ::dafny_runtime::MaybePlacebo::from(_nw0.clone()); - res = ::dafny_runtime::MaybePlacebo::from(::std::rc::Rc::new( - super::r#_Wrappers_Compile::Result::< - ::dafny_runtime::Object< - super::r#_simple_drefinement_dinternaldafny::SimpleRefinementClient, - >, - ::std::rc::Rc, - >::Success { - value: client.read(), - }, - )); - return res.read(); - return res.read(); - } - pub fn CreateSuccessOfClient( - client: &::dafny_runtime::Object< - dyn super::r#_simple_drefinement_dinternaldafny_dtypes::ISimpleRefinementClient, - >, - ) -> ::std::rc::Rc< - super::r#_Wrappers_Compile::Result< - ::dafny_runtime::Object< - dyn super::r#_simple_drefinement_dinternaldafny_dtypes::ISimpleRefinementClient, - >, - ::std::rc::Rc, - >, - > { - ::std::rc::Rc::new(super::r#_Wrappers_Compile::Result::< - ::dafny_runtime::Object< - dyn super::r#_simple_drefinement_dinternaldafny_dtypes::ISimpleRefinementClient, - >, - ::std::rc::Rc, - >::Success { - value: client.clone(), - }) - } - pub fn CreateFailureOfError( - error: &::std::rc::Rc, - ) -> ::std::rc::Rc< - super::r#_Wrappers_Compile::Result< - ::dafny_runtime::Object< - dyn super::r#_simple_drefinement_dinternaldafny_dtypes::ISimpleRefinementClient, - >, - ::std::rc::Rc, - >, - > { - ::std::rc::Rc::new(super::r#_Wrappers_Compile::Result::< - ::dafny_runtime::Object< - dyn super::r#_simple_drefinement_dinternaldafny_dtypes::ISimpleRefinementClient, - >, - ::std::rc::Rc, - >::Failure { - error: error.clone(), - }) - } - } - - pub struct SimpleRefinementClient { - pub r#__i_config: ::std::rc::Rc, - } - - impl SimpleRefinementClient { - pub fn _allocate_rcmut() -> ::dafny_runtime::Object { - ::dafny_runtime::allocate_rcmut::() - } - pub fn _ctor( - this: &::dafny_runtime::Object, - config: &::std::rc::Rc, - ) -> () { - let mut _set__i_config: bool = false; - ::dafny_runtime::update_field_uninit_rcmut!( - this.clone(), - r#__i_config, - _set__i_config, - config.clone() - ); - return (); - } - pub fn config(&self) -> ::std::rc::Rc { - self.r#__i_config.clone() - } - } - - impl super::r#_simple_drefinement_dinternaldafny_dtypes::ISimpleRefinementClient - for super::r#_simple_drefinement_dinternaldafny::SimpleRefinementClient - { - fn GetRefinement( - &mut self, - input: &::std::rc::Rc< - super::r#_simple_drefinement_dinternaldafny_dtypes::GetRefinementInput, - >, - ) -> ::std::rc::Rc< - super::r#_Wrappers_Compile::Result< - ::std::rc::Rc< - super::r#_simple_drefinement_dinternaldafny_dtypes::GetRefinementOutput, - >, - ::std::rc::Rc, - >, - > { - let mut output = ::dafny_runtime::MaybePlacebo::< - ::std::rc::Rc< - super::r#_Wrappers_Compile::Result< - ::std::rc::Rc< - super::r#_simple_drefinement_dinternaldafny_dtypes::GetRefinementOutput, - >, - ::std::rc::Rc, - >, - >, - >::new(); - let mut _out0 = ::dafny_runtime::MaybePlacebo::< - ::std::rc::Rc< - super::r#_Wrappers_Compile::Result< - ::std::rc::Rc< - super::r#_simple_drefinement_dinternaldafny_dtypes::GetRefinementOutput, - >, - ::std::rc::Rc, - >, - >, - >::new(); - _out0 = ::dafny_runtime::MaybePlacebo::from( - super::r#_SimpleRefinementImpl_Compile::_default::GetRefinement( - &self.config(), - input, - ), - ); - output = ::dafny_runtime::MaybePlacebo::from(_out0.read()); - return output.read(); - } - fn OnlyInput( - &mut self, - input: &::std::rc::Rc< - super::r#_simple_drefinement_dinternaldafny_dtypes::OnlyInputInput, - >, - ) -> ::std::rc::Rc< - super::r#_Wrappers_Compile::Result< - (), - ::std::rc::Rc, - >, - > { - let mut output = ::dafny_runtime::MaybePlacebo::< - ::std::rc::Rc< - super::r#_Wrappers_Compile::Result< - (), - ::std::rc::Rc, - >, - >, - >::new(); - let mut _out1 = ::dafny_runtime::MaybePlacebo::< - ::std::rc::Rc< - super::r#_Wrappers_Compile::Result< - (), - ::std::rc::Rc, - >, - >, - >::new(); - _out1 = ::dafny_runtime::MaybePlacebo::from( - super::r#_SimpleRefinementImpl_Compile::_default::OnlyInput(&self.config(), input), - ); - output = ::dafny_runtime::MaybePlacebo::from(_out1.read()); - return output.read(); - } - fn OnlyOutput( - &mut self, - ) -> ::std::rc::Rc< - super::r#_Wrappers_Compile::Result< - ::std::rc::Rc, - ::std::rc::Rc, - >, - > { - let mut output = ::dafny_runtime::MaybePlacebo::< - ::std::rc::Rc< - super::r#_Wrappers_Compile::Result< - ::std::rc::Rc< - super::r#_simple_drefinement_dinternaldafny_dtypes::OnlyOutputOutput, - >, - ::std::rc::Rc, - >, - >, - >::new(); - let mut _out2 = ::dafny_runtime::MaybePlacebo::< - ::std::rc::Rc< - super::r#_Wrappers_Compile::Result< - ::std::rc::Rc< - super::r#_simple_drefinement_dinternaldafny_dtypes::OnlyOutputOutput, - >, - ::std::rc::Rc, - >, - >, - >::new(); - _out2 = ::dafny_runtime::MaybePlacebo::from( - super::r#_SimpleRefinementImpl_Compile::_default::OnlyOutput(&self.config()), - ); - output = ::dafny_runtime::MaybePlacebo::from(_out2.read()); - return output.read(); - } - fn ReadonlyOperation( - &self, - input: &::std::rc::Rc< - super::r#_simple_drefinement_dinternaldafny_dtypes::ReadonlyOperationInput, - >, - ) -> ::std::rc::Rc< - super::r#_Wrappers_Compile::Result< - ::std::rc::Rc< - super::r#_simple_drefinement_dinternaldafny_dtypes::ReadonlyOperationOutput, - >, - ::std::rc::Rc, - >, - > { - super::r#_SimpleRefinementImpl_Compile::_default::ReadonlyOperation( - &self.config(), - input, - ) - } - } -} -pub mod _module {} diff --git a/TestModels/Resource/runtimes/rust/dafny_impl/src/implementation_from_dafny.rs b/TestModels/Resource/runtimes/rust/dafny_impl/src/implementation_from_dafny.rs deleted file mode 100644 index 8b0cf6332b..0000000000 --- a/TestModels/Resource/runtimes/rust/dafny_impl/src/implementation_from_dafny.rs +++ /dev/null @@ -1,1298 +0,0 @@ -#![allow(warnings, unconditional_panic)] -#![allow(nonstandard_style)] -pub use dafny_standard_library::implementation_from_dafny::*; - -pub mod r#_simple_dresources_dinternaldafny_dtypes { - #[derive(PartialEq, Clone)] - pub enum DafnyCallEvent { - DafnyCallEvent { input: I, output: O }, - _PhantomVariant(::std::marker::PhantomData, ::std::marker::PhantomData), - } - - impl DafnyCallEvent { - pub fn input(&self) -> &I { - match self { - DafnyCallEvent::DafnyCallEvent { input, output } => input, - DafnyCallEvent::_PhantomVariant(..) => panic!(), - } - } - pub fn output(&self) -> &O { - match self { - DafnyCallEvent::DafnyCallEvent { input, output } => output, - DafnyCallEvent::_PhantomVariant(..) => panic!(), - } - } - } - - impl ::std::fmt::Debug - for DafnyCallEvent - { - fn fmt(&self, f: &mut ::std::fmt::Formatter) -> std::fmt::Result { - ::dafny_runtime::DafnyPrint::fmt_print(self, f, true) - } - } - - impl ::dafny_runtime::DafnyPrint - for DafnyCallEvent - { - fn fmt_print( - &self, - _formatter: &mut ::std::fmt::Formatter, - _in_seq: bool, - ) -> std::fmt::Result { - match self { - DafnyCallEvent::DafnyCallEvent { input, output } => { - write!( - _formatter, - "r#_simple_dresources_dinternaldafny_dtypes.DafnyCallEvent.DafnyCallEvent(" - )?; - ::dafny_runtime::DafnyPrint::fmt_print(input, _formatter, false)?; - write!(_formatter, ", ")?; - ::dafny_runtime::DafnyPrint::fmt_print(output, _formatter, false)?; - write!(_formatter, ")")?; - Ok(()) - } - DafnyCallEvent::_PhantomVariant(..) => { - panic!() - } - } - } - } - - impl Eq - for DafnyCallEvent - { - } - - impl< - I: ::dafny_runtime::DafnyType + ::std::hash::Hash, - O: ::dafny_runtime::DafnyType + ::std::hash::Hash, - > ::std::hash::Hash for DafnyCallEvent - { - fn hash<_H: ::std::hash::Hasher>(&self, _state: &mut _H) { - match self { - DafnyCallEvent::DafnyCallEvent { input, output } => { - input.hash(_state); - output.hash(_state) - } - DafnyCallEvent::_PhantomVariant(..) => { - panic!() - } - } - } - } - - impl< - I: ::dafny_runtime::DafnyType + ::std::default::Default, - O: ::dafny_runtime::DafnyType + ::std::default::Default, - > ::std::default::Default for DafnyCallEvent - { - fn default() -> DafnyCallEvent { - DafnyCallEvent::DafnyCallEvent { - input: ::std::default::Default::default(), - output: ::std::default::Default::default(), - } - } - } - - impl - ::std::convert::AsRef> for &DafnyCallEvent - { - fn as_ref(&self) -> Self { - self - } - } - - #[derive(PartialEq, Clone)] - pub enum GetResourceDataInput { - GetResourceDataInput { - blobValue: - ::std::rc::Rc>>, - booleanValue: ::std::rc::Rc>, - stringValue: ::std::rc::Rc< - super::r#_Wrappers_Compile::Option< - ::dafny_runtime::Sequence<::dafny_runtime::DafnyCharUTF16>, - >, - >, - integerValue: ::std::rc::Rc>, - longValue: ::std::rc::Rc>, - }, - } - - impl GetResourceDataInput { - pub fn blobValue( - &self, - ) -> &::std::rc::Rc>> - { - match self { - GetResourceDataInput::GetResourceDataInput { - blobValue, - booleanValue, - stringValue, - integerValue, - longValue, - } => blobValue, - } - } - pub fn booleanValue(&self) -> &::std::rc::Rc> { - match self { - GetResourceDataInput::GetResourceDataInput { - blobValue, - booleanValue, - stringValue, - integerValue, - longValue, - } => booleanValue, - } - } - pub fn stringValue( - &self, - ) -> &::std::rc::Rc< - super::r#_Wrappers_Compile::Option< - ::dafny_runtime::Sequence<::dafny_runtime::DafnyCharUTF16>, - >, - > { - match self { - GetResourceDataInput::GetResourceDataInput { - blobValue, - booleanValue, - stringValue, - integerValue, - longValue, - } => stringValue, - } - } - pub fn integerValue(&self) -> &::std::rc::Rc> { - match self { - GetResourceDataInput::GetResourceDataInput { - blobValue, - booleanValue, - stringValue, - integerValue, - longValue, - } => integerValue, - } - } - pub fn longValue(&self) -> &::std::rc::Rc> { - match self { - GetResourceDataInput::GetResourceDataInput { - blobValue, - booleanValue, - stringValue, - integerValue, - longValue, - } => longValue, - } - } - } - - impl ::std::fmt::Debug for GetResourceDataInput { - fn fmt(&self, f: &mut ::std::fmt::Formatter) -> std::fmt::Result { - ::dafny_runtime::DafnyPrint::fmt_print(self, f, true) - } - } - - impl ::dafny_runtime::DafnyPrint for GetResourceDataInput { - fn fmt_print( - &self, - _formatter: &mut ::std::fmt::Formatter, - _in_seq: bool, - ) -> std::fmt::Result { - match self { - GetResourceDataInput::GetResourceDataInput { - blobValue, - booleanValue, - stringValue, - integerValue, - longValue, - } => { - write!(_formatter, "r#_simple_dresources_dinternaldafny_dtypes.GetResourceDataInput.GetResourceDataInput(")?; - ::dafny_runtime::DafnyPrint::fmt_print(blobValue, _formatter, false)?; - write!(_formatter, ", ")?; - ::dafny_runtime::DafnyPrint::fmt_print(booleanValue, _formatter, false)?; - write!(_formatter, ", ")?; - ::dafny_runtime::DafnyPrint::fmt_print(stringValue, _formatter, false)?; - write!(_formatter, ", ")?; - ::dafny_runtime::DafnyPrint::fmt_print(integerValue, _formatter, false)?; - write!(_formatter, ", ")?; - ::dafny_runtime::DafnyPrint::fmt_print(longValue, _formatter, false)?; - write!(_formatter, ")")?; - Ok(()) - } - } - } - } - - impl Eq for GetResourceDataInput {} - - impl ::std::hash::Hash for GetResourceDataInput { - fn hash<_H: ::std::hash::Hasher>(&self, _state: &mut _H) { - match self { - GetResourceDataInput::GetResourceDataInput { - blobValue, - booleanValue, - stringValue, - integerValue, - longValue, - } => { - blobValue.hash(_state); - booleanValue.hash(_state); - stringValue.hash(_state); - integerValue.hash(_state); - longValue.hash(_state) - } - } - } - } - - impl ::std::default::Default for GetResourceDataInput { - fn default() -> GetResourceDataInput { - GetResourceDataInput::GetResourceDataInput { - blobValue: ::std::default::Default::default(), - booleanValue: ::std::default::Default::default(), - stringValue: ::std::default::Default::default(), - integerValue: ::std::default::Default::default(), - longValue: ::std::default::Default::default(), - } - } - } - - impl ::std::convert::AsRef for &GetResourceDataInput { - fn as_ref(&self) -> Self { - self - } - } - - #[derive(PartialEq, Clone)] - pub enum GetResourceDataOutput { - GetResourceDataOutput { - blobValue: - ::std::rc::Rc>>, - booleanValue: ::std::rc::Rc>, - stringValue: ::std::rc::Rc< - super::r#_Wrappers_Compile::Option< - ::dafny_runtime::Sequence<::dafny_runtime::DafnyCharUTF16>, - >, - >, - integerValue: ::std::rc::Rc>, - longValue: ::std::rc::Rc>, - }, - } - - impl GetResourceDataOutput { - pub fn blobValue( - &self, - ) -> &::std::rc::Rc>> - { - match self { - GetResourceDataOutput::GetResourceDataOutput { - blobValue, - booleanValue, - stringValue, - integerValue, - longValue, - } => blobValue, - } - } - pub fn booleanValue(&self) -> &::std::rc::Rc> { - match self { - GetResourceDataOutput::GetResourceDataOutput { - blobValue, - booleanValue, - stringValue, - integerValue, - longValue, - } => booleanValue, - } - } - pub fn stringValue( - &self, - ) -> &::std::rc::Rc< - super::r#_Wrappers_Compile::Option< - ::dafny_runtime::Sequence<::dafny_runtime::DafnyCharUTF16>, - >, - > { - match self { - GetResourceDataOutput::GetResourceDataOutput { - blobValue, - booleanValue, - stringValue, - integerValue, - longValue, - } => stringValue, - } - } - pub fn integerValue(&self) -> &::std::rc::Rc> { - match self { - GetResourceDataOutput::GetResourceDataOutput { - blobValue, - booleanValue, - stringValue, - integerValue, - longValue, - } => integerValue, - } - } - pub fn longValue(&self) -> &::std::rc::Rc> { - match self { - GetResourceDataOutput::GetResourceDataOutput { - blobValue, - booleanValue, - stringValue, - integerValue, - longValue, - } => longValue, - } - } - } - - impl ::std::fmt::Debug for GetResourceDataOutput { - fn fmt(&self, f: &mut ::std::fmt::Formatter) -> std::fmt::Result { - ::dafny_runtime::DafnyPrint::fmt_print(self, f, true) - } - } - - impl ::dafny_runtime::DafnyPrint for GetResourceDataOutput { - fn fmt_print( - &self, - _formatter: &mut ::std::fmt::Formatter, - _in_seq: bool, - ) -> std::fmt::Result { - match self { - GetResourceDataOutput::GetResourceDataOutput { - blobValue, - booleanValue, - stringValue, - integerValue, - longValue, - } => { - write!(_formatter, "r#_simple_dresources_dinternaldafny_dtypes.GetResourceDataOutput.GetResourceDataOutput(")?; - ::dafny_runtime::DafnyPrint::fmt_print(blobValue, _formatter, false)?; - write!(_formatter, ", ")?; - ::dafny_runtime::DafnyPrint::fmt_print(booleanValue, _formatter, false)?; - write!(_formatter, ", ")?; - ::dafny_runtime::DafnyPrint::fmt_print(stringValue, _formatter, false)?; - write!(_formatter, ", ")?; - ::dafny_runtime::DafnyPrint::fmt_print(integerValue, _formatter, false)?; - write!(_formatter, ", ")?; - ::dafny_runtime::DafnyPrint::fmt_print(longValue, _formatter, false)?; - write!(_formatter, ")")?; - Ok(()) - } - } - } - } - - impl Eq for GetResourceDataOutput {} - - impl ::std::hash::Hash for GetResourceDataOutput { - fn hash<_H: ::std::hash::Hasher>(&self, _state: &mut _H) { - match self { - GetResourceDataOutput::GetResourceDataOutput { - blobValue, - booleanValue, - stringValue, - integerValue, - longValue, - } => { - blobValue.hash(_state); - booleanValue.hash(_state); - stringValue.hash(_state); - integerValue.hash(_state); - longValue.hash(_state) - } - } - } - } - - impl ::std::default::Default for GetResourceDataOutput { - fn default() -> GetResourceDataOutput { - GetResourceDataOutput::GetResourceDataOutput { - blobValue: ::std::default::Default::default(), - booleanValue: ::std::default::Default::default(), - stringValue: ::std::default::Default::default(), - integerValue: ::std::default::Default::default(), - longValue: ::std::default::Default::default(), - } - } - } - - impl ::std::convert::AsRef for &GetResourceDataOutput { - fn as_ref(&self) -> Self { - self - } - } - - #[derive(PartialEq, Clone)] - pub enum GetResourcesInput { - GetResourcesInput { - value: ::std::rc::Rc< - super::r#_Wrappers_Compile::Option< - ::dafny_runtime::Sequence<::dafny_runtime::DafnyCharUTF16>, - >, - >, - }, - } - - impl GetResourcesInput { - pub fn value( - &self, - ) -> &::std::rc::Rc< - super::r#_Wrappers_Compile::Option< - ::dafny_runtime::Sequence<::dafny_runtime::DafnyCharUTF16>, - >, - > { - match self { - GetResourcesInput::GetResourcesInput { value } => value, - } - } - } - - impl ::std::fmt::Debug for GetResourcesInput { - fn fmt(&self, f: &mut ::std::fmt::Formatter) -> std::fmt::Result { - ::dafny_runtime::DafnyPrint::fmt_print(self, f, true) - } - } - - impl ::dafny_runtime::DafnyPrint for GetResourcesInput { - fn fmt_print( - &self, - _formatter: &mut ::std::fmt::Formatter, - _in_seq: bool, - ) -> std::fmt::Result { - match self { - GetResourcesInput::GetResourcesInput { value } => { - write!(_formatter, "r#_simple_dresources_dinternaldafny_dtypes.GetResourcesInput.GetResourcesInput(")?; - ::dafny_runtime::DafnyPrint::fmt_print(value, _formatter, false)?; - write!(_formatter, ")")?; - Ok(()) - } - } - } - } - - impl Eq for GetResourcesInput {} - - impl ::std::hash::Hash for GetResourcesInput { - fn hash<_H: ::std::hash::Hasher>(&self, _state: &mut _H) { - match self { - GetResourcesInput::GetResourcesInput { value } => value.hash(_state), - } - } - } - - impl ::std::default::Default for GetResourcesInput { - fn default() -> GetResourcesInput { - GetResourcesInput::GetResourcesInput { - value: ::std::default::Default::default(), - } - } - } - - impl ::std::convert::AsRef for &GetResourcesInput { - fn as_ref(&self) -> Self { - self - } - } - - #[derive(PartialEq, Clone)] - pub enum GetResourcesOutput { - GetResourcesOutput { - output: ::dafny_runtime::Object< - dyn super::r#_simple_dresources_dinternaldafny_dtypes::ISimpleResource, - >, - }, - } - - impl GetResourcesOutput { - pub fn output( - &self, - ) -> &::dafny_runtime::Object< - dyn super::r#_simple_dresources_dinternaldafny_dtypes::ISimpleResource, - > { - match self { - GetResourcesOutput::GetResourcesOutput { output } => output, - } - } - } - - impl ::std::fmt::Debug for GetResourcesOutput { - fn fmt(&self, f: &mut ::std::fmt::Formatter) -> std::fmt::Result { - ::dafny_runtime::DafnyPrint::fmt_print(self, f, true) - } - } - - impl ::dafny_runtime::DafnyPrint for GetResourcesOutput { - fn fmt_print( - &self, - _formatter: &mut ::std::fmt::Formatter, - _in_seq: bool, - ) -> std::fmt::Result { - match self { - GetResourcesOutput::GetResourcesOutput { output } => { - write!(_formatter, "r#_simple_dresources_dinternaldafny_dtypes.GetResourcesOutput.GetResourcesOutput(")?; - ::dafny_runtime::DafnyPrint::fmt_print(output, _formatter, false)?; - write!(_formatter, ")")?; - Ok(()) - } - } - } - } - - impl Eq for GetResourcesOutput {} - - impl ::std::hash::Hash for GetResourcesOutput { - fn hash<_H: ::std::hash::Hasher>(&self, _state: &mut _H) { - match self { - GetResourcesOutput::GetResourcesOutput { output } => output.hash(_state), - } - } - } - - // the trait `Default` is not implemented for `Object<(dyn ISimpleResource + 'static)>` - // impl ::std::default::Default for GetResourcesOutput { - // fn default() -> GetResourcesOutput { - // GetResourcesOutput::GetResourcesOutput { - // output: ::std::default::Default::default(), - // } - // } - // } - - impl ::std::convert::AsRef for &GetResourcesOutput { - fn as_ref(&self) -> Self { - self - } - } - - pub struct ISimpleResourceCallHistory {} - - impl ISimpleResourceCallHistory { - pub fn _allocate_rcmut() -> ::dafny_runtime::Object { - ::dafny_runtime::allocate_rcmut::() - } - } - - pub trait ISimpleResource { - fn GetResourceData( - &mut self, - input: &::std::rc::Rc< - super::r#_simple_dresources_dinternaldafny_dtypes::GetResourceDataInput, - >, - ) -> ::std::rc::Rc< - super::r#_Wrappers_Compile::Result< - ::std::rc::Rc< - super::r#_simple_dresources_dinternaldafny_dtypes::GetResourceDataOutput, - >, - ::std::rc::Rc, - >, - > { - let mut output = ::dafny_runtime::MaybePlacebo::<::std::rc::Rc, ::std::rc::Rc>>>::new(); - let mut _out0 = ::dafny_runtime::MaybePlacebo::<::std::rc::Rc, ::std::rc::Rc>>>::new(); - _out0 = ::dafny_runtime::MaybePlacebo::from( - self.r#_GetResourceData_k(input), - ); - output = ::dafny_runtime::MaybePlacebo::from(_out0.read()); - return output.read(); - } - fn r#_GetResourceData_k( - &mut self, - input: &::std::rc::Rc< - super::r#_simple_dresources_dinternaldafny_dtypes::GetResourceDataInput, - >, - ) -> ::std::rc::Rc< - super::r#_Wrappers_Compile::Result< - ::std::rc::Rc< - super::r#_simple_dresources_dinternaldafny_dtypes::GetResourceDataOutput, - >, - ::std::rc::Rc, - >, - >; - } - - pub struct ISimpleResourcesClientCallHistory {} - - impl ISimpleResourcesClientCallHistory { - pub fn _allocate_rcmut() -> ::dafny_runtime::Object { - ::dafny_runtime::allocate_rcmut::() - } - } - - pub trait ISimpleResourcesClient { - fn GetResources( - &mut self, - input: &::std::rc::Rc< - super::r#_simple_dresources_dinternaldafny_dtypes::GetResourcesInput, - >, - ) -> ::std::rc::Rc< - super::r#_Wrappers_Compile::Result< - ::std::rc::Rc< - super::r#_simple_dresources_dinternaldafny_dtypes::GetResourcesOutput, - >, - ::std::rc::Rc, - >, - >; - } - - #[derive(PartialEq, Clone)] - pub enum SimpleResourcesConfig { - SimpleResourcesConfig { - name: ::dafny_runtime::Sequence<::dafny_runtime::DafnyCharUTF16>, - }, - } - - impl SimpleResourcesConfig { - pub fn name(&self) -> &::dafny_runtime::Sequence<::dafny_runtime::DafnyCharUTF16> { - match self { - SimpleResourcesConfig::SimpleResourcesConfig { name } => name, - } - } - } - - impl ::std::fmt::Debug for SimpleResourcesConfig { - fn fmt(&self, f: &mut ::std::fmt::Formatter) -> std::fmt::Result { - ::dafny_runtime::DafnyPrint::fmt_print(self, f, true) - } - } - - impl ::dafny_runtime::DafnyPrint for SimpleResourcesConfig { - fn fmt_print( - &self, - _formatter: &mut ::std::fmt::Formatter, - _in_seq: bool, - ) -> std::fmt::Result { - match self { - SimpleResourcesConfig::SimpleResourcesConfig { name } => { - write!(_formatter, "r#_simple_dresources_dinternaldafny_dtypes.SimpleResourcesConfig.SimpleResourcesConfig(")?; - ::dafny_runtime::DafnyPrint::fmt_print(name, _formatter, false)?; - write!(_formatter, ")")?; - Ok(()) - } - } - } - } - - impl Eq for SimpleResourcesConfig {} - - impl ::std::hash::Hash for SimpleResourcesConfig { - fn hash<_H: ::std::hash::Hasher>(&self, _state: &mut _H) { - match self { - SimpleResourcesConfig::SimpleResourcesConfig { name } => name.hash(_state), - } - } - } - - impl ::std::default::Default for SimpleResourcesConfig { - fn default() -> SimpleResourcesConfig { - SimpleResourcesConfig::SimpleResourcesConfig { - name: ::std::default::Default::default(), - } - } - } - - impl ::std::convert::AsRef for &SimpleResourcesConfig { - fn as_ref(&self) -> Self { - self - } - } - - #[derive(PartialEq, Clone)] - pub enum Error { - SimpleResourcesException { - message: ::dafny_runtime::Sequence<::dafny_runtime::DafnyCharUTF16>, - }, - CollectionOfErrors { - list: ::dafny_runtime::Sequence< - ::std::rc::Rc, - >, - message: ::dafny_runtime::Sequence<::dafny_runtime::DafnyCharUTF16>, - }, - Opaque { - obj: ::dafny_runtime::Object, - }, - } - - impl Error { - pub fn message(&self) -> &::dafny_runtime::Sequence<::dafny_runtime::DafnyCharUTF16> { - match self { - Error::SimpleResourcesException { message } => message, - Error::CollectionOfErrors { list, message } => message, - Error::Opaque { obj } => panic!("field does not exist on this variant"), - } - } - pub fn list( - &self, - ) -> &::dafny_runtime::Sequence< - ::std::rc::Rc, - > { - match self { - Error::SimpleResourcesException { message } => { - panic!("field does not exist on this variant") - } - Error::CollectionOfErrors { list, message } => list, - Error::Opaque { obj } => panic!("field does not exist on this variant"), - } - } - pub fn obj(&self) -> &::dafny_runtime::Object { - match self { - Error::SimpleResourcesException { message } => { - panic!("field does not exist on this variant") - } - Error::CollectionOfErrors { list, message } => { - panic!("field does not exist on this variant") - } - Error::Opaque { obj } => obj, - } - } - } - - impl ::std::fmt::Debug for Error { - fn fmt(&self, f: &mut ::std::fmt::Formatter) -> std::fmt::Result { - ::dafny_runtime::DafnyPrint::fmt_print(self, f, true) - } - } - - impl ::dafny_runtime::DafnyPrint for Error { - fn fmt_print( - &self, - _formatter: &mut ::std::fmt::Formatter, - _in_seq: bool, - ) -> std::fmt::Result { - match self { - Error::SimpleResourcesException { message } => { - write!(_formatter, "r#_simple_dresources_dinternaldafny_dtypes.Error.SimpleResourcesException(")?; - ::dafny_runtime::DafnyPrint::fmt_print(message, _formatter, false)?; - write!(_formatter, ")")?; - Ok(()) - } - Error::CollectionOfErrors { list, message } => { - write!( - _formatter, - "r#_simple_dresources_dinternaldafny_dtypes.Error.CollectionOfErrors(" - )?; - ::dafny_runtime::DafnyPrint::fmt_print(list, _formatter, false)?; - write!(_formatter, ", ")?; - ::dafny_runtime::DafnyPrint::fmt_print(message, _formatter, false)?; - write!(_formatter, ")")?; - Ok(()) - } - Error::Opaque { obj } => { - write!( - _formatter, - "r#_simple_dresources_dinternaldafny_dtypes.Error.Opaque(" - )?; - ::dafny_runtime::DafnyPrint::fmt_print(obj, _formatter, false)?; - write!(_formatter, ")")?; - Ok(()) - } - } - } - } - - impl Eq for Error {} - - impl ::std::hash::Hash for Error { - fn hash<_H: ::std::hash::Hasher>(&self, _state: &mut _H) { - match self { - Error::SimpleResourcesException { message } => message.hash(_state), - Error::CollectionOfErrors { list, message } => { - list.hash(_state); - message.hash(_state) - } - Error::Opaque { obj } => obj.hash(_state), - } - } - } - - impl ::std::default::Default for Error { - fn default() -> Error { - Error::SimpleResourcesException { - message: ::std::default::Default::default(), - } - } - } - - impl ::std::convert::AsRef for &Error { - fn as_ref(&self) -> Self { - self - } - } - - pub type OpaqueError = ::std::rc::Rc; -} -pub mod r#_SimpleResource_Compile { - pub struct SimpleResource { - pub r#__i_value: ::std::rc::Rc< - super::r#_Wrappers_Compile::Option< - ::dafny_runtime::Sequence<::dafny_runtime::DafnyCharUTF16>, - >, - >, - pub r#__i_name: ::dafny_runtime::Sequence<::dafny_runtime::DafnyCharUTF16>, - } - - impl SimpleResource { - pub fn _allocate_rcmut() -> ::dafny_runtime::Object { - ::dafny_runtime::allocate_rcmut::() - } - pub fn GetResourceData( - &mut self, - input: &::std::rc::Rc< - super::r#_simple_dresources_dinternaldafny_dtypes::GetResourceDataInput, - >, - ) -> ::std::rc::Rc< - super::r#_Wrappers_Compile::Result< - ::std::rc::Rc< - super::r#_simple_dresources_dinternaldafny_dtypes::GetResourceDataOutput, - >, - ::std::rc::Rc, - >, - > { - let mut _out1 = ::dafny_runtime::MaybePlacebo::<::std::rc::Rc, ::std::rc::Rc>>>::new(); - _out1 = ::dafny_runtime::MaybePlacebo::from( - super::r#_simple_dresources_dinternaldafny_dtypes::ISimpleResource::GetResourceData( - self, - input, - ), - ); - _out1.read() - } - pub fn _ctor( - this: &::dafny_runtime::Object, - value: &::std::rc::Rc< - super::r#_Wrappers_Compile::Option< - ::dafny_runtime::Sequence<::dafny_runtime::DafnyCharUTF16>, - >, - >, - name: &::dafny_runtime::Sequence<::dafny_runtime::DafnyCharUTF16>, - ) -> () { - let mut _set__i_value: bool = false; - let mut _set__i_name: bool = false; - ::dafny_runtime::update_field_uninit_rcmut!( - this.clone(), - r#__i_value, - _set__i_value, - value.clone() - ); - ::dafny_runtime::update_field_uninit_rcmut!( - this.clone(), - r#__i_name, - _set__i_name, - name.clone() - ); - return (); - } - pub fn value( - &self, - ) -> ::std::rc::Rc< - super::r#_Wrappers_Compile::Option< - ::dafny_runtime::Sequence<::dafny_runtime::DafnyCharUTF16>, - >, - > { - self.r#__i_value.clone() - } - pub fn name(&self) -> ::dafny_runtime::Sequence<::dafny_runtime::DafnyCharUTF16> { - self.r#__i_name.clone() - } - } - - impl super::r#_simple_dresources_dinternaldafny_dtypes::ISimpleResource - for super::r#_SimpleResource_Compile::SimpleResource - { - fn r#_GetResourceData_k( - &mut self, - input: &::std::rc::Rc< - super::r#_simple_dresources_dinternaldafny_dtypes::GetResourceDataInput, - >, - ) -> ::std::rc::Rc< - super::r#_Wrappers_Compile::Result< - ::std::rc::Rc< - super::r#_simple_dresources_dinternaldafny_dtypes::GetResourceDataOutput, - >, - ::std::rc::Rc, - >, - > { - let mut output = ::dafny_runtime::MaybePlacebo::<::std::rc::Rc, ::std::rc::Rc>>>::new(); - let mut rtnString: ::dafny_runtime::Sequence<::dafny_runtime::DafnyCharUTF16> = (if matches!( - input.stringValue().as_ref(), - super::r#_Wrappers_Compile::Option::Some { .. } - ) { - self.name() - .concat(&::dafny_runtime::string_utf16_of(" ")) - .concat(input.stringValue().value()) - } else { - self.name() - }); - rtnString = (if matches!( - input.stringValue().as_ref(), - super::r#_Wrappers_Compile::Option::Some { .. } - ) { - self.name() - .concat(&::dafny_runtime::string_utf16_of(" ")) - .concat(input.stringValue().value()) - } else { - self.name() - }); - let mut rtn: ::std::rc::Rc = ::std::rc::Rc::new(super::r#_simple_dresources_dinternaldafny_dtypes::GetResourceDataOutput::GetResourceDataOutput { - blobValue: input.blobValue().clone(), - booleanValue: input.booleanValue().clone(), - stringValue: ::std::rc::Rc::new(super::r#_Wrappers_Compile::Option::<::dafny_runtime::Sequence<::dafny_runtime::DafnyCharUTF16>>::Some { - value: rtnString.clone() - }), - integerValue: input.integerValue().clone(), - longValue: input.longValue().clone() - }); - rtn = ::std::rc::Rc::new(super::r#_simple_dresources_dinternaldafny_dtypes::GetResourceDataOutput::GetResourceDataOutput { - blobValue: input.blobValue().clone(), - booleanValue: input.booleanValue().clone(), - stringValue: ::std::rc::Rc::new(super::r#_Wrappers_Compile::Option::<::dafny_runtime::Sequence<::dafny_runtime::DafnyCharUTF16>>::Some { - value: rtnString.clone() - }), - integerValue: input.integerValue().clone(), - longValue: input.longValue().clone() - }); - output = ::dafny_runtime::MaybePlacebo::from(::std::rc::Rc::new( - super::r#_Wrappers_Compile::Result::< - ::std::rc::Rc< - super::r#_simple_dresources_dinternaldafny_dtypes::GetResourceDataOutput, - >, - ::std::rc::Rc, - >::Success { - value: rtn.clone(), - }, - )); - return output.read(); - return output.read(); - } - } -} -pub mod r#_SimpleResourcesOperations_Compile { - pub struct _default {} - - impl _default { - pub fn _allocate_rcmut() -> ::dafny_runtime::Object { - ::dafny_runtime::allocate_rcmut::() - } - pub fn r#_ValidInternalConfig_q( - config: &::std::rc::Rc, - ) -> bool { - true && ::dafny_runtime::int!(0) < config.name().cardinality() - } - pub fn GetResources( - config: &::std::rc::Rc, - input: &::std::rc::Rc< - super::r#_simple_dresources_dinternaldafny_dtypes::GetResourcesInput, - >, - ) -> ::std::rc::Rc< - super::r#_Wrappers_Compile::Result< - ::std::rc::Rc< - super::r#_simple_dresources_dinternaldafny_dtypes::GetResourcesOutput, - >, - ::std::rc::Rc, - >, - > { - let mut output = ::dafny_runtime::MaybePlacebo::< - ::std::rc::Rc< - super::r#_Wrappers_Compile::Result< - ::std::rc::Rc< - super::r#_simple_dresources_dinternaldafny_dtypes::GetResourcesOutput, - >, - ::std::rc::Rc, - >, - >, - >::new(); - let mut resource = ::dafny_runtime::MaybePlacebo::< - ::dafny_runtime::Object, - >::new(); - let mut _nw0: ::dafny_runtime::Object< - super::r#_SimpleResource_Compile::SimpleResource, - > = super::r#_SimpleResource_Compile::SimpleResource::_allocate_rcmut(); - super::r#_SimpleResource_Compile::SimpleResource::_ctor( - &_nw0, - input.value(), - config.name(), - ); - resource = ::dafny_runtime::MaybePlacebo::from(_nw0.clone()); - let mut result: ::std::rc::Rc = ::std::rc::Rc::new(super::r#_simple_dresources_dinternaldafny_dtypes::GetResourcesOutput::GetResourcesOutput { - output: ::dafny_runtime::UpcastTo::<::dafny_runtime::Object>::upcast_to(resource.read()) - }); - result = ::std::rc::Rc::new(super::r#_simple_dresources_dinternaldafny_dtypes::GetResourcesOutput::GetResourcesOutput { - output: ::dafny_runtime::UpcastTo::<::dafny_runtime::Object>::upcast_to(resource.read()) - }); - output = ::dafny_runtime::MaybePlacebo::from(::std::rc::Rc::new( - super::r#_Wrappers_Compile::Result::< - ::std::rc::Rc< - super::r#_simple_dresources_dinternaldafny_dtypes::GetResourcesOutput, - >, - ::std::rc::Rc, - >::Success { - value: result.clone(), - }, - )); - return output.read(); - return output.read(); - } - } - - #[derive(PartialEq, Clone)] - pub enum Config { - Config { - name: ::dafny_runtime::Sequence<::dafny_runtime::DafnyCharUTF16>, - }, - } - - impl Config { - pub fn name(&self) -> &::dafny_runtime::Sequence<::dafny_runtime::DafnyCharUTF16> { - match self { - Config::Config { name } => name, - } - } - } - - impl ::std::fmt::Debug for Config { - fn fmt(&self, f: &mut ::std::fmt::Formatter) -> std::fmt::Result { - ::dafny_runtime::DafnyPrint::fmt_print(self, f, true) - } - } - - impl ::dafny_runtime::DafnyPrint for Config { - fn fmt_print( - &self, - _formatter: &mut ::std::fmt::Formatter, - _in_seq: bool, - ) -> std::fmt::Result { - match self { - Config::Config { name } => { - write!( - _formatter, - "r#_SimpleResourcesOperations_Compile.Config.Config(" - )?; - ::dafny_runtime::DafnyPrint::fmt_print(name, _formatter, false)?; - write!(_formatter, ")")?; - Ok(()) - } - } - } - } - - impl Eq for Config {} - - impl ::std::hash::Hash for Config { - fn hash<_H: ::std::hash::Hasher>(&self, _state: &mut _H) { - match self { - Config::Config { name } => name.hash(_state), - } - } - } - - impl ::std::default::Default for Config { - fn default() -> Config { - Config::Config { - name: ::std::default::Default::default(), - } - } - } - - impl ::std::convert::AsRef for &Config { - fn as_ref(&self) -> Self { - self - } - } -} -pub mod r#_simple_dresources_dinternaldafny { - pub struct _default {} - - impl _default { - pub fn _allocate_rcmut() -> ::dafny_runtime::Object { - ::dafny_runtime::allocate_rcmut::() - } - pub fn DefaultSimpleResourcesConfig( - ) -> ::std::rc::Rc - { - ::std::rc::Rc::new(super::r#_simple_dresources_dinternaldafny_dtypes::SimpleResourcesConfig::SimpleResourcesConfig { - name: ::dafny_runtime::string_utf16_of("default") - }) - } - pub fn SimpleResources( - config: &::std::rc::Rc< - super::r#_simple_dresources_dinternaldafny_dtypes::SimpleResourcesConfig, - >, - ) -> ::std::rc::Rc< - super::r#_Wrappers_Compile::Result< - ::dafny_runtime::Object< - super::r#_simple_dresources_dinternaldafny::SimpleResourcesClient, - >, - ::std::rc::Rc, - >, - > { - let mut res = ::dafny_runtime::MaybePlacebo::< - ::std::rc::Rc< - super::r#_Wrappers_Compile::Result< - ::dafny_runtime::Object< - super::r#_simple_dresources_dinternaldafny::SimpleResourcesClient, - >, - ::std::rc::Rc, - >, - >, - >::new(); - let mut internalConfig: ::std::rc::Rc< - super::r#_SimpleResourcesOperations_Compile::Config, - > = ::std::rc::Rc::new( - super::r#_SimpleResourcesOperations_Compile::Config::Config { - name: config.name().clone(), - }, - ); - internalConfig = ::std::rc::Rc::new( - super::r#_SimpleResourcesOperations_Compile::Config::Config { - name: config.name().clone(), - }, - ); - if super::r#_SimpleResourcesOperations_Compile::_default::r#_ValidInternalConfig_q( - &internalConfig, - ) { - let mut client = ::dafny_runtime::MaybePlacebo::< - ::dafny_runtime::Object< - super::r#_simple_dresources_dinternaldafny::SimpleResourcesClient, - >, - >::new(); - let mut _nw1: ::dafny_runtime::Object = super::r#_simple_dresources_dinternaldafny::SimpleResourcesClient::_allocate_rcmut(); - super::r#_simple_dresources_dinternaldafny::SimpleResourcesClient::_ctor( - &_nw1, - &internalConfig, - ); - client = ::dafny_runtime::MaybePlacebo::from(_nw1.clone()); - res = ::dafny_runtime::MaybePlacebo::from(::std::rc::Rc::new( - super::r#_Wrappers_Compile::Result::< - ::dafny_runtime::Object< - super::r#_simple_dresources_dinternaldafny::SimpleResourcesClient, - >, - ::std::rc::Rc, - >::Success { - value: client.read(), - }, - )); - return res.read(); - } else { - res = ::dafny_runtime::MaybePlacebo::from(::std::rc::Rc::new(super::r#_Wrappers_Compile::Result::<::dafny_runtime::Object, ::std::rc::Rc>::Failure { - error: ::std::rc::Rc::new(super::r#_simple_dresources_dinternaldafny_dtypes::Error::SimpleResourcesException { - message: ::dafny_runtime::string_utf16_of("Length of name must be greater than 0") - }) - })); - return res.read(); - }; - return res.read(); - } - pub fn CreateSuccessOfClient( - client: &::dafny_runtime::Object< - dyn super::r#_simple_dresources_dinternaldafny_dtypes::ISimpleResourcesClient, - >, - ) -> ::std::rc::Rc< - super::r#_Wrappers_Compile::Result< - ::dafny_runtime::Object< - dyn super::r#_simple_dresources_dinternaldafny_dtypes::ISimpleResourcesClient, - >, - ::std::rc::Rc, - >, - > { - ::std::rc::Rc::new(super::r#_Wrappers_Compile::Result::< - ::dafny_runtime::Object< - dyn super::r#_simple_dresources_dinternaldafny_dtypes::ISimpleResourcesClient, - >, - ::std::rc::Rc, - >::Success { - value: client.clone(), - }) - } - pub fn CreateFailureOfError( - error: &::std::rc::Rc, - ) -> ::std::rc::Rc< - super::r#_Wrappers_Compile::Result< - ::dafny_runtime::Object< - dyn super::r#_simple_dresources_dinternaldafny_dtypes::ISimpleResourcesClient, - >, - ::std::rc::Rc, - >, - > { - ::std::rc::Rc::new(super::r#_Wrappers_Compile::Result::< - ::dafny_runtime::Object< - dyn super::r#_simple_dresources_dinternaldafny_dtypes::ISimpleResourcesClient, - >, - ::std::rc::Rc, - >::Failure { - error: error.clone(), - }) - } - } - - pub struct SimpleResourcesClient { - pub r#__i_config: ::std::rc::Rc, - } - - impl SimpleResourcesClient { - pub fn _allocate_rcmut() -> ::dafny_runtime::Object { - ::dafny_runtime::allocate_rcmut::() - } - pub fn _ctor( - this: &::dafny_runtime::Object, - config: &::std::rc::Rc, - ) -> () { - let mut _set__i_config: bool = false; - ::dafny_runtime::update_field_uninit_rcmut!( - this.clone(), - r#__i_config, - _set__i_config, - config.clone() - ); - return (); - } - pub fn config(&self) -> ::std::rc::Rc { - self.r#__i_config.clone() - } - } - - impl super::r#_simple_dresources_dinternaldafny_dtypes::ISimpleResourcesClient - for super::r#_simple_dresources_dinternaldafny::SimpleResourcesClient - { - fn GetResources( - &mut self, - input: &::std::rc::Rc< - super::r#_simple_dresources_dinternaldafny_dtypes::GetResourcesInput, - >, - ) -> ::std::rc::Rc< - super::r#_Wrappers_Compile::Result< - ::std::rc::Rc< - super::r#_simple_dresources_dinternaldafny_dtypes::GetResourcesOutput, - >, - ::std::rc::Rc, - >, - > { - let mut output = ::dafny_runtime::MaybePlacebo::< - ::std::rc::Rc< - super::r#_Wrappers_Compile::Result< - ::std::rc::Rc< - super::r#_simple_dresources_dinternaldafny_dtypes::GetResourcesOutput, - >, - ::std::rc::Rc, - >, - >, - >::new(); - let mut _out2 = ::dafny_runtime::MaybePlacebo::< - ::std::rc::Rc< - super::r#_Wrappers_Compile::Result< - ::std::rc::Rc< - super::r#_simple_dresources_dinternaldafny_dtypes::GetResourcesOutput, - >, - ::std::rc::Rc, - >, - >, - >::new(); - _out2 = ::dafny_runtime::MaybePlacebo::from( - super::r#_SimpleResourcesOperations_Compile::_default::GetResources( - &self.config(), - input, - ), - ); - output = ::dafny_runtime::MaybePlacebo::from(_out2.read()); - return output.read(); - } - } -} -pub mod _module {} diff --git a/TestModels/SimpleTypes/SimpleBlob/runtimes/rust/dafny_impl/src/implementation_from_dafny.rs b/TestModels/SimpleTypes/SimpleBlob/runtimes/rust/dafny_impl/src/implementation_from_dafny.rs deleted file mode 100644 index a683be1b7a..0000000000 --- a/TestModels/SimpleTypes/SimpleBlob/runtimes/rust/dafny_impl/src/implementation_from_dafny.rs +++ /dev/null @@ -1,843 +0,0 @@ -#![allow(warnings, unconditional_panic)] -#![allow(nonstandard_style)] -pub use dafny_standard_library::implementation_from_dafny::*; - -pub mod r#_simple_dtypes_dblob_dinternaldafny_dtypes { - #[derive(PartialEq, Clone)] - pub enum DafnyCallEvent { - DafnyCallEvent { input: I, output: O }, - _PhantomVariant(::std::marker::PhantomData, ::std::marker::PhantomData), - } - - impl DafnyCallEvent { - pub fn input(&self) -> &I { - match self { - DafnyCallEvent::DafnyCallEvent { input, output } => input, - DafnyCallEvent::_PhantomVariant(..) => panic!(), - } - } - pub fn output(&self) -> &O { - match self { - DafnyCallEvent::DafnyCallEvent { input, output } => output, - DafnyCallEvent::_PhantomVariant(..) => panic!(), - } - } - } - - impl ::std::fmt::Debug - for DafnyCallEvent - { - fn fmt(&self, f: &mut ::std::fmt::Formatter) -> std::fmt::Result { - ::dafny_runtime::DafnyPrint::fmt_print(self, f, true) - } - } - - impl ::dafny_runtime::DafnyPrint - for DafnyCallEvent - { - fn fmt_print( - &self, - _formatter: &mut ::std::fmt::Formatter, - _in_seq: bool, - ) -> std::fmt::Result { - match self { - DafnyCallEvent::DafnyCallEvent { input, output } => { - write!(_formatter, "r#_simple_dtypes_dblob_dinternaldafny_dtypes.DafnyCallEvent.DafnyCallEvent(")?; - ::dafny_runtime::DafnyPrint::fmt_print(input, _formatter, false)?; - write!(_formatter, ", ")?; - ::dafny_runtime::DafnyPrint::fmt_print(output, _formatter, false)?; - write!(_formatter, ")")?; - Ok(()) - } - DafnyCallEvent::_PhantomVariant(..) => { - panic!() - } - } - } - } - - impl Eq - for DafnyCallEvent - { - } - - impl< - I: ::dafny_runtime::DafnyType + ::std::hash::Hash, - O: ::dafny_runtime::DafnyType + ::std::hash::Hash, - > ::std::hash::Hash for DafnyCallEvent - { - fn hash<_H: ::std::hash::Hasher>(&self, _state: &mut _H) { - match self { - DafnyCallEvent::DafnyCallEvent { input, output } => { - input.hash(_state); - output.hash(_state) - } - DafnyCallEvent::_PhantomVariant(..) => { - panic!() - } - } - } - } - - impl< - I: ::dafny_runtime::DafnyType + ::std::default::Default, - O: ::dafny_runtime::DafnyType + ::std::default::Default, - > ::std::default::Default for DafnyCallEvent - { - fn default() -> DafnyCallEvent { - DafnyCallEvent::DafnyCallEvent { - input: ::std::default::Default::default(), - output: ::std::default::Default::default(), - } - } - } - - impl - ::std::convert::AsRef> for &DafnyCallEvent - { - fn as_ref(&self) -> Self { - self - } - } - - #[derive(PartialEq, Clone)] - pub enum GetBlobInput { - GetBlobInput { - value: ::std::rc::Rc>>, - }, - } - - impl GetBlobInput { - pub fn value( - &self, - ) -> &::std::rc::Rc>> - { - match self { - GetBlobInput::GetBlobInput { value } => value, - } - } - } - - impl ::std::fmt::Debug for GetBlobInput { - fn fmt(&self, f: &mut ::std::fmt::Formatter) -> std::fmt::Result { - ::dafny_runtime::DafnyPrint::fmt_print(self, f, true) - } - } - - impl ::dafny_runtime::DafnyPrint for GetBlobInput { - fn fmt_print( - &self, - _formatter: &mut ::std::fmt::Formatter, - _in_seq: bool, - ) -> std::fmt::Result { - match self { - GetBlobInput::GetBlobInput { value } => { - write!( - _formatter, - "r#_simple_dtypes_dblob_dinternaldafny_dtypes.GetBlobInput.GetBlobInput(" - )?; - ::dafny_runtime::DafnyPrint::fmt_print(value, _formatter, false)?; - write!(_formatter, ")")?; - Ok(()) - } - } - } - } - - impl Eq for GetBlobInput {} - - impl ::std::hash::Hash for GetBlobInput { - fn hash<_H: ::std::hash::Hasher>(&self, _state: &mut _H) { - match self { - GetBlobInput::GetBlobInput { value } => value.hash(_state), - } - } - } - - impl ::std::default::Default for GetBlobInput { - fn default() -> GetBlobInput { - GetBlobInput::GetBlobInput { - value: ::std::default::Default::default(), - } - } - } - - impl ::std::convert::AsRef for &GetBlobInput { - fn as_ref(&self) -> Self { - self - } - } - - #[derive(PartialEq, Clone)] - pub enum GetBlobOutput { - GetBlobOutput { - value: ::std::rc::Rc>>, - }, - } - - impl GetBlobOutput { - pub fn value( - &self, - ) -> &::std::rc::Rc>> - { - match self { - GetBlobOutput::GetBlobOutput { value } => value, - } - } - } - - impl ::std::fmt::Debug for GetBlobOutput { - fn fmt(&self, f: &mut ::std::fmt::Formatter) -> std::fmt::Result { - ::dafny_runtime::DafnyPrint::fmt_print(self, f, true) - } - } - - impl ::dafny_runtime::DafnyPrint for GetBlobOutput { - fn fmt_print( - &self, - _formatter: &mut ::std::fmt::Formatter, - _in_seq: bool, - ) -> std::fmt::Result { - match self { - GetBlobOutput::GetBlobOutput { value } => { - write!( - _formatter, - "r#_simple_dtypes_dblob_dinternaldafny_dtypes.GetBlobOutput.GetBlobOutput(" - )?; - ::dafny_runtime::DafnyPrint::fmt_print(value, _formatter, false)?; - write!(_formatter, ")")?; - Ok(()) - } - } - } - } - - impl Eq for GetBlobOutput {} - - impl ::std::hash::Hash for GetBlobOutput { - fn hash<_H: ::std::hash::Hasher>(&self, _state: &mut _H) { - match self { - GetBlobOutput::GetBlobOutput { value } => value.hash(_state), - } - } - } - - impl ::std::default::Default for GetBlobOutput { - fn default() -> GetBlobOutput { - GetBlobOutput::GetBlobOutput { - value: ::std::default::Default::default(), - } - } - } - - impl ::std::convert::AsRef for &GetBlobOutput { - fn as_ref(&self) -> Self { - self - } - } - - #[derive(PartialEq, Clone)] - pub enum SimpleBlobConfig { - SimpleBlobConfig {}, - } - - impl SimpleBlobConfig {} - - impl ::std::fmt::Debug for SimpleBlobConfig { - fn fmt(&self, f: &mut ::std::fmt::Formatter) -> std::fmt::Result { - ::dafny_runtime::DafnyPrint::fmt_print(self, f, true) - } - } - - impl ::dafny_runtime::DafnyPrint for SimpleBlobConfig { - fn fmt_print( - &self, - _formatter: &mut ::std::fmt::Formatter, - _in_seq: bool, - ) -> std::fmt::Result { - match self { - SimpleBlobConfig::SimpleBlobConfig {} => { - write!(_formatter, "r#_simple_dtypes_dblob_dinternaldafny_dtypes.SimpleBlobConfig.SimpleBlobConfig")?; - Ok(()) - } - } - } - } - - impl Eq for SimpleBlobConfig {} - - impl ::std::hash::Hash for SimpleBlobConfig { - fn hash<_H: ::std::hash::Hasher>(&self, _state: &mut _H) { - match self { - SimpleBlobConfig::SimpleBlobConfig {} => {} - } - } - } - - impl ::std::default::Default for SimpleBlobConfig { - fn default() -> SimpleBlobConfig { - SimpleBlobConfig::SimpleBlobConfig {} - } - } - - impl ::std::convert::AsRef for &SimpleBlobConfig { - fn as_ref(&self) -> Self { - self - } - } - - pub struct ISimpleTypesBlobClientCallHistory {} - - impl ISimpleTypesBlobClientCallHistory { - pub fn _allocate_rcmut() -> ::dafny_runtime::Object { - ::dafny_runtime::allocate_rcmut::() - } - } - - pub trait ISimpleTypesBlobClient { - fn GetBlob( - &mut self, - input: &::std::rc::Rc< - super::r#_simple_dtypes_dblob_dinternaldafny_dtypes::GetBlobInput, - >, - ) -> ::std::rc::Rc< - super::r#_Wrappers_Compile::Result< - ::std::rc::Rc, - ::std::rc::Rc, - >, - >; - fn GetBlobKnownValueTest( - &mut self, - input: &::std::rc::Rc< - super::r#_simple_dtypes_dblob_dinternaldafny_dtypes::GetBlobInput, - >, - ) -> ::std::rc::Rc< - super::r#_Wrappers_Compile::Result< - ::std::rc::Rc, - ::std::rc::Rc, - >, - >; - } - - #[derive(PartialEq, Clone)] - pub enum Error { - CollectionOfErrors { - list: ::dafny_runtime::Sequence< - ::std::rc::Rc, - >, - message: ::dafny_runtime::Sequence<::dafny_runtime::DafnyCharUTF16>, - }, - Opaque { - obj: ::dafny_runtime::Object, - }, - } - - impl Error { - pub fn list( - &self, - ) -> &::dafny_runtime::Sequence< - ::std::rc::Rc, - > { - match self { - Error::CollectionOfErrors { list, message } => list, - Error::Opaque { obj } => panic!("field does not exist on this variant"), - } - } - pub fn message(&self) -> &::dafny_runtime::Sequence<::dafny_runtime::DafnyCharUTF16> { - match self { - Error::CollectionOfErrors { list, message } => message, - Error::Opaque { obj } => panic!("field does not exist on this variant"), - } - } - pub fn obj(&self) -> &::dafny_runtime::Object { - match self { - Error::CollectionOfErrors { list, message } => { - panic!("field does not exist on this variant") - } - Error::Opaque { obj } => obj, - } - } - } - - impl ::std::fmt::Debug for Error { - fn fmt(&self, f: &mut ::std::fmt::Formatter) -> std::fmt::Result { - ::dafny_runtime::DafnyPrint::fmt_print(self, f, true) - } - } - - impl ::dafny_runtime::DafnyPrint for Error { - fn fmt_print( - &self, - _formatter: &mut ::std::fmt::Formatter, - _in_seq: bool, - ) -> std::fmt::Result { - match self { - Error::CollectionOfErrors { list, message } => { - write!( - _formatter, - "r#_simple_dtypes_dblob_dinternaldafny_dtypes.Error.CollectionOfErrors(" - )?; - ::dafny_runtime::DafnyPrint::fmt_print(list, _formatter, false)?; - write!(_formatter, ", ")?; - ::dafny_runtime::DafnyPrint::fmt_print(message, _formatter, false)?; - write!(_formatter, ")")?; - Ok(()) - } - Error::Opaque { obj } => { - write!( - _formatter, - "r#_simple_dtypes_dblob_dinternaldafny_dtypes.Error.Opaque(" - )?; - ::dafny_runtime::DafnyPrint::fmt_print(obj, _formatter, false)?; - write!(_formatter, ")")?; - Ok(()) - } - } - } - } - - impl Eq for Error {} - - impl ::std::hash::Hash for Error { - fn hash<_H: ::std::hash::Hasher>(&self, _state: &mut _H) { - match self { - Error::CollectionOfErrors { list, message } => { - list.hash(_state); - message.hash(_state) - } - Error::Opaque { obj } => obj.hash(_state), - } - } - } - - impl ::std::default::Default for Error { - fn default() -> Error { - Error::CollectionOfErrors { - list: ::std::default::Default::default(), - message: ::std::default::Default::default(), - } - } - } - - impl ::std::convert::AsRef for &Error { - fn as_ref(&self) -> Self { - self - } - } - - pub type OpaqueError = - ::std::rc::Rc; -} -pub mod r#_SimpleBlobImpl_Compile { - pub struct _default {} - - impl _default { - pub fn _allocate_rcmut() -> ::dafny_runtime::Object { - ::dafny_runtime::allocate_rcmut::() - } - pub fn GetBlob( - config: &::std::rc::Rc, - input: &::std::rc::Rc< - super::r#_simple_dtypes_dblob_dinternaldafny_dtypes::GetBlobInput, - >, - ) -> ::std::rc::Rc< - super::r#_Wrappers_Compile::Result< - ::std::rc::Rc, - ::std::rc::Rc, - >, - > { - let mut output = ::dafny_runtime::MaybePlacebo::< - ::std::rc::Rc< - super::r#_Wrappers_Compile::Result< - ::std::rc::Rc< - super::r#_simple_dtypes_dblob_dinternaldafny_dtypes::GetBlobOutput, - >, - ::std::rc::Rc, - >, - >, - >::new(); - if !matches!( - input.value().as_ref(), - super::r#_Wrappers_Compile::Option::Some { .. } - ) { - panic!("Halt") - }; - super::r#_SimpleBlobImpl_Compile::_default::ValidateBlobType(input.value().value()); - let mut res: ::std::rc::Rc< - super::r#_simple_dtypes_dblob_dinternaldafny_dtypes::GetBlobOutput, - > = ::std::rc::Rc::new( - super::r#_simple_dtypes_dblob_dinternaldafny_dtypes::GetBlobOutput::GetBlobOutput { - value: input.value().clone(), - }, - ); - res = ::std::rc::Rc::new( - super::r#_simple_dtypes_dblob_dinternaldafny_dtypes::GetBlobOutput::GetBlobOutput { - value: input.value().clone(), - }, - ); - if !matches!( - res.value().as_ref(), - super::r#_Wrappers_Compile::Option::Some { .. } - ) { - panic!("Halt") - }; - super::r#_SimpleBlobImpl_Compile::_default::ValidateBlobType(res.value().value()); - if !(res.value().value().clone() == input.value().value().clone()) { - panic!("Halt") - }; - output = ::dafny_runtime::MaybePlacebo::from(::std::rc::Rc::new( - super::r#_Wrappers_Compile::Result::< - ::std::rc::Rc< - super::r#_simple_dtypes_dblob_dinternaldafny_dtypes::GetBlobOutput, - >, - ::std::rc::Rc, - >::Success { - value: res.clone(), - }, - )); - return output.read(); - return output.read(); - } - pub fn GetBlobKnownValueTest( - config: &::std::rc::Rc, - input: &::std::rc::Rc< - super::r#_simple_dtypes_dblob_dinternaldafny_dtypes::GetBlobInput, - >, - ) -> ::std::rc::Rc< - super::r#_Wrappers_Compile::Result< - ::std::rc::Rc, - ::std::rc::Rc, - >, - > { - let mut output = ::dafny_runtime::MaybePlacebo::< - ::std::rc::Rc< - super::r#_Wrappers_Compile::Result< - ::std::rc::Rc< - super::r#_simple_dtypes_dblob_dinternaldafny_dtypes::GetBlobOutput, - >, - ::std::rc::Rc, - >, - >, - >::new(); - if !matches!( - input.value().as_ref(), - super::r#_Wrappers_Compile::Option::Some { .. } - ) { - panic!("Halt") - }; - super::r#_SimpleBlobImpl_Compile::_default::ValidateBlobType(input.value().value()); - if !(input.value().value().clone() == ::dafny_runtime::seq![0, 2, 4]) { - panic!("Halt") - }; - let mut res: ::std::rc::Rc< - super::r#_simple_dtypes_dblob_dinternaldafny_dtypes::GetBlobOutput, - > = ::std::rc::Rc::new( - super::r#_simple_dtypes_dblob_dinternaldafny_dtypes::GetBlobOutput::GetBlobOutput { - value: input.value().clone(), - }, - ); - res = ::std::rc::Rc::new( - super::r#_simple_dtypes_dblob_dinternaldafny_dtypes::GetBlobOutput::GetBlobOutput { - value: input.value().clone(), - }, - ); - if !matches!( - res.value().as_ref(), - super::r#_Wrappers_Compile::Option::Some { .. } - ) { - panic!("Halt") - }; - super::r#_SimpleBlobImpl_Compile::_default::ValidateBlobType(res.value().value()); - if !(res.value().value().clone() == input.value().value().clone()) { - panic!("Halt") - }; - output = ::dafny_runtime::MaybePlacebo::from(::std::rc::Rc::new( - super::r#_Wrappers_Compile::Result::< - ::std::rc::Rc< - super::r#_simple_dtypes_dblob_dinternaldafny_dtypes::GetBlobOutput, - >, - ::std::rc::Rc, - >::Success { - value: res.clone(), - }, - )); - return output.read(); - return output.read(); - } - pub fn ValidateBlobType(input: &::dafny_runtime::Sequence) -> () { - if !(input.cardinality() >= ::dafny_runtime::int!(0)) { - panic!("Halt") - }; - let mut _hi0: ::dafny_runtime::DafnyInt = input.cardinality(); - for i in ::dafny_runtime::integer_range(::dafny_runtime::int!(0), _hi0.clone()) { - let mut inputElement: u8 = input.get(&i); - inputElement = input.get(&i); - if !(inputElement >= 0) { - panic!("Halt") - } - } - return (); - } - } - - #[derive(PartialEq, Clone)] - pub enum Config { - Config {}, - } - - impl Config {} - - impl ::std::fmt::Debug for Config { - fn fmt(&self, f: &mut ::std::fmt::Formatter) -> std::fmt::Result { - ::dafny_runtime::DafnyPrint::fmt_print(self, f, true) - } - } - - impl ::dafny_runtime::DafnyPrint for Config { - fn fmt_print( - &self, - _formatter: &mut ::std::fmt::Formatter, - _in_seq: bool, - ) -> std::fmt::Result { - match self { - Config::Config {} => { - write!(_formatter, "r#_SimpleBlobImpl_Compile.Config.Config")?; - Ok(()) - } - } - } - } - - impl Eq for Config {} - - impl ::std::hash::Hash for Config { - fn hash<_H: ::std::hash::Hasher>(&self, _state: &mut _H) { - match self { - Config::Config {} => {} - } - } - } - - impl ::std::default::Default for Config { - fn default() -> Config { - Config::Config {} - } - } - - impl ::std::convert::AsRef for &Config { - fn as_ref(&self) -> Self { - self - } - } -} -pub mod r#_simple_dtypes_dblob_dinternaldafny { - pub struct _default {} - - impl _default { - pub fn _allocate_rcmut() -> ::dafny_runtime::Object { - ::dafny_runtime::allocate_rcmut::() - } - pub fn DefaultSimpleBlobConfig( - ) -> ::std::rc::Rc - { - ::std::rc::Rc::new(super::r#_simple_dtypes_dblob_dinternaldafny_dtypes::SimpleBlobConfig::SimpleBlobConfig {}) - } - pub fn SimpleBlob( - config: &::std::rc::Rc< - super::r#_simple_dtypes_dblob_dinternaldafny_dtypes::SimpleBlobConfig, - >, - ) -> ::std::rc::Rc< - super::r#_Wrappers_Compile::Result< - ::dafny_runtime::Object< - super::r#_simple_dtypes_dblob_dinternaldafny::SimpleBlobClient, - >, - ::std::rc::Rc, - >, - > { - let mut res = ::dafny_runtime::MaybePlacebo::< - ::std::rc::Rc< - super::r#_Wrappers_Compile::Result< - ::dafny_runtime::Object< - super::r#_simple_dtypes_dblob_dinternaldafny::SimpleBlobClient, - >, - ::std::rc::Rc, - >, - >, - >::new(); - let mut client = ::dafny_runtime::MaybePlacebo::< - ::dafny_runtime::Object< - super::r#_simple_dtypes_dblob_dinternaldafny::SimpleBlobClient, - >, - >::new(); - let mut _nw0: ::dafny_runtime::Object< - super::r#_simple_dtypes_dblob_dinternaldafny::SimpleBlobClient, - > = super::r#_simple_dtypes_dblob_dinternaldafny::SimpleBlobClient::_allocate_rcmut(); - super::r#_simple_dtypes_dblob_dinternaldafny::SimpleBlobClient::_ctor( - &_nw0, - &::std::rc::Rc::new(super::r#_SimpleBlobImpl_Compile::Config::Config {}), - ); - client = ::dafny_runtime::MaybePlacebo::from(_nw0.clone()); - res = ::dafny_runtime::MaybePlacebo::from(::std::rc::Rc::new( - super::r#_Wrappers_Compile::Result::< - ::dafny_runtime::Object< - super::r#_simple_dtypes_dblob_dinternaldafny::SimpleBlobClient, - >, - ::std::rc::Rc, - >::Success { - value: client.read(), - }, - )); - return res.read(); - return res.read(); - } - pub fn CreateSuccessOfClient( - client: &::dafny_runtime::Object< - dyn super::r#_simple_dtypes_dblob_dinternaldafny_dtypes::ISimpleTypesBlobClient, - >, - ) -> ::std::rc::Rc< - super::r#_Wrappers_Compile::Result< - ::dafny_runtime::Object< - dyn super::r#_simple_dtypes_dblob_dinternaldafny_dtypes::ISimpleTypesBlobClient, - >, - ::std::rc::Rc, - >, - > { - ::std::rc::Rc::new(super::r#_Wrappers_Compile::Result::< - ::dafny_runtime::Object< - dyn super::r#_simple_dtypes_dblob_dinternaldafny_dtypes::ISimpleTypesBlobClient, - >, - ::std::rc::Rc, - >::Success { - value: client.clone(), - }) - } - pub fn CreateFailureOfError( - error: &::std::rc::Rc, - ) -> ::std::rc::Rc< - super::r#_Wrappers_Compile::Result< - ::dafny_runtime::Object< - dyn super::r#_simple_dtypes_dblob_dinternaldafny_dtypes::ISimpleTypesBlobClient, - >, - ::std::rc::Rc, - >, - > { - ::std::rc::Rc::new(super::r#_Wrappers_Compile::Result::< - ::dafny_runtime::Object< - dyn super::r#_simple_dtypes_dblob_dinternaldafny_dtypes::ISimpleTypesBlobClient, - >, - ::std::rc::Rc, - >::Failure { - error: error.clone(), - }) - } - } - - pub struct SimpleBlobClient { - pub r#__i_config: ::std::rc::Rc, - } - - impl SimpleBlobClient { - pub fn _allocate_rcmut() -> ::dafny_runtime::Object { - ::dafny_runtime::allocate_rcmut::() - } - pub fn _ctor( - this: &::dafny_runtime::Object, - config: &::std::rc::Rc, - ) -> () { - let mut _set__i_config: bool = false; - ::dafny_runtime::update_field_uninit_rcmut!( - this.clone(), - r#__i_config, - _set__i_config, - config.clone() - ); - return (); - } - pub fn config(&self) -> ::std::rc::Rc { - self.r#__i_config.clone() - } - } - - impl super::r#_simple_dtypes_dblob_dinternaldafny_dtypes::ISimpleTypesBlobClient - for super::r#_simple_dtypes_dblob_dinternaldafny::SimpleBlobClient - { - fn GetBlob( - &mut self, - input: &::std::rc::Rc< - super::r#_simple_dtypes_dblob_dinternaldafny_dtypes::GetBlobInput, - >, - ) -> ::std::rc::Rc< - super::r#_Wrappers_Compile::Result< - ::std::rc::Rc, - ::std::rc::Rc, - >, - > { - let mut output = ::dafny_runtime::MaybePlacebo::< - ::std::rc::Rc< - super::r#_Wrappers_Compile::Result< - ::std::rc::Rc< - super::r#_simple_dtypes_dblob_dinternaldafny_dtypes::GetBlobOutput, - >, - ::std::rc::Rc, - >, - >, - >::new(); - let mut _out0 = ::dafny_runtime::MaybePlacebo::< - ::std::rc::Rc< - super::r#_Wrappers_Compile::Result< - ::std::rc::Rc< - super::r#_simple_dtypes_dblob_dinternaldafny_dtypes::GetBlobOutput, - >, - ::std::rc::Rc, - >, - >, - >::new(); - _out0 = ::dafny_runtime::MaybePlacebo::from( - super::r#_SimpleBlobImpl_Compile::_default::GetBlob(&self.config(), input), - ); - output = ::dafny_runtime::MaybePlacebo::from(_out0.read()); - return output.read(); - } - fn GetBlobKnownValueTest( - &mut self, - input: &::std::rc::Rc< - super::r#_simple_dtypes_dblob_dinternaldafny_dtypes::GetBlobInput, - >, - ) -> ::std::rc::Rc< - super::r#_Wrappers_Compile::Result< - ::std::rc::Rc, - ::std::rc::Rc, - >, - > { - let mut output = ::dafny_runtime::MaybePlacebo::< - ::std::rc::Rc< - super::r#_Wrappers_Compile::Result< - ::std::rc::Rc< - super::r#_simple_dtypes_dblob_dinternaldafny_dtypes::GetBlobOutput, - >, - ::std::rc::Rc, - >, - >, - >::new(); - let mut _out1 = ::dafny_runtime::MaybePlacebo::< - ::std::rc::Rc< - super::r#_Wrappers_Compile::Result< - ::std::rc::Rc< - super::r#_simple_dtypes_dblob_dinternaldafny_dtypes::GetBlobOutput, - >, - ::std::rc::Rc, - >, - >, - >::new(); - _out1 = ::dafny_runtime::MaybePlacebo::from( - super::r#_SimpleBlobImpl_Compile::_default::GetBlobKnownValueTest( - &self.config(), - input, - ), - ); - output = ::dafny_runtime::MaybePlacebo::from(_out1.read()); - return output.read(); - } - } -} -pub mod _module {} diff --git a/TestModels/SimpleTypes/SimpleBoolean/runtimes/rust/dafny_impl/src/implementation_from_dafny.rs b/TestModels/SimpleTypes/SimpleBoolean/runtimes/rust/dafny_impl/src/implementation_from_dafny.rs deleted file mode 100644 index 06c0c0eab0..0000000000 --- a/TestModels/SimpleTypes/SimpleBoolean/runtimes/rust/dafny_impl/src/implementation_from_dafny.rs +++ /dev/null @@ -1,641 +0,0 @@ -#![allow(warnings, unconditional_panic)] -#![allow(nonstandard_style)] -pub use dafny_standard_library::implementation_from_dafny::*; - -pub mod r#_simple_dtypes_dboolean_dinternaldafny_dtypes { - #[derive(PartialEq, Clone)] - pub enum DafnyCallEvent { - DafnyCallEvent { input: I, output: O }, - _PhantomVariant(::std::marker::PhantomData, ::std::marker::PhantomData), - } - - impl DafnyCallEvent { - pub fn input(&self) -> &I { - match self { - DafnyCallEvent::DafnyCallEvent { input, output } => input, - DafnyCallEvent::_PhantomVariant(..) => panic!(), - } - } - pub fn output(&self) -> &O { - match self { - DafnyCallEvent::DafnyCallEvent { input, output } => output, - DafnyCallEvent::_PhantomVariant(..) => panic!(), - } - } - } - - impl ::std::fmt::Debug - for DafnyCallEvent - { - fn fmt(&self, f: &mut ::std::fmt::Formatter) -> std::fmt::Result { - ::dafny_runtime::DafnyPrint::fmt_print(self, f, true) - } - } - - impl ::dafny_runtime::DafnyPrint - for DafnyCallEvent - { - fn fmt_print( - &self, - _formatter: &mut ::std::fmt::Formatter, - _in_seq: bool, - ) -> std::fmt::Result { - match self { - DafnyCallEvent::DafnyCallEvent { input, output } => { - write!(_formatter, "r#_simple_dtypes_dboolean_dinternaldafny_dtypes.DafnyCallEvent.DafnyCallEvent(")?; - ::dafny_runtime::DafnyPrint::fmt_print(input, _formatter, false)?; - write!(_formatter, ", ")?; - ::dafny_runtime::DafnyPrint::fmt_print(output, _formatter, false)?; - write!(_formatter, ")")?; - Ok(()) - } - DafnyCallEvent::_PhantomVariant(..) => { - panic!() - } - } - } - } - - impl Eq - for DafnyCallEvent - { - } - - impl< - I: ::dafny_runtime::DafnyType + ::std::hash::Hash, - O: ::dafny_runtime::DafnyType + ::std::hash::Hash, - > ::std::hash::Hash for DafnyCallEvent - { - fn hash<_H: ::std::hash::Hasher>(&self, _state: &mut _H) { - match self { - DafnyCallEvent::DafnyCallEvent { input, output } => { - input.hash(_state); - output.hash(_state) - } - DafnyCallEvent::_PhantomVariant(..) => { - panic!() - } - } - } - } - - impl< - I: ::dafny_runtime::DafnyType + ::std::default::Default, - O: ::dafny_runtime::DafnyType + ::std::default::Default, - > ::std::default::Default for DafnyCallEvent - { - fn default() -> DafnyCallEvent { - DafnyCallEvent::DafnyCallEvent { - input: ::std::default::Default::default(), - output: ::std::default::Default::default(), - } - } - } - - impl - ::std::convert::AsRef> for &DafnyCallEvent - { - fn as_ref(&self) -> Self { - self - } - } - - #[derive(PartialEq, Clone)] - pub enum GetBooleanInput { - GetBooleanInput { - value: ::std::rc::Rc>, - }, - } - - impl GetBooleanInput { - pub fn value(&self) -> &::std::rc::Rc> { - match self { - GetBooleanInput::GetBooleanInput { value } => value, - } - } - } - - impl ::std::fmt::Debug for GetBooleanInput { - fn fmt(&self, f: &mut ::std::fmt::Formatter) -> std::fmt::Result { - ::dafny_runtime::DafnyPrint::fmt_print(self, f, true) - } - } - - impl ::dafny_runtime::DafnyPrint for GetBooleanInput { - fn fmt_print( - &self, - _formatter: &mut ::std::fmt::Formatter, - _in_seq: bool, - ) -> std::fmt::Result { - match self { - GetBooleanInput::GetBooleanInput { value } => { - write!(_formatter, "r#_simple_dtypes_dboolean_dinternaldafny_dtypes.GetBooleanInput.GetBooleanInput(")?; - ::dafny_runtime::DafnyPrint::fmt_print(value, _formatter, false)?; - write!(_formatter, ")")?; - Ok(()) - } - } - } - } - - impl Eq for GetBooleanInput {} - - impl ::std::hash::Hash for GetBooleanInput { - fn hash<_H: ::std::hash::Hasher>(&self, _state: &mut _H) { - match self { - GetBooleanInput::GetBooleanInput { value } => value.hash(_state), - } - } - } - - impl ::std::default::Default for GetBooleanInput { - fn default() -> GetBooleanInput { - GetBooleanInput::GetBooleanInput { - value: ::std::default::Default::default(), - } - } - } - - impl ::std::convert::AsRef for &GetBooleanInput { - fn as_ref(&self) -> Self { - self - } - } - - #[derive(PartialEq, Clone)] - pub enum GetBooleanOutput { - GetBooleanOutput { - value: ::std::rc::Rc>, - }, - } - - impl GetBooleanOutput { - pub fn value(&self) -> &::std::rc::Rc> { - match self { - GetBooleanOutput::GetBooleanOutput { value } => value, - } - } - } - - impl ::std::fmt::Debug for GetBooleanOutput { - fn fmt(&self, f: &mut ::std::fmt::Formatter) -> std::fmt::Result { - ::dafny_runtime::DafnyPrint::fmt_print(self, f, true) - } - } - - impl ::dafny_runtime::DafnyPrint for GetBooleanOutput { - fn fmt_print( - &self, - _formatter: &mut ::std::fmt::Formatter, - _in_seq: bool, - ) -> std::fmt::Result { - match self { - GetBooleanOutput::GetBooleanOutput { value } => { - write!(_formatter, "r#_simple_dtypes_dboolean_dinternaldafny_dtypes.GetBooleanOutput.GetBooleanOutput(")?; - ::dafny_runtime::DafnyPrint::fmt_print(value, _formatter, false)?; - write!(_formatter, ")")?; - Ok(()) - } - } - } - } - - impl Eq for GetBooleanOutput {} - - impl ::std::hash::Hash for GetBooleanOutput { - fn hash<_H: ::std::hash::Hasher>(&self, _state: &mut _H) { - match self { - GetBooleanOutput::GetBooleanOutput { value } => value.hash(_state), - } - } - } - - impl ::std::default::Default for GetBooleanOutput { - fn default() -> GetBooleanOutput { - GetBooleanOutput::GetBooleanOutput { - value: ::std::default::Default::default(), - } - } - } - - impl ::std::convert::AsRef for &GetBooleanOutput { - fn as_ref(&self) -> Self { - self - } - } - - #[derive(PartialEq, Clone)] - pub enum SimpleBooleanConfig { - SimpleBooleanConfig {}, - } - - impl SimpleBooleanConfig {} - - impl ::std::fmt::Debug for SimpleBooleanConfig { - fn fmt(&self, f: &mut ::std::fmt::Formatter) -> std::fmt::Result { - ::dafny_runtime::DafnyPrint::fmt_print(self, f, true) - } - } - - impl ::dafny_runtime::DafnyPrint for SimpleBooleanConfig { - fn fmt_print( - &self, - _formatter: &mut ::std::fmt::Formatter, - _in_seq: bool, - ) -> std::fmt::Result { - match self { - SimpleBooleanConfig::SimpleBooleanConfig {} => { - write!(_formatter, "r#_simple_dtypes_dboolean_dinternaldafny_dtypes.SimpleBooleanConfig.SimpleBooleanConfig")?; - Ok(()) - } - } - } - } - - impl Eq for SimpleBooleanConfig {} - - impl ::std::hash::Hash for SimpleBooleanConfig { - fn hash<_H: ::std::hash::Hasher>(&self, _state: &mut _H) { - match self { - SimpleBooleanConfig::SimpleBooleanConfig {} => {} - } - } - } - - impl ::std::default::Default for SimpleBooleanConfig { - fn default() -> SimpleBooleanConfig { - SimpleBooleanConfig::SimpleBooleanConfig {} - } - } - - impl ::std::convert::AsRef for &SimpleBooleanConfig { - fn as_ref(&self) -> Self { - self - } - } - - pub struct ISimpleTypesBooleanClientCallHistory {} - - impl ISimpleTypesBooleanClientCallHistory { - pub fn _allocate_rcmut() -> ::dafny_runtime::Object { - ::dafny_runtime::allocate_rcmut::() - } - } - - pub trait ISimpleTypesBooleanClient { - fn GetBoolean( - &mut self, - input: &::std::rc::Rc< - super::r#_simple_dtypes_dboolean_dinternaldafny_dtypes::GetBooleanInput, - >, - ) -> ::std::rc::Rc< - super::r#_Wrappers_Compile::Result< - ::std::rc::Rc< - super::r#_simple_dtypes_dboolean_dinternaldafny_dtypes::GetBooleanOutput, - >, - ::std::rc::Rc, - >, - >; - } - - #[derive(PartialEq, Clone)] - pub enum Error { - CollectionOfErrors { - list: ::dafny_runtime::Sequence< - ::std::rc::Rc, - >, - message: ::dafny_runtime::Sequence<::dafny_runtime::DafnyCharUTF16>, - }, - Opaque { - obj: ::dafny_runtime::Object, - }, - } - - impl Error { - pub fn list( - &self, - ) -> &::dafny_runtime::Sequence< - ::std::rc::Rc, - > { - match self { - Error::CollectionOfErrors { list, message } => list, - Error::Opaque { obj } => panic!("field does not exist on this variant"), - } - } - pub fn message(&self) -> &::dafny_runtime::Sequence<::dafny_runtime::DafnyCharUTF16> { - match self { - Error::CollectionOfErrors { list, message } => message, - Error::Opaque { obj } => panic!("field does not exist on this variant"), - } - } - pub fn obj(&self) -> &::dafny_runtime::Object { - match self { - Error::CollectionOfErrors { list, message } => { - panic!("field does not exist on this variant") - } - Error::Opaque { obj } => obj, - } - } - } - - impl ::std::fmt::Debug for Error { - fn fmt(&self, f: &mut ::std::fmt::Formatter) -> std::fmt::Result { - ::dafny_runtime::DafnyPrint::fmt_print(self, f, true) - } - } - - impl ::dafny_runtime::DafnyPrint for Error { - fn fmt_print( - &self, - _formatter: &mut ::std::fmt::Formatter, - _in_seq: bool, - ) -> std::fmt::Result { - match self { - Error::CollectionOfErrors { list, message } => { - write!( - _formatter, - "r#_simple_dtypes_dboolean_dinternaldafny_dtypes.Error.CollectionOfErrors(" - )?; - ::dafny_runtime::DafnyPrint::fmt_print(list, _formatter, false)?; - write!(_formatter, ", ")?; - ::dafny_runtime::DafnyPrint::fmt_print(message, _formatter, false)?; - write!(_formatter, ")")?; - Ok(()) - } - Error::Opaque { obj } => { - write!( - _formatter, - "r#_simple_dtypes_dboolean_dinternaldafny_dtypes.Error.Opaque(" - )?; - ::dafny_runtime::DafnyPrint::fmt_print(obj, _formatter, false)?; - write!(_formatter, ")")?; - Ok(()) - } - } - } - } - - impl Eq for Error {} - - impl ::std::hash::Hash for Error { - fn hash<_H: ::std::hash::Hasher>(&self, _state: &mut _H) { - match self { - Error::CollectionOfErrors { list, message } => { - list.hash(_state); - message.hash(_state) - } - Error::Opaque { obj } => obj.hash(_state), - } - } - } - - impl ::std::default::Default for Error { - fn default() -> Error { - Error::CollectionOfErrors { - list: ::std::default::Default::default(), - message: ::std::default::Default::default(), - } - } - } - - impl ::std::convert::AsRef for &Error { - fn as_ref(&self) -> Self { - self - } - } - - pub type OpaqueError = - ::std::rc::Rc; -} -pub mod r#_SimpleBooleanImpl_Compile { - pub struct _default {} - - impl _default { - pub fn _allocate_rcmut() -> ::dafny_runtime::Object { - ::dafny_runtime::allocate_rcmut::() - } - pub fn GetBoolean( - config: &::std::rc::Rc, - input: &::std::rc::Rc< - super::r#_simple_dtypes_dboolean_dinternaldafny_dtypes::GetBooleanInput, - >, - ) -> ::std::rc::Rc< - super::r#_Wrappers_Compile::Result< - ::std::rc::Rc< - super::r#_simple_dtypes_dboolean_dinternaldafny_dtypes::GetBooleanOutput, - >, - ::std::rc::Rc, - >, - > { - let mut output = ::dafny_runtime::MaybePlacebo::<::std::rc::Rc, ::std::rc::Rc>>>::new(); - if !matches!( - input.value().as_ref(), - super::r#_Wrappers_Compile::Option::Some { .. } - ) { - panic!("Halt") - }; - if !(*input.value().value() == true || *input.value().value() == false) { - panic!("Halt") - }; - let mut res: ::std::rc::Rc = ::std::rc::Rc::new(super::r#_simple_dtypes_dboolean_dinternaldafny_dtypes::GetBooleanOutput::GetBooleanOutput { - value: input.value().clone() - }); - res = ::std::rc::Rc::new(super::r#_simple_dtypes_dboolean_dinternaldafny_dtypes::GetBooleanOutput::GetBooleanOutput { - value: input.value().clone() - }); - if !(*res.value().value() == true || *res.value().value() == false) { - panic!("Halt") - }; - if !(input.value().value() == res.value().value()) { - panic!("Halt") - }; - output = ::dafny_runtime::MaybePlacebo::from(::std::rc::Rc::new( - super::r#_Wrappers_Compile::Result::< - ::std::rc::Rc< - super::r#_simple_dtypes_dboolean_dinternaldafny_dtypes::GetBooleanOutput, - >, - ::std::rc::Rc, - >::Success { - value: res.clone(), - }, - )); - return output.read(); - return output.read(); - } - } - - #[derive(PartialEq, Clone)] - pub enum Config { - Config {}, - } - - impl Config {} - - impl ::std::fmt::Debug for Config { - fn fmt(&self, f: &mut ::std::fmt::Formatter) -> std::fmt::Result { - ::dafny_runtime::DafnyPrint::fmt_print(self, f, true) - } - } - - impl ::dafny_runtime::DafnyPrint for Config { - fn fmt_print( - &self, - _formatter: &mut ::std::fmt::Formatter, - _in_seq: bool, - ) -> std::fmt::Result { - match self { - Config::Config {} => { - write!(_formatter, "r#_SimpleBooleanImpl_Compile.Config.Config")?; - Ok(()) - } - } - } - } - - impl Eq for Config {} - - impl ::std::hash::Hash for Config { - fn hash<_H: ::std::hash::Hasher>(&self, _state: &mut _H) { - match self { - Config::Config {} => {} - } - } - } - - impl ::std::default::Default for Config { - fn default() -> Config { - Config::Config {} - } - } - - impl ::std::convert::AsRef for &Config { - fn as_ref(&self) -> Self { - self - } - } -} -pub mod r#_simple_dtypes_dboolean_dinternaldafny { - pub struct _default {} - - impl _default { - pub fn _allocate_rcmut() -> ::dafny_runtime::Object { - ::dafny_runtime::allocate_rcmut::() - } - pub fn DefaultSimpleBooleanConfig() -> ::std::rc::Rc< - super::r#_simple_dtypes_dboolean_dinternaldafny_dtypes::SimpleBooleanConfig, - > { - ::std::rc::Rc::new(super::r#_simple_dtypes_dboolean_dinternaldafny_dtypes::SimpleBooleanConfig::SimpleBooleanConfig {}) - } - pub fn SimpleBoolean( - config: &::std::rc::Rc< - super::r#_simple_dtypes_dboolean_dinternaldafny_dtypes::SimpleBooleanConfig, - >, - ) -> ::std::rc::Rc< - super::r#_Wrappers_Compile::Result< - ::dafny_runtime::Object< - super::r#_simple_dtypes_dboolean_dinternaldafny::SimpleBooleanClient, - >, - ::std::rc::Rc, - >, - > { - let mut res = ::dafny_runtime::MaybePlacebo::< - ::std::rc::Rc< - super::r#_Wrappers_Compile::Result< - ::dafny_runtime::Object< - super::r#_simple_dtypes_dboolean_dinternaldafny::SimpleBooleanClient, - >, - ::std::rc::Rc< - super::r#_simple_dtypes_dboolean_dinternaldafny_dtypes::Error, - >, - >, - >, - >::new(); - let mut client = ::dafny_runtime::MaybePlacebo::< - ::dafny_runtime::Object< - super::r#_simple_dtypes_dboolean_dinternaldafny::SimpleBooleanClient, - >, - >::new(); - let mut _nw0: ::dafny_runtime::Object = super::r#_simple_dtypes_dboolean_dinternaldafny::SimpleBooleanClient::_allocate_rcmut(); - super::r#_simple_dtypes_dboolean_dinternaldafny::SimpleBooleanClient::_ctor( - &_nw0, - &::std::rc::Rc::new(super::r#_SimpleBooleanImpl_Compile::Config::Config {}), - ); - client = ::dafny_runtime::MaybePlacebo::from(_nw0.clone()); - res = ::dafny_runtime::MaybePlacebo::from(::std::rc::Rc::new( - super::r#_Wrappers_Compile::Result::< - ::dafny_runtime::Object< - super::r#_simple_dtypes_dboolean_dinternaldafny::SimpleBooleanClient, - >, - ::std::rc::Rc, - >::Success { - value: client.read(), - }, - )); - return res.read(); - return res.read(); - } - pub fn CreateSuccessOfClient(client: &::dafny_runtime::Object) -> ::std::rc::Rc, ::std::rc::Rc>>{ - ::std::rc::Rc::new(super::r#_Wrappers_Compile::Result::<::dafny_runtime::Object, ::std::rc::Rc>::Success { - value: client.clone() - }) - } - pub fn CreateFailureOfError(error: &::std::rc::Rc) -> ::std::rc::Rc, ::std::rc::Rc>>{ - ::std::rc::Rc::new(super::r#_Wrappers_Compile::Result::<::dafny_runtime::Object, ::std::rc::Rc>::Failure { - error: error.clone() - }) - } - } - - pub struct SimpleBooleanClient { - pub r#__i_config: ::std::rc::Rc, - } - - impl SimpleBooleanClient { - pub fn _allocate_rcmut() -> ::dafny_runtime::Object { - ::dafny_runtime::allocate_rcmut::() - } - pub fn _ctor( - this: &::dafny_runtime::Object, - config: &::std::rc::Rc, - ) -> () { - let mut _set__i_config: bool = false; - ::dafny_runtime::update_field_uninit_rcmut!( - this.clone(), - r#__i_config, - _set__i_config, - config.clone() - ); - return (); - } - pub fn config(&self) -> ::std::rc::Rc { - self.r#__i_config.clone() - } - } - - impl super::r#_simple_dtypes_dboolean_dinternaldafny_dtypes::ISimpleTypesBooleanClient - for super::r#_simple_dtypes_dboolean_dinternaldafny::SimpleBooleanClient - { - fn GetBoolean( - &mut self, - input: &::std::rc::Rc< - super::r#_simple_dtypes_dboolean_dinternaldafny_dtypes::GetBooleanInput, - >, - ) -> ::std::rc::Rc< - super::r#_Wrappers_Compile::Result< - ::std::rc::Rc< - super::r#_simple_dtypes_dboolean_dinternaldafny_dtypes::GetBooleanOutput, - >, - ::std::rc::Rc, - >, - > { - let mut output = ::dafny_runtime::MaybePlacebo::<::std::rc::Rc, ::std::rc::Rc>>>::new(); - let mut _out0 = ::dafny_runtime::MaybePlacebo::<::std::rc::Rc, ::std::rc::Rc>>>::new(); - _out0 = ::dafny_runtime::MaybePlacebo::from( - super::r#_SimpleBooleanImpl_Compile::_default::GetBoolean(&self.config(), input), - ); - output = ::dafny_runtime::MaybePlacebo::from(_out0.read()); - return output.read(); - } - } -} -pub mod _module {} diff --git a/TestModels/SimpleTypes/SimpleDouble/runtimes/rust/dafny_impl/src/implementation_from_dafny.rs b/TestModels/SimpleTypes/SimpleDouble/runtimes/rust/dafny_impl/src/implementation_from_dafny.rs deleted file mode 100644 index 0609bbe647..0000000000 --- a/TestModels/SimpleTypes/SimpleDouble/runtimes/rust/dafny_impl/src/implementation_from_dafny.rs +++ /dev/null @@ -1,649 +0,0 @@ -#![allow(warnings, unconditional_panic)] -#![allow(nonstandard_style)] -pub use dafny_standard_library::implementation_from_dafny::*; - -pub mod r#_simple_dtypes_dsmithydouble_dinternaldafny_dtypes { - #[derive(PartialEq, Clone)] - pub enum DafnyCallEvent { - DafnyCallEvent { input: I, output: O }, - _PhantomVariant(::std::marker::PhantomData, ::std::marker::PhantomData), - } - - impl DafnyCallEvent { - pub fn input(&self) -> &I { - match self { - DafnyCallEvent::DafnyCallEvent { input, output } => input, - DafnyCallEvent::_PhantomVariant(..) => panic!(), - } - } - pub fn output(&self) -> &O { - match self { - DafnyCallEvent::DafnyCallEvent { input, output } => output, - DafnyCallEvent::_PhantomVariant(..) => panic!(), - } - } - } - - impl ::std::fmt::Debug - for DafnyCallEvent - { - fn fmt(&self, f: &mut ::std::fmt::Formatter) -> std::fmt::Result { - ::dafny_runtime::DafnyPrint::fmt_print(self, f, true) - } - } - - impl ::dafny_runtime::DafnyPrint - for DafnyCallEvent - { - fn fmt_print( - &self, - _formatter: &mut ::std::fmt::Formatter, - _in_seq: bool, - ) -> std::fmt::Result { - match self { - DafnyCallEvent::DafnyCallEvent { input, output } => { - write!(_formatter, "r#_simple_dtypes_dsmithydouble_dinternaldafny_dtypes.DafnyCallEvent.DafnyCallEvent(")?; - ::dafny_runtime::DafnyPrint::fmt_print(input, _formatter, false)?; - write!(_formatter, ", ")?; - ::dafny_runtime::DafnyPrint::fmt_print(output, _formatter, false)?; - write!(_formatter, ")")?; - Ok(()) - } - DafnyCallEvent::_PhantomVariant(..) => { - panic!() - } - } - } - } - - impl Eq - for DafnyCallEvent - { - } - - impl< - I: ::dafny_runtime::DafnyType + ::std::hash::Hash, - O: ::dafny_runtime::DafnyType + ::std::hash::Hash, - > ::std::hash::Hash for DafnyCallEvent - { - fn hash<_H: ::std::hash::Hasher>(&self, _state: &mut _H) { - match self { - DafnyCallEvent::DafnyCallEvent { input, output } => { - input.hash(_state); - output.hash(_state) - } - DafnyCallEvent::_PhantomVariant(..) => { - panic!() - } - } - } - } - - impl< - I: ::dafny_runtime::DafnyType + ::std::default::Default, - O: ::dafny_runtime::DafnyType + ::std::default::Default, - > ::std::default::Default for DafnyCallEvent - { - fn default() -> DafnyCallEvent { - DafnyCallEvent::DafnyCallEvent { - input: ::std::default::Default::default(), - output: ::std::default::Default::default(), - } - } - } - - impl - ::std::convert::AsRef> for &DafnyCallEvent - { - fn as_ref(&self) -> Self { - self - } - } - - #[derive(PartialEq, Clone)] - pub enum GetDoubleInput { - GetDoubleInput { - value: ::std::rc::Rc>>, - }, - } - - impl GetDoubleInput { - pub fn value( - &self, - ) -> &::std::rc::Rc>> - { - match self { - GetDoubleInput::GetDoubleInput { value } => value, - } - } - } - - impl ::std::fmt::Debug for GetDoubleInput { - fn fmt(&self, f: &mut ::std::fmt::Formatter) -> std::fmt::Result { - ::dafny_runtime::DafnyPrint::fmt_print(self, f, true) - } - } - - impl ::dafny_runtime::DafnyPrint for GetDoubleInput { - fn fmt_print( - &self, - _formatter: &mut ::std::fmt::Formatter, - _in_seq: bool, - ) -> std::fmt::Result { - match self { - GetDoubleInput::GetDoubleInput { value } => { - write!(_formatter, "r#_simple_dtypes_dsmithydouble_dinternaldafny_dtypes.GetDoubleInput.GetDoubleInput(")?; - ::dafny_runtime::DafnyPrint::fmt_print(value, _formatter, false)?; - write!(_formatter, ")")?; - Ok(()) - } - } - } - } - - impl Eq for GetDoubleInput {} - - impl ::std::hash::Hash for GetDoubleInput { - fn hash<_H: ::std::hash::Hasher>(&self, _state: &mut _H) { - match self { - GetDoubleInput::GetDoubleInput { value } => value.hash(_state), - } - } - } - - impl ::std::default::Default for GetDoubleInput { - fn default() -> GetDoubleInput { - GetDoubleInput::GetDoubleInput { - value: ::std::default::Default::default(), - } - } - } - - impl ::std::convert::AsRef for &GetDoubleInput { - fn as_ref(&self) -> Self { - self - } - } - - #[derive(PartialEq, Clone)] - pub enum GetDoubleOutput { - GetDoubleOutput { - value: ::std::rc::Rc>>, - }, - } - - impl GetDoubleOutput { - pub fn value( - &self, - ) -> &::std::rc::Rc>> - { - match self { - GetDoubleOutput::GetDoubleOutput { value } => value, - } - } - } - - impl ::std::fmt::Debug for GetDoubleOutput { - fn fmt(&self, f: &mut ::std::fmt::Formatter) -> std::fmt::Result { - ::dafny_runtime::DafnyPrint::fmt_print(self, f, true) - } - } - - impl ::dafny_runtime::DafnyPrint for GetDoubleOutput { - fn fmt_print( - &self, - _formatter: &mut ::std::fmt::Formatter, - _in_seq: bool, - ) -> std::fmt::Result { - match self { - GetDoubleOutput::GetDoubleOutput { value } => { - write!(_formatter, "r#_simple_dtypes_dsmithydouble_dinternaldafny_dtypes.GetDoubleOutput.GetDoubleOutput(")?; - ::dafny_runtime::DafnyPrint::fmt_print(value, _formatter, false)?; - write!(_formatter, ")")?; - Ok(()) - } - } - } - } - - impl Eq for GetDoubleOutput {} - - impl ::std::hash::Hash for GetDoubleOutput { - fn hash<_H: ::std::hash::Hasher>(&self, _state: &mut _H) { - match self { - GetDoubleOutput::GetDoubleOutput { value } => value.hash(_state), - } - } - } - - impl ::std::default::Default for GetDoubleOutput { - fn default() -> GetDoubleOutput { - GetDoubleOutput::GetDoubleOutput { - value: ::std::default::Default::default(), - } - } - } - - impl ::std::convert::AsRef for &GetDoubleOutput { - fn as_ref(&self) -> Self { - self - } - } - - #[derive(PartialEq, Clone)] - pub enum SimpleDoubleConfig { - SimpleDoubleConfig {}, - } - - impl SimpleDoubleConfig {} - - impl ::std::fmt::Debug for SimpleDoubleConfig { - fn fmt(&self, f: &mut ::std::fmt::Formatter) -> std::fmt::Result { - ::dafny_runtime::DafnyPrint::fmt_print(self, f, true) - } - } - - impl ::dafny_runtime::DafnyPrint for SimpleDoubleConfig { - fn fmt_print( - &self, - _formatter: &mut ::std::fmt::Formatter, - _in_seq: bool, - ) -> std::fmt::Result { - match self { - SimpleDoubleConfig::SimpleDoubleConfig {} => { - write!(_formatter, "r#_simple_dtypes_dsmithydouble_dinternaldafny_dtypes.SimpleDoubleConfig.SimpleDoubleConfig")?; - Ok(()) - } - } - } - } - - impl Eq for SimpleDoubleConfig {} - - impl ::std::hash::Hash for SimpleDoubleConfig { - fn hash<_H: ::std::hash::Hasher>(&self, _state: &mut _H) { - match self { - SimpleDoubleConfig::SimpleDoubleConfig {} => {} - } - } - } - - impl ::std::default::Default for SimpleDoubleConfig { - fn default() -> SimpleDoubleConfig { - SimpleDoubleConfig::SimpleDoubleConfig {} - } - } - - impl ::std::convert::AsRef for &SimpleDoubleConfig { - fn as_ref(&self) -> Self { - self - } - } - - pub struct ISimpleTypesDoubleClientCallHistory {} - - impl ISimpleTypesDoubleClientCallHistory { - pub fn _allocate_rcmut() -> ::dafny_runtime::Object { - ::dafny_runtime::allocate_rcmut::() - } - } - - pub trait ISimpleTypesDoubleClient { - fn GetDouble( - &mut self, - input: &::std::rc::Rc< - super::r#_simple_dtypes_dsmithydouble_dinternaldafny_dtypes::GetDoubleInput, - >, - ) -> ::std::rc::Rc< - super::r#_Wrappers_Compile::Result< - ::std::rc::Rc< - super::r#_simple_dtypes_dsmithydouble_dinternaldafny_dtypes::GetDoubleOutput, - >, - ::std::rc::Rc, - >, - >; - } - - #[derive(PartialEq, Clone)] - pub enum Error { - CollectionOfErrors { - list: ::dafny_runtime::Sequence< - ::std::rc::Rc, - >, - message: ::dafny_runtime::Sequence<::dafny_runtime::DafnyCharUTF16>, - }, - Opaque { - obj: ::dafny_runtime::Object, - }, - } - - impl Error { - pub fn list( - &self, - ) -> &::dafny_runtime::Sequence< - ::std::rc::Rc, - > { - match self { - Error::CollectionOfErrors { list, message } => list, - Error::Opaque { obj } => panic!("field does not exist on this variant"), - } - } - pub fn message(&self) -> &::dafny_runtime::Sequence<::dafny_runtime::DafnyCharUTF16> { - match self { - Error::CollectionOfErrors { list, message } => message, - Error::Opaque { obj } => panic!("field does not exist on this variant"), - } - } - pub fn obj(&self) -> &::dafny_runtime::Object { - match self { - Error::CollectionOfErrors { list, message } => { - panic!("field does not exist on this variant") - } - Error::Opaque { obj } => obj, - } - } - } - - impl ::std::fmt::Debug for Error { - fn fmt(&self, f: &mut ::std::fmt::Formatter) -> std::fmt::Result { - ::dafny_runtime::DafnyPrint::fmt_print(self, f, true) - } - } - - impl ::dafny_runtime::DafnyPrint for Error { - fn fmt_print( - &self, - _formatter: &mut ::std::fmt::Formatter, - _in_seq: bool, - ) -> std::fmt::Result { - match self { - Error::CollectionOfErrors { list, message } => { - write!(_formatter, "r#_simple_dtypes_dsmithydouble_dinternaldafny_dtypes.Error.CollectionOfErrors(")?; - ::dafny_runtime::DafnyPrint::fmt_print(list, _formatter, false)?; - write!(_formatter, ", ")?; - ::dafny_runtime::DafnyPrint::fmt_print(message, _formatter, false)?; - write!(_formatter, ")")?; - Ok(()) - } - Error::Opaque { obj } => { - write!( - _formatter, - "r#_simple_dtypes_dsmithydouble_dinternaldafny_dtypes.Error.Opaque(" - )?; - ::dafny_runtime::DafnyPrint::fmt_print(obj, _formatter, false)?; - write!(_formatter, ")")?; - Ok(()) - } - } - } - } - - impl Eq for Error {} - - impl ::std::hash::Hash for Error { - fn hash<_H: ::std::hash::Hasher>(&self, _state: &mut _H) { - match self { - Error::CollectionOfErrors { list, message } => { - list.hash(_state); - message.hash(_state) - } - Error::Opaque { obj } => obj.hash(_state), - } - } - } - - impl ::std::default::Default for Error { - fn default() -> Error { - Error::CollectionOfErrors { - list: ::std::default::Default::default(), - message: ::std::default::Default::default(), - } - } - } - - impl ::std::convert::AsRef for &Error { - fn as_ref(&self) -> Self { - self - } - } - - pub type OpaqueError = - ::std::rc::Rc; -} -pub mod r#_SimpleSmithyDoubleOperations_Compile { - pub struct _default {} - - impl _default { - pub fn _allocate_rcmut() -> ::dafny_runtime::Object { - ::dafny_runtime::allocate_rcmut::() - } - pub fn r#_ValidInternalConfig_q( - config: &::std::rc::Rc, - ) -> bool { - true - } - pub fn GetDouble( - config: &::std::rc::Rc, - input: &::std::rc::Rc< - super::r#_simple_dtypes_dsmithydouble_dinternaldafny_dtypes::GetDoubleInput, - >, - ) -> ::std::rc::Rc< - super::r#_Wrappers_Compile::Result< - ::std::rc::Rc< - super::r#_simple_dtypes_dsmithydouble_dinternaldafny_dtypes::GetDoubleOutput, - >, - ::std::rc::Rc, - >, - > { - let mut output = ::dafny_runtime::MaybePlacebo::<::std::rc::Rc, ::std::rc::Rc>>>::new(); - if !matches!( - input.value().as_ref(), - super::r#_Wrappers_Compile::Option::Some { .. } - ) { - panic!("Halt") - }; - let mut check: bool = ::default(); - let mut _out0: bool = ::default(); - _out0 = super::r#_SimpleSmithyDoubleOperations_Compile::_default::ValidateDoubleType( - input.value().value(), - ); - check = _out0; - if !check { - panic!("Halt") - }; - let mut result: ::std::rc::Rc = ::std::rc::Rc::new(super::r#_simple_dtypes_dsmithydouble_dinternaldafny_dtypes::GetDoubleOutput::GetDoubleOutput { - value: input.value().clone() - }); - result = ::std::rc::Rc::new(super::r#_simple_dtypes_dsmithydouble_dinternaldafny_dtypes::GetDoubleOutput::GetDoubleOutput { - value: input.value().clone() - }); - output = ::dafny_runtime::MaybePlacebo::from(::std::rc::Rc::new(super::r#_Wrappers_Compile::Result::<::std::rc::Rc, ::std::rc::Rc>::Success { - value: result.clone() - })); - return output.read(); - return output.read(); - } - pub fn ValidateDoubleType(input: &::dafny_runtime::Sequence) -> bool { - let mut output: bool = ::default(); - output = input.cardinality() == ::dafny_runtime::int!(8); - return output; - return output; - } - } - - #[derive(PartialEq, Clone)] - pub enum Config { - Config {}, - } - - impl Config {} - - impl ::std::fmt::Debug for Config { - fn fmt(&self, f: &mut ::std::fmt::Formatter) -> std::fmt::Result { - ::dafny_runtime::DafnyPrint::fmt_print(self, f, true) - } - } - - impl ::dafny_runtime::DafnyPrint for Config { - fn fmt_print( - &self, - _formatter: &mut ::std::fmt::Formatter, - _in_seq: bool, - ) -> std::fmt::Result { - match self { - Config::Config {} => { - write!( - _formatter, - "r#_SimpleSmithyDoubleOperations_Compile.Config.Config" - )?; - Ok(()) - } - } - } - } - - impl Eq for Config {} - - impl ::std::hash::Hash for Config { - fn hash<_H: ::std::hash::Hasher>(&self, _state: &mut _H) { - match self { - Config::Config {} => {} - } - } - } - - impl ::std::default::Default for Config { - fn default() -> Config { - Config::Config {} - } - } - - impl ::std::convert::AsRef for &Config { - fn as_ref(&self) -> Self { - self - } - } -} -pub mod r#_simple_dtypes_dsmithydouble_dinternaldafny { - pub struct _default {} - - impl _default { - pub fn _allocate_rcmut() -> ::dafny_runtime::Object { - ::dafny_runtime::allocate_rcmut::() - } - pub fn DefaultSimpleDoubleConfig() -> ::std::rc::Rc< - super::r#_simple_dtypes_dsmithydouble_dinternaldafny_dtypes::SimpleDoubleConfig, - > { - ::std::rc::Rc::new(super::r#_simple_dtypes_dsmithydouble_dinternaldafny_dtypes::SimpleDoubleConfig::SimpleDoubleConfig {}) - } - pub fn SimpleDouble( - config: &::std::rc::Rc< - super::r#_simple_dtypes_dsmithydouble_dinternaldafny_dtypes::SimpleDoubleConfig, - >, - ) -> ::std::rc::Rc< - super::r#_Wrappers_Compile::Result< - ::dafny_runtime::Object< - super::r#_simple_dtypes_dsmithydouble_dinternaldafny::SimpleDoubleClient, - >, - ::std::rc::Rc, - >, - > { - let mut res = ::dafny_runtime::MaybePlacebo::<::std::rc::Rc, ::std::rc::Rc>>>::new(); - let mut client = ::dafny_runtime::MaybePlacebo::< - ::dafny_runtime::Object< - super::r#_simple_dtypes_dsmithydouble_dinternaldafny::SimpleDoubleClient, - >, - >::new(); - let mut _nw0: ::dafny_runtime::Object = super::r#_simple_dtypes_dsmithydouble_dinternaldafny::SimpleDoubleClient::_allocate_rcmut(); - super::r#_simple_dtypes_dsmithydouble_dinternaldafny::SimpleDoubleClient::_ctor( - &_nw0, - &::std::rc::Rc::new( - super::r#_SimpleSmithyDoubleOperations_Compile::Config::Config {}, - ), - ); - client = ::dafny_runtime::MaybePlacebo::from(_nw0.clone()); - res = ::dafny_runtime::MaybePlacebo::from(::std::rc::Rc::new( - super::r#_Wrappers_Compile::Result::< - ::dafny_runtime::Object< - super::r#_simple_dtypes_dsmithydouble_dinternaldafny::SimpleDoubleClient, - >, - ::std::rc::Rc< - super::r#_simple_dtypes_dsmithydouble_dinternaldafny_dtypes::Error, - >, - >::Success { - value: client.read(), - }, - )); - return res.read(); - return res.read(); - } - pub fn CreateSuccessOfClient(client: &::dafny_runtime::Object) -> ::std::rc::Rc, ::std::rc::Rc>>{ - ::std::rc::Rc::new(super::r#_Wrappers_Compile::Result::<::dafny_runtime::Object, ::std::rc::Rc>::Success { - value: client.clone() - }) - } - pub fn CreateFailureOfError(error: &::std::rc::Rc) -> ::std::rc::Rc, ::std::rc::Rc>>{ - ::std::rc::Rc::new(super::r#_Wrappers_Compile::Result::<::dafny_runtime::Object, ::std::rc::Rc>::Failure { - error: error.clone() - }) - } - } - - pub struct SimpleDoubleClient { - pub r#__i_config: ::std::rc::Rc, - } - - impl SimpleDoubleClient { - pub fn _allocate_rcmut() -> ::dafny_runtime::Object { - ::dafny_runtime::allocate_rcmut::() - } - pub fn _ctor( - this: &::dafny_runtime::Object, - config: &::std::rc::Rc, - ) -> () { - let mut _set__i_config: bool = false; - ::dafny_runtime::update_field_uninit_rcmut!( - this.clone(), - r#__i_config, - _set__i_config, - config.clone() - ); - return (); - } - pub fn config( - &self, - ) -> ::std::rc::Rc { - self.r#__i_config.clone() - } - } - - impl super::r#_simple_dtypes_dsmithydouble_dinternaldafny_dtypes::ISimpleTypesDoubleClient - for super::r#_simple_dtypes_dsmithydouble_dinternaldafny::SimpleDoubleClient - { - fn GetDouble( - &mut self, - input: &::std::rc::Rc< - super::r#_simple_dtypes_dsmithydouble_dinternaldafny_dtypes::GetDoubleInput, - >, - ) -> ::std::rc::Rc< - super::r#_Wrappers_Compile::Result< - ::std::rc::Rc< - super::r#_simple_dtypes_dsmithydouble_dinternaldafny_dtypes::GetDoubleOutput, - >, - ::std::rc::Rc, - >, - > { - let mut output = ::dafny_runtime::MaybePlacebo::<::std::rc::Rc, ::std::rc::Rc>>>::new(); - let mut _out1 = ::dafny_runtime::MaybePlacebo::<::std::rc::Rc, ::std::rc::Rc>>>::new(); - _out1 = ::dafny_runtime::MaybePlacebo::from( - super::r#_SimpleSmithyDoubleOperations_Compile::_default::GetDouble( - &self.config(), - input, - ), - ); - output = ::dafny_runtime::MaybePlacebo::from(_out1.read()); - return output.read(); - } - } -} -pub mod _module {} diff --git a/TestModels/SimpleTypes/SimpleEnum/runtimes/rust/dafny_impl/src/implementation_from_dafny.rs b/TestModels/SimpleTypes/SimpleEnum/runtimes/rust/dafny_impl/src/implementation_from_dafny.rs deleted file mode 100644 index d013389610..0000000000 --- a/TestModels/SimpleTypes/SimpleEnum/runtimes/rust/dafny_impl/src/implementation_from_dafny.rs +++ /dev/null @@ -1,986 +0,0 @@ -#![allow(warnings, unconditional_panic)] -#![allow(nonstandard_style)] -pub use dafny_standard_library::implementation_from_dafny::*; - -pub mod r#_simple_dtypes_dsmithyenum_dinternaldafny_dtypes { - #[derive(PartialEq, Clone)] - pub enum DafnyCallEvent { - DafnyCallEvent { input: I, output: O }, - _PhantomVariant(::std::marker::PhantomData, ::std::marker::PhantomData), - } - - impl DafnyCallEvent { - pub fn input(&self) -> &I { - match self { - DafnyCallEvent::DafnyCallEvent { input, output } => input, - DafnyCallEvent::_PhantomVariant(..) => panic!(), - } - } - pub fn output(&self) -> &O { - match self { - DafnyCallEvent::DafnyCallEvent { input, output } => output, - DafnyCallEvent::_PhantomVariant(..) => panic!(), - } - } - } - - impl ::std::fmt::Debug - for DafnyCallEvent - { - fn fmt(&self, f: &mut ::std::fmt::Formatter) -> std::fmt::Result { - ::dafny_runtime::DafnyPrint::fmt_print(self, f, true) - } - } - - impl ::dafny_runtime::DafnyPrint - for DafnyCallEvent - { - fn fmt_print( - &self, - _formatter: &mut ::std::fmt::Formatter, - _in_seq: bool, - ) -> std::fmt::Result { - match self { - DafnyCallEvent::DafnyCallEvent { input, output } => { - write!(_formatter, "r#_simple_dtypes_dsmithyenum_dinternaldafny_dtypes.DafnyCallEvent.DafnyCallEvent(")?; - ::dafny_runtime::DafnyPrint::fmt_print(input, _formatter, false)?; - write!(_formatter, ", ")?; - ::dafny_runtime::DafnyPrint::fmt_print(output, _formatter, false)?; - write!(_formatter, ")")?; - Ok(()) - } - DafnyCallEvent::_PhantomVariant(..) => { - panic!() - } - } - } - } - - impl Eq - for DafnyCallEvent - { - } - - impl< - I: ::dafny_runtime::DafnyType + ::std::hash::Hash, - O: ::dafny_runtime::DafnyType + ::std::hash::Hash, - > ::std::hash::Hash for DafnyCallEvent - { - fn hash<_H: ::std::hash::Hasher>(&self, _state: &mut _H) { - match self { - DafnyCallEvent::DafnyCallEvent { input, output } => { - input.hash(_state); - output.hash(_state) - } - DafnyCallEvent::_PhantomVariant(..) => { - panic!() - } - } - } - } - - impl< - I: ::dafny_runtime::DafnyType + ::std::default::Default, - O: ::dafny_runtime::DafnyType + ::std::default::Default, - > ::std::default::Default for DafnyCallEvent - { - fn default() -> DafnyCallEvent { - DafnyCallEvent::DafnyCallEvent { - input: ::std::default::Default::default(), - output: ::std::default::Default::default(), - } - } - } - - impl - ::std::convert::AsRef> for &DafnyCallEvent - { - fn as_ref(&self) -> Self { - self - } - } - - #[derive(PartialEq, Clone)] - pub enum GetEnumInput { - GetEnumInput { - value: ::std::rc::Rc< - super::r#_Wrappers_Compile::Option< - ::std::rc::Rc< - super::r#_simple_dtypes_dsmithyenum_dinternaldafny_dtypes::SimpleEnumShape, - >, - >, - >, - }, - } - - impl GetEnumInput { - pub fn value( - &self, - ) -> &::std::rc::Rc< - super::r#_Wrappers_Compile::Option< - ::std::rc::Rc< - super::r#_simple_dtypes_dsmithyenum_dinternaldafny_dtypes::SimpleEnumShape, - >, - >, - > { - match self { - GetEnumInput::GetEnumInput { value } => value, - } - } - } - - impl ::std::fmt::Debug for GetEnumInput { - fn fmt(&self, f: &mut ::std::fmt::Formatter) -> std::fmt::Result { - ::dafny_runtime::DafnyPrint::fmt_print(self, f, true) - } - } - - impl ::dafny_runtime::DafnyPrint for GetEnumInput { - fn fmt_print( - &self, - _formatter: &mut ::std::fmt::Formatter, - _in_seq: bool, - ) -> std::fmt::Result { - match self { - GetEnumInput::GetEnumInput { value } => { - write!(_formatter, "r#_simple_dtypes_dsmithyenum_dinternaldafny_dtypes.GetEnumInput.GetEnumInput(")?; - ::dafny_runtime::DafnyPrint::fmt_print(value, _formatter, false)?; - write!(_formatter, ")")?; - Ok(()) - } - } - } - } - - impl Eq for GetEnumInput {} - - impl ::std::hash::Hash for GetEnumInput { - fn hash<_H: ::std::hash::Hasher>(&self, _state: &mut _H) { - match self { - GetEnumInput::GetEnumInput { value } => value.hash(_state), - } - } - } - - impl ::std::default::Default for GetEnumInput { - fn default() -> GetEnumInput { - GetEnumInput::GetEnumInput { - value: ::std::default::Default::default(), - } - } - } - - impl ::std::convert::AsRef for &GetEnumInput { - fn as_ref(&self) -> Self { - self - } - } - - #[derive(PartialEq, Clone)] - pub enum GetEnumOutput { - GetEnumOutput { - value: ::std::rc::Rc< - super::r#_Wrappers_Compile::Option< - ::std::rc::Rc< - super::r#_simple_dtypes_dsmithyenum_dinternaldafny_dtypes::SimpleEnumShape, - >, - >, - >, - }, - } - - impl GetEnumOutput { - pub fn value( - &self, - ) -> &::std::rc::Rc< - super::r#_Wrappers_Compile::Option< - ::std::rc::Rc< - super::r#_simple_dtypes_dsmithyenum_dinternaldafny_dtypes::SimpleEnumShape, - >, - >, - > { - match self { - GetEnumOutput::GetEnumOutput { value } => value, - } - } - } - - impl ::std::fmt::Debug for GetEnumOutput { - fn fmt(&self, f: &mut ::std::fmt::Formatter) -> std::fmt::Result { - ::dafny_runtime::DafnyPrint::fmt_print(self, f, true) - } - } - - impl ::dafny_runtime::DafnyPrint for GetEnumOutput { - fn fmt_print( - &self, - _formatter: &mut ::std::fmt::Formatter, - _in_seq: bool, - ) -> std::fmt::Result { - match self { - GetEnumOutput::GetEnumOutput { value } => { - write!(_formatter, "r#_simple_dtypes_dsmithyenum_dinternaldafny_dtypes.GetEnumOutput.GetEnumOutput(")?; - ::dafny_runtime::DafnyPrint::fmt_print(value, _formatter, false)?; - write!(_formatter, ")")?; - Ok(()) - } - } - } - } - - impl Eq for GetEnumOutput {} - - impl ::std::hash::Hash for GetEnumOutput { - fn hash<_H: ::std::hash::Hasher>(&self, _state: &mut _H) { - match self { - GetEnumOutput::GetEnumOutput { value } => value.hash(_state), - } - } - } - - impl ::std::default::Default for GetEnumOutput { - fn default() -> GetEnumOutput { - GetEnumOutput::GetEnumOutput { - value: ::std::default::Default::default(), - } - } - } - - impl ::std::convert::AsRef for &GetEnumOutput { - fn as_ref(&self) -> Self { - self - } - } - - #[derive(PartialEq, Clone)] - pub enum SimpleEnumConfig { - SimpleEnumConfig {}, - } - - impl SimpleEnumConfig {} - - impl ::std::fmt::Debug for SimpleEnumConfig { - fn fmt(&self, f: &mut ::std::fmt::Formatter) -> std::fmt::Result { - ::dafny_runtime::DafnyPrint::fmt_print(self, f, true) - } - } - - impl ::dafny_runtime::DafnyPrint for SimpleEnumConfig { - fn fmt_print( - &self, - _formatter: &mut ::std::fmt::Formatter, - _in_seq: bool, - ) -> std::fmt::Result { - match self { - SimpleEnumConfig::SimpleEnumConfig {} => { - write!(_formatter, "r#_simple_dtypes_dsmithyenum_dinternaldafny_dtypes.SimpleEnumConfig.SimpleEnumConfig")?; - Ok(()) - } - } - } - } - - impl Eq for SimpleEnumConfig {} - - impl ::std::hash::Hash for SimpleEnumConfig { - fn hash<_H: ::std::hash::Hasher>(&self, _state: &mut _H) { - match self { - SimpleEnumConfig::SimpleEnumConfig {} => {} - } - } - } - - impl ::std::default::Default for SimpleEnumConfig { - fn default() -> SimpleEnumConfig { - SimpleEnumConfig::SimpleEnumConfig {} - } - } - - impl ::std::convert::AsRef for &SimpleEnumConfig { - fn as_ref(&self) -> Self { - self - } - } - - #[derive(PartialEq, Clone)] - pub enum SimpleEnumShape { - FIRST {}, - SECOND {}, - THIRD {}, - } - - impl SimpleEnumShape {} - - impl ::std::fmt::Debug for SimpleEnumShape { - fn fmt(&self, f: &mut ::std::fmt::Formatter) -> std::fmt::Result { - ::dafny_runtime::DafnyPrint::fmt_print(self, f, true) - } - } - - impl ::dafny_runtime::DafnyPrint for SimpleEnumShape { - fn fmt_print( - &self, - _formatter: &mut ::std::fmt::Formatter, - _in_seq: bool, - ) -> std::fmt::Result { - match self { - SimpleEnumShape::FIRST {} => { - write!( - _formatter, - "r#_simple_dtypes_dsmithyenum_dinternaldafny_dtypes.SimpleEnumShape.FIRST" - )?; - Ok(()) - } - SimpleEnumShape::SECOND {} => { - write!( - _formatter, - "r#_simple_dtypes_dsmithyenum_dinternaldafny_dtypes.SimpleEnumShape.SECOND" - )?; - Ok(()) - } - SimpleEnumShape::THIRD {} => { - write!( - _formatter, - "r#_simple_dtypes_dsmithyenum_dinternaldafny_dtypes.SimpleEnumShape.THIRD" - )?; - Ok(()) - } - } - } - } - - impl Eq for SimpleEnumShape {} - - impl ::std::hash::Hash for SimpleEnumShape { - fn hash<_H: ::std::hash::Hasher>(&self, _state: &mut _H) { - match self { - SimpleEnumShape::FIRST {} => {} - SimpleEnumShape::SECOND {} => {} - SimpleEnumShape::THIRD {} => {} - } - } - } - - impl ::std::default::Default for SimpleEnumShape { - fn default() -> SimpleEnumShape { - SimpleEnumShape::FIRST {} - } - } - - impl ::std::convert::AsRef for &SimpleEnumShape { - fn as_ref(&self) -> Self { - self - } - } - - pub struct ISimpleTypesEnumClientCallHistory {} - - impl ISimpleTypesEnumClientCallHistory { - pub fn _allocate_rcmut() -> ::dafny_runtime::Object { - ::dafny_runtime::allocate_rcmut::() - } - } - - pub trait ISimpleTypesEnumClient { - fn GetEnum( - &mut self, - input: &::std::rc::Rc< - super::r#_simple_dtypes_dsmithyenum_dinternaldafny_dtypes::GetEnumInput, - >, - ) -> ::std::rc::Rc< - super::r#_Wrappers_Compile::Result< - ::std::rc::Rc< - super::r#_simple_dtypes_dsmithyenum_dinternaldafny_dtypes::GetEnumOutput, - >, - ::std::rc::Rc, - >, - >; - fn GetEnumFirstKnownValueTest( - &mut self, - input: &::std::rc::Rc< - super::r#_simple_dtypes_dsmithyenum_dinternaldafny_dtypes::GetEnumInput, - >, - ) -> ::std::rc::Rc< - super::r#_Wrappers_Compile::Result< - ::std::rc::Rc< - super::r#_simple_dtypes_dsmithyenum_dinternaldafny_dtypes::GetEnumOutput, - >, - ::std::rc::Rc, - >, - >; - fn GetEnumSecondKnownValueTest( - &mut self, - input: &::std::rc::Rc< - super::r#_simple_dtypes_dsmithyenum_dinternaldafny_dtypes::GetEnumInput, - >, - ) -> ::std::rc::Rc< - super::r#_Wrappers_Compile::Result< - ::std::rc::Rc< - super::r#_simple_dtypes_dsmithyenum_dinternaldafny_dtypes::GetEnumOutput, - >, - ::std::rc::Rc, - >, - >; - fn GetEnumThirdKnownValueTest( - &mut self, - input: &::std::rc::Rc< - super::r#_simple_dtypes_dsmithyenum_dinternaldafny_dtypes::GetEnumInput, - >, - ) -> ::std::rc::Rc< - super::r#_Wrappers_Compile::Result< - ::std::rc::Rc< - super::r#_simple_dtypes_dsmithyenum_dinternaldafny_dtypes::GetEnumOutput, - >, - ::std::rc::Rc, - >, - >; - } - - #[derive(PartialEq, Clone)] - pub enum Error { - CollectionOfErrors { - list: ::dafny_runtime::Sequence< - ::std::rc::Rc, - >, - message: ::dafny_runtime::Sequence<::dafny_runtime::DafnyCharUTF16>, - }, - Opaque { - obj: ::dafny_runtime::Object, - }, - } - - impl Error { - pub fn list( - &self, - ) -> &::dafny_runtime::Sequence< - ::std::rc::Rc, - > { - match self { - Error::CollectionOfErrors { list, message } => list, - Error::Opaque { obj } => panic!("field does not exist on this variant"), - } - } - pub fn message(&self) -> &::dafny_runtime::Sequence<::dafny_runtime::DafnyCharUTF16> { - match self { - Error::CollectionOfErrors { list, message } => message, - Error::Opaque { obj } => panic!("field does not exist on this variant"), - } - } - pub fn obj(&self) -> &::dafny_runtime::Object { - match self { - Error::CollectionOfErrors { list, message } => { - panic!("field does not exist on this variant") - } - Error::Opaque { obj } => obj, - } - } - } - - impl ::std::fmt::Debug for Error { - fn fmt(&self, f: &mut ::std::fmt::Formatter) -> std::fmt::Result { - ::dafny_runtime::DafnyPrint::fmt_print(self, f, true) - } - } - - impl ::dafny_runtime::DafnyPrint for Error { - fn fmt_print( - &self, - _formatter: &mut ::std::fmt::Formatter, - _in_seq: bool, - ) -> std::fmt::Result { - match self { - Error::CollectionOfErrors { list, message } => { - write!(_formatter, "r#_simple_dtypes_dsmithyenum_dinternaldafny_dtypes.Error.CollectionOfErrors(")?; - ::dafny_runtime::DafnyPrint::fmt_print(list, _formatter, false)?; - write!(_formatter, ", ")?; - ::dafny_runtime::DafnyPrint::fmt_print(message, _formatter, false)?; - write!(_formatter, ")")?; - Ok(()) - } - Error::Opaque { obj } => { - write!( - _formatter, - "r#_simple_dtypes_dsmithyenum_dinternaldafny_dtypes.Error.Opaque(" - )?; - ::dafny_runtime::DafnyPrint::fmt_print(obj, _formatter, false)?; - write!(_formatter, ")")?; - Ok(()) - } - } - } - } - - impl Eq for Error {} - - impl ::std::hash::Hash for Error { - fn hash<_H: ::std::hash::Hasher>(&self, _state: &mut _H) { - match self { - Error::CollectionOfErrors { list, message } => { - list.hash(_state); - message.hash(_state) - } - Error::Opaque { obj } => obj.hash(_state), - } - } - } - - impl ::std::default::Default for Error { - fn default() -> Error { - Error::CollectionOfErrors { - list: ::std::default::Default::default(), - message: ::std::default::Default::default(), - } - } - } - - impl ::std::convert::AsRef for &Error { - fn as_ref(&self) -> Self { - self - } - } - - pub type OpaqueError = - ::std::rc::Rc; -} -pub mod r#_SimpleEnumImpl_Compile { - pub struct _default {} - - impl _default { - pub fn _allocate_rcmut() -> ::dafny_runtime::Object { - ::dafny_runtime::allocate_rcmut::() - } - pub fn GetEnum( - config: &::std::rc::Rc, - input: &::std::rc::Rc< - super::r#_simple_dtypes_dsmithyenum_dinternaldafny_dtypes::GetEnumInput, - >, - ) -> ::std::rc::Rc< - super::r#_Wrappers_Compile::Result< - ::std::rc::Rc< - super::r#_simple_dtypes_dsmithyenum_dinternaldafny_dtypes::GetEnumOutput, - >, - ::std::rc::Rc, - >, - > { - let mut output = ::dafny_runtime::MaybePlacebo::<::std::rc::Rc, ::std::rc::Rc>>>::new(); - let mut res: ::std::rc::Rc = ::std::rc::Rc::new(super::r#_simple_dtypes_dsmithyenum_dinternaldafny_dtypes::GetEnumOutput::GetEnumOutput { - value: input.value().clone() - }); - res = ::std::rc::Rc::new(super::r#_simple_dtypes_dsmithyenum_dinternaldafny_dtypes::GetEnumOutput::GetEnumOutput { - value: input.value().clone() - }); - output = ::dafny_runtime::MaybePlacebo::from(::std::rc::Rc::new( - super::r#_Wrappers_Compile::Result::< - ::std::rc::Rc< - super::r#_simple_dtypes_dsmithyenum_dinternaldafny_dtypes::GetEnumOutput, - >, - ::std::rc::Rc, - >::Success { - value: res.clone(), - }, - )); - return output.read(); - return output.read(); - } - pub fn GetEnumFirstKnownValueTest( - config: &::std::rc::Rc, - input: &::std::rc::Rc< - super::r#_simple_dtypes_dsmithyenum_dinternaldafny_dtypes::GetEnumInput, - >, - ) -> ::std::rc::Rc< - super::r#_Wrappers_Compile::Result< - ::std::rc::Rc< - super::r#_simple_dtypes_dsmithyenum_dinternaldafny_dtypes::GetEnumOutput, - >, - ::std::rc::Rc, - >, - > { - let mut output = ::dafny_runtime::MaybePlacebo::<::std::rc::Rc, ::std::rc::Rc>>>::new(); - if !matches!( - input.value().as_ref(), - super::r#_Wrappers_Compile::Option::Some { .. } - ) { - panic!("Halt") - }; - if !(input.value().value().clone() == ::std::rc::Rc::new(super::r#_simple_dtypes_dsmithyenum_dinternaldafny_dtypes::SimpleEnumShape::FIRST {})) { - panic!("Halt") - }; - let mut res: ::std::rc::Rc = ::std::rc::Rc::new(super::r#_simple_dtypes_dsmithyenum_dinternaldafny_dtypes::GetEnumOutput::GetEnumOutput { - value: input.value().clone() - }); - res = ::std::rc::Rc::new(super::r#_simple_dtypes_dsmithyenum_dinternaldafny_dtypes::GetEnumOutput::GetEnumOutput { - value: input.value().clone() - }); - if !matches!( - res.value().as_ref(), - super::r#_Wrappers_Compile::Option::Some { .. } - ) { - panic!("Halt") - }; - if !(res.value().value().clone() == ::std::rc::Rc::new(super::r#_simple_dtypes_dsmithyenum_dinternaldafny_dtypes::SimpleEnumShape::FIRST {})) { - panic!("Halt") - }; - output = ::dafny_runtime::MaybePlacebo::from(::std::rc::Rc::new( - super::r#_Wrappers_Compile::Result::< - ::std::rc::Rc< - super::r#_simple_dtypes_dsmithyenum_dinternaldafny_dtypes::GetEnumOutput, - >, - ::std::rc::Rc, - >::Success { - value: res.clone(), - }, - )); - return output.read(); - return output.read(); - } - pub fn GetEnumSecondKnownValueTest( - config: &::std::rc::Rc, - input: &::std::rc::Rc< - super::r#_simple_dtypes_dsmithyenum_dinternaldafny_dtypes::GetEnumInput, - >, - ) -> ::std::rc::Rc< - super::r#_Wrappers_Compile::Result< - ::std::rc::Rc< - super::r#_simple_dtypes_dsmithyenum_dinternaldafny_dtypes::GetEnumOutput, - >, - ::std::rc::Rc, - >, - > { - let mut output = ::dafny_runtime::MaybePlacebo::<::std::rc::Rc, ::std::rc::Rc>>>::new(); - if !matches!( - input.value().as_ref(), - super::r#_Wrappers_Compile::Option::Some { .. } - ) { - panic!("Halt") - }; - if !(input.value().value().clone() == ::std::rc::Rc::new(super::r#_simple_dtypes_dsmithyenum_dinternaldafny_dtypes::SimpleEnumShape::SECOND {})) { - panic!("Halt") - }; - let mut res: ::std::rc::Rc = ::std::rc::Rc::new(super::r#_simple_dtypes_dsmithyenum_dinternaldafny_dtypes::GetEnumOutput::GetEnumOutput { - value: input.value().clone() - }); - res = ::std::rc::Rc::new(super::r#_simple_dtypes_dsmithyenum_dinternaldafny_dtypes::GetEnumOutput::GetEnumOutput { - value: input.value().clone() - }); - if !matches!( - res.value().as_ref(), - super::r#_Wrappers_Compile::Option::Some { .. } - ) { - panic!("Halt") - }; - if !(res.value().value().clone() == ::std::rc::Rc::new(super::r#_simple_dtypes_dsmithyenum_dinternaldafny_dtypes::SimpleEnumShape::SECOND {})) { - panic!("Halt") - }; - output = ::dafny_runtime::MaybePlacebo::from(::std::rc::Rc::new( - super::r#_Wrappers_Compile::Result::< - ::std::rc::Rc< - super::r#_simple_dtypes_dsmithyenum_dinternaldafny_dtypes::GetEnumOutput, - >, - ::std::rc::Rc, - >::Success { - value: res.clone(), - }, - )); - return output.read(); - return output.read(); - } - pub fn GetEnumThirdKnownValueTest( - config: &::std::rc::Rc, - input: &::std::rc::Rc< - super::r#_simple_dtypes_dsmithyenum_dinternaldafny_dtypes::GetEnumInput, - >, - ) -> ::std::rc::Rc< - super::r#_Wrappers_Compile::Result< - ::std::rc::Rc< - super::r#_simple_dtypes_dsmithyenum_dinternaldafny_dtypes::GetEnumOutput, - >, - ::std::rc::Rc, - >, - > { - let mut output = ::dafny_runtime::MaybePlacebo::<::std::rc::Rc, ::std::rc::Rc>>>::new(); - if !matches!( - input.value().as_ref(), - super::r#_Wrappers_Compile::Option::Some { .. } - ) { - panic!("Halt") - }; - if !(input.value().value().clone() == ::std::rc::Rc::new(super::r#_simple_dtypes_dsmithyenum_dinternaldafny_dtypes::SimpleEnumShape::THIRD {})) { - panic!("Halt") - }; - let mut res: ::std::rc::Rc = ::std::rc::Rc::new(super::r#_simple_dtypes_dsmithyenum_dinternaldafny_dtypes::GetEnumOutput::GetEnumOutput { - value: input.value().clone() - }); - res = ::std::rc::Rc::new(super::r#_simple_dtypes_dsmithyenum_dinternaldafny_dtypes::GetEnumOutput::GetEnumOutput { - value: input.value().clone() - }); - if !matches!( - res.value().as_ref(), - super::r#_Wrappers_Compile::Option::Some { .. } - ) { - panic!("Halt") - }; - if !(res.value().value().clone() == ::std::rc::Rc::new(super::r#_simple_dtypes_dsmithyenum_dinternaldafny_dtypes::SimpleEnumShape::THIRD {})) { - panic!("Halt") - }; - output = ::dafny_runtime::MaybePlacebo::from(::std::rc::Rc::new( - super::r#_Wrappers_Compile::Result::< - ::std::rc::Rc< - super::r#_simple_dtypes_dsmithyenum_dinternaldafny_dtypes::GetEnumOutput, - >, - ::std::rc::Rc, - >::Success { - value: res.clone(), - }, - )); - return output.read(); - return output.read(); - } - } - - #[derive(PartialEq, Clone)] - pub enum Config { - Config {}, - } - - impl Config {} - - impl ::std::fmt::Debug for Config { - fn fmt(&self, f: &mut ::std::fmt::Formatter) -> std::fmt::Result { - ::dafny_runtime::DafnyPrint::fmt_print(self, f, true) - } - } - - impl ::dafny_runtime::DafnyPrint for Config { - fn fmt_print( - &self, - _formatter: &mut ::std::fmt::Formatter, - _in_seq: bool, - ) -> std::fmt::Result { - match self { - Config::Config {} => { - write!(_formatter, "r#_SimpleEnumImpl_Compile.Config.Config")?; - Ok(()) - } - } - } - } - - impl Eq for Config {} - - impl ::std::hash::Hash for Config { - fn hash<_H: ::std::hash::Hasher>(&self, _state: &mut _H) { - match self { - Config::Config {} => {} - } - } - } - - impl ::std::default::Default for Config { - fn default() -> Config { - Config::Config {} - } - } - - impl ::std::convert::AsRef for &Config { - fn as_ref(&self) -> Self { - self - } - } -} -pub mod r#_simple_dtypes_dsmithyenum_dinternaldafny { - pub struct _default {} - - impl _default { - pub fn _allocate_rcmut() -> ::dafny_runtime::Object { - ::dafny_runtime::allocate_rcmut::() - } - pub fn DefaultSimpleEnumConfig() -> ::std::rc::Rc< - super::r#_simple_dtypes_dsmithyenum_dinternaldafny_dtypes::SimpleEnumConfig, - > { - ::std::rc::Rc::new(super::r#_simple_dtypes_dsmithyenum_dinternaldafny_dtypes::SimpleEnumConfig::SimpleEnumConfig {}) - } - pub fn SimpleEnum( - config: &::std::rc::Rc< - super::r#_simple_dtypes_dsmithyenum_dinternaldafny_dtypes::SimpleEnumConfig, - >, - ) -> ::std::rc::Rc< - super::r#_Wrappers_Compile::Result< - ::dafny_runtime::Object< - super::r#_simple_dtypes_dsmithyenum_dinternaldafny::SimpleEnumClient, - >, - ::std::rc::Rc, - >, - > { - let mut res = ::dafny_runtime::MaybePlacebo::< - ::std::rc::Rc< - super::r#_Wrappers_Compile::Result< - ::dafny_runtime::Object< - super::r#_simple_dtypes_dsmithyenum_dinternaldafny::SimpleEnumClient, - >, - ::std::rc::Rc< - super::r#_simple_dtypes_dsmithyenum_dinternaldafny_dtypes::Error, - >, - >, - >, - >::new(); - let mut client = ::dafny_runtime::MaybePlacebo::< - ::dafny_runtime::Object< - super::r#_simple_dtypes_dsmithyenum_dinternaldafny::SimpleEnumClient, - >, - >::new(); - let mut _nw0: ::dafny_runtime::Object = super::r#_simple_dtypes_dsmithyenum_dinternaldafny::SimpleEnumClient::_allocate_rcmut(); - super::r#_simple_dtypes_dsmithyenum_dinternaldafny::SimpleEnumClient::_ctor( - &_nw0, - &::std::rc::Rc::new(super::r#_SimpleEnumImpl_Compile::Config::Config {}), - ); - client = ::dafny_runtime::MaybePlacebo::from(_nw0.clone()); - res = ::dafny_runtime::MaybePlacebo::from(::std::rc::Rc::new( - super::r#_Wrappers_Compile::Result::< - ::dafny_runtime::Object< - super::r#_simple_dtypes_dsmithyenum_dinternaldafny::SimpleEnumClient, - >, - ::std::rc::Rc, - >::Success { - value: client.read(), - }, - )); - return res.read(); - return res.read(); - } - pub fn CreateSuccessOfClient(client: &::dafny_runtime::Object) -> ::std::rc::Rc, ::std::rc::Rc>>{ - ::std::rc::Rc::new(super::r#_Wrappers_Compile::Result::<::dafny_runtime::Object, ::std::rc::Rc>::Success { - value: client.clone() - }) - } - pub fn CreateFailureOfError(error: &::std::rc::Rc) -> ::std::rc::Rc, ::std::rc::Rc>>{ - ::std::rc::Rc::new(super::r#_Wrappers_Compile::Result::<::dafny_runtime::Object, ::std::rc::Rc>::Failure { - error: error.clone() - }) - } - } - - pub struct SimpleEnumClient { - pub r#__i_config: ::std::rc::Rc, - } - - impl SimpleEnumClient { - pub fn _allocate_rcmut() -> ::dafny_runtime::Object { - ::dafny_runtime::allocate_rcmut::() - } - pub fn _ctor( - this: &::dafny_runtime::Object, - config: &::std::rc::Rc, - ) -> () { - let mut _set__i_config: bool = false; - ::dafny_runtime::update_field_uninit_rcmut!( - this.clone(), - r#__i_config, - _set__i_config, - config.clone() - ); - return (); - } - pub fn config(&self) -> ::std::rc::Rc { - self.r#__i_config.clone() - } - } - - impl super::r#_simple_dtypes_dsmithyenum_dinternaldafny_dtypes::ISimpleTypesEnumClient - for super::r#_simple_dtypes_dsmithyenum_dinternaldafny::SimpleEnumClient - { - fn GetEnum( - &mut self, - input: &::std::rc::Rc< - super::r#_simple_dtypes_dsmithyenum_dinternaldafny_dtypes::GetEnumInput, - >, - ) -> ::std::rc::Rc< - super::r#_Wrappers_Compile::Result< - ::std::rc::Rc< - super::r#_simple_dtypes_dsmithyenum_dinternaldafny_dtypes::GetEnumOutput, - >, - ::std::rc::Rc, - >, - > { - let mut output = ::dafny_runtime::MaybePlacebo::<::std::rc::Rc, ::std::rc::Rc>>>::new(); - let mut _out0 = ::dafny_runtime::MaybePlacebo::<::std::rc::Rc, ::std::rc::Rc>>>::new(); - _out0 = ::dafny_runtime::MaybePlacebo::from( - super::r#_SimpleEnumImpl_Compile::_default::GetEnum(&self.config(), input), - ); - output = ::dafny_runtime::MaybePlacebo::from(_out0.read()); - return output.read(); - } - fn GetEnumFirstKnownValueTest( - &mut self, - input: &::std::rc::Rc< - super::r#_simple_dtypes_dsmithyenum_dinternaldafny_dtypes::GetEnumInput, - >, - ) -> ::std::rc::Rc< - super::r#_Wrappers_Compile::Result< - ::std::rc::Rc< - super::r#_simple_dtypes_dsmithyenum_dinternaldafny_dtypes::GetEnumOutput, - >, - ::std::rc::Rc, - >, - > { - let mut output = ::dafny_runtime::MaybePlacebo::<::std::rc::Rc, ::std::rc::Rc>>>::new(); - let mut _out1 = ::dafny_runtime::MaybePlacebo::<::std::rc::Rc, ::std::rc::Rc>>>::new(); - _out1 = ::dafny_runtime::MaybePlacebo::from( - super::r#_SimpleEnumImpl_Compile::_default::GetEnumFirstKnownValueTest( - &self.config(), - input, - ), - ); - output = ::dafny_runtime::MaybePlacebo::from(_out1.read()); - return output.read(); - } - fn GetEnumSecondKnownValueTest( - &mut self, - input: &::std::rc::Rc< - super::r#_simple_dtypes_dsmithyenum_dinternaldafny_dtypes::GetEnumInput, - >, - ) -> ::std::rc::Rc< - super::r#_Wrappers_Compile::Result< - ::std::rc::Rc< - super::r#_simple_dtypes_dsmithyenum_dinternaldafny_dtypes::GetEnumOutput, - >, - ::std::rc::Rc, - >, - > { - let mut output = ::dafny_runtime::MaybePlacebo::<::std::rc::Rc, ::std::rc::Rc>>>::new(); - let mut _out2 = ::dafny_runtime::MaybePlacebo::<::std::rc::Rc, ::std::rc::Rc>>>::new(); - _out2 = ::dafny_runtime::MaybePlacebo::from( - super::r#_SimpleEnumImpl_Compile::_default::GetEnumSecondKnownValueTest( - &self.config(), - input, - ), - ); - output = ::dafny_runtime::MaybePlacebo::from(_out2.read()); - return output.read(); - } - fn GetEnumThirdKnownValueTest( - &mut self, - input: &::std::rc::Rc< - super::r#_simple_dtypes_dsmithyenum_dinternaldafny_dtypes::GetEnumInput, - >, - ) -> ::std::rc::Rc< - super::r#_Wrappers_Compile::Result< - ::std::rc::Rc< - super::r#_simple_dtypes_dsmithyenum_dinternaldafny_dtypes::GetEnumOutput, - >, - ::std::rc::Rc, - >, - > { - let mut output = ::dafny_runtime::MaybePlacebo::<::std::rc::Rc, ::std::rc::Rc>>>::new(); - let mut _out3 = ::dafny_runtime::MaybePlacebo::<::std::rc::Rc, ::std::rc::Rc>>>::new(); - _out3 = ::dafny_runtime::MaybePlacebo::from( - super::r#_SimpleEnumImpl_Compile::_default::GetEnumThirdKnownValueTest( - &self.config(), - input, - ), - ); - output = ::dafny_runtime::MaybePlacebo::from(_out3.read()); - return output.read(); - } - } -} -pub mod _module {} diff --git a/TestModels/SimpleTypes/SimpleEnumV2/runtimes/rust/dafny_impl/src/implementation_from_dafny.rs b/TestModels/SimpleTypes/SimpleEnumV2/runtimes/rust/dafny_impl/src/implementation_from_dafny.rs deleted file mode 100644 index 73c2e7d2d1..0000000000 --- a/TestModels/SimpleTypes/SimpleEnumV2/runtimes/rust/dafny_impl/src/implementation_from_dafny.rs +++ /dev/null @@ -1,1098 +0,0 @@ -#![allow(warnings, unconditional_panic)] -#![allow(nonstandard_style)] -pub use dafny_standard_library::implementation_from_dafny::*; - -pub mod r#_simple_dtypes_denumv2_dinternaldafny_dtypes { - #[derive(PartialEq, Clone)] - pub enum DafnyCallEvent { - DafnyCallEvent { input: I, output: O }, - _PhantomVariant(::std::marker::PhantomData, ::std::marker::PhantomData), - } - - impl DafnyCallEvent { - pub fn input(&self) -> &I { - match self { - DafnyCallEvent::DafnyCallEvent { input, output } => input, - DafnyCallEvent::_PhantomVariant(..) => panic!(), - } - } - pub fn output(&self) -> &O { - match self { - DafnyCallEvent::DafnyCallEvent { input, output } => output, - DafnyCallEvent::_PhantomVariant(..) => panic!(), - } - } - } - - impl ::std::fmt::Debug - for DafnyCallEvent - { - fn fmt(&self, f: &mut ::std::fmt::Formatter) -> std::fmt::Result { - ::dafny_runtime::DafnyPrint::fmt_print(self, f, true) - } - } - - impl ::dafny_runtime::DafnyPrint - for DafnyCallEvent - { - fn fmt_print( - &self, - _formatter: &mut ::std::fmt::Formatter, - _in_seq: bool, - ) -> std::fmt::Result { - match self { - DafnyCallEvent::DafnyCallEvent { input, output } => { - write!(_formatter, "r#_simple_dtypes_denumv2_dinternaldafny_dtypes.DafnyCallEvent.DafnyCallEvent(")?; - ::dafny_runtime::DafnyPrint::fmt_print(input, _formatter, false)?; - write!(_formatter, ", ")?; - ::dafny_runtime::DafnyPrint::fmt_print(output, _formatter, false)?; - write!(_formatter, ")")?; - Ok(()) - } - DafnyCallEvent::_PhantomVariant(..) => { - panic!() - } - } - } - } - - impl Eq - for DafnyCallEvent - { - } - - impl< - I: ::dafny_runtime::DafnyType + ::std::hash::Hash, - O: ::dafny_runtime::DafnyType + ::std::hash::Hash, - > ::std::hash::Hash for DafnyCallEvent - { - fn hash<_H: ::std::hash::Hasher>(&self, _state: &mut _H) { - match self { - DafnyCallEvent::DafnyCallEvent { input, output } => { - input.hash(_state); - output.hash(_state) - } - DafnyCallEvent::_PhantomVariant(..) => { - panic!() - } - } - } - } - - impl< - I: ::dafny_runtime::DafnyType + ::std::default::Default, - O: ::dafny_runtime::DafnyType + ::std::default::Default, - > ::std::default::Default for DafnyCallEvent - { - fn default() -> DafnyCallEvent { - DafnyCallEvent::DafnyCallEvent { - input: ::std::default::Default::default(), - output: ::std::default::Default::default(), - } - } - } - - impl - ::std::convert::AsRef> for &DafnyCallEvent - { - fn as_ref(&self) -> Self { - self - } - } - - #[derive(PartialEq, Clone)] - pub enum GetEnumV2Input { - GetEnumV2Input { - value: ::std::rc::Rc< - super::r#_Wrappers_Compile::Option< - ::std::rc::Rc< - super::r#_simple_dtypes_denumv2_dinternaldafny_dtypes::SimpleEnumV2Shape, - >, - >, - >, - }, - } - - impl GetEnumV2Input { - pub fn value( - &self, - ) -> &::std::rc::Rc< - super::r#_Wrappers_Compile::Option< - ::std::rc::Rc< - super::r#_simple_dtypes_denumv2_dinternaldafny_dtypes::SimpleEnumV2Shape, - >, - >, - > { - match self { - GetEnumV2Input::GetEnumV2Input { value } => value, - } - } - } - - impl ::std::fmt::Debug for GetEnumV2Input { - fn fmt(&self, f: &mut ::std::fmt::Formatter) -> std::fmt::Result { - ::dafny_runtime::DafnyPrint::fmt_print(self, f, true) - } - } - - impl ::dafny_runtime::DafnyPrint for GetEnumV2Input { - fn fmt_print( - &self, - _formatter: &mut ::std::fmt::Formatter, - _in_seq: bool, - ) -> std::fmt::Result { - match self { - GetEnumV2Input::GetEnumV2Input { value } => { - write!(_formatter, "r#_simple_dtypes_denumv2_dinternaldafny_dtypes.GetEnumV2Input.GetEnumV2Input(")?; - ::dafny_runtime::DafnyPrint::fmt_print(value, _formatter, false)?; - write!(_formatter, ")")?; - Ok(()) - } - } - } - } - - impl Eq for GetEnumV2Input {} - - impl ::std::hash::Hash for GetEnumV2Input { - fn hash<_H: ::std::hash::Hasher>(&self, _state: &mut _H) { - match self { - GetEnumV2Input::GetEnumV2Input { value } => value.hash(_state), - } - } - } - - impl ::std::default::Default for GetEnumV2Input { - fn default() -> GetEnumV2Input { - GetEnumV2Input::GetEnumV2Input { - value: ::std::default::Default::default(), - } - } - } - - impl ::std::convert::AsRef for &GetEnumV2Input { - fn as_ref(&self) -> Self { - self - } - } - - #[derive(PartialEq, Clone)] - pub enum GetEnumV2Output { - GetEnumV2Output { - value: ::std::rc::Rc< - super::r#_Wrappers_Compile::Option< - ::std::rc::Rc< - super::r#_simple_dtypes_denumv2_dinternaldafny_dtypes::SimpleEnumV2Shape, - >, - >, - >, - }, - } - - impl GetEnumV2Output { - pub fn value( - &self, - ) -> &::std::rc::Rc< - super::r#_Wrappers_Compile::Option< - ::std::rc::Rc< - super::r#_simple_dtypes_denumv2_dinternaldafny_dtypes::SimpleEnumV2Shape, - >, - >, - > { - match self { - GetEnumV2Output::GetEnumV2Output { value } => value, - } - } - } - - impl ::std::fmt::Debug for GetEnumV2Output { - fn fmt(&self, f: &mut ::std::fmt::Formatter) -> std::fmt::Result { - ::dafny_runtime::DafnyPrint::fmt_print(self, f, true) - } - } - - impl ::dafny_runtime::DafnyPrint for GetEnumV2Output { - fn fmt_print( - &self, - _formatter: &mut ::std::fmt::Formatter, - _in_seq: bool, - ) -> std::fmt::Result { - match self { - GetEnumV2Output::GetEnumV2Output { value } => { - write!(_formatter, "r#_simple_dtypes_denumv2_dinternaldafny_dtypes.GetEnumV2Output.GetEnumV2Output(")?; - ::dafny_runtime::DafnyPrint::fmt_print(value, _formatter, false)?; - write!(_formatter, ")")?; - Ok(()) - } - } - } - } - - impl Eq for GetEnumV2Output {} - - impl ::std::hash::Hash for GetEnumV2Output { - fn hash<_H: ::std::hash::Hasher>(&self, _state: &mut _H) { - match self { - GetEnumV2Output::GetEnumV2Output { value } => value.hash(_state), - } - } - } - - impl ::std::default::Default for GetEnumV2Output { - fn default() -> GetEnumV2Output { - GetEnumV2Output::GetEnumV2Output { - value: ::std::default::Default::default(), - } - } - } - - impl ::std::convert::AsRef for &GetEnumV2Output { - fn as_ref(&self) -> Self { - self - } - } - - #[derive(PartialEq, Clone)] - pub enum SimpleEnumV2Config { - SimpleEnumV2Config {}, - } - - impl SimpleEnumV2Config {} - - impl ::std::fmt::Debug for SimpleEnumV2Config { - fn fmt(&self, f: &mut ::std::fmt::Formatter) -> std::fmt::Result { - ::dafny_runtime::DafnyPrint::fmt_print(self, f, true) - } - } - - impl ::dafny_runtime::DafnyPrint for SimpleEnumV2Config { - fn fmt_print( - &self, - _formatter: &mut ::std::fmt::Formatter, - _in_seq: bool, - ) -> std::fmt::Result { - match self { - SimpleEnumV2Config::SimpleEnumV2Config {} => { - write!(_formatter, "r#_simple_dtypes_denumv2_dinternaldafny_dtypes.SimpleEnumV2Config.SimpleEnumV2Config")?; - Ok(()) - } - } - } - } - - impl Eq for SimpleEnumV2Config {} - - impl ::std::hash::Hash for SimpleEnumV2Config { - fn hash<_H: ::std::hash::Hasher>(&self, _state: &mut _H) { - match self { - SimpleEnumV2Config::SimpleEnumV2Config {} => {} - } - } - } - - impl ::std::default::Default for SimpleEnumV2Config { - fn default() -> SimpleEnumV2Config { - SimpleEnumV2Config::SimpleEnumV2Config {} - } - } - - impl ::std::convert::AsRef for &SimpleEnumV2Config { - fn as_ref(&self) -> Self { - self - } - } - - #[derive(PartialEq, Clone)] - pub enum SimpleEnumV2Shape { - FIRST {}, - SECOND {}, - THIRD {}, - } - - impl SimpleEnumV2Shape {} - - impl ::std::fmt::Debug for SimpleEnumV2Shape { - fn fmt(&self, f: &mut ::std::fmt::Formatter) -> std::fmt::Result { - ::dafny_runtime::DafnyPrint::fmt_print(self, f, true) - } - } - - impl ::dafny_runtime::DafnyPrint for SimpleEnumV2Shape { - fn fmt_print( - &self, - _formatter: &mut ::std::fmt::Formatter, - _in_seq: bool, - ) -> std::fmt::Result { - match self { - SimpleEnumV2Shape::FIRST {} => { - write!( - _formatter, - "r#_simple_dtypes_denumv2_dinternaldafny_dtypes.SimpleEnumV2Shape.FIRST" - )?; - Ok(()) - } - SimpleEnumV2Shape::SECOND {} => { - write!( - _formatter, - "r#_simple_dtypes_denumv2_dinternaldafny_dtypes.SimpleEnumV2Shape.SECOND" - )?; - Ok(()) - } - SimpleEnumV2Shape::THIRD {} => { - write!( - _formatter, - "r#_simple_dtypes_denumv2_dinternaldafny_dtypes.SimpleEnumV2Shape.THIRD" - )?; - Ok(()) - } - } - } - } - - impl Eq for SimpleEnumV2Shape {} - - impl ::std::hash::Hash for SimpleEnumV2Shape { - fn hash<_H: ::std::hash::Hasher>(&self, _state: &mut _H) { - match self { - SimpleEnumV2Shape::FIRST {} => {} - SimpleEnumV2Shape::SECOND {} => {} - SimpleEnumV2Shape::THIRD {} => {} - } - } - } - - impl ::std::default::Default for SimpleEnumV2Shape { - fn default() -> SimpleEnumV2Shape { - SimpleEnumV2Shape::FIRST {} - } - } - - impl ::std::convert::AsRef for &SimpleEnumV2Shape { - fn as_ref(&self) -> Self { - self - } - } - - pub struct ISimpleTypesEnumV2ClientCallHistory {} - - impl ISimpleTypesEnumV2ClientCallHistory { - pub fn _allocate_rcmut() -> ::dafny_runtime::Object { - ::dafny_runtime::allocate_rcmut::() - } - } - - pub trait ISimpleTypesEnumV2Client { - fn GetEnumV2( - &mut self, - input: &::std::rc::Rc< - super::r#_simple_dtypes_denumv2_dinternaldafny_dtypes::GetEnumV2Input, - >, - ) -> ::std::rc::Rc< - super::r#_Wrappers_Compile::Result< - ::std::rc::Rc< - super::r#_simple_dtypes_denumv2_dinternaldafny_dtypes::GetEnumV2Output, - >, - ::std::rc::Rc, - >, - >; - fn GetEnumV2FirstKnownValueTest( - &mut self, - input: &::std::rc::Rc< - super::r#_simple_dtypes_denumv2_dinternaldafny_dtypes::GetEnumV2Input, - >, - ) -> ::std::rc::Rc< - super::r#_Wrappers_Compile::Result< - ::std::rc::Rc< - super::r#_simple_dtypes_denumv2_dinternaldafny_dtypes::GetEnumV2Output, - >, - ::std::rc::Rc, - >, - >; - fn GetEnumV2SecondKnownValueTest( - &mut self, - input: &::std::rc::Rc< - super::r#_simple_dtypes_denumv2_dinternaldafny_dtypes::GetEnumV2Input, - >, - ) -> ::std::rc::Rc< - super::r#_Wrappers_Compile::Result< - ::std::rc::Rc< - super::r#_simple_dtypes_denumv2_dinternaldafny_dtypes::GetEnumV2Output, - >, - ::std::rc::Rc, - >, - >; - fn GetEnumV2ThirdKnownValueTest( - &mut self, - input: &::std::rc::Rc< - super::r#_simple_dtypes_denumv2_dinternaldafny_dtypes::GetEnumV2Input, - >, - ) -> ::std::rc::Rc< - super::r#_Wrappers_Compile::Result< - ::std::rc::Rc< - super::r#_simple_dtypes_denumv2_dinternaldafny_dtypes::GetEnumV2Output, - >, - ::std::rc::Rc, - >, - >; - } - - #[derive(PartialEq, Clone)] - pub enum Error { - CollectionOfErrors { - list: ::dafny_runtime::Sequence< - ::std::rc::Rc, - >, - message: ::dafny_runtime::Sequence<::dafny_runtime::DafnyCharUTF16>, - }, - Opaque { - obj: ::dafny_runtime::Object, - }, - } - - impl Error { - pub fn list( - &self, - ) -> &::dafny_runtime::Sequence< - ::std::rc::Rc, - > { - match self { - Error::CollectionOfErrors { list, message } => list, - Error::Opaque { obj } => panic!("field does not exist on this variant"), - } - } - pub fn message(&self) -> &::dafny_runtime::Sequence<::dafny_runtime::DafnyCharUTF16> { - match self { - Error::CollectionOfErrors { list, message } => message, - Error::Opaque { obj } => panic!("field does not exist on this variant"), - } - } - pub fn obj(&self) -> &::dafny_runtime::Object { - match self { - Error::CollectionOfErrors { list, message } => { - panic!("field does not exist on this variant") - } - Error::Opaque { obj } => obj, - } - } - } - - impl ::std::fmt::Debug for Error { - fn fmt(&self, f: &mut ::std::fmt::Formatter) -> std::fmt::Result { - ::dafny_runtime::DafnyPrint::fmt_print(self, f, true) - } - } - - impl ::dafny_runtime::DafnyPrint for Error { - fn fmt_print( - &self, - _formatter: &mut ::std::fmt::Formatter, - _in_seq: bool, - ) -> std::fmt::Result { - match self { - Error::CollectionOfErrors { list, message } => { - write!( - _formatter, - "r#_simple_dtypes_denumv2_dinternaldafny_dtypes.Error.CollectionOfErrors(" - )?; - ::dafny_runtime::DafnyPrint::fmt_print(list, _formatter, false)?; - write!(_formatter, ", ")?; - ::dafny_runtime::DafnyPrint::fmt_print(message, _formatter, false)?; - write!(_formatter, ")")?; - Ok(()) - } - Error::Opaque { obj } => { - write!( - _formatter, - "r#_simple_dtypes_denumv2_dinternaldafny_dtypes.Error.Opaque(" - )?; - ::dafny_runtime::DafnyPrint::fmt_print(obj, _formatter, false)?; - write!(_formatter, ")")?; - Ok(()) - } - } - } - } - - impl Eq for Error {} - - impl ::std::hash::Hash for Error { - fn hash<_H: ::std::hash::Hasher>(&self, _state: &mut _H) { - match self { - Error::CollectionOfErrors { list, message } => { - list.hash(_state); - message.hash(_state) - } - Error::Opaque { obj } => obj.hash(_state), - } - } - } - - impl ::std::default::Default for Error { - fn default() -> Error { - Error::CollectionOfErrors { - list: ::std::default::Default::default(), - message: ::std::default::Default::default(), - } - } - } - - impl ::std::convert::AsRef for &Error { - fn as_ref(&self) -> Self { - self - } - } - - pub type OpaqueError = - ::std::rc::Rc; -} -pub mod r#_SimpleEnumV2Impl_Compile { - pub struct _default {} - - impl _default { - pub fn _allocate_rcmut() -> ::dafny_runtime::Object { - ::dafny_runtime::allocate_rcmut::() - } - pub fn GetEnumV2( - config: &::std::rc::Rc, - input: &::std::rc::Rc< - super::r#_simple_dtypes_denumv2_dinternaldafny_dtypes::GetEnumV2Input, - >, - ) -> ::std::rc::Rc< - super::r#_Wrappers_Compile::Result< - ::std::rc::Rc< - super::r#_simple_dtypes_denumv2_dinternaldafny_dtypes::GetEnumV2Output, - >, - ::std::rc::Rc, - >, - > { - let mut output = ::dafny_runtime::MaybePlacebo::< - ::std::rc::Rc< - super::r#_Wrappers_Compile::Result< - ::std::rc::Rc< - super::r#_simple_dtypes_denumv2_dinternaldafny_dtypes::GetEnumV2Output, - >, - ::std::rc::Rc, - >, - >, - >::new(); - let mut res: ::std::rc::Rc = ::std::rc::Rc::new(super::r#_simple_dtypes_denumv2_dinternaldafny_dtypes::GetEnumV2Output::GetEnumV2Output { - value: input.value().clone() - }); - res = ::std::rc::Rc::new(super::r#_simple_dtypes_denumv2_dinternaldafny_dtypes::GetEnumV2Output::GetEnumV2Output { - value: input.value().clone() - }); - output = ::dafny_runtime::MaybePlacebo::from(::std::rc::Rc::new( - super::r#_Wrappers_Compile::Result::< - ::std::rc::Rc< - super::r#_simple_dtypes_denumv2_dinternaldafny_dtypes::GetEnumV2Output, - >, - ::std::rc::Rc, - >::Success { - value: res.clone(), - }, - )); - return output.read(); - return output.read(); - } - pub fn GetEnumV2FirstKnownValueTest( - config: &::std::rc::Rc, - input: &::std::rc::Rc< - super::r#_simple_dtypes_denumv2_dinternaldafny_dtypes::GetEnumV2Input, - >, - ) -> ::std::rc::Rc< - super::r#_Wrappers_Compile::Result< - ::std::rc::Rc< - super::r#_simple_dtypes_denumv2_dinternaldafny_dtypes::GetEnumV2Output, - >, - ::std::rc::Rc, - >, - > { - let mut output = ::dafny_runtime::MaybePlacebo::< - ::std::rc::Rc< - super::r#_Wrappers_Compile::Result< - ::std::rc::Rc< - super::r#_simple_dtypes_denumv2_dinternaldafny_dtypes::GetEnumV2Output, - >, - ::std::rc::Rc, - >, - >, - >::new(); - if !matches!( - input.value().as_ref(), - super::r#_Wrappers_Compile::Option::Some { .. } - ) { - panic!("Halt") - }; - if !(input.value().value().clone() == ::std::rc::Rc::new(super::r#_simple_dtypes_denumv2_dinternaldafny_dtypes::SimpleEnumV2Shape::FIRST {})) { - panic!("Halt") - }; - let mut res: ::std::rc::Rc = ::std::rc::Rc::new(super::r#_simple_dtypes_denumv2_dinternaldafny_dtypes::GetEnumV2Output::GetEnumV2Output { - value: input.value().clone() - }); - res = ::std::rc::Rc::new(super::r#_simple_dtypes_denumv2_dinternaldafny_dtypes::GetEnumV2Output::GetEnumV2Output { - value: input.value().clone() - }); - if !matches!( - res.value().as_ref(), - super::r#_Wrappers_Compile::Option::Some { .. } - ) { - panic!("Halt") - }; - if !(res.value().value().clone() == ::std::rc::Rc::new(super::r#_simple_dtypes_denumv2_dinternaldafny_dtypes::SimpleEnumV2Shape::FIRST {})) { - panic!("Halt") - }; - output = ::dafny_runtime::MaybePlacebo::from(::std::rc::Rc::new( - super::r#_Wrappers_Compile::Result::< - ::std::rc::Rc< - super::r#_simple_dtypes_denumv2_dinternaldafny_dtypes::GetEnumV2Output, - >, - ::std::rc::Rc, - >::Success { - value: res.clone(), - }, - )); - return output.read(); - return output.read(); - } - pub fn GetEnumV2SecondKnownValueTest( - config: &::std::rc::Rc, - input: &::std::rc::Rc< - super::r#_simple_dtypes_denumv2_dinternaldafny_dtypes::GetEnumV2Input, - >, - ) -> ::std::rc::Rc< - super::r#_Wrappers_Compile::Result< - ::std::rc::Rc< - super::r#_simple_dtypes_denumv2_dinternaldafny_dtypes::GetEnumV2Output, - >, - ::std::rc::Rc, - >, - > { - let mut output = ::dafny_runtime::MaybePlacebo::< - ::std::rc::Rc< - super::r#_Wrappers_Compile::Result< - ::std::rc::Rc< - super::r#_simple_dtypes_denumv2_dinternaldafny_dtypes::GetEnumV2Output, - >, - ::std::rc::Rc, - >, - >, - >::new(); - if !matches!( - input.value().as_ref(), - super::r#_Wrappers_Compile::Option::Some { .. } - ) { - panic!("Halt") - }; - if !(input.value().value().clone() == ::std::rc::Rc::new(super::r#_simple_dtypes_denumv2_dinternaldafny_dtypes::SimpleEnumV2Shape::SECOND {})) { - panic!("Halt") - }; - let mut res: ::std::rc::Rc = ::std::rc::Rc::new(super::r#_simple_dtypes_denumv2_dinternaldafny_dtypes::GetEnumV2Output::GetEnumV2Output { - value: input.value().clone() - }); - res = ::std::rc::Rc::new(super::r#_simple_dtypes_denumv2_dinternaldafny_dtypes::GetEnumV2Output::GetEnumV2Output { - value: input.value().clone() - }); - if !matches!( - res.value().as_ref(), - super::r#_Wrappers_Compile::Option::Some { .. } - ) { - panic!("Halt") - }; - if !(res.value().value().clone() == ::std::rc::Rc::new(super::r#_simple_dtypes_denumv2_dinternaldafny_dtypes::SimpleEnumV2Shape::SECOND {})) { - panic!("Halt") - }; - output = ::dafny_runtime::MaybePlacebo::from(::std::rc::Rc::new( - super::r#_Wrappers_Compile::Result::< - ::std::rc::Rc< - super::r#_simple_dtypes_denumv2_dinternaldafny_dtypes::GetEnumV2Output, - >, - ::std::rc::Rc, - >::Success { - value: res.clone(), - }, - )); - return output.read(); - return output.read(); - } - pub fn GetEnumV2ThirdKnownValueTest( - config: &::std::rc::Rc, - input: &::std::rc::Rc< - super::r#_simple_dtypes_denumv2_dinternaldafny_dtypes::GetEnumV2Input, - >, - ) -> ::std::rc::Rc< - super::r#_Wrappers_Compile::Result< - ::std::rc::Rc< - super::r#_simple_dtypes_denumv2_dinternaldafny_dtypes::GetEnumV2Output, - >, - ::std::rc::Rc, - >, - > { - let mut output = ::dafny_runtime::MaybePlacebo::< - ::std::rc::Rc< - super::r#_Wrappers_Compile::Result< - ::std::rc::Rc< - super::r#_simple_dtypes_denumv2_dinternaldafny_dtypes::GetEnumV2Output, - >, - ::std::rc::Rc, - >, - >, - >::new(); - if !matches!( - input.value().as_ref(), - super::r#_Wrappers_Compile::Option::Some { .. } - ) { - panic!("Halt") - }; - if !(input.value().value().clone() == ::std::rc::Rc::new(super::r#_simple_dtypes_denumv2_dinternaldafny_dtypes::SimpleEnumV2Shape::THIRD {})) { - panic!("Halt") - }; - let mut res: ::std::rc::Rc = ::std::rc::Rc::new(super::r#_simple_dtypes_denumv2_dinternaldafny_dtypes::GetEnumV2Output::GetEnumV2Output { - value: input.value().clone() - }); - res = ::std::rc::Rc::new(super::r#_simple_dtypes_denumv2_dinternaldafny_dtypes::GetEnumV2Output::GetEnumV2Output { - value: input.value().clone() - }); - if !matches!( - res.value().as_ref(), - super::r#_Wrappers_Compile::Option::Some { .. } - ) { - panic!("Halt") - }; - if !(res.value().value().clone() == ::std::rc::Rc::new(super::r#_simple_dtypes_denumv2_dinternaldafny_dtypes::SimpleEnumV2Shape::THIRD {})) { - panic!("Halt") - }; - output = ::dafny_runtime::MaybePlacebo::from(::std::rc::Rc::new( - super::r#_Wrappers_Compile::Result::< - ::std::rc::Rc< - super::r#_simple_dtypes_denumv2_dinternaldafny_dtypes::GetEnumV2Output, - >, - ::std::rc::Rc, - >::Success { - value: res.clone(), - }, - )); - return output.read(); - return output.read(); - } - } - - #[derive(PartialEq, Clone)] - pub enum Config { - Config {}, - } - - impl Config {} - - impl ::std::fmt::Debug for Config { - fn fmt(&self, f: &mut ::std::fmt::Formatter) -> std::fmt::Result { - ::dafny_runtime::DafnyPrint::fmt_print(self, f, true) - } - } - - impl ::dafny_runtime::DafnyPrint for Config { - fn fmt_print( - &self, - _formatter: &mut ::std::fmt::Formatter, - _in_seq: bool, - ) -> std::fmt::Result { - match self { - Config::Config {} => { - write!(_formatter, "r#_SimpleEnumV2Impl_Compile.Config.Config")?; - Ok(()) - } - } - } - } - - impl Eq for Config {} - - impl ::std::hash::Hash for Config { - fn hash<_H: ::std::hash::Hasher>(&self, _state: &mut _H) { - match self { - Config::Config {} => {} - } - } - } - - impl ::std::default::Default for Config { - fn default() -> Config { - Config::Config {} - } - } - - impl ::std::convert::AsRef for &Config { - fn as_ref(&self) -> Self { - self - } - } -} -pub mod r#_simple_dtypes_denumv2_dinternaldafny { - pub struct _default {} - - impl _default { - pub fn _allocate_rcmut() -> ::dafny_runtime::Object { - ::dafny_runtime::allocate_rcmut::() - } - pub fn DefaultSimpleEnumV2Config( - ) -> ::std::rc::Rc - { - ::std::rc::Rc::new(super::r#_simple_dtypes_denumv2_dinternaldafny_dtypes::SimpleEnumV2Config::SimpleEnumV2Config {}) - } - pub fn SimpleEnumV2( - config: &::std::rc::Rc< - super::r#_simple_dtypes_denumv2_dinternaldafny_dtypes::SimpleEnumV2Config, - >, - ) -> ::std::rc::Rc< - super::r#_Wrappers_Compile::Result< - ::dafny_runtime::Object< - super::r#_simple_dtypes_denumv2_dinternaldafny::SimpleEnumV2Client, - >, - ::std::rc::Rc, - >, - > { - let mut res = ::dafny_runtime::MaybePlacebo::< - ::std::rc::Rc< - super::r#_Wrappers_Compile::Result< - ::dafny_runtime::Object< - super::r#_simple_dtypes_denumv2_dinternaldafny::SimpleEnumV2Client, - >, - ::std::rc::Rc, - >, - >, - >::new(); - let mut client = ::dafny_runtime::MaybePlacebo::< - ::dafny_runtime::Object< - super::r#_simple_dtypes_denumv2_dinternaldafny::SimpleEnumV2Client, - >, - >::new(); - let mut _nw0: ::dafny_runtime::Object< - super::r#_simple_dtypes_denumv2_dinternaldafny::SimpleEnumV2Client, - > = super::r#_simple_dtypes_denumv2_dinternaldafny::SimpleEnumV2Client::_allocate_rcmut( - ); - super::r#_simple_dtypes_denumv2_dinternaldafny::SimpleEnumV2Client::_ctor( - &_nw0, - &::std::rc::Rc::new(super::r#_SimpleEnumV2Impl_Compile::Config::Config {}), - ); - client = ::dafny_runtime::MaybePlacebo::from(_nw0.clone()); - res = ::dafny_runtime::MaybePlacebo::from(::std::rc::Rc::new( - super::r#_Wrappers_Compile::Result::< - ::dafny_runtime::Object< - super::r#_simple_dtypes_denumv2_dinternaldafny::SimpleEnumV2Client, - >, - ::std::rc::Rc, - >::Success { - value: client.read(), - }, - )); - return res.read(); - return res.read(); - } - pub fn CreateSuccessOfClient(client: &::dafny_runtime::Object) -> ::std::rc::Rc, ::std::rc::Rc>>{ - ::std::rc::Rc::new(super::r#_Wrappers_Compile::Result::<::dafny_runtime::Object, ::std::rc::Rc>::Success { - value: client.clone() - }) - } - pub fn CreateFailureOfError(error: &::std::rc::Rc) -> ::std::rc::Rc, ::std::rc::Rc>>{ - ::std::rc::Rc::new(super::r#_Wrappers_Compile::Result::<::dafny_runtime::Object, ::std::rc::Rc>::Failure { - error: error.clone() - }) - } - } - - pub struct SimpleEnumV2Client { - pub r#__i_config: ::std::rc::Rc, - } - - impl SimpleEnumV2Client { - pub fn _allocate_rcmut() -> ::dafny_runtime::Object { - ::dafny_runtime::allocate_rcmut::() - } - pub fn _ctor( - this: &::dafny_runtime::Object, - config: &::std::rc::Rc, - ) -> () { - let mut _set__i_config: bool = false; - ::dafny_runtime::update_field_uninit_rcmut!( - this.clone(), - r#__i_config, - _set__i_config, - config.clone() - ); - return (); - } - pub fn config(&self) -> ::std::rc::Rc { - self.r#__i_config.clone() - } - } - - impl super::r#_simple_dtypes_denumv2_dinternaldafny_dtypes::ISimpleTypesEnumV2Client - for super::r#_simple_dtypes_denumv2_dinternaldafny::SimpleEnumV2Client - { - fn GetEnumV2( - &mut self, - input: &::std::rc::Rc< - super::r#_simple_dtypes_denumv2_dinternaldafny_dtypes::GetEnumV2Input, - >, - ) -> ::std::rc::Rc< - super::r#_Wrappers_Compile::Result< - ::std::rc::Rc< - super::r#_simple_dtypes_denumv2_dinternaldafny_dtypes::GetEnumV2Output, - >, - ::std::rc::Rc, - >, - > { - let mut output = ::dafny_runtime::MaybePlacebo::< - ::std::rc::Rc< - super::r#_Wrappers_Compile::Result< - ::std::rc::Rc< - super::r#_simple_dtypes_denumv2_dinternaldafny_dtypes::GetEnumV2Output, - >, - ::std::rc::Rc, - >, - >, - >::new(); - let mut _out0 = ::dafny_runtime::MaybePlacebo::< - ::std::rc::Rc< - super::r#_Wrappers_Compile::Result< - ::std::rc::Rc< - super::r#_simple_dtypes_denumv2_dinternaldafny_dtypes::GetEnumV2Output, - >, - ::std::rc::Rc, - >, - >, - >::new(); - _out0 = ::dafny_runtime::MaybePlacebo::from( - super::r#_SimpleEnumV2Impl_Compile::_default::GetEnumV2(&self.config(), input), - ); - output = ::dafny_runtime::MaybePlacebo::from(_out0.read()); - return output.read(); - } - fn GetEnumV2FirstKnownValueTest( - &mut self, - input: &::std::rc::Rc< - super::r#_simple_dtypes_denumv2_dinternaldafny_dtypes::GetEnumV2Input, - >, - ) -> ::std::rc::Rc< - super::r#_Wrappers_Compile::Result< - ::std::rc::Rc< - super::r#_simple_dtypes_denumv2_dinternaldafny_dtypes::GetEnumV2Output, - >, - ::std::rc::Rc, - >, - > { - let mut output = ::dafny_runtime::MaybePlacebo::< - ::std::rc::Rc< - super::r#_Wrappers_Compile::Result< - ::std::rc::Rc< - super::r#_simple_dtypes_denumv2_dinternaldafny_dtypes::GetEnumV2Output, - >, - ::std::rc::Rc, - >, - >, - >::new(); - let mut _out1 = ::dafny_runtime::MaybePlacebo::< - ::std::rc::Rc< - super::r#_Wrappers_Compile::Result< - ::std::rc::Rc< - super::r#_simple_dtypes_denumv2_dinternaldafny_dtypes::GetEnumV2Output, - >, - ::std::rc::Rc, - >, - >, - >::new(); - _out1 = ::dafny_runtime::MaybePlacebo::from( - super::r#_SimpleEnumV2Impl_Compile::_default::GetEnumV2FirstKnownValueTest( - &self.config(), - input, - ), - ); - output = ::dafny_runtime::MaybePlacebo::from(_out1.read()); - return output.read(); - } - fn GetEnumV2SecondKnownValueTest( - &mut self, - input: &::std::rc::Rc< - super::r#_simple_dtypes_denumv2_dinternaldafny_dtypes::GetEnumV2Input, - >, - ) -> ::std::rc::Rc< - super::r#_Wrappers_Compile::Result< - ::std::rc::Rc< - super::r#_simple_dtypes_denumv2_dinternaldafny_dtypes::GetEnumV2Output, - >, - ::std::rc::Rc, - >, - > { - let mut output = ::dafny_runtime::MaybePlacebo::< - ::std::rc::Rc< - super::r#_Wrappers_Compile::Result< - ::std::rc::Rc< - super::r#_simple_dtypes_denumv2_dinternaldafny_dtypes::GetEnumV2Output, - >, - ::std::rc::Rc, - >, - >, - >::new(); - let mut _out2 = ::dafny_runtime::MaybePlacebo::< - ::std::rc::Rc< - super::r#_Wrappers_Compile::Result< - ::std::rc::Rc< - super::r#_simple_dtypes_denumv2_dinternaldafny_dtypes::GetEnumV2Output, - >, - ::std::rc::Rc, - >, - >, - >::new(); - _out2 = ::dafny_runtime::MaybePlacebo::from( - super::r#_SimpleEnumV2Impl_Compile::_default::GetEnumV2SecondKnownValueTest( - &self.config(), - input, - ), - ); - output = ::dafny_runtime::MaybePlacebo::from(_out2.read()); - return output.read(); - } - fn GetEnumV2ThirdKnownValueTest( - &mut self, - input: &::std::rc::Rc< - super::r#_simple_dtypes_denumv2_dinternaldafny_dtypes::GetEnumV2Input, - >, - ) -> ::std::rc::Rc< - super::r#_Wrappers_Compile::Result< - ::std::rc::Rc< - super::r#_simple_dtypes_denumv2_dinternaldafny_dtypes::GetEnumV2Output, - >, - ::std::rc::Rc, - >, - > { - let mut output = ::dafny_runtime::MaybePlacebo::< - ::std::rc::Rc< - super::r#_Wrappers_Compile::Result< - ::std::rc::Rc< - super::r#_simple_dtypes_denumv2_dinternaldafny_dtypes::GetEnumV2Output, - >, - ::std::rc::Rc, - >, - >, - >::new(); - let mut _out3 = ::dafny_runtime::MaybePlacebo::< - ::std::rc::Rc< - super::r#_Wrappers_Compile::Result< - ::std::rc::Rc< - super::r#_simple_dtypes_denumv2_dinternaldafny_dtypes::GetEnumV2Output, - >, - ::std::rc::Rc, - >, - >, - >::new(); - _out3 = ::dafny_runtime::MaybePlacebo::from( - super::r#_SimpleEnumV2Impl_Compile::_default::GetEnumV2ThirdKnownValueTest( - &self.config(), - input, - ), - ); - output = ::dafny_runtime::MaybePlacebo::from(_out3.read()); - return output.read(); - } - } -} -pub mod _module {} diff --git a/TestModels/SimpleTypes/SimpleInteger/runtimes/rust/dafny_impl/src/implementation_from_dafny.rs b/TestModels/SimpleTypes/SimpleInteger/runtimes/rust/dafny_impl/src/implementation_from_dafny.rs deleted file mode 100644 index 44f718295e..0000000000 --- a/TestModels/SimpleTypes/SimpleInteger/runtimes/rust/dafny_impl/src/implementation_from_dafny.rs +++ /dev/null @@ -1,709 +0,0 @@ -#![allow(warnings, unconditional_panic)] -#![allow(nonstandard_style)] -pub use dafny_standard_library::implementation_from_dafny::*; - -pub mod r#_simple_dtypes_dinteger_dinternaldafny_dtypes { - #[derive(PartialEq, Clone)] - pub enum DafnyCallEvent { - DafnyCallEvent { input: I, output: O }, - _PhantomVariant(::std::marker::PhantomData, ::std::marker::PhantomData), - } - - impl DafnyCallEvent { - pub fn input(&self) -> &I { - match self { - DafnyCallEvent::DafnyCallEvent { input, output } => input, - DafnyCallEvent::_PhantomVariant(..) => panic!(), - } - } - pub fn output(&self) -> &O { - match self { - DafnyCallEvent::DafnyCallEvent { input, output } => output, - DafnyCallEvent::_PhantomVariant(..) => panic!(), - } - } - } - - impl ::std::fmt::Debug - for DafnyCallEvent - { - fn fmt(&self, f: &mut ::std::fmt::Formatter) -> std::fmt::Result { - ::dafny_runtime::DafnyPrint::fmt_print(self, f, true) - } - } - - impl ::dafny_runtime::DafnyPrint - for DafnyCallEvent - { - fn fmt_print( - &self, - _formatter: &mut ::std::fmt::Formatter, - _in_seq: bool, - ) -> std::fmt::Result { - match self { - DafnyCallEvent::DafnyCallEvent { input, output } => { - write!(_formatter, "r#_simple_dtypes_dinteger_dinternaldafny_dtypes.DafnyCallEvent.DafnyCallEvent(")?; - ::dafny_runtime::DafnyPrint::fmt_print(input, _formatter, false)?; - write!(_formatter, ", ")?; - ::dafny_runtime::DafnyPrint::fmt_print(output, _formatter, false)?; - write!(_formatter, ")")?; - Ok(()) - } - DafnyCallEvent::_PhantomVariant(..) => { - panic!() - } - } - } - } - - impl Eq - for DafnyCallEvent - { - } - - impl< - I: ::dafny_runtime::DafnyType + ::std::hash::Hash, - O: ::dafny_runtime::DafnyType + ::std::hash::Hash, - > ::std::hash::Hash for DafnyCallEvent - { - fn hash<_H: ::std::hash::Hasher>(&self, _state: &mut _H) { - match self { - DafnyCallEvent::DafnyCallEvent { input, output } => { - input.hash(_state); - output.hash(_state) - } - DafnyCallEvent::_PhantomVariant(..) => { - panic!() - } - } - } - } - - impl< - I: ::dafny_runtime::DafnyType + ::std::default::Default, - O: ::dafny_runtime::DafnyType + ::std::default::Default, - > ::std::default::Default for DafnyCallEvent - { - fn default() -> DafnyCallEvent { - DafnyCallEvent::DafnyCallEvent { - input: ::std::default::Default::default(), - output: ::std::default::Default::default(), - } - } - } - - impl - ::std::convert::AsRef> for &DafnyCallEvent - { - fn as_ref(&self) -> Self { - self - } - } - - #[derive(PartialEq, Clone)] - pub enum GetIntegerInput { - GetIntegerInput { - value: ::std::rc::Rc>, - }, - } - - impl GetIntegerInput { - pub fn value(&self) -> &::std::rc::Rc> { - match self { - GetIntegerInput::GetIntegerInput { value } => value, - } - } - } - - impl ::std::fmt::Debug for GetIntegerInput { - fn fmt(&self, f: &mut ::std::fmt::Formatter) -> std::fmt::Result { - ::dafny_runtime::DafnyPrint::fmt_print(self, f, true) - } - } - - impl ::dafny_runtime::DafnyPrint for GetIntegerInput { - fn fmt_print( - &self, - _formatter: &mut ::std::fmt::Formatter, - _in_seq: bool, - ) -> std::fmt::Result { - match self { - GetIntegerInput::GetIntegerInput { value } => { - write!(_formatter, "r#_simple_dtypes_dinteger_dinternaldafny_dtypes.GetIntegerInput.GetIntegerInput(")?; - ::dafny_runtime::DafnyPrint::fmt_print(value, _formatter, false)?; - write!(_formatter, ")")?; - Ok(()) - } - } - } - } - - impl Eq for GetIntegerInput {} - - impl ::std::hash::Hash for GetIntegerInput { - fn hash<_H: ::std::hash::Hasher>(&self, _state: &mut _H) { - match self { - GetIntegerInput::GetIntegerInput { value } => value.hash(_state), - } - } - } - - impl ::std::default::Default for GetIntegerInput { - fn default() -> GetIntegerInput { - GetIntegerInput::GetIntegerInput { - value: ::std::default::Default::default(), - } - } - } - - impl ::std::convert::AsRef for &GetIntegerInput { - fn as_ref(&self) -> Self { - self - } - } - - #[derive(PartialEq, Clone)] - pub enum GetIntegerOutput { - GetIntegerOutput { - value: ::std::rc::Rc>, - }, - } - - impl GetIntegerOutput { - pub fn value(&self) -> &::std::rc::Rc> { - match self { - GetIntegerOutput::GetIntegerOutput { value } => value, - } - } - } - - impl ::std::fmt::Debug for GetIntegerOutput { - fn fmt(&self, f: &mut ::std::fmt::Formatter) -> std::fmt::Result { - ::dafny_runtime::DafnyPrint::fmt_print(self, f, true) - } - } - - impl ::dafny_runtime::DafnyPrint for GetIntegerOutput { - fn fmt_print( - &self, - _formatter: &mut ::std::fmt::Formatter, - _in_seq: bool, - ) -> std::fmt::Result { - match self { - GetIntegerOutput::GetIntegerOutput { value } => { - write!(_formatter, "r#_simple_dtypes_dinteger_dinternaldafny_dtypes.GetIntegerOutput.GetIntegerOutput(")?; - ::dafny_runtime::DafnyPrint::fmt_print(value, _formatter, false)?; - write!(_formatter, ")")?; - Ok(()) - } - } - } - } - - impl Eq for GetIntegerOutput {} - - impl ::std::hash::Hash for GetIntegerOutput { - fn hash<_H: ::std::hash::Hasher>(&self, _state: &mut _H) { - match self { - GetIntegerOutput::GetIntegerOutput { value } => value.hash(_state), - } - } - } - - impl ::std::default::Default for GetIntegerOutput { - fn default() -> GetIntegerOutput { - GetIntegerOutput::GetIntegerOutput { - value: ::std::default::Default::default(), - } - } - } - - impl ::std::convert::AsRef for &GetIntegerOutput { - fn as_ref(&self) -> Self { - self - } - } - - #[derive(PartialEq, Clone)] - pub enum SimpleIntegerConfig { - SimpleIntegerConfig {}, - } - - impl SimpleIntegerConfig {} - - impl ::std::fmt::Debug for SimpleIntegerConfig { - fn fmt(&self, f: &mut ::std::fmt::Formatter) -> std::fmt::Result { - ::dafny_runtime::DafnyPrint::fmt_print(self, f, true) - } - } - - impl ::dafny_runtime::DafnyPrint for SimpleIntegerConfig { - fn fmt_print( - &self, - _formatter: &mut ::std::fmt::Formatter, - _in_seq: bool, - ) -> std::fmt::Result { - match self { - SimpleIntegerConfig::SimpleIntegerConfig {} => { - write!(_formatter, "r#_simple_dtypes_dinteger_dinternaldafny_dtypes.SimpleIntegerConfig.SimpleIntegerConfig")?; - Ok(()) - } - } - } - } - - impl Eq for SimpleIntegerConfig {} - - impl ::std::hash::Hash for SimpleIntegerConfig { - fn hash<_H: ::std::hash::Hasher>(&self, _state: &mut _H) { - match self { - SimpleIntegerConfig::SimpleIntegerConfig {} => {} - } - } - } - - impl ::std::default::Default for SimpleIntegerConfig { - fn default() -> SimpleIntegerConfig { - SimpleIntegerConfig::SimpleIntegerConfig {} - } - } - - impl ::std::convert::AsRef for &SimpleIntegerConfig { - fn as_ref(&self) -> Self { - self - } - } - - pub struct ISimpleTypesIntegerClientCallHistory {} - - impl ISimpleTypesIntegerClientCallHistory { - pub fn _allocate_rcmut() -> ::dafny_runtime::Object { - ::dafny_runtime::allocate_rcmut::() - } - } - - pub trait ISimpleTypesIntegerClient { - fn GetInteger( - &mut self, - input: &::std::rc::Rc< - super::r#_simple_dtypes_dinteger_dinternaldafny_dtypes::GetIntegerInput, - >, - ) -> ::std::rc::Rc< - super::r#_Wrappers_Compile::Result< - ::std::rc::Rc< - super::r#_simple_dtypes_dinteger_dinternaldafny_dtypes::GetIntegerOutput, - >, - ::std::rc::Rc, - >, - >; - fn GetIntegerKnownValueTest( - &mut self, - input: &::std::rc::Rc< - super::r#_simple_dtypes_dinteger_dinternaldafny_dtypes::GetIntegerInput, - >, - ) -> ::std::rc::Rc< - super::r#_Wrappers_Compile::Result< - ::std::rc::Rc< - super::r#_simple_dtypes_dinteger_dinternaldafny_dtypes::GetIntegerOutput, - >, - ::std::rc::Rc, - >, - >; - } - - #[derive(PartialEq, Clone)] - pub enum Error { - CollectionOfErrors { - list: ::dafny_runtime::Sequence< - ::std::rc::Rc, - >, - message: ::dafny_runtime::Sequence<::dafny_runtime::DafnyCharUTF16>, - }, - Opaque { - obj: ::dafny_runtime::Object, - }, - } - - impl Error { - pub fn list( - &self, - ) -> &::dafny_runtime::Sequence< - ::std::rc::Rc, - > { - match self { - Error::CollectionOfErrors { list, message } => list, - Error::Opaque { obj } => panic!("field does not exist on this variant"), - } - } - pub fn message(&self) -> &::dafny_runtime::Sequence<::dafny_runtime::DafnyCharUTF16> { - match self { - Error::CollectionOfErrors { list, message } => message, - Error::Opaque { obj } => panic!("field does not exist on this variant"), - } - } - pub fn obj(&self) -> &::dafny_runtime::Object { - match self { - Error::CollectionOfErrors { list, message } => { - panic!("field does not exist on this variant") - } - Error::Opaque { obj } => obj, - } - } - } - - impl ::std::fmt::Debug for Error { - fn fmt(&self, f: &mut ::std::fmt::Formatter) -> std::fmt::Result { - ::dafny_runtime::DafnyPrint::fmt_print(self, f, true) - } - } - - impl ::dafny_runtime::DafnyPrint for Error { - fn fmt_print( - &self, - _formatter: &mut ::std::fmt::Formatter, - _in_seq: bool, - ) -> std::fmt::Result { - match self { - Error::CollectionOfErrors { list, message } => { - write!( - _formatter, - "r#_simple_dtypes_dinteger_dinternaldafny_dtypes.Error.CollectionOfErrors(" - )?; - ::dafny_runtime::DafnyPrint::fmt_print(list, _formatter, false)?; - write!(_formatter, ", ")?; - ::dafny_runtime::DafnyPrint::fmt_print(message, _formatter, false)?; - write!(_formatter, ")")?; - Ok(()) - } - Error::Opaque { obj } => { - write!( - _formatter, - "r#_simple_dtypes_dinteger_dinternaldafny_dtypes.Error.Opaque(" - )?; - ::dafny_runtime::DafnyPrint::fmt_print(obj, _formatter, false)?; - write!(_formatter, ")")?; - Ok(()) - } - } - } - } - - impl Eq for Error {} - - impl ::std::hash::Hash for Error { - fn hash<_H: ::std::hash::Hasher>(&self, _state: &mut _H) { - match self { - Error::CollectionOfErrors { list, message } => { - list.hash(_state); - message.hash(_state) - } - Error::Opaque { obj } => obj.hash(_state), - } - } - } - - impl ::std::default::Default for Error { - fn default() -> Error { - Error::CollectionOfErrors { - list: ::std::default::Default::default(), - message: ::std::default::Default::default(), - } - } - } - - impl ::std::convert::AsRef for &Error { - fn as_ref(&self) -> Self { - self - } - } - - pub type OpaqueError = - ::std::rc::Rc; -} -pub mod r#_SimpleIntegerImpl_Compile { - pub struct _default {} - - impl _default { - pub fn _allocate_rcmut() -> ::dafny_runtime::Object { - ::dafny_runtime::allocate_rcmut::() - } - pub fn GetInteger( - config: &::std::rc::Rc, - input: &::std::rc::Rc< - super::r#_simple_dtypes_dinteger_dinternaldafny_dtypes::GetIntegerInput, - >, - ) -> ::std::rc::Rc< - super::r#_Wrappers_Compile::Result< - ::std::rc::Rc< - super::r#_simple_dtypes_dinteger_dinternaldafny_dtypes::GetIntegerOutput, - >, - ::std::rc::Rc, - >, - > { - let mut output = ::dafny_runtime::MaybePlacebo::<::std::rc::Rc, ::std::rc::Rc>>>::new(); - if !matches!( - input.value().as_ref(), - super::r#_Wrappers_Compile::Option::Some { .. } - ) { - panic!("Halt") - }; - - let mut res: ::std::rc::Rc = ::std::rc::Rc::new(super::r#_simple_dtypes_dinteger_dinternaldafny_dtypes::GetIntegerOutput::GetIntegerOutput { - value: input.value().clone() - }); - res = ::std::rc::Rc::new(super::r#_simple_dtypes_dinteger_dinternaldafny_dtypes::GetIntegerOutput::GetIntegerOutput { - value: input.value().clone() - }); - output = ::dafny_runtime::MaybePlacebo::from(::std::rc::Rc::new( - super::r#_Wrappers_Compile::Result::< - ::std::rc::Rc< - super::r#_simple_dtypes_dinteger_dinternaldafny_dtypes::GetIntegerOutput, - >, - ::std::rc::Rc, - >::Success { - value: res.clone(), - }, - )); - return output.read(); - return output.read(); - } - pub fn GetIntegerKnownValueTest( - config: &::std::rc::Rc, - input: &::std::rc::Rc< - super::r#_simple_dtypes_dinteger_dinternaldafny_dtypes::GetIntegerInput, - >, - ) -> ::std::rc::Rc< - super::r#_Wrappers_Compile::Result< - ::std::rc::Rc< - super::r#_simple_dtypes_dinteger_dinternaldafny_dtypes::GetIntegerOutput, - >, - ::std::rc::Rc, - >, - > { - let mut output = ::dafny_runtime::MaybePlacebo::<::std::rc::Rc, ::std::rc::Rc>>>::new(); - if !matches!( - input.value().as_ref(), - super::r#_Wrappers_Compile::Option::Some { .. } - ) { - panic!("Halt") - }; - let mut res: ::std::rc::Rc = ::std::rc::Rc::new(super::r#_simple_dtypes_dinteger_dinternaldafny_dtypes::GetIntegerOutput::GetIntegerOutput { - value: input.value().clone() - }); - res = ::std::rc::Rc::new(super::r#_simple_dtypes_dinteger_dinternaldafny_dtypes::GetIntegerOutput::GetIntegerOutput { - value: input.value().clone() - }); - output = ::dafny_runtime::MaybePlacebo::from(::std::rc::Rc::new( - super::r#_Wrappers_Compile::Result::< - ::std::rc::Rc< - super::r#_simple_dtypes_dinteger_dinternaldafny_dtypes::GetIntegerOutput, - >, - ::std::rc::Rc, - >::Success { - value: res.clone(), - }, - )); - return output.read(); - return output.read(); - } - } - - #[derive(PartialEq, Clone)] - pub enum Config { - Config {}, - } - - impl Config {} - - impl ::std::fmt::Debug for Config { - fn fmt(&self, f: &mut ::std::fmt::Formatter) -> std::fmt::Result { - ::dafny_runtime::DafnyPrint::fmt_print(self, f, true) - } - } - - impl ::dafny_runtime::DafnyPrint for Config { - fn fmt_print( - &self, - _formatter: &mut ::std::fmt::Formatter, - _in_seq: bool, - ) -> std::fmt::Result { - match self { - Config::Config {} => { - write!(_formatter, "r#_SimpleIntegerImpl_Compile.Config.Config")?; - Ok(()) - } - } - } - } - - impl Eq for Config {} - - impl ::std::hash::Hash for Config { - fn hash<_H: ::std::hash::Hasher>(&self, _state: &mut _H) { - match self { - Config::Config {} => {} - } - } - } - - impl ::std::default::Default for Config { - fn default() -> Config { - Config::Config {} - } - } - - impl ::std::convert::AsRef for &Config { - fn as_ref(&self) -> Self { - self - } - } -} -pub mod r#_simple_dtypes_dinteger_dinternaldafny { - pub struct _default {} - - impl _default { - pub fn _allocate_rcmut() -> ::dafny_runtime::Object { - ::dafny_runtime::allocate_rcmut::() - } - pub fn DefaultSimpleIntegerConfig() -> ::std::rc::Rc< - super::r#_simple_dtypes_dinteger_dinternaldafny_dtypes::SimpleIntegerConfig, - > { - ::std::rc::Rc::new(super::r#_simple_dtypes_dinteger_dinternaldafny_dtypes::SimpleIntegerConfig::SimpleIntegerConfig {}) - } - pub fn SimpleInteger( - config: &::std::rc::Rc< - super::r#_simple_dtypes_dinteger_dinternaldafny_dtypes::SimpleIntegerConfig, - >, - ) -> ::std::rc::Rc< - super::r#_Wrappers_Compile::Result< - ::dafny_runtime::Object< - super::r#_simple_dtypes_dinteger_dinternaldafny::SimpleIntegerClient, - >, - ::std::rc::Rc, - >, - > { - let mut res = ::dafny_runtime::MaybePlacebo::< - ::std::rc::Rc< - super::r#_Wrappers_Compile::Result< - ::dafny_runtime::Object< - super::r#_simple_dtypes_dinteger_dinternaldafny::SimpleIntegerClient, - >, - ::std::rc::Rc< - super::r#_simple_dtypes_dinteger_dinternaldafny_dtypes::Error, - >, - >, - >, - >::new(); - let mut client = ::dafny_runtime::MaybePlacebo::< - ::dafny_runtime::Object< - super::r#_simple_dtypes_dinteger_dinternaldafny::SimpleIntegerClient, - >, - >::new(); - let mut _nw0: ::dafny_runtime::Object = super::r#_simple_dtypes_dinteger_dinternaldafny::SimpleIntegerClient::_allocate_rcmut(); - super::r#_simple_dtypes_dinteger_dinternaldafny::SimpleIntegerClient::_ctor( - &_nw0, - &::std::rc::Rc::new(super::r#_SimpleIntegerImpl_Compile::Config::Config {}), - ); - client = ::dafny_runtime::MaybePlacebo::from(_nw0.clone()); - res = ::dafny_runtime::MaybePlacebo::from(::std::rc::Rc::new( - super::r#_Wrappers_Compile::Result::< - ::dafny_runtime::Object< - super::r#_simple_dtypes_dinteger_dinternaldafny::SimpleIntegerClient, - >, - ::std::rc::Rc, - >::Success { - value: client.read(), - }, - )); - return res.read(); - return res.read(); - } - pub fn CreateSuccessOfClient(client: &::dafny_runtime::Object) -> ::std::rc::Rc, ::std::rc::Rc>>{ - ::std::rc::Rc::new(super::r#_Wrappers_Compile::Result::<::dafny_runtime::Object, ::std::rc::Rc>::Success { - value: client.clone() - }) - } - pub fn CreateFailureOfError(error: &::std::rc::Rc) -> ::std::rc::Rc, ::std::rc::Rc>>{ - ::std::rc::Rc::new(super::r#_Wrappers_Compile::Result::<::dafny_runtime::Object, ::std::rc::Rc>::Failure { - error: error.clone() - }) - } - } - - pub struct SimpleIntegerClient { - pub r#__i_config: ::std::rc::Rc, - } - - impl SimpleIntegerClient { - pub fn _allocate_rcmut() -> ::dafny_runtime::Object { - ::dafny_runtime::allocate_rcmut::() - } - pub fn _ctor( - this: &::dafny_runtime::Object, - config: &::std::rc::Rc, - ) -> () { - let mut _set__i_config: bool = false; - ::dafny_runtime::update_field_uninit_rcmut!( - this.clone(), - r#__i_config, - _set__i_config, - config.clone() - ); - return (); - } - pub fn config(&self) -> ::std::rc::Rc { - self.r#__i_config.clone() - } - } - - impl super::r#_simple_dtypes_dinteger_dinternaldafny_dtypes::ISimpleTypesIntegerClient - for super::r#_simple_dtypes_dinteger_dinternaldafny::SimpleIntegerClient - { - fn GetInteger( - &mut self, - input: &::std::rc::Rc< - super::r#_simple_dtypes_dinteger_dinternaldafny_dtypes::GetIntegerInput, - >, - ) -> ::std::rc::Rc< - super::r#_Wrappers_Compile::Result< - ::std::rc::Rc< - super::r#_simple_dtypes_dinteger_dinternaldafny_dtypes::GetIntegerOutput, - >, - ::std::rc::Rc, - >, - > { - let mut output = ::dafny_runtime::MaybePlacebo::<::std::rc::Rc, ::std::rc::Rc>>>::new(); - let mut _out0 = ::dafny_runtime::MaybePlacebo::<::std::rc::Rc, ::std::rc::Rc>>>::new(); - _out0 = ::dafny_runtime::MaybePlacebo::from( - super::r#_SimpleIntegerImpl_Compile::_default::GetInteger(&self.config(), input), - ); - output = ::dafny_runtime::MaybePlacebo::from(_out0.read()); - return output.read(); - } - fn GetIntegerKnownValueTest( - &mut self, - input: &::std::rc::Rc< - super::r#_simple_dtypes_dinteger_dinternaldafny_dtypes::GetIntegerInput, - >, - ) -> ::std::rc::Rc< - super::r#_Wrappers_Compile::Result< - ::std::rc::Rc< - super::r#_simple_dtypes_dinteger_dinternaldafny_dtypes::GetIntegerOutput, - >, - ::std::rc::Rc, - >, - > { - let mut output = ::dafny_runtime::MaybePlacebo::<::std::rc::Rc, ::std::rc::Rc>>>::new(); - let mut _out1 = ::dafny_runtime::MaybePlacebo::<::std::rc::Rc, ::std::rc::Rc>>>::new(); - _out1 = ::dafny_runtime::MaybePlacebo::from( - super::r#_SimpleIntegerImpl_Compile::_default::GetIntegerKnownValueTest( - &self.config(), - input, - ), - ); - output = ::dafny_runtime::MaybePlacebo::from(_out1.read()); - return output.read(); - } - } -} -pub mod _module {} diff --git a/TestModels/SimpleTypes/SimpleLong/runtimes/rust/dafny_impl/src/implementation_from_dafny.rs b/TestModels/SimpleTypes/SimpleLong/runtimes/rust/dafny_impl/src/implementation_from_dafny.rs deleted file mode 100644 index 0d923e39ca..0000000000 --- a/TestModels/SimpleTypes/SimpleLong/runtimes/rust/dafny_impl/src/implementation_from_dafny.rs +++ /dev/null @@ -1,761 +0,0 @@ -#![allow(warnings, unconditional_panic)] -#![allow(nonstandard_style)] -pub use dafny_standard_library::implementation_from_dafny::*; - -pub mod r#_simple_dtypes_dsmithylong_dinternaldafny_dtypes { - #[derive(PartialEq, Clone)] - pub enum DafnyCallEvent { - DafnyCallEvent { input: I, output: O }, - _PhantomVariant(::std::marker::PhantomData, ::std::marker::PhantomData), - } - - impl DafnyCallEvent { - pub fn input(&self) -> &I { - match self { - DafnyCallEvent::DafnyCallEvent { input, output } => input, - DafnyCallEvent::_PhantomVariant(..) => panic!(), - } - } - pub fn output(&self) -> &O { - match self { - DafnyCallEvent::DafnyCallEvent { input, output } => output, - DafnyCallEvent::_PhantomVariant(..) => panic!(), - } - } - } - - impl ::std::fmt::Debug - for DafnyCallEvent - { - fn fmt(&self, f: &mut ::std::fmt::Formatter) -> std::fmt::Result { - ::dafny_runtime::DafnyPrint::fmt_print(self, f, true) - } - } - - impl ::dafny_runtime::DafnyPrint - for DafnyCallEvent - { - fn fmt_print( - &self, - _formatter: &mut ::std::fmt::Formatter, - _in_seq: bool, - ) -> std::fmt::Result { - match self { - DafnyCallEvent::DafnyCallEvent { input, output } => { - write!(_formatter, "r#_simple_dtypes_dsmithylong_dinternaldafny_dtypes.DafnyCallEvent.DafnyCallEvent(")?; - ::dafny_runtime::DafnyPrint::fmt_print(input, _formatter, false)?; - write!(_formatter, ", ")?; - ::dafny_runtime::DafnyPrint::fmt_print(output, _formatter, false)?; - write!(_formatter, ")")?; - Ok(()) - } - DafnyCallEvent::_PhantomVariant(..) => { - panic!() - } - } - } - } - - impl Eq - for DafnyCallEvent - { - } - - impl< - I: ::dafny_runtime::DafnyType + ::std::hash::Hash, - O: ::dafny_runtime::DafnyType + ::std::hash::Hash, - > ::std::hash::Hash for DafnyCallEvent - { - fn hash<_H: ::std::hash::Hasher>(&self, _state: &mut _H) { - match self { - DafnyCallEvent::DafnyCallEvent { input, output } => { - input.hash(_state); - output.hash(_state) - } - DafnyCallEvent::_PhantomVariant(..) => { - panic!() - } - } - } - } - - impl< - I: ::dafny_runtime::DafnyType + ::std::default::Default, - O: ::dafny_runtime::DafnyType + ::std::default::Default, - > ::std::default::Default for DafnyCallEvent - { - fn default() -> DafnyCallEvent { - DafnyCallEvent::DafnyCallEvent { - input: ::std::default::Default::default(), - output: ::std::default::Default::default(), - } - } - } - - impl - ::std::convert::AsRef> for &DafnyCallEvent - { - fn as_ref(&self) -> Self { - self - } - } - - #[derive(PartialEq, Clone)] - pub enum GetLongInput { - GetLongInput { - value: ::std::rc::Rc>, - }, - } - - impl GetLongInput { - pub fn value(&self) -> &::std::rc::Rc> { - match self { - GetLongInput::GetLongInput { value } => value, - } - } - } - - impl ::std::fmt::Debug for GetLongInput { - fn fmt(&self, f: &mut ::std::fmt::Formatter) -> std::fmt::Result { - ::dafny_runtime::DafnyPrint::fmt_print(self, f, true) - } - } - - impl ::dafny_runtime::DafnyPrint for GetLongInput { - fn fmt_print( - &self, - _formatter: &mut ::std::fmt::Formatter, - _in_seq: bool, - ) -> std::fmt::Result { - match self { - GetLongInput::GetLongInput { value } => { - write!(_formatter, "r#_simple_dtypes_dsmithylong_dinternaldafny_dtypes.GetLongInput.GetLongInput(")?; - ::dafny_runtime::DafnyPrint::fmt_print(value, _formatter, false)?; - write!(_formatter, ")")?; - Ok(()) - } - } - } - } - - impl Eq for GetLongInput {} - - impl ::std::hash::Hash for GetLongInput { - fn hash<_H: ::std::hash::Hasher>(&self, _state: &mut _H) { - match self { - GetLongInput::GetLongInput { value } => value.hash(_state), - } - } - } - - impl ::std::default::Default for GetLongInput { - fn default() -> GetLongInput { - GetLongInput::GetLongInput { - value: ::std::default::Default::default(), - } - } - } - - impl ::std::convert::AsRef for &GetLongInput { - fn as_ref(&self) -> Self { - self - } - } - - #[derive(PartialEq, Clone)] - pub enum GetLongOutput { - GetLongOutput { - value: ::std::rc::Rc>, - }, - } - - impl GetLongOutput { - pub fn value(&self) -> &::std::rc::Rc> { - match self { - GetLongOutput::GetLongOutput { value } => value, - } - } - } - - impl ::std::fmt::Debug for GetLongOutput { - fn fmt(&self, f: &mut ::std::fmt::Formatter) -> std::fmt::Result { - ::dafny_runtime::DafnyPrint::fmt_print(self, f, true) - } - } - - impl ::dafny_runtime::DafnyPrint for GetLongOutput { - fn fmt_print( - &self, - _formatter: &mut ::std::fmt::Formatter, - _in_seq: bool, - ) -> std::fmt::Result { - match self { - GetLongOutput::GetLongOutput { value } => { - write!(_formatter, "r#_simple_dtypes_dsmithylong_dinternaldafny_dtypes.GetLongOutput.GetLongOutput(")?; - ::dafny_runtime::DafnyPrint::fmt_print(value, _formatter, false)?; - write!(_formatter, ")")?; - Ok(()) - } - } - } - } - - impl Eq for GetLongOutput {} - - impl ::std::hash::Hash for GetLongOutput { - fn hash<_H: ::std::hash::Hasher>(&self, _state: &mut _H) { - match self { - GetLongOutput::GetLongOutput { value } => value.hash(_state), - } - } - } - - impl ::std::default::Default for GetLongOutput { - fn default() -> GetLongOutput { - GetLongOutput::GetLongOutput { - value: ::std::default::Default::default(), - } - } - } - - impl ::std::convert::AsRef for &GetLongOutput { - fn as_ref(&self) -> Self { - self - } - } - - #[derive(PartialEq, Clone)] - pub enum SimpleLongConfig { - SimpleLongConfig {}, - } - - impl SimpleLongConfig {} - - impl ::std::fmt::Debug for SimpleLongConfig { - fn fmt(&self, f: &mut ::std::fmt::Formatter) -> std::fmt::Result { - ::dafny_runtime::DafnyPrint::fmt_print(self, f, true) - } - } - - impl ::dafny_runtime::DafnyPrint for SimpleLongConfig { - fn fmt_print( - &self, - _formatter: &mut ::std::fmt::Formatter, - _in_seq: bool, - ) -> std::fmt::Result { - match self { - SimpleLongConfig::SimpleLongConfig {} => { - write!(_formatter, "r#_simple_dtypes_dsmithylong_dinternaldafny_dtypes.SimpleLongConfig.SimpleLongConfig")?; - Ok(()) - } - } - } - } - - impl Eq for SimpleLongConfig {} - - impl ::std::hash::Hash for SimpleLongConfig { - fn hash<_H: ::std::hash::Hasher>(&self, _state: &mut _H) { - match self { - SimpleLongConfig::SimpleLongConfig {} => {} - } - } - } - - impl ::std::default::Default for SimpleLongConfig { - fn default() -> SimpleLongConfig { - SimpleLongConfig::SimpleLongConfig {} - } - } - - impl ::std::convert::AsRef for &SimpleLongConfig { - fn as_ref(&self) -> Self { - self - } - } - - pub struct ISimpleTypesLongClientCallHistory {} - - impl ISimpleTypesLongClientCallHistory { - pub fn _allocate_rcmut() -> ::dafny_runtime::Object { - ::dafny_runtime::allocate_rcmut::() - } - } - - pub trait ISimpleTypesLongClient { - fn GetLong( - &mut self, - input: &::std::rc::Rc< - super::r#_simple_dtypes_dsmithylong_dinternaldafny_dtypes::GetLongInput, - >, - ) -> ::std::rc::Rc< - super::r#_Wrappers_Compile::Result< - ::std::rc::Rc< - super::r#_simple_dtypes_dsmithylong_dinternaldafny_dtypes::GetLongOutput, - >, - ::std::rc::Rc, - >, - >; - fn GetLongKnownValueTest( - &mut self, - input: &::std::rc::Rc< - super::r#_simple_dtypes_dsmithylong_dinternaldafny_dtypes::GetLongInput, - >, - ) -> ::std::rc::Rc< - super::r#_Wrappers_Compile::Result< - ::std::rc::Rc< - super::r#_simple_dtypes_dsmithylong_dinternaldafny_dtypes::GetLongOutput, - >, - ::std::rc::Rc, - >, - >; - } - - #[derive(PartialEq, Clone)] - pub enum Error { - CollectionOfErrors { - list: ::dafny_runtime::Sequence< - ::std::rc::Rc, - >, - message: ::dafny_runtime::Sequence<::dafny_runtime::DafnyCharUTF16>, - }, - Opaque { - obj: ::dafny_runtime::Object, - }, - } - - impl Error { - pub fn list( - &self, - ) -> &::dafny_runtime::Sequence< - ::std::rc::Rc, - > { - match self { - Error::CollectionOfErrors { list, message } => list, - Error::Opaque { obj } => panic!("field does not exist on this variant"), - } - } - pub fn message(&self) -> &::dafny_runtime::Sequence<::dafny_runtime::DafnyCharUTF16> { - match self { - Error::CollectionOfErrors { list, message } => message, - Error::Opaque { obj } => panic!("field does not exist on this variant"), - } - } - pub fn obj(&self) -> &::dafny_runtime::Object { - match self { - Error::CollectionOfErrors { list, message } => { - panic!("field does not exist on this variant") - } - Error::Opaque { obj } => obj, - } - } - } - - impl ::std::fmt::Debug for Error { - fn fmt(&self, f: &mut ::std::fmt::Formatter) -> std::fmt::Result { - ::dafny_runtime::DafnyPrint::fmt_print(self, f, true) - } - } - - impl ::dafny_runtime::DafnyPrint for Error { - fn fmt_print( - &self, - _formatter: &mut ::std::fmt::Formatter, - _in_seq: bool, - ) -> std::fmt::Result { - match self { - Error::CollectionOfErrors { list, message } => { - write!(_formatter, "r#_simple_dtypes_dsmithylong_dinternaldafny_dtypes.Error.CollectionOfErrors(")?; - ::dafny_runtime::DafnyPrint::fmt_print(list, _formatter, false)?; - write!(_formatter, ", ")?; - ::dafny_runtime::DafnyPrint::fmt_print(message, _formatter, false)?; - write!(_formatter, ")")?; - Ok(()) - } - Error::Opaque { obj } => { - write!( - _formatter, - "r#_simple_dtypes_dsmithylong_dinternaldafny_dtypes.Error.Opaque(" - )?; - ::dafny_runtime::DafnyPrint::fmt_print(obj, _formatter, false)?; - write!(_formatter, ")")?; - Ok(()) - } - } - } - } - - impl Eq for Error {} - - impl ::std::hash::Hash for Error { - fn hash<_H: ::std::hash::Hasher>(&self, _state: &mut _H) { - match self { - Error::CollectionOfErrors { list, message } => { - list.hash(_state); - message.hash(_state) - } - Error::Opaque { obj } => obj.hash(_state), - } - } - } - - impl ::std::default::Default for Error { - fn default() -> Error { - Error::CollectionOfErrors { - list: ::std::default::Default::default(), - message: ::std::default::Default::default(), - } - } - } - - impl ::std::convert::AsRef for &Error { - fn as_ref(&self) -> Self { - self - } - } - - pub type OpaqueError = - ::std::rc::Rc; -} -pub mod r#_SimpleLongImpl_Compile { - pub struct _default {} - - impl _default { - pub fn _allocate_rcmut() -> ::dafny_runtime::Object { - ::dafny_runtime::allocate_rcmut::() - } - pub fn GetLong( - config: &::std::rc::Rc, - input: &::std::rc::Rc< - super::r#_simple_dtypes_dsmithylong_dinternaldafny_dtypes::GetLongInput, - >, - ) -> ::std::rc::Rc< - super::r#_Wrappers_Compile::Result< - ::std::rc::Rc< - super::r#_simple_dtypes_dsmithylong_dinternaldafny_dtypes::GetLongOutput, - >, - ::std::rc::Rc, - >, - > { - let mut output = ::dafny_runtime::MaybePlacebo::<::std::rc::Rc, ::std::rc::Rc>>>::new(); - if !matches!( - input.value().as_ref(), - super::r#_Wrappers_Compile::Option::Some { .. } - ) { - panic!("Halt") - }; - super::r#_SimpleLongImpl_Compile::_default::ValidateLongType(*input.value().value()); - let mut res: ::std::rc::Rc = ::std::rc::Rc::new(super::r#_simple_dtypes_dsmithylong_dinternaldafny_dtypes::GetLongOutput::GetLongOutput { - value: input.value().clone() - }); - res = ::std::rc::Rc::new(super::r#_simple_dtypes_dsmithylong_dinternaldafny_dtypes::GetLongOutput::GetLongOutput { - value: input.value().clone() - }); - if !matches!( - res.value().as_ref(), - super::r#_Wrappers_Compile::Option::Some { .. } - ) { - panic!("Halt") - }; - super::r#_SimpleLongImpl_Compile::_default::ValidateLongType(*res.value().value()); - output = ::dafny_runtime::MaybePlacebo::from(::std::rc::Rc::new( - super::r#_Wrappers_Compile::Result::< - ::std::rc::Rc< - super::r#_simple_dtypes_dsmithylong_dinternaldafny_dtypes::GetLongOutput, - >, - ::std::rc::Rc, - >::Success { - value: res.clone(), - }, - )); - return output.read(); - return output.read(); - } - pub fn GetLongKnownValueTest( - config: &::std::rc::Rc, - input: &::std::rc::Rc< - super::r#_simple_dtypes_dsmithylong_dinternaldafny_dtypes::GetLongInput, - >, - ) -> ::std::rc::Rc< - super::r#_Wrappers_Compile::Result< - ::std::rc::Rc< - super::r#_simple_dtypes_dsmithylong_dinternaldafny_dtypes::GetLongOutput, - >, - ::std::rc::Rc, - >, - > { - let mut output = ::dafny_runtime::MaybePlacebo::<::std::rc::Rc, ::std::rc::Rc>>>::new(); - if !matches!( - input.value().as_ref(), - super::r#_Wrappers_Compile::Option::Some { .. } - ) { - panic!("Halt") - }; - super::r#_SimpleLongImpl_Compile::_default::ValidateLongType(*input.value().value()); - if !(input.value().value() == &33i64) { - panic!("Halt") - }; - let mut res: ::std::rc::Rc = ::std::rc::Rc::new(super::r#_simple_dtypes_dsmithylong_dinternaldafny_dtypes::GetLongOutput::GetLongOutput { - value: input.value().clone() - }); - res = ::std::rc::Rc::new(super::r#_simple_dtypes_dsmithylong_dinternaldafny_dtypes::GetLongOutput::GetLongOutput { - value: input.value().clone() - }); - if !matches!( - res.value().as_ref(), - super::r#_Wrappers_Compile::Option::Some { .. } - ) { - panic!("Halt") - }; - super::r#_SimpleLongImpl_Compile::_default::ValidateLongType(*res.value().value()); - output = ::dafny_runtime::MaybePlacebo::from(::std::rc::Rc::new( - super::r#_Wrappers_Compile::Result::< - ::std::rc::Rc< - super::r#_simple_dtypes_dsmithylong_dinternaldafny_dtypes::GetLongOutput, - >, - ::std::rc::Rc, - >::Success { - value: res.clone(), - }, - )); - return output.read(); - return output.read(); - } - pub fn ValidateLongType(input: i64) -> () { - return; - if input >= 0 { - if input - >= ::dafny_runtime::truncate!( - super::r#_StandardLibrary_Compile_dUInt_Compile::_default::INT64_MAX_LIMIT( - ), - i64 - ) - { - return (); - }; - if !(0 < input - + ::dafny_runtime::truncate!( - super::r#_StandardLibrary_Compile_dUInt_Compile::_default::INT64_MAX_LIMIT( - ), - i64 - )) - { - panic!("Halt") - } - } else { - if input < 0 { - if input < 0 - ::dafny_runtime::truncate!(super::r#_StandardLibrary_Compile_dUInt_Compile::_default::INT64_MAX_LIMIT(), i64) { - return (); - }; - if !(input + (0 - ::dafny_runtime::truncate!(super::r#_StandardLibrary_Compile_dUInt_Compile::_default::INT64_MAX_LIMIT(), i64)) < 0) { - panic!("Halt") - } - } else { - if !false { - panic!("Halt") - } - } - }; - return (); - } - } - - #[derive(PartialEq, Clone)] - pub enum Config { - Config {}, - } - - impl Config {} - - impl ::std::fmt::Debug for Config { - fn fmt(&self, f: &mut ::std::fmt::Formatter) -> std::fmt::Result { - ::dafny_runtime::DafnyPrint::fmt_print(self, f, true) - } - } - - impl ::dafny_runtime::DafnyPrint for Config { - fn fmt_print( - &self, - _formatter: &mut ::std::fmt::Formatter, - _in_seq: bool, - ) -> std::fmt::Result { - match self { - Config::Config {} => { - write!(_formatter, "r#_SimpleLongImpl_Compile.Config.Config")?; - Ok(()) - } - } - } - } - - impl Eq for Config {} - - impl ::std::hash::Hash for Config { - fn hash<_H: ::std::hash::Hasher>(&self, _state: &mut _H) { - match self { - Config::Config {} => {} - } - } - } - - impl ::std::default::Default for Config { - fn default() -> Config { - Config::Config {} - } - } - - impl ::std::convert::AsRef for &Config { - fn as_ref(&self) -> Self { - self - } - } -} -pub mod r#_simple_dtypes_dsmithylong_dinternaldafny { - pub struct _default {} - - impl _default { - pub fn _allocate_rcmut() -> ::dafny_runtime::Object { - ::dafny_runtime::allocate_rcmut::() - } - pub fn DefaultSimpleLongConfig() -> ::std::rc::Rc< - super::r#_simple_dtypes_dsmithylong_dinternaldafny_dtypes::SimpleLongConfig, - > { - ::std::rc::Rc::new(super::r#_simple_dtypes_dsmithylong_dinternaldafny_dtypes::SimpleLongConfig::SimpleLongConfig {}) - } - pub fn SimpleLong( - config: &::std::rc::Rc< - super::r#_simple_dtypes_dsmithylong_dinternaldafny_dtypes::SimpleLongConfig, - >, - ) -> ::std::rc::Rc< - super::r#_Wrappers_Compile::Result< - ::dafny_runtime::Object< - super::r#_simple_dtypes_dsmithylong_dinternaldafny::SimpleLongClient, - >, - ::std::rc::Rc, - >, - > { - let mut res = ::dafny_runtime::MaybePlacebo::< - ::std::rc::Rc< - super::r#_Wrappers_Compile::Result< - ::dafny_runtime::Object< - super::r#_simple_dtypes_dsmithylong_dinternaldafny::SimpleLongClient, - >, - ::std::rc::Rc< - super::r#_simple_dtypes_dsmithylong_dinternaldafny_dtypes::Error, - >, - >, - >, - >::new(); - let mut client = ::dafny_runtime::MaybePlacebo::< - ::dafny_runtime::Object< - super::r#_simple_dtypes_dsmithylong_dinternaldafny::SimpleLongClient, - >, - >::new(); - let mut _nw0: ::dafny_runtime::Object = super::r#_simple_dtypes_dsmithylong_dinternaldafny::SimpleLongClient::_allocate_rcmut(); - super::r#_simple_dtypes_dsmithylong_dinternaldafny::SimpleLongClient::_ctor( - &_nw0, - &::std::rc::Rc::new(super::r#_SimpleLongImpl_Compile::Config::Config {}), - ); - client = ::dafny_runtime::MaybePlacebo::from(_nw0.clone()); - res = ::dafny_runtime::MaybePlacebo::from(::std::rc::Rc::new( - super::r#_Wrappers_Compile::Result::< - ::dafny_runtime::Object< - super::r#_simple_dtypes_dsmithylong_dinternaldafny::SimpleLongClient, - >, - ::std::rc::Rc, - >::Success { - value: client.read(), - }, - )); - return res.read(); - return res.read(); - } - pub fn CreateSuccessOfClient(client: &::dafny_runtime::Object) -> ::std::rc::Rc, ::std::rc::Rc>>{ - ::std::rc::Rc::new(super::r#_Wrappers_Compile::Result::<::dafny_runtime::Object, ::std::rc::Rc>::Success { - value: client.clone() - }) - } - pub fn CreateFailureOfError(error: &::std::rc::Rc) -> ::std::rc::Rc, ::std::rc::Rc>>{ - ::std::rc::Rc::new(super::r#_Wrappers_Compile::Result::<::dafny_runtime::Object, ::std::rc::Rc>::Failure { - error: error.clone() - }) - } - } - - pub struct SimpleLongClient { - pub r#__i_config: ::std::rc::Rc, - } - - impl SimpleLongClient { - pub fn _allocate_rcmut() -> ::dafny_runtime::Object { - ::dafny_runtime::allocate_rcmut::() - } - pub fn _ctor( - this: &::dafny_runtime::Object, - config: &::std::rc::Rc, - ) -> () { - let mut _set__i_config: bool = false; - ::dafny_runtime::update_field_uninit_rcmut!( - this.clone(), - r#__i_config, - _set__i_config, - config.clone() - ); - return (); - } - pub fn config(&self) -> ::std::rc::Rc { - self.r#__i_config.clone() - } - } - - impl super::r#_simple_dtypes_dsmithylong_dinternaldafny_dtypes::ISimpleTypesLongClient - for super::r#_simple_dtypes_dsmithylong_dinternaldafny::SimpleLongClient - { - fn GetLong( - &mut self, - input: &::std::rc::Rc< - super::r#_simple_dtypes_dsmithylong_dinternaldafny_dtypes::GetLongInput, - >, - ) -> ::std::rc::Rc< - super::r#_Wrappers_Compile::Result< - ::std::rc::Rc< - super::r#_simple_dtypes_dsmithylong_dinternaldafny_dtypes::GetLongOutput, - >, - ::std::rc::Rc, - >, - > { - let mut output = ::dafny_runtime::MaybePlacebo::<::std::rc::Rc, ::std::rc::Rc>>>::new(); - let mut _out0 = ::dafny_runtime::MaybePlacebo::<::std::rc::Rc, ::std::rc::Rc>>>::new(); - _out0 = ::dafny_runtime::MaybePlacebo::from( - super::r#_SimpleLongImpl_Compile::_default::GetLong(&self.config(), input), - ); - output = ::dafny_runtime::MaybePlacebo::from(_out0.read()); - return output.read(); - } - fn GetLongKnownValueTest( - &mut self, - input: &::std::rc::Rc< - super::r#_simple_dtypes_dsmithylong_dinternaldafny_dtypes::GetLongInput, - >, - ) -> ::std::rc::Rc< - super::r#_Wrappers_Compile::Result< - ::std::rc::Rc< - super::r#_simple_dtypes_dsmithylong_dinternaldafny_dtypes::GetLongOutput, - >, - ::std::rc::Rc, - >, - > { - let mut output = ::dafny_runtime::MaybePlacebo::<::std::rc::Rc, ::std::rc::Rc>>>::new(); - let mut _out1 = ::dafny_runtime::MaybePlacebo::<::std::rc::Rc, ::std::rc::Rc>>>::new(); - _out1 = ::dafny_runtime::MaybePlacebo::from( - super::r#_SimpleLongImpl_Compile::_default::GetLongKnownValueTest( - &self.config(), - input, - ), - ); - output = ::dafny_runtime::MaybePlacebo::from(_out1.read()); - return output.read(); - } - } -} -pub mod _module {} diff --git a/TestModels/SimpleTypes/SimpleString/runtimes/rust/dafny_impl/src/implementation_from_dafny.rs b/TestModels/SimpleTypes/SimpleString/runtimes/rust/dafny_impl/src/implementation_from_dafny.rs deleted file mode 100644 index a0d75180dd..0000000000 --- a/TestModels/SimpleTypes/SimpleString/runtimes/rust/dafny_impl/src/implementation_from_dafny.rs +++ /dev/null @@ -1,767 +0,0 @@ -#![allow(warnings, unconditional_panic)] -#![allow(nonstandard_style)] -pub use dafny_standard_library::implementation_from_dafny::*; - -pub mod r#_simple_dtypes_dsmithystring_dinternaldafny_dtypes { - #[derive(PartialEq, Clone)] - pub enum DafnyCallEvent { - DafnyCallEvent { input: I, output: O }, - _PhantomVariant(::std::marker::PhantomData, ::std::marker::PhantomData), - } - - impl DafnyCallEvent { - pub fn input(&self) -> &I { - match self { - DafnyCallEvent::DafnyCallEvent { input, output } => input, - DafnyCallEvent::_PhantomVariant(..) => panic!(), - } - } - pub fn output(&self) -> &O { - match self { - DafnyCallEvent::DafnyCallEvent { input, output } => output, - DafnyCallEvent::_PhantomVariant(..) => panic!(), - } - } - } - - impl ::std::fmt::Debug - for DafnyCallEvent - { - fn fmt(&self, f: &mut ::std::fmt::Formatter) -> std::fmt::Result { - ::dafny_runtime::DafnyPrint::fmt_print(self, f, true) - } - } - - impl ::dafny_runtime::DafnyPrint - for DafnyCallEvent - { - fn fmt_print( - &self, - _formatter: &mut ::std::fmt::Formatter, - _in_seq: bool, - ) -> std::fmt::Result { - match self { - DafnyCallEvent::DafnyCallEvent { input, output } => { - write!(_formatter, "r#_simple_dtypes_dsmithystring_dinternaldafny_dtypes.DafnyCallEvent.DafnyCallEvent(")?; - ::dafny_runtime::DafnyPrint::fmt_print(input, _formatter, false)?; - write!(_formatter, ", ")?; - ::dafny_runtime::DafnyPrint::fmt_print(output, _formatter, false)?; - write!(_formatter, ")")?; - Ok(()) - } - DafnyCallEvent::_PhantomVariant(..) => { - panic!() - } - } - } - } - - impl Eq - for DafnyCallEvent - { - } - - impl< - I: ::dafny_runtime::DafnyType + ::std::hash::Hash, - O: ::dafny_runtime::DafnyType + ::std::hash::Hash, - > ::std::hash::Hash for DafnyCallEvent - { - fn hash<_H: ::std::hash::Hasher>(&self, _state: &mut _H) { - match self { - DafnyCallEvent::DafnyCallEvent { input, output } => { - input.hash(_state); - output.hash(_state) - } - DafnyCallEvent::_PhantomVariant(..) => { - panic!() - } - } - } - } - - impl< - I: ::dafny_runtime::DafnyType + ::std::default::Default, - O: ::dafny_runtime::DafnyType + ::std::default::Default, - > ::std::default::Default for DafnyCallEvent - { - fn default() -> DafnyCallEvent { - DafnyCallEvent::DafnyCallEvent { - input: ::std::default::Default::default(), - output: ::std::default::Default::default(), - } - } - } - - impl - ::std::convert::AsRef> for &DafnyCallEvent - { - fn as_ref(&self) -> Self { - self - } - } - - #[derive(PartialEq, Clone)] - pub enum GetStringInput { - GetStringInput { - value: ::std::rc::Rc< - super::r#_Wrappers_Compile::Option< - ::dafny_runtime::Sequence<::dafny_runtime::DafnyCharUTF16>, - >, - >, - }, - } - - impl GetStringInput { - pub fn value( - &self, - ) -> &::std::rc::Rc< - super::r#_Wrappers_Compile::Option< - ::dafny_runtime::Sequence<::dafny_runtime::DafnyCharUTF16>, - >, - > { - match self { - GetStringInput::GetStringInput { value } => value, - } - } - } - - impl ::std::fmt::Debug for GetStringInput { - fn fmt(&self, f: &mut ::std::fmt::Formatter) -> std::fmt::Result { - ::dafny_runtime::DafnyPrint::fmt_print(self, f, true) - } - } - - impl ::dafny_runtime::DafnyPrint for GetStringInput { - fn fmt_print( - &self, - _formatter: &mut ::std::fmt::Formatter, - _in_seq: bool, - ) -> std::fmt::Result { - match self { - GetStringInput::GetStringInput { value } => { - write!(_formatter, "r#_simple_dtypes_dsmithystring_dinternaldafny_dtypes.GetStringInput.GetStringInput(")?; - ::dafny_runtime::DafnyPrint::fmt_print(value, _formatter, false)?; - write!(_formatter, ")")?; - Ok(()) - } - } - } - } - - impl Eq for GetStringInput {} - - impl ::std::hash::Hash for GetStringInput { - fn hash<_H: ::std::hash::Hasher>(&self, _state: &mut _H) { - match self { - GetStringInput::GetStringInput { value } => value.hash(_state), - } - } - } - - impl ::std::default::Default for GetStringInput { - fn default() -> GetStringInput { - GetStringInput::GetStringInput { - value: ::std::default::Default::default(), - } - } - } - - impl ::std::convert::AsRef for &GetStringInput { - fn as_ref(&self) -> Self { - self - } - } - - #[derive(PartialEq, Clone)] - pub enum GetStringOutput { - GetStringOutput { - value: ::std::rc::Rc< - super::r#_Wrappers_Compile::Option< - ::dafny_runtime::Sequence<::dafny_runtime::DafnyCharUTF16>, - >, - >, - }, - } - - impl GetStringOutput { - pub fn value( - &self, - ) -> &::std::rc::Rc< - super::r#_Wrappers_Compile::Option< - ::dafny_runtime::Sequence<::dafny_runtime::DafnyCharUTF16>, - >, - > { - match self { - GetStringOutput::GetStringOutput { value } => value, - } - } - } - - impl ::std::fmt::Debug for GetStringOutput { - fn fmt(&self, f: &mut ::std::fmt::Formatter) -> std::fmt::Result { - ::dafny_runtime::DafnyPrint::fmt_print(self, f, true) - } - } - - impl ::dafny_runtime::DafnyPrint for GetStringOutput { - fn fmt_print( - &self, - _formatter: &mut ::std::fmt::Formatter, - _in_seq: bool, - ) -> std::fmt::Result { - match self { - GetStringOutput::GetStringOutput { value } => { - write!(_formatter, "r#_simple_dtypes_dsmithystring_dinternaldafny_dtypes.GetStringOutput.GetStringOutput(")?; - ::dafny_runtime::DafnyPrint::fmt_print(value, _formatter, false)?; - write!(_formatter, ")")?; - Ok(()) - } - } - } - } - - impl Eq for GetStringOutput {} - - impl ::std::hash::Hash for GetStringOutput { - fn hash<_H: ::std::hash::Hasher>(&self, _state: &mut _H) { - match self { - GetStringOutput::GetStringOutput { value } => value.hash(_state), - } - } - } - - impl ::std::default::Default for GetStringOutput { - fn default() -> GetStringOutput { - GetStringOutput::GetStringOutput { - value: ::std::default::Default::default(), - } - } - } - - impl ::std::convert::AsRef for &GetStringOutput { - fn as_ref(&self) -> Self { - self - } - } - - #[derive(PartialEq, Clone)] - pub enum SimpleStringConfig { - SimpleStringConfig {}, - } - - impl SimpleStringConfig {} - - impl ::std::fmt::Debug for SimpleStringConfig { - fn fmt(&self, f: &mut ::std::fmt::Formatter) -> std::fmt::Result { - ::dafny_runtime::DafnyPrint::fmt_print(self, f, true) - } - } - - impl ::dafny_runtime::DafnyPrint for SimpleStringConfig { - fn fmt_print( - &self, - _formatter: &mut ::std::fmt::Formatter, - _in_seq: bool, - ) -> std::fmt::Result { - match self { - SimpleStringConfig::SimpleStringConfig {} => { - write!(_formatter, "r#_simple_dtypes_dsmithystring_dinternaldafny_dtypes.SimpleStringConfig.SimpleStringConfig")?; - Ok(()) - } - } - } - } - - impl Eq for SimpleStringConfig {} - - impl ::std::hash::Hash for SimpleStringConfig { - fn hash<_H: ::std::hash::Hasher>(&self, _state: &mut _H) { - match self { - SimpleStringConfig::SimpleStringConfig {} => {} - } - } - } - - impl ::std::default::Default for SimpleStringConfig { - fn default() -> SimpleStringConfig { - SimpleStringConfig::SimpleStringConfig {} - } - } - - impl ::std::convert::AsRef for &SimpleStringConfig { - fn as_ref(&self) -> Self { - self - } - } - - pub struct ISimpleTypesStringClientCallHistory {} - - impl ISimpleTypesStringClientCallHistory { - pub fn _allocate_rcmut() -> ::dafny_runtime::Object { - ::dafny_runtime::allocate_rcmut::() - } - } - - pub trait ISimpleTypesStringClient { - fn GetString( - &mut self, - input: &::std::rc::Rc< - super::r#_simple_dtypes_dsmithystring_dinternaldafny_dtypes::GetStringInput, - >, - ) -> ::std::rc::Rc< - super::r#_Wrappers_Compile::Result< - ::std::rc::Rc< - super::r#_simple_dtypes_dsmithystring_dinternaldafny_dtypes::GetStringOutput, - >, - ::std::rc::Rc, - >, - >; - fn GetStringKnownValue( - &mut self, - input: &::std::rc::Rc< - super::r#_simple_dtypes_dsmithystring_dinternaldafny_dtypes::GetStringInput, - >, - ) -> ::std::rc::Rc< - super::r#_Wrappers_Compile::Result< - ::std::rc::Rc< - super::r#_simple_dtypes_dsmithystring_dinternaldafny_dtypes::GetStringOutput, - >, - ::std::rc::Rc, - >, - >; - fn GetStringUTF8( - &mut self, - input: &::std::rc::Rc< - super::r#_simple_dtypes_dsmithystring_dinternaldafny_dtypes::GetStringInput, - >, - ) -> ::std::rc::Rc< - super::r#_Wrappers_Compile::Result< - ::std::rc::Rc< - super::r#_simple_dtypes_dsmithystring_dinternaldafny_dtypes::GetStringOutput, - >, - ::std::rc::Rc, - >, - >; - } - - #[derive(PartialEq, Clone)] - pub enum Error { - CollectionOfErrors { - list: ::dafny_runtime::Sequence< - ::std::rc::Rc, - >, - message: ::dafny_runtime::Sequence<::dafny_runtime::DafnyCharUTF16>, - }, - Opaque { - obj: ::dafny_runtime::Object, - }, - } - - impl Error { - pub fn list( - &self, - ) -> &::dafny_runtime::Sequence< - ::std::rc::Rc, - > { - match self { - Error::CollectionOfErrors { list, message } => list, - Error::Opaque { obj } => panic!("field does not exist on this variant"), - } - } - pub fn message(&self) -> &::dafny_runtime::Sequence<::dafny_runtime::DafnyCharUTF16> { - match self { - Error::CollectionOfErrors { list, message } => message, - Error::Opaque { obj } => panic!("field does not exist on this variant"), - } - } - pub fn obj(&self) -> &::dafny_runtime::Object { - match self { - Error::CollectionOfErrors { list, message } => { - panic!("field does not exist on this variant") - } - Error::Opaque { obj } => obj, - } - } - } - - impl ::std::fmt::Debug for Error { - fn fmt(&self, f: &mut ::std::fmt::Formatter) -> std::fmt::Result { - ::dafny_runtime::DafnyPrint::fmt_print(self, f, true) - } - } - - impl ::dafny_runtime::DafnyPrint for Error { - fn fmt_print( - &self, - _formatter: &mut ::std::fmt::Formatter, - _in_seq: bool, - ) -> std::fmt::Result { - match self { - Error::CollectionOfErrors { list, message } => { - write!(_formatter, "r#_simple_dtypes_dsmithystring_dinternaldafny_dtypes.Error.CollectionOfErrors(")?; - ::dafny_runtime::DafnyPrint::fmt_print(list, _formatter, false)?; - write!(_formatter, ", ")?; - ::dafny_runtime::DafnyPrint::fmt_print(message, _formatter, false)?; - write!(_formatter, ")")?; - Ok(()) - } - Error::Opaque { obj } => { - write!( - _formatter, - "r#_simple_dtypes_dsmithystring_dinternaldafny_dtypes.Error.Opaque(" - )?; - ::dafny_runtime::DafnyPrint::fmt_print(obj, _formatter, false)?; - write!(_formatter, ")")?; - Ok(()) - } - } - } - } - - impl Eq for Error {} - - impl ::std::hash::Hash for Error { - fn hash<_H: ::std::hash::Hasher>(&self, _state: &mut _H) { - match self { - Error::CollectionOfErrors { list, message } => { - list.hash(_state); - message.hash(_state) - } - Error::Opaque { obj } => obj.hash(_state), - } - } - } - - impl ::std::default::Default for Error { - fn default() -> Error { - Error::CollectionOfErrors { - list: ::std::default::Default::default(), - message: ::std::default::Default::default(), - } - } - } - - impl ::std::convert::AsRef for &Error { - fn as_ref(&self) -> Self { - self - } - } - - pub type OpaqueError = - ::std::rc::Rc; -} -pub mod r#_SimpleStringImpl_Compile { - pub struct _default {} - - impl _default { - pub fn _allocate_rcmut() -> ::dafny_runtime::Object { - ::dafny_runtime::allocate_rcmut::() - } - pub fn GetString( - config: &::std::rc::Rc, - input: &::std::rc::Rc< - super::r#_simple_dtypes_dsmithystring_dinternaldafny_dtypes::GetStringInput, - >, - ) -> ::std::rc::Rc< - super::r#_Wrappers_Compile::Result< - ::std::rc::Rc< - super::r#_simple_dtypes_dsmithystring_dinternaldafny_dtypes::GetStringOutput, - >, - ::std::rc::Rc, - >, - > { - let mut output = ::dafny_runtime::MaybePlacebo::<::std::rc::Rc, ::std::rc::Rc>>>::new(); - let mut res: ::std::rc::Rc = ::std::rc::Rc::new(super::r#_simple_dtypes_dsmithystring_dinternaldafny_dtypes::GetStringOutput::GetStringOutput { - value: input.value().clone() - }); - res = ::std::rc::Rc::new(super::r#_simple_dtypes_dsmithystring_dinternaldafny_dtypes::GetStringOutput::GetStringOutput { - value: input.value().clone() - }); - output = ::dafny_runtime::MaybePlacebo::from(::std::rc::Rc::new(super::r#_Wrappers_Compile::Result::<::std::rc::Rc, ::std::rc::Rc>::Success { - value: res.clone() - })); - return output.read(); - return output.read(); - } - pub fn GetStringKnownValue( - config: &::std::rc::Rc, - input: &::std::rc::Rc< - super::r#_simple_dtypes_dsmithystring_dinternaldafny_dtypes::GetStringInput, - >, - ) -> ::std::rc::Rc< - super::r#_Wrappers_Compile::Result< - ::std::rc::Rc< - super::r#_simple_dtypes_dsmithystring_dinternaldafny_dtypes::GetStringOutput, - >, - ::std::rc::Rc, - >, - > { - let mut output = ::dafny_runtime::MaybePlacebo::<::std::rc::Rc, ::std::rc::Rc>>>::new(); - if !matches!( - input.value().as_ref(), - super::r#_Wrappers_Compile::Option::Some { .. } - ) { - panic!("Halt") - }; - if !(input.value().value().clone() - == ::dafny_runtime::string_utf16_of("TEST_SIMPLE_STRING_KNOWN_VALUE")) - { - panic!("Halt") - }; - let mut res: ::std::rc::Rc = ::std::rc::Rc::new(super::r#_simple_dtypes_dsmithystring_dinternaldafny_dtypes::GetStringOutput::GetStringOutput { - value: input.value().clone() - }); - res = ::std::rc::Rc::new(super::r#_simple_dtypes_dsmithystring_dinternaldafny_dtypes::GetStringOutput::GetStringOutput { - value: input.value().clone() - }); - output = ::dafny_runtime::MaybePlacebo::from(::std::rc::Rc::new(super::r#_Wrappers_Compile::Result::<::std::rc::Rc, ::std::rc::Rc>::Success { - value: res.clone() - })); - return output.read(); - return output.read(); - } - pub fn GetStringUTF8( - config: &::std::rc::Rc, - input: &::std::rc::Rc< - super::r#_simple_dtypes_dsmithystring_dinternaldafny_dtypes::GetStringInput, - >, - ) -> ::std::rc::Rc< - super::r#_Wrappers_Compile::Result< - ::std::rc::Rc< - super::r#_simple_dtypes_dsmithystring_dinternaldafny_dtypes::GetStringOutput, - >, - ::std::rc::Rc, - >, - > { - let mut output = ::dafny_runtime::MaybePlacebo::<::std::rc::Rc, ::std::rc::Rc>>>::new(); - if !matches!( - input.value().as_ref(), - super::r#_Wrappers_Compile::Option::Some { .. } - ) { - panic!("Halt") - }; - let mut res: ::std::rc::Rc = ::std::rc::Rc::new(super::r#_simple_dtypes_dsmithystring_dinternaldafny_dtypes::GetStringOutput::GetStringOutput { - value: input.value().clone() - }); - res = ::std::rc::Rc::new(super::r#_simple_dtypes_dsmithystring_dinternaldafny_dtypes::GetStringOutput::GetStringOutput { - value: input.value().clone() - }); - output = ::dafny_runtime::MaybePlacebo::from(::std::rc::Rc::new(super::r#_Wrappers_Compile::Result::<::std::rc::Rc, ::std::rc::Rc>::Success { - value: res.clone() - })); - return output.read(); - return output.read(); - } - } - - #[derive(PartialEq, Clone)] - pub enum Config { - Config {}, - } - - impl Config {} - - impl ::std::fmt::Debug for Config { - fn fmt(&self, f: &mut ::std::fmt::Formatter) -> std::fmt::Result { - ::dafny_runtime::DafnyPrint::fmt_print(self, f, true) - } - } - - impl ::dafny_runtime::DafnyPrint for Config { - fn fmt_print( - &self, - _formatter: &mut ::std::fmt::Formatter, - _in_seq: bool, - ) -> std::fmt::Result { - match self { - Config::Config {} => { - write!(_formatter, "r#_SimpleStringImpl_Compile.Config.Config")?; - Ok(()) - } - } - } - } - - impl Eq for Config {} - - impl ::std::hash::Hash for Config { - fn hash<_H: ::std::hash::Hasher>(&self, _state: &mut _H) { - match self { - Config::Config {} => {} - } - } - } - - impl ::std::default::Default for Config { - fn default() -> Config { - Config::Config {} - } - } - - impl ::std::convert::AsRef for &Config { - fn as_ref(&self) -> Self { - self - } - } -} -pub mod r#_simple_dtypes_dsmithystring_dinternaldafny { - pub struct _default {} - - impl _default { - pub fn _allocate_rcmut() -> ::dafny_runtime::Object { - ::dafny_runtime::allocate_rcmut::() - } - pub fn DefaultSimpleStringConfig() -> ::std::rc::Rc< - super::r#_simple_dtypes_dsmithystring_dinternaldafny_dtypes::SimpleStringConfig, - > { - ::std::rc::Rc::new(super::r#_simple_dtypes_dsmithystring_dinternaldafny_dtypes::SimpleStringConfig::SimpleStringConfig {}) - } - pub fn SimpleString( - config: &::std::rc::Rc< - super::r#_simple_dtypes_dsmithystring_dinternaldafny_dtypes::SimpleStringConfig, - >, - ) -> ::std::rc::Rc< - super::r#_Wrappers_Compile::Result< - ::dafny_runtime::Object< - super::r#_simple_dtypes_dsmithystring_dinternaldafny::SimpleStringClient, - >, - ::std::rc::Rc, - >, - > { - let mut res = ::dafny_runtime::MaybePlacebo::<::std::rc::Rc, ::std::rc::Rc>>>::new(); - let mut client = ::dafny_runtime::MaybePlacebo::< - ::dafny_runtime::Object< - super::r#_simple_dtypes_dsmithystring_dinternaldafny::SimpleStringClient, - >, - >::new(); - let mut _nw0: ::dafny_runtime::Object = super::r#_simple_dtypes_dsmithystring_dinternaldafny::SimpleStringClient::_allocate_rcmut(); - super::r#_simple_dtypes_dsmithystring_dinternaldafny::SimpleStringClient::_ctor( - &_nw0, - &::std::rc::Rc::new(super::r#_SimpleStringImpl_Compile::Config::Config {}), - ); - client = ::dafny_runtime::MaybePlacebo::from(_nw0.clone()); - res = ::dafny_runtime::MaybePlacebo::from(::std::rc::Rc::new( - super::r#_Wrappers_Compile::Result::< - ::dafny_runtime::Object< - super::r#_simple_dtypes_dsmithystring_dinternaldafny::SimpleStringClient, - >, - ::std::rc::Rc< - super::r#_simple_dtypes_dsmithystring_dinternaldafny_dtypes::Error, - >, - >::Success { - value: client.read(), - }, - )); - return res.read(); - return res.read(); - } - pub fn CreateSuccessOfClient(client: &::dafny_runtime::Object) -> ::std::rc::Rc, ::std::rc::Rc>>{ - ::std::rc::Rc::new(super::r#_Wrappers_Compile::Result::<::dafny_runtime::Object, ::std::rc::Rc>::Success { - value: client.clone() - }) - } - pub fn CreateFailureOfError(error: &::std::rc::Rc) -> ::std::rc::Rc, ::std::rc::Rc>>{ - ::std::rc::Rc::new(super::r#_Wrappers_Compile::Result::<::dafny_runtime::Object, ::std::rc::Rc>::Failure { - error: error.clone() - }) - } - } - - pub struct SimpleStringClient { - pub r#__i_config: ::std::rc::Rc, - } - - impl SimpleStringClient { - pub fn _allocate_rcmut() -> ::dafny_runtime::Object { - ::dafny_runtime::allocate_rcmut::() - } - pub fn _ctor( - this: &::dafny_runtime::Object, - config: &::std::rc::Rc, - ) -> () { - let mut _set__i_config: bool = false; - ::dafny_runtime::update_field_uninit_rcmut!( - this.clone(), - r#__i_config, - _set__i_config, - config.clone() - ); - return (); - } - pub fn config(&self) -> ::std::rc::Rc { - self.r#__i_config.clone() - } - } - - impl super::r#_simple_dtypes_dsmithystring_dinternaldafny_dtypes::ISimpleTypesStringClient - for super::r#_simple_dtypes_dsmithystring_dinternaldafny::SimpleStringClient - { - fn GetString( - &mut self, - input: &::std::rc::Rc< - super::r#_simple_dtypes_dsmithystring_dinternaldafny_dtypes::GetStringInput, - >, - ) -> ::std::rc::Rc< - super::r#_Wrappers_Compile::Result< - ::std::rc::Rc< - super::r#_simple_dtypes_dsmithystring_dinternaldafny_dtypes::GetStringOutput, - >, - ::std::rc::Rc, - >, - > { - let mut output = ::dafny_runtime::MaybePlacebo::<::std::rc::Rc, ::std::rc::Rc>>>::new(); - let mut _out0 = ::dafny_runtime::MaybePlacebo::<::std::rc::Rc, ::std::rc::Rc>>>::new(); - _out0 = ::dafny_runtime::MaybePlacebo::from( - super::r#_SimpleStringImpl_Compile::_default::GetString(&self.config(), input), - ); - output = ::dafny_runtime::MaybePlacebo::from(_out0.read()); - return output.read(); - } - fn GetStringKnownValue( - &mut self, - input: &::std::rc::Rc< - super::r#_simple_dtypes_dsmithystring_dinternaldafny_dtypes::GetStringInput, - >, - ) -> ::std::rc::Rc< - super::r#_Wrappers_Compile::Result< - ::std::rc::Rc< - super::r#_simple_dtypes_dsmithystring_dinternaldafny_dtypes::GetStringOutput, - >, - ::std::rc::Rc, - >, - > { - let mut output = ::dafny_runtime::MaybePlacebo::<::std::rc::Rc, ::std::rc::Rc>>>::new(); - let mut _out1 = ::dafny_runtime::MaybePlacebo::<::std::rc::Rc, ::std::rc::Rc>>>::new(); - _out1 = ::dafny_runtime::MaybePlacebo::from( - super::r#_SimpleStringImpl_Compile::_default::GetStringKnownValue( - &self.config(), - input, - ), - ); - output = ::dafny_runtime::MaybePlacebo::from(_out1.read()); - return output.read(); - } - fn GetStringUTF8( - &mut self, - input: &::std::rc::Rc< - super::r#_simple_dtypes_dsmithystring_dinternaldafny_dtypes::GetStringInput, - >, - ) -> ::std::rc::Rc< - super::r#_Wrappers_Compile::Result< - ::std::rc::Rc< - super::r#_simple_dtypes_dsmithystring_dinternaldafny_dtypes::GetStringOutput, - >, - ::std::rc::Rc, - >, - > { - let mut output = ::dafny_runtime::MaybePlacebo::<::std::rc::Rc, ::std::rc::Rc>>>::new(); - let mut _out2 = ::dafny_runtime::MaybePlacebo::<::std::rc::Rc, ::std::rc::Rc>>>::new(); - _out2 = ::dafny_runtime::MaybePlacebo::from( - super::r#_SimpleStringImpl_Compile::_default::GetStringUTF8(&self.config(), input), - ); - output = ::dafny_runtime::MaybePlacebo::from(_out2.read()); - return output.read(); - } - } -} -pub mod _module {} diff --git a/TestModels/Union/runtimes/rust/dafny_impl/src/implementation_from_dafny.rs b/TestModels/Union/runtimes/rust/dafny_impl/src/implementation_from_dafny.rs deleted file mode 100644 index eeb13dc0a5..0000000000 --- a/TestModels/Union/runtimes/rust/dafny_impl/src/implementation_from_dafny.rs +++ /dev/null @@ -1,1096 +0,0 @@ -#![allow(warnings, unconditional_panic)] -#![allow(nonstandard_style)] -pub use dafny_standard_library::implementation_from_dafny::*; - -pub mod r#_simple_dunion_dinternaldafny_dtypes { - #[derive(PartialEq, Clone)] - pub enum DafnyCallEvent { - DafnyCallEvent { input: I, output: O }, - _PhantomVariant(::std::marker::PhantomData, ::std::marker::PhantomData), - } - - impl DafnyCallEvent { - pub fn input(&self) -> &I { - match self { - DafnyCallEvent::DafnyCallEvent { input, output } => input, - DafnyCallEvent::_PhantomVariant(..) => panic!(), - } - } - pub fn output(&self) -> &O { - match self { - DafnyCallEvent::DafnyCallEvent { input, output } => output, - DafnyCallEvent::_PhantomVariant(..) => panic!(), - } - } - } - - impl ::std::fmt::Debug - for DafnyCallEvent - { - fn fmt(&self, f: &mut ::std::fmt::Formatter) -> std::fmt::Result { - ::dafny_runtime::DafnyPrint::fmt_print(self, f, true) - } - } - - impl ::dafny_runtime::DafnyPrint - for DafnyCallEvent - { - fn fmt_print( - &self, - _formatter: &mut ::std::fmt::Formatter, - _in_seq: bool, - ) -> std::fmt::Result { - match self { - DafnyCallEvent::DafnyCallEvent { input, output } => { - write!( - _formatter, - "r#_simple_dunion_dinternaldafny_dtypes.DafnyCallEvent.DafnyCallEvent(" - )?; - ::dafny_runtime::DafnyPrint::fmt_print(input, _formatter, false)?; - write!(_formatter, ", ")?; - ::dafny_runtime::DafnyPrint::fmt_print(output, _formatter, false)?; - write!(_formatter, ")")?; - Ok(()) - } - DafnyCallEvent::_PhantomVariant(..) => { - panic!() - } - } - } - } - - impl Eq - for DafnyCallEvent - { - } - - impl< - I: ::dafny_runtime::DafnyType + ::std::hash::Hash, - O: ::dafny_runtime::DafnyType + ::std::hash::Hash, - > ::std::hash::Hash for DafnyCallEvent - { - fn hash<_H: ::std::hash::Hasher>(&self, _state: &mut _H) { - match self { - DafnyCallEvent::DafnyCallEvent { input, output } => { - input.hash(_state); - output.hash(_state) - } - DafnyCallEvent::_PhantomVariant(..) => { - panic!() - } - } - } - } - - impl< - I: ::dafny_runtime::DafnyType + ::std::default::Default, - O: ::dafny_runtime::DafnyType + ::std::default::Default, - > ::std::default::Default for DafnyCallEvent - { - fn default() -> DafnyCallEvent { - DafnyCallEvent::DafnyCallEvent { - input: ::std::default::Default::default(), - output: ::std::default::Default::default(), - } - } - } - - impl - ::std::convert::AsRef> for &DafnyCallEvent - { - fn as_ref(&self) -> Self { - self - } - } - - #[derive(PartialEq, Clone)] - pub enum GetKnownValueUnionInput { - GetKnownValueUnionInput { - r#union: ::std::rc::Rc< - super::r#_Wrappers_Compile::Option< - ::std::rc::Rc, - >, - >, - }, - } - - impl GetKnownValueUnionInput { - pub fn r#union( - &self, - ) -> &::std::rc::Rc< - super::r#_Wrappers_Compile::Option< - ::std::rc::Rc, - >, - > { - match self { - GetKnownValueUnionInput::GetKnownValueUnionInput { r#union } => r#union, - } - } - } - - impl ::std::fmt::Debug for GetKnownValueUnionInput { - fn fmt(&self, f: &mut ::std::fmt::Formatter) -> std::fmt::Result { - ::dafny_runtime::DafnyPrint::fmt_print(self, f, true) - } - } - - impl ::dafny_runtime::DafnyPrint for GetKnownValueUnionInput { - fn fmt_print( - &self, - _formatter: &mut ::std::fmt::Formatter, - _in_seq: bool, - ) -> std::fmt::Result { - match self { - GetKnownValueUnionInput::GetKnownValueUnionInput { r#union } => { - write!(_formatter, "r#_simple_dunion_dinternaldafny_dtypes.GetKnownValueUnionInput.GetKnownValueUnionInput(")?; - ::dafny_runtime::DafnyPrint::fmt_print(r#union, _formatter, false)?; - write!(_formatter, ")")?; - Ok(()) - } - } - } - } - - impl Eq for GetKnownValueUnionInput {} - - impl ::std::hash::Hash for GetKnownValueUnionInput { - fn hash<_H: ::std::hash::Hasher>(&self, _state: &mut _H) { - match self { - GetKnownValueUnionInput::GetKnownValueUnionInput { r#union } => { - r#union.hash(_state) - } - } - } - } - - impl ::std::default::Default for GetKnownValueUnionInput { - fn default() -> GetKnownValueUnionInput { - GetKnownValueUnionInput::GetKnownValueUnionInput { - r#union: ::std::default::Default::default(), - } - } - } - - impl ::std::convert::AsRef for &GetKnownValueUnionInput { - fn as_ref(&self) -> Self { - self - } - } - - #[derive(PartialEq, Clone)] - pub enum GetKnownValueUnionOutput { - GetKnownValueUnionOutput { - r#union: ::std::rc::Rc< - super::r#_Wrappers_Compile::Option< - ::std::rc::Rc, - >, - >, - }, - } - - impl GetKnownValueUnionOutput { - pub fn r#union( - &self, - ) -> &::std::rc::Rc< - super::r#_Wrappers_Compile::Option< - ::std::rc::Rc, - >, - > { - match self { - GetKnownValueUnionOutput::GetKnownValueUnionOutput { r#union } => r#union, - } - } - } - - impl ::std::fmt::Debug for GetKnownValueUnionOutput { - fn fmt(&self, f: &mut ::std::fmt::Formatter) -> std::fmt::Result { - ::dafny_runtime::DafnyPrint::fmt_print(self, f, true) - } - } - - impl ::dafny_runtime::DafnyPrint for GetKnownValueUnionOutput { - fn fmt_print( - &self, - _formatter: &mut ::std::fmt::Formatter, - _in_seq: bool, - ) -> std::fmt::Result { - match self { - GetKnownValueUnionOutput::GetKnownValueUnionOutput { r#union } => { - write!(_formatter, "r#_simple_dunion_dinternaldafny_dtypes.GetKnownValueUnionOutput.GetKnownValueUnionOutput(")?; - ::dafny_runtime::DafnyPrint::fmt_print(r#union, _formatter, false)?; - write!(_formatter, ")")?; - Ok(()) - } - } - } - } - - impl Eq for GetKnownValueUnionOutput {} - - impl ::std::hash::Hash for GetKnownValueUnionOutput { - fn hash<_H: ::std::hash::Hasher>(&self, _state: &mut _H) { - match self { - GetKnownValueUnionOutput::GetKnownValueUnionOutput { r#union } => { - r#union.hash(_state) - } - } - } - } - - impl ::std::default::Default for GetKnownValueUnionOutput { - fn default() -> GetKnownValueUnionOutput { - GetKnownValueUnionOutput::GetKnownValueUnionOutput { - r#union: ::std::default::Default::default(), - } - } - } - - impl ::std::convert::AsRef for &GetKnownValueUnionOutput { - fn as_ref(&self) -> Self { - self - } - } - - #[derive(PartialEq, Clone)] - pub enum GetUnionInput { - GetUnionInput { - r#union: ::std::rc::Rc< - super::r#_Wrappers_Compile::Option< - ::std::rc::Rc, - >, - >, - }, - } - - impl GetUnionInput { - pub fn r#union( - &self, - ) -> &::std::rc::Rc< - super::r#_Wrappers_Compile::Option< - ::std::rc::Rc, - >, - > { - match self { - GetUnionInput::GetUnionInput { r#union } => r#union, - } - } - } - - impl ::std::fmt::Debug for GetUnionInput { - fn fmt(&self, f: &mut ::std::fmt::Formatter) -> std::fmt::Result { - ::dafny_runtime::DafnyPrint::fmt_print(self, f, true) - } - } - - impl ::dafny_runtime::DafnyPrint for GetUnionInput { - fn fmt_print( - &self, - _formatter: &mut ::std::fmt::Formatter, - _in_seq: bool, - ) -> std::fmt::Result { - match self { - GetUnionInput::GetUnionInput { r#union } => { - write!( - _formatter, - "r#_simple_dunion_dinternaldafny_dtypes.GetUnionInput.GetUnionInput(" - )?; - ::dafny_runtime::DafnyPrint::fmt_print(r#union, _formatter, false)?; - write!(_formatter, ")")?; - Ok(()) - } - } - } - } - - impl Eq for GetUnionInput {} - - impl ::std::hash::Hash for GetUnionInput { - fn hash<_H: ::std::hash::Hasher>(&self, _state: &mut _H) { - match self { - GetUnionInput::GetUnionInput { r#union } => r#union.hash(_state), - } - } - } - - impl ::std::default::Default for GetUnionInput { - fn default() -> GetUnionInput { - GetUnionInput::GetUnionInput { - r#union: ::std::default::Default::default(), - } - } - } - - impl ::std::convert::AsRef for &GetUnionInput { - fn as_ref(&self) -> Self { - self - } - } - - #[derive(PartialEq, Clone)] - pub enum GetUnionOutput { - GetUnionOutput { - r#union: ::std::rc::Rc< - super::r#_Wrappers_Compile::Option< - ::std::rc::Rc, - >, - >, - }, - } - - impl GetUnionOutput { - pub fn r#union( - &self, - ) -> &::std::rc::Rc< - super::r#_Wrappers_Compile::Option< - ::std::rc::Rc, - >, - > { - match self { - GetUnionOutput::GetUnionOutput { r#union } => r#union, - } - } - } - - impl ::std::fmt::Debug for GetUnionOutput { - fn fmt(&self, f: &mut ::std::fmt::Formatter) -> std::fmt::Result { - ::dafny_runtime::DafnyPrint::fmt_print(self, f, true) - } - } - - impl ::dafny_runtime::DafnyPrint for GetUnionOutput { - fn fmt_print( - &self, - _formatter: &mut ::std::fmt::Formatter, - _in_seq: bool, - ) -> std::fmt::Result { - match self { - GetUnionOutput::GetUnionOutput { r#union } => { - write!( - _formatter, - "r#_simple_dunion_dinternaldafny_dtypes.GetUnionOutput.GetUnionOutput(" - )?; - ::dafny_runtime::DafnyPrint::fmt_print(r#union, _formatter, false)?; - write!(_formatter, ")")?; - Ok(()) - } - } - } - } - - impl Eq for GetUnionOutput {} - - impl ::std::hash::Hash for GetUnionOutput { - fn hash<_H: ::std::hash::Hasher>(&self, _state: &mut _H) { - match self { - GetUnionOutput::GetUnionOutput { r#union } => r#union.hash(_state), - } - } - } - - impl ::std::default::Default for GetUnionOutput { - fn default() -> GetUnionOutput { - GetUnionOutput::GetUnionOutput { - r#union: ::std::default::Default::default(), - } - } - } - - impl ::std::convert::AsRef for &GetUnionOutput { - fn as_ref(&self) -> Self { - self - } - } - - #[derive(PartialEq, Clone)] - pub enum KnownValueUnion { - Value { Value: i32 }, - } - - impl KnownValueUnion { - pub fn Value(&self) -> &i32 { - match self { - KnownValueUnion::Value { Value } => Value, - } - } - } - - impl ::std::fmt::Debug for KnownValueUnion { - fn fmt(&self, f: &mut ::std::fmt::Formatter) -> std::fmt::Result { - ::dafny_runtime::DafnyPrint::fmt_print(self, f, true) - } - } - - impl ::dafny_runtime::DafnyPrint for KnownValueUnion { - fn fmt_print( - &self, - _formatter: &mut ::std::fmt::Formatter, - _in_seq: bool, - ) -> std::fmt::Result { - match self { - KnownValueUnion::Value { Value } => { - write!( - _formatter, - "r#_simple_dunion_dinternaldafny_dtypes.KnownValueUnion.Value(" - )?; - ::dafny_runtime::DafnyPrint::fmt_print(Value, _formatter, false)?; - write!(_formatter, ")")?; - Ok(()) - } - } - } - } - - impl Eq for KnownValueUnion {} - - impl ::std::hash::Hash for KnownValueUnion { - fn hash<_H: ::std::hash::Hasher>(&self, _state: &mut _H) { - match self { - KnownValueUnion::Value { Value } => Value.hash(_state), - } - } - } - - impl ::std::default::Default for KnownValueUnion { - fn default() -> KnownValueUnion { - KnownValueUnion::Value { - Value: ::std::default::Default::default(), - } - } - } - - impl ::std::convert::AsRef for &KnownValueUnion { - fn as_ref(&self) -> Self { - self - } - } - - #[derive(PartialEq, Clone)] - pub enum MyUnion { - IntegerValue { - IntegerValue: i32, - }, - StringValue { - StringValue: ::dafny_runtime::Sequence<::dafny_runtime::DafnyCharUTF16>, - }, - } - - impl MyUnion { - pub fn IntegerValue(&self) -> &i32 { - match self { - MyUnion::IntegerValue { IntegerValue } => IntegerValue, - MyUnion::StringValue { StringValue } => { - panic!("field does not exist on this variant") - } - } - } - pub fn StringValue(&self) -> &::dafny_runtime::Sequence<::dafny_runtime::DafnyCharUTF16> { - match self { - MyUnion::IntegerValue { IntegerValue } => { - panic!("field does not exist on this variant") - } - MyUnion::StringValue { StringValue } => StringValue, - } - } - } - - impl ::std::fmt::Debug for MyUnion { - fn fmt(&self, f: &mut ::std::fmt::Formatter) -> std::fmt::Result { - ::dafny_runtime::DafnyPrint::fmt_print(self, f, true) - } - } - - impl ::dafny_runtime::DafnyPrint for MyUnion { - fn fmt_print( - &self, - _formatter: &mut ::std::fmt::Formatter, - _in_seq: bool, - ) -> std::fmt::Result { - match self { - MyUnion::IntegerValue { IntegerValue } => { - write!( - _formatter, - "r#_simple_dunion_dinternaldafny_dtypes.MyUnion.IntegerValue(" - )?; - ::dafny_runtime::DafnyPrint::fmt_print(IntegerValue, _formatter, false)?; - write!(_formatter, ")")?; - Ok(()) - } - MyUnion::StringValue { StringValue } => { - write!( - _formatter, - "r#_simple_dunion_dinternaldafny_dtypes.MyUnion.StringValue(" - )?; - ::dafny_runtime::DafnyPrint::fmt_print(StringValue, _formatter, false)?; - write!(_formatter, ")")?; - Ok(()) - } - } - } - } - - impl Eq for MyUnion {} - - impl ::std::hash::Hash for MyUnion { - fn hash<_H: ::std::hash::Hasher>(&self, _state: &mut _H) { - match self { - MyUnion::IntegerValue { IntegerValue } => IntegerValue.hash(_state), - MyUnion::StringValue { StringValue } => StringValue.hash(_state), - } - } - } - - impl ::std::default::Default for MyUnion { - fn default() -> MyUnion { - MyUnion::IntegerValue { - IntegerValue: ::std::default::Default::default(), - } - } - } - - impl ::std::convert::AsRef for &MyUnion { - fn as_ref(&self) -> Self { - self - } - } - - pub struct ISimpleUnionClientCallHistory {} - - impl ISimpleUnionClientCallHistory { - pub fn _allocate_rcmut() -> ::dafny_runtime::Object { - ::dafny_runtime::allocate_rcmut::() - } - } - - pub trait ISimpleUnionClient { - fn GetUnion( - &mut self, - input: &::std::rc::Rc, - ) -> ::std::rc::Rc< - super::r#_Wrappers_Compile::Result< - ::std::rc::Rc, - ::std::rc::Rc, - >, - >; - fn GetKnownValueUnion( - &mut self, - input: &::std::rc::Rc< - super::r#_simple_dunion_dinternaldafny_dtypes::GetKnownValueUnionInput, - >, - ) -> ::std::rc::Rc< - super::r#_Wrappers_Compile::Result< - ::std::rc::Rc< - super::r#_simple_dunion_dinternaldafny_dtypes::GetKnownValueUnionOutput, - >, - ::std::rc::Rc, - >, - >; - } - - #[derive(PartialEq, Clone)] - pub enum SimpleUnionConfig { - SimpleUnionConfig {}, - } - - impl SimpleUnionConfig {} - - impl ::std::fmt::Debug for SimpleUnionConfig { - fn fmt(&self, f: &mut ::std::fmt::Formatter) -> std::fmt::Result { - ::dafny_runtime::DafnyPrint::fmt_print(self, f, true) - } - } - - impl ::dafny_runtime::DafnyPrint for SimpleUnionConfig { - fn fmt_print( - &self, - _formatter: &mut ::std::fmt::Formatter, - _in_seq: bool, - ) -> std::fmt::Result { - match self { - SimpleUnionConfig::SimpleUnionConfig {} => { - write!(_formatter, "r#_simple_dunion_dinternaldafny_dtypes.SimpleUnionConfig.SimpleUnionConfig")?; - Ok(()) - } - } - } - } - - impl Eq for SimpleUnionConfig {} - - impl ::std::hash::Hash for SimpleUnionConfig { - fn hash<_H: ::std::hash::Hasher>(&self, _state: &mut _H) { - match self { - SimpleUnionConfig::SimpleUnionConfig {} => {} - } - } - } - - impl ::std::default::Default for SimpleUnionConfig { - fn default() -> SimpleUnionConfig { - SimpleUnionConfig::SimpleUnionConfig {} - } - } - - impl ::std::convert::AsRef for &SimpleUnionConfig { - fn as_ref(&self) -> Self { - self - } - } - - #[derive(PartialEq, Clone)] - pub enum Error { - CollectionOfErrors { - list: ::dafny_runtime::Sequence< - ::std::rc::Rc, - >, - message: ::dafny_runtime::Sequence<::dafny_runtime::DafnyCharUTF16>, - }, - Opaque { - obj: ::dafny_runtime::Object, - }, - } - - impl Error { - pub fn list( - &self, - ) -> &::dafny_runtime::Sequence< - ::std::rc::Rc, - > { - match self { - Error::CollectionOfErrors { list, message } => list, - Error::Opaque { obj } => panic!("field does not exist on this variant"), - } - } - pub fn message(&self) -> &::dafny_runtime::Sequence<::dafny_runtime::DafnyCharUTF16> { - match self { - Error::CollectionOfErrors { list, message } => message, - Error::Opaque { obj } => panic!("field does not exist on this variant"), - } - } - pub fn obj(&self) -> &::dafny_runtime::Object { - match self { - Error::CollectionOfErrors { list, message } => { - panic!("field does not exist on this variant") - } - Error::Opaque { obj } => obj, - } - } - } - - impl ::std::fmt::Debug for Error { - fn fmt(&self, f: &mut ::std::fmt::Formatter) -> std::fmt::Result { - ::dafny_runtime::DafnyPrint::fmt_print(self, f, true) - } - } - - impl ::dafny_runtime::DafnyPrint for Error { - fn fmt_print( - &self, - _formatter: &mut ::std::fmt::Formatter, - _in_seq: bool, - ) -> std::fmt::Result { - match self { - Error::CollectionOfErrors { list, message } => { - write!( - _formatter, - "r#_simple_dunion_dinternaldafny_dtypes.Error.CollectionOfErrors(" - )?; - ::dafny_runtime::DafnyPrint::fmt_print(list, _formatter, false)?; - write!(_formatter, ", ")?; - ::dafny_runtime::DafnyPrint::fmt_print(message, _formatter, false)?; - write!(_formatter, ")")?; - Ok(()) - } - Error::Opaque { obj } => { - write!( - _formatter, - "r#_simple_dunion_dinternaldafny_dtypes.Error.Opaque(" - )?; - ::dafny_runtime::DafnyPrint::fmt_print(obj, _formatter, false)?; - write!(_formatter, ")")?; - Ok(()) - } - } - } - } - - impl Eq for Error {} - - impl ::std::hash::Hash for Error { - fn hash<_H: ::std::hash::Hasher>(&self, _state: &mut _H) { - match self { - Error::CollectionOfErrors { list, message } => { - list.hash(_state); - message.hash(_state) - } - Error::Opaque { obj } => obj.hash(_state), - } - } - } - - impl ::std::default::Default for Error { - fn default() -> Error { - Error::CollectionOfErrors { - list: ::std::default::Default::default(), - message: ::std::default::Default::default(), - } - } - } - - impl ::std::convert::AsRef for &Error { - fn as_ref(&self) -> Self { - self - } - } - - pub type OpaqueError = ::std::rc::Rc; -} -pub mod r#_SimpleUnionImpl_Compile { - pub struct _default {} - - impl _default { - pub fn _allocate_rcmut() -> ::dafny_runtime::Object { - ::dafny_runtime::allocate_rcmut::() - } - pub fn GetUnion( - config: &::std::rc::Rc, - input: &::std::rc::Rc, - ) -> ::std::rc::Rc< - super::r#_Wrappers_Compile::Result< - ::std::rc::Rc, - ::std::rc::Rc, - >, - > { - let mut output = ::dafny_runtime::MaybePlacebo::< - ::std::rc::Rc< - super::r#_Wrappers_Compile::Result< - ::std::rc::Rc< - super::r#_simple_dunion_dinternaldafny_dtypes::GetUnionOutput, - >, - ::std::rc::Rc, - >, - >, - >::new(); - let mut res: ::std::rc::Rc< - super::r#_simple_dunion_dinternaldafny_dtypes::GetUnionOutput, - > = ::std::rc::Rc::new( - super::r#_simple_dunion_dinternaldafny_dtypes::GetUnionOutput::GetUnionOutput { - union: input.r#union().clone(), - }, - ); - res = ::std::rc::Rc::new( - super::r#_simple_dunion_dinternaldafny_dtypes::GetUnionOutput::GetUnionOutput { - union: input.r#union().clone(), - }, - ); - output = ::dafny_runtime::MaybePlacebo::from(::std::rc::Rc::new( - super::r#_Wrappers_Compile::Result::< - ::std::rc::Rc, - ::std::rc::Rc, - >::Success { - value: res.clone(), - }, - )); - return output.read(); - return output.read(); - } - pub fn GetKnownValueUnion( - config: &::std::rc::Rc, - input: &::std::rc::Rc< - super::r#_simple_dunion_dinternaldafny_dtypes::GetKnownValueUnionInput, - >, - ) -> ::std::rc::Rc< - super::r#_Wrappers_Compile::Result< - ::std::rc::Rc< - super::r#_simple_dunion_dinternaldafny_dtypes::GetKnownValueUnionOutput, - >, - ::std::rc::Rc, - >, - > { - let mut output = ::dafny_runtime::MaybePlacebo::< - ::std::rc::Rc< - super::r#_Wrappers_Compile::Result< - ::std::rc::Rc< - super::r#_simple_dunion_dinternaldafny_dtypes::GetKnownValueUnionOutput, - >, - ::std::rc::Rc, - >, - >, - >::new(); - let mut res: ::std::rc::Rc = ::std::rc::Rc::new(super::r#_simple_dunion_dinternaldafny_dtypes::GetKnownValueUnionOutput::GetKnownValueUnionOutput { - union: input.r#union().clone() - }); - res = ::std::rc::Rc::new(super::r#_simple_dunion_dinternaldafny_dtypes::GetKnownValueUnionOutput::GetKnownValueUnionOutput { - union: input.r#union().clone() - }); - output = ::dafny_runtime::MaybePlacebo::from(::std::rc::Rc::new( - super::r#_Wrappers_Compile::Result::< - ::std::rc::Rc< - super::r#_simple_dunion_dinternaldafny_dtypes::GetKnownValueUnionOutput, - >, - ::std::rc::Rc, - >::Success { - value: res.clone(), - }, - )); - return output.read(); - return output.read(); - } - } - - #[derive(PartialEq, Clone)] - pub enum Config { - Config {}, - } - - impl Config {} - - impl ::std::fmt::Debug for Config { - fn fmt(&self, f: &mut ::std::fmt::Formatter) -> std::fmt::Result { - ::dafny_runtime::DafnyPrint::fmt_print(self, f, true) - } - } - - impl ::dafny_runtime::DafnyPrint for Config { - fn fmt_print( - &self, - _formatter: &mut ::std::fmt::Formatter, - _in_seq: bool, - ) -> std::fmt::Result { - match self { - Config::Config {} => { - write!(_formatter, "r#_SimpleUnionImpl_Compile.Config.Config")?; - Ok(()) - } - } - } - } - - impl Eq for Config {} - - impl ::std::hash::Hash for Config { - fn hash<_H: ::std::hash::Hasher>(&self, _state: &mut _H) { - match self { - Config::Config {} => {} - } - } - } - - impl ::std::default::Default for Config { - fn default() -> Config { - Config::Config {} - } - } - - impl ::std::convert::AsRef for &Config { - fn as_ref(&self) -> Self { - self - } - } -} -pub mod r#_simple_dunion_dinternaldafny { - pub struct _default {} - - impl _default { - pub fn _allocate_rcmut() -> ::dafny_runtime::Object { - ::dafny_runtime::allocate_rcmut::() - } - pub fn DefaultSimpleUnionConfig( - ) -> ::std::rc::Rc - { - ::std::rc::Rc::new(super::r#_simple_dunion_dinternaldafny_dtypes::SimpleUnionConfig::SimpleUnionConfig {}) - } - pub fn SimpleUnion( - config: &::std::rc::Rc< - super::r#_simple_dunion_dinternaldafny_dtypes::SimpleUnionConfig, - >, - ) -> ::std::rc::Rc< - super::r#_Wrappers_Compile::Result< - ::dafny_runtime::Object, - ::std::rc::Rc, - >, - > { - let mut res = ::dafny_runtime::MaybePlacebo::< - ::std::rc::Rc< - super::r#_Wrappers_Compile::Result< - ::dafny_runtime::Object< - super::r#_simple_dunion_dinternaldafny::SimpleUnionClient, - >, - ::std::rc::Rc, - >, - >, - >::new(); - let mut client = ::dafny_runtime::MaybePlacebo::< - ::dafny_runtime::Object, - >::new(); - let mut _nw0: ::dafny_runtime::Object< - super::r#_simple_dunion_dinternaldafny::SimpleUnionClient, - > = super::r#_simple_dunion_dinternaldafny::SimpleUnionClient::_allocate_rcmut(); - super::r#_simple_dunion_dinternaldafny::SimpleUnionClient::_ctor( - &_nw0, - &::std::rc::Rc::new(super::r#_SimpleUnionImpl_Compile::Config::Config {}), - ); - client = ::dafny_runtime::MaybePlacebo::from(_nw0.clone()); - res = ::dafny_runtime::MaybePlacebo::from(::std::rc::Rc::new( - super::r#_Wrappers_Compile::Result::< - ::dafny_runtime::Object< - super::r#_simple_dunion_dinternaldafny::SimpleUnionClient, - >, - ::std::rc::Rc, - >::Success { - value: client.read(), - }, - )); - return res.read(); - return res.read(); - } - pub fn CreateSuccessOfClient( - client: &::dafny_runtime::Object< - dyn super::r#_simple_dunion_dinternaldafny_dtypes::ISimpleUnionClient, - >, - ) -> ::std::rc::Rc< - super::r#_Wrappers_Compile::Result< - ::dafny_runtime::Object< - dyn super::r#_simple_dunion_dinternaldafny_dtypes::ISimpleUnionClient, - >, - ::std::rc::Rc, - >, - > { - ::std::rc::Rc::new(super::r#_Wrappers_Compile::Result::< - ::dafny_runtime::Object< - dyn super::r#_simple_dunion_dinternaldafny_dtypes::ISimpleUnionClient, - >, - ::std::rc::Rc, - >::Success { - value: client.clone(), - }) - } - pub fn CreateFailureOfError( - error: &::std::rc::Rc, - ) -> ::std::rc::Rc< - super::r#_Wrappers_Compile::Result< - ::dafny_runtime::Object< - dyn super::r#_simple_dunion_dinternaldafny_dtypes::ISimpleUnionClient, - >, - ::std::rc::Rc, - >, - > { - ::std::rc::Rc::new(super::r#_Wrappers_Compile::Result::< - ::dafny_runtime::Object< - dyn super::r#_simple_dunion_dinternaldafny_dtypes::ISimpleUnionClient, - >, - ::std::rc::Rc, - >::Failure { - error: error.clone(), - }) - } - } - - pub struct SimpleUnionClient { - pub r#__i_config: ::std::rc::Rc, - } - - impl SimpleUnionClient { - pub fn _allocate_rcmut() -> ::dafny_runtime::Object { - ::dafny_runtime::allocate_rcmut::() - } - pub fn _ctor( - this: &::dafny_runtime::Object, - config: &::std::rc::Rc, - ) -> () { - let mut _set__i_config: bool = false; - ::dafny_runtime::update_field_uninit_rcmut!( - this.clone(), - r#__i_config, - _set__i_config, - config.clone() - ); - return (); - } - pub fn config(&self) -> ::std::rc::Rc { - self.r#__i_config.clone() - } - } - - impl super::r#_simple_dunion_dinternaldafny_dtypes::ISimpleUnionClient - for super::r#_simple_dunion_dinternaldafny::SimpleUnionClient - { - fn GetUnion( - &mut self, - input: &::std::rc::Rc, - ) -> ::std::rc::Rc< - super::r#_Wrappers_Compile::Result< - ::std::rc::Rc, - ::std::rc::Rc, - >, - > { - let mut output = ::dafny_runtime::MaybePlacebo::< - ::std::rc::Rc< - super::r#_Wrappers_Compile::Result< - ::std::rc::Rc< - super::r#_simple_dunion_dinternaldafny_dtypes::GetUnionOutput, - >, - ::std::rc::Rc, - >, - >, - >::new(); - let mut _out0 = ::dafny_runtime::MaybePlacebo::< - ::std::rc::Rc< - super::r#_Wrappers_Compile::Result< - ::std::rc::Rc< - super::r#_simple_dunion_dinternaldafny_dtypes::GetUnionOutput, - >, - ::std::rc::Rc, - >, - >, - >::new(); - _out0 = ::dafny_runtime::MaybePlacebo::from( - super::r#_SimpleUnionImpl_Compile::_default::GetUnion(&self.config(), input), - ); - output = ::dafny_runtime::MaybePlacebo::from(_out0.read()); - return output.read(); - } - fn GetKnownValueUnion( - &mut self, - input: &::std::rc::Rc< - super::r#_simple_dunion_dinternaldafny_dtypes::GetKnownValueUnionInput, - >, - ) -> ::std::rc::Rc< - super::r#_Wrappers_Compile::Result< - ::std::rc::Rc< - super::r#_simple_dunion_dinternaldafny_dtypes::GetKnownValueUnionOutput, - >, - ::std::rc::Rc, - >, - > { - let mut output = ::dafny_runtime::MaybePlacebo::< - ::std::rc::Rc< - super::r#_Wrappers_Compile::Result< - ::std::rc::Rc< - super::r#_simple_dunion_dinternaldafny_dtypes::GetKnownValueUnionOutput, - >, - ::std::rc::Rc, - >, - >, - >::new(); - let mut _out1 = ::dafny_runtime::MaybePlacebo::< - ::std::rc::Rc< - super::r#_Wrappers_Compile::Result< - ::std::rc::Rc< - super::r#_simple_dunion_dinternaldafny_dtypes::GetKnownValueUnionOutput, - >, - ::std::rc::Rc, - >, - >, - >::new(); - _out1 = ::dafny_runtime::MaybePlacebo::from( - super::r#_SimpleUnionImpl_Compile::_default::GetKnownValueUnion( - &self.config(), - input, - ), - ); - output = ::dafny_runtime::MaybePlacebo::from(_out1.read()); - return output.read(); - } - } -} -pub mod _module {} From 40b4d932bfff1c797de95bb26efa3ba724088670 Mon Sep 17 00:00:00 2001 From: Robin Salkeld Date: Tue, 9 Jul 2024 14:41:02 -0700 Subject: [PATCH 20/53] Missing sealed_unhandled.rs change --- .../Aggregate/runtimes/rust/src/error/sealed_unhandled.rs | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/TestModels/Aggregate/runtimes/rust/src/error/sealed_unhandled.rs b/TestModels/Aggregate/runtimes/rust/src/error/sealed_unhandled.rs index 9d21fbd695..cce22d1cfd 100644 --- a/TestModels/Aggregate/runtimes/rust/src/error/sealed_unhandled.rs +++ b/TestModels/Aggregate/runtimes/rust/src/error/sealed_unhandled.rs @@ -20,3 +20,7 @@ pub struct Unhandled { pub(crate) source: ::aws_smithy_runtime_api::box_error::BoxError, pub(crate) meta: ::aws_smithy_types::error::metadata::ErrorMetadata, } + +impl ::dafny_runtime::UpcastObject for Unhandled { + ::dafny_runtime::UpcastObjectFn!(dyn ::std::any::Any); +} From bcbbbdc994295424ad886298e393fe048ee7efa4 Mon Sep 17 00:00:00 2001 From: Robin Salkeld Date: Tue, 9 Jul 2024 14:41:25 -0700 Subject: [PATCH 21/53] Ignore implementation_from_dafny.rs --- TestModels/.gitignore | 1 + 1 file changed, 1 insertion(+) diff --git a/TestModels/.gitignore b/TestModels/.gitignore index a72df25c1b..d94474d142 100644 --- a/TestModels/.gitignore +++ b/TestModels/.gitignore @@ -12,6 +12,7 @@ # Dafny Generated Rust # (Rust code generation is incomplete so we're patching and checking in for now) #**/runtimes/rust +**/runtimes/rust/dafny_impl/src # Cargo.lock files should only be committed for binaries, not libraries **/Cargo.lock From 636b83b311d3f5eceb6f4d906358f5ac834aeca0 Mon Sep 17 00:00:00 2001 From: Robin Salkeld Date: Tue, 9 Jul 2024 14:42:34 -0700 Subject: [PATCH 22/53] Tweak ignore --- TestModels/.gitignore | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/TestModels/.gitignore b/TestModels/.gitignore index d94474d142..68d8517225 100644 --- a/TestModels/.gitignore +++ b/TestModels/.gitignore @@ -12,7 +12,7 @@ # Dafny Generated Rust # (Rust code generation is incomplete so we're patching and checking in for now) #**/runtimes/rust -**/runtimes/rust/dafny_impl/src +**/implementation_from_dafny.rs # Cargo.lock files should only be committed for binaries, not libraries **/Cargo.lock From 17407117847c6956dd186e378882d9f45b26be1a Mon Sep 17 00:00:00 2001 From: Robin Salkeld Date: Tue, 9 Jul 2024 14:44:47 -0700 Subject: [PATCH 23/53] UpcastObject impl for SimpleResourceWrapper --- .../src/conversions/get_resources/_get_resources_output.rs | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/TestModels/Resource/runtimes/rust/src/conversions/get_resources/_get_resources_output.rs b/TestModels/Resource/runtimes/rust/src/conversions/get_resources/_get_resources_output.rs index b141fcb551..e606e8e8b6 100644 --- a/TestModels/Resource/runtimes/rust/src/conversions/get_resources/_get_resources_output.rs +++ b/TestModels/Resource/runtimes/rust/src/conversions/get_resources/_get_resources_output.rs @@ -35,6 +35,10 @@ pub struct SimpleResourceWrapper { obj: crate::types::simple_resource::SimpleResourceRef, } +impl ::dafny_runtime::UpcastObject for SimpleResourceWrapper { + ::dafny_runtime::UpcastObjectFn!(dyn ::std::any::Any); +} + impl ::simple_resources_dafny::r#_simple_dresources_dinternaldafny_dtypes::ISimpleResource for SimpleResourceWrapper { From 15216179aca1c82d41127b9bf4b1a8868a124e72 Mon Sep 17 00:00:00 2001 From: Robin Salkeld Date: Tue, 9 Jul 2024 14:58:08 -0700 Subject: [PATCH 24/53] Update patch files --- .../codegen-patches/rust/dafny-4.5.0.patch | 20 +++++++------ .../codegen-patches/rust/dafny-4.5.0.patch | 28 +++++++++++-------- .../codegen-patches/rust/dafny-4.5.0.patch | 28 ++++++++++++------- .../codegen-patches/rust/dafny-4.5.0.patch | 20 +++++++------ .../codegen-patches/rust/dafny-4.5.0.patch | 21 ++++++++++---- .../codegen-patches/rust/dafny-4.5.0.patch | 16 +++++++---- .../codegen-patches/rust/dafny-4.5.0.patch | 28 +++++++++++-------- .../codegen-patches/rust/dafny-4.5.0.patch | 28 +++++++++++-------- .../codegen-patches/rust/dafny-4.5.0.patch | 20 +++++++------ .../codegen-patches/rust/dafny-4.5.0.patch | 20 +++++++------ .../codegen-patches/rust/dafny-4.5.0.patch | 24 +++++++++------- .../codegen-patches/rust/dafny-4.5.0.patch | 20 +++++++------ 12 files changed, 165 insertions(+), 108 deletions(-) diff --git a/TestModels/Aggregate/codegen-patches/rust/dafny-4.5.0.patch b/TestModels/Aggregate/codegen-patches/rust/dafny-4.5.0.patch index 109a150235..477ba228ba 100644 --- a/TestModels/Aggregate/codegen-patches/rust/dafny-4.5.0.patch +++ b/TestModels/Aggregate/codegen-patches/rust/dafny-4.5.0.patch @@ -1,6 +1,6 @@ diff --git b/TestModels/Aggregate/runtimes/rust/src/client.rs a/TestModels/Aggregate/runtimes/rust/src/client.rs new file mode 100644 -index 00000000..d5fef505 +index 00000000..96a89e4d --- /dev/null +++ a/TestModels/Aggregate/runtimes/rust/src/client.rs @@ -0,0 +1,43 @@ @@ -39,7 +39,7 @@ index 00000000..d5fef505 + )); + } + Ok(Self { -+ dafny_client: ::dafny_runtime::UpcastTo::>::upcast_to(inner.Extract()), ++ dafny_client: ::dafny_runtime::upcast_object()(inner.Extract()), + }) + } +} @@ -109,7 +109,7 @@ index 00000000..b5acb2be +pub mod structure_list_element; diff --git b/TestModels/Aggregate/runtimes/rust/src/conversions/get_aggregate.rs a/TestModels/Aggregate/runtimes/rust/src/conversions/get_aggregate.rs new file mode 100644 -index 00000000..1918663b +index 00000000..8db680b5 --- /dev/null +++ a/TestModels/Aggregate/runtimes/rust/src/conversions/get_aggregate.rs @@ -0,0 +1,32 @@ @@ -123,7 +123,7 @@ index 00000000..1918663b +) -> ::std::rc::Rc<::simple_aggregate_dafny::r#_simple_daggregate_dinternaldafny_dtypes::Error> { + match value { + crate::operation::get_aggregate::GetAggregateError::Unhandled(unhandled) => -+ ::std::rc::Rc::new(::simple_aggregate_dafny::r#_simple_daggregate_dinternaldafny_dtypes::Error::Opaque { obj: ::dafny_runtime::UpcastTo::<::dafny_runtime::Object>::upcast_to(::dafny_runtime::object::new(unhandled)) }) ++ ::std::rc::Rc::new(::simple_aggregate_dafny::r#_simple_daggregate_dinternaldafny_dtypes::Error::Opaque { obj: ::dafny_runtime::upcast_object()(::dafny_runtime::object::new(unhandled)) }) + } +} + @@ -401,7 +401,7 @@ index 00000000..0a0bee21 +} diff --git b/TestModels/Aggregate/runtimes/rust/src/conversions/get_aggregate_known_value_test.rs a/TestModels/Aggregate/runtimes/rust/src/conversions/get_aggregate_known_value_test.rs new file mode 100644 -index 00000000..e013077c +index 00000000..a128f451 --- /dev/null +++ a/TestModels/Aggregate/runtimes/rust/src/conversions/get_aggregate_known_value_test.rs @@ -0,0 +1,39 @@ @@ -418,7 +418,7 @@ index 00000000..e013077c + unhandled, + ) => ::std::rc::Rc::new( + ::simple_aggregate_dafny::r#_simple_daggregate_dinternaldafny_dtypes::Error::Opaque { -+ obj: ::dafny_runtime::UpcastTo::<::dafny_runtime::Object>::upcast_to( ++ obj: ::dafny_runtime::upcast_object()( + ::dafny_runtime::object::new(unhandled), + ), + }, @@ -1007,10 +1007,10 @@ index 00000000..ec89cbec +pub(crate) mod sealed_unhandled; diff --git b/TestModels/Aggregate/runtimes/rust/src/error/sealed_unhandled.rs a/TestModels/Aggregate/runtimes/rust/src/error/sealed_unhandled.rs new file mode 100644 -index 00000000..9d21fbd6 +index 00000000..cce22d1c --- /dev/null +++ a/TestModels/Aggregate/runtimes/rust/src/error/sealed_unhandled.rs -@@ -0,0 +1,22 @@ +@@ -0,0 +1,26 @@ +// Code generated by software.amazon.smithy.rust.codegen.smithy-rs. DO NOT EDIT. +/// This struct is not intended to be used. +/// @@ -1033,6 +1033,10 @@ index 00000000..9d21fbd6 + pub(crate) source: ::aws_smithy_runtime_api::box_error::BoxError, + pub(crate) meta: ::aws_smithy_types::error::metadata::ErrorMetadata, +} ++ ++impl ::dafny_runtime::UpcastObject for Unhandled { ++ ::dafny_runtime::UpcastObjectFn!(dyn ::std::any::Any); ++} diff --git b/TestModels/Aggregate/runtimes/rust/src/lib.rs a/TestModels/Aggregate/runtimes/rust/src/lib.rs new file mode 100644 index 00000000..89dacaff diff --git a/TestModels/Refinement/codegen-patches/rust/dafny-4.5.0.patch b/TestModels/Refinement/codegen-patches/rust/dafny-4.5.0.patch index 9e7c0e53f3..d5a1801fba 100644 --- a/TestModels/Refinement/codegen-patches/rust/dafny-4.5.0.patch +++ b/TestModels/Refinement/codegen-patches/rust/dafny-4.5.0.patch @@ -1,6 +1,6 @@ diff --git b/TestModels/Refinement/runtimes/rust/src/client.rs a/TestModels/Refinement/runtimes/rust/src/client.rs new file mode 100644 -index 00000000..d7e87890 +index 00000000..d13672bd --- /dev/null +++ a/TestModels/Refinement/runtimes/rust/src/client.rs @@ -0,0 +1,40 @@ @@ -35,7 +35,7 @@ index 00000000..d7e87890 + )); + } + Ok(Self { -+ dafny_client: ::dafny_runtime::UpcastTo::>::upcast_to(inner.Extract()), ++ dafny_client: ::dafny_runtime::upcast_object()(inner.Extract()), + }) + } +} @@ -143,7 +143,7 @@ index 00000000..54b3f0f2 +pub mod simple_refinement_config; diff --git b/TestModels/Refinement/runtimes/rust/src/conversions/get_refinement.rs a/TestModels/Refinement/runtimes/rust/src/conversions/get_refinement.rs new file mode 100644 -index 00000000..7d9afc33 +index 00000000..600b0008 --- /dev/null +++ a/TestModels/Refinement/runtimes/rust/src/conversions/get_refinement.rs @@ -0,0 +1,32 @@ @@ -157,7 +157,7 @@ index 00000000..7d9afc33 +) -> ::std::rc::Rc<::simple_refinement_dafny::r#_simple_drefinement_dinternaldafny_dtypes::Error> { + match value { + crate::operation::get_refinement::GetRefinementError::Unhandled(unhandled) => -+ ::std::rc::Rc::new(::simple_refinement_dafny::r#_simple_drefinement_dinternaldafny_dtypes::Error::Opaque { obj: ::dafny_runtime::UpcastTo::<::dafny_runtime::Object>::upcast_to(::dafny_runtime::object::new(unhandled)) }) ++ ::std::rc::Rc::new(::simple_refinement_dafny::r#_simple_drefinement_dinternaldafny_dtypes::Error::Opaque { obj: ::dafny_runtime::upcast_object()(::dafny_runtime::object::new(unhandled)) }) + } +} + @@ -297,7 +297,7 @@ index 00000000..a190e228 +} diff --git b/TestModels/Refinement/runtimes/rust/src/conversions/only_input.rs a/TestModels/Refinement/runtimes/rust/src/conversions/only_input.rs new file mode 100644 -index 00000000..68745fe3 +index 00000000..080dfdc9 --- /dev/null +++ a/TestModels/Refinement/runtimes/rust/src/conversions/only_input.rs @@ -0,0 +1,37 @@ @@ -312,7 +312,7 @@ index 00000000..68745fe3 + match value { + crate::operation::only_input::OnlyInputError::Unhandled(unhandled) => ::std::rc::Rc::new( + ::simple_refinement_dafny::r#_simple_drefinement_dinternaldafny_dtypes::Error::Opaque { -+ obj: ::dafny_runtime::UpcastTo::<::dafny_runtime::Object>::upcast_to( ++ obj: ::dafny_runtime::upcast_object()( + ::dafny_runtime::object::new(unhandled), + ), + }, @@ -397,7 +397,7 @@ index 00000000..24a58661 +} diff --git b/TestModels/Refinement/runtimes/rust/src/conversions/only_output.rs a/TestModels/Refinement/runtimes/rust/src/conversions/only_output.rs new file mode 100644 -index 00000000..2dfa7b01 +index 00000000..e0cde99f --- /dev/null +++ a/TestModels/Refinement/runtimes/rust/src/conversions/only_output.rs @@ -0,0 +1,37 @@ @@ -412,7 +412,7 @@ index 00000000..2dfa7b01 + match value { + crate::operation::only_output::OnlyOutputError::Unhandled(unhandled) => ::std::rc::Rc::new( + ::simple_refinement_dafny::r#_simple_drefinement_dinternaldafny_dtypes::Error::Opaque { -+ obj: ::dafny_runtime::UpcastTo::<::dafny_runtime::Object>::upcast_to( ++ obj: ::dafny_runtime::upcast_object()( + ::dafny_runtime::object::new(unhandled), + ), + }, @@ -497,7 +497,7 @@ index 00000000..1217ce39 +} diff --git b/TestModels/Refinement/runtimes/rust/src/conversions/readonly_operation.rs a/TestModels/Refinement/runtimes/rust/src/conversions/readonly_operation.rs new file mode 100644 -index 00000000..e584f835 +index 00000000..c19efc31 --- /dev/null +++ a/TestModels/Refinement/runtimes/rust/src/conversions/readonly_operation.rs @@ -0,0 +1,32 @@ @@ -511,7 +511,7 @@ index 00000000..e584f835 +) -> ::std::rc::Rc<::simple_refinement_dafny::r#_simple_drefinement_dinternaldafny_dtypes::Error> { + match value { + crate::operation::readonly_operation::ReadonlyOperationError::Unhandled(unhandled) => -+ ::std::rc::Rc::new(::simple_refinement_dafny::r#_simple_drefinement_dinternaldafny_dtypes::Error::Opaque { obj: ::dafny_runtime::UpcastTo::<::dafny_runtime::Object>::upcast_to(::dafny_runtime::object::new(unhandled)) }) ++ ::std::rc::Rc::new(::simple_refinement_dafny::r#_simple_drefinement_dinternaldafny_dtypes::Error::Opaque { obj: ::dafny_runtime::upcast_object()(::dafny_runtime::object::new(unhandled)) }) + } +} + @@ -705,10 +705,10 @@ index 00000000..ec89cbec +pub(crate) mod sealed_unhandled; diff --git b/TestModels/Refinement/runtimes/rust/src/error/sealed_unhandled.rs a/TestModels/Refinement/runtimes/rust/src/error/sealed_unhandled.rs new file mode 100644 -index 00000000..9d21fbd6 +index 00000000..cce22d1c --- /dev/null +++ a/TestModels/Refinement/runtimes/rust/src/error/sealed_unhandled.rs -@@ -0,0 +1,22 @@ +@@ -0,0 +1,26 @@ +// Code generated by software.amazon.smithy.rust.codegen.smithy-rs. DO NOT EDIT. +/// This struct is not intended to be used. +/// @@ -731,6 +731,10 @@ index 00000000..9d21fbd6 + pub(crate) source: ::aws_smithy_runtime_api::box_error::BoxError, + pub(crate) meta: ::aws_smithy_types::error::metadata::ErrorMetadata, +} ++ ++impl ::dafny_runtime::UpcastObject for Unhandled { ++ ::dafny_runtime::UpcastObjectFn!(dyn ::std::any::Any); ++} diff --git b/TestModels/Refinement/runtimes/rust/src/lib.rs a/TestModels/Refinement/runtimes/rust/src/lib.rs new file mode 100644 index 00000000..c584447b diff --git a/TestModels/Resource/codegen-patches/rust/dafny-4.5.0.patch b/TestModels/Resource/codegen-patches/rust/dafny-4.5.0.patch index 5be06d626e..4308e04c33 100644 --- a/TestModels/Resource/codegen-patches/rust/dafny-4.5.0.patch +++ b/TestModels/Resource/codegen-patches/rust/dafny-4.5.0.patch @@ -1,6 +1,6 @@ diff --git b/TestModels/Resource/runtimes/rust/src/client.rs a/TestModels/Resource/runtimes/rust/src/client.rs new file mode 100644 -index 00000000..a6d9e55b +index 00000000..3a3b2ebe --- /dev/null +++ a/TestModels/Resource/runtimes/rust/src/client.rs @@ -0,0 +1,39 @@ @@ -37,7 +37,7 @@ index 00000000..a6d9e55b + )); + } + Ok(Self { -+ dafny_client: ::dafny_runtime::UpcastTo::>::upcast_to(inner.Extract()), ++ dafny_client: ::dafny_runtime::upcast_object()(inner.Extract()), + }) + } +} @@ -78,7 +78,7 @@ index 00000000..6db43c2c +pub mod simple_resources_config; diff --git b/TestModels/Resource/runtimes/rust/src/conversions/get_resource_data.rs a/TestModels/Resource/runtimes/rust/src/conversions/get_resource_data.rs new file mode 100644 -index 00000000..358e1fd1 +index 00000000..6ea51fa7 --- /dev/null +++ a/TestModels/Resource/runtimes/rust/src/conversions/get_resource_data.rs @@ -0,0 +1,32 @@ @@ -92,7 +92,7 @@ index 00000000..358e1fd1 +) -> ::std::rc::Rc<::simple_resources_dafny::r#_simple_dresources_dinternaldafny_dtypes::Error> { + match value { + crate::operation::get_resource_data::GetResourceDataError::Unhandled(unhandled) => -+ ::std::rc::Rc::new(::simple_resources_dafny::r#_simple_dresources_dinternaldafny_dtypes::Error::Opaque { obj: ::dafny_runtime::UpcastTo::<::dafny_runtime::Object>::upcast_to(::dafny_runtime::object::new(unhandled)) }) ++ ::std::rc::Rc::new(::simple_resources_dafny::r#_simple_dresources_dinternaldafny_dtypes::Error::Opaque { obj: ::dafny_runtime::upcast_object()(::dafny_runtime::object::new(unhandled)) }) + } +} + @@ -206,7 +206,7 @@ index 00000000..cbc002dc +} diff --git b/TestModels/Resource/runtimes/rust/src/conversions/get_resources.rs a/TestModels/Resource/runtimes/rust/src/conversions/get_resources.rs new file mode 100644 -index 00000000..b0b6bd95 +index 00000000..115f6d06 --- /dev/null +++ a/TestModels/Resource/runtimes/rust/src/conversions/get_resources.rs @@ -0,0 +1,32 @@ @@ -220,7 +220,7 @@ index 00000000..b0b6bd95 +) -> ::std::rc::Rc<::simple_resources_dafny::r#_simple_dresources_dinternaldafny_dtypes::Error> { + match value { + crate::operation::get_resources::GetResourcesError::Unhandled(unhandled) => -+ ::std::rc::Rc::new(::simple_resources_dafny::r#_simple_dresources_dinternaldafny_dtypes::Error::Opaque { obj: ::dafny_runtime::UpcastTo::<::dafny_runtime::Object>::upcast_to(::dafny_runtime::object::new(unhandled)) }) ++ ::std::rc::Rc::new(::simple_resources_dafny::r#_simple_dresources_dinternaldafny_dtypes::Error::Opaque { obj: ::dafny_runtime::upcast_object()(::dafny_runtime::object::new(unhandled)) }) + } +} + @@ -293,10 +293,10 @@ index 00000000..c47e35ec +} diff --git b/TestModels/Resource/runtimes/rust/src/conversions/get_resources/_get_resources_output.rs a/TestModels/Resource/runtimes/rust/src/conversions/get_resources/_get_resources_output.rs new file mode 100644 -index 00000000..b141fcb5 +index 00000000..e606e8e8 --- /dev/null +++ a/TestModels/Resource/runtimes/rust/src/conversions/get_resources/_get_resources_output.rs -@@ -0,0 +1,107 @@ +@@ -0,0 +1,111 @@ +// Code generated by software.amazon.smithy.rust.codegen.smithy-rs. DO NOT EDIT. +use crate::types::simple_resource::SimpleResource; +#[allow(dead_code)] @@ -334,6 +334,10 @@ index 00000000..b141fcb5 + obj: crate::types::simple_resource::SimpleResourceRef, +} + ++impl ::dafny_runtime::UpcastObject for SimpleResourceWrapper { ++ ::dafny_runtime::UpcastObjectFn!(dyn ::std::any::Any); ++} ++ +impl ::simple_resources_dafny::r#_simple_dresources_dinternaldafny_dtypes::ISimpleResource + for SimpleResourceWrapper +{ @@ -467,10 +471,10 @@ index 00000000..ec89cbec +pub(crate) mod sealed_unhandled; diff --git b/TestModels/Resource/runtimes/rust/src/error/sealed_unhandled.rs a/TestModels/Resource/runtimes/rust/src/error/sealed_unhandled.rs new file mode 100644 -index 00000000..9d21fbd6 +index 00000000..cce22d1c --- /dev/null +++ a/TestModels/Resource/runtimes/rust/src/error/sealed_unhandled.rs -@@ -0,0 +1,22 @@ +@@ -0,0 +1,26 @@ +// Code generated by software.amazon.smithy.rust.codegen.smithy-rs. DO NOT EDIT. +/// This struct is not intended to be used. +/// @@ -493,6 +497,10 @@ index 00000000..9d21fbd6 + pub(crate) source: ::aws_smithy_runtime_api::box_error::BoxError, + pub(crate) meta: ::aws_smithy_types::error::metadata::ErrorMetadata, +} ++ ++impl ::dafny_runtime::UpcastObject for Unhandled { ++ ::dafny_runtime::UpcastObjectFn!(dyn ::std::any::Any); ++} diff --git b/TestModels/Resource/runtimes/rust/src/lib.rs a/TestModels/Resource/runtimes/rust/src/lib.rs new file mode 100644 index 00000000..8912e4a7 diff --git a/TestModels/SimpleTypes/SimpleBlob/codegen-patches/rust/dafny-4.5.0.patch b/TestModels/SimpleTypes/SimpleBlob/codegen-patches/rust/dafny-4.5.0.patch index 7000576c61..83b5788259 100644 --- a/TestModels/SimpleTypes/SimpleBlob/codegen-patches/rust/dafny-4.5.0.patch +++ b/TestModels/SimpleTypes/SimpleBlob/codegen-patches/rust/dafny-4.5.0.patch @@ -1,6 +1,6 @@ diff --git b/TestModels/SimpleTypes/SimpleBlob/runtimes/rust/src/client.rs a/TestModels/SimpleTypes/SimpleBlob/runtimes/rust/src/client.rs new file mode 100644 -index 00000000..32d3eb4e +index 00000000..f46656e4 --- /dev/null +++ a/TestModels/SimpleTypes/SimpleBlob/runtimes/rust/src/client.rs @@ -0,0 +1,38 @@ @@ -34,7 +34,7 @@ index 00000000..32d3eb4e + )); + } + Ok(Self { -+ dafny_client: ::dafny_runtime::UpcastTo::>::upcast_to(inner.Extract()), ++ dafny_client: ::dafny_runtime::upcast_object()(inner.Extract()), + }) + } +} @@ -98,7 +98,7 @@ index 00000000..1cd4ad22 +pub mod simple_blob_config; diff --git b/TestModels/SimpleTypes/SimpleBlob/runtimes/rust/src/conversions/get_blob.rs a/TestModels/SimpleTypes/SimpleBlob/runtimes/rust/src/conversions/get_blob.rs new file mode 100644 -index 00000000..1ebbffef +index 00000000..deef9ee2 --- /dev/null +++ a/TestModels/SimpleTypes/SimpleBlob/runtimes/rust/src/conversions/get_blob.rs @@ -0,0 +1,37 @@ @@ -113,7 +113,7 @@ index 00000000..1ebbffef + match value { + crate::operation::get_blob::GetBlobError::Unhandled(unhandled) => ::std::rc::Rc::new( + ::simple_blob_dafny::r#_simple_dtypes_dblob_dinternaldafny_dtypes::Error::Opaque { -+ obj: ::dafny_runtime::UpcastTo::<::dafny_runtime::Object>::upcast_to( ++ obj: ::dafny_runtime::upcast_object()( + ::dafny_runtime::object::new(unhandled), + ), + }, @@ -238,7 +238,7 @@ index 00000000..407033f6 +} diff --git b/TestModels/SimpleTypes/SimpleBlob/runtimes/rust/src/conversions/get_blob_known_value.rs a/TestModels/SimpleTypes/SimpleBlob/runtimes/rust/src/conversions/get_blob_known_value.rs new file mode 100644 -index 00000000..6d8eea5f +index 00000000..60b2c1af --- /dev/null +++ a/TestModels/SimpleTypes/SimpleBlob/runtimes/rust/src/conversions/get_blob_known_value.rs @@ -0,0 +1,39 @@ @@ -254,7 +254,7 @@ index 00000000..6d8eea5f + crate::operation::get_blob_known_value::GetBlobKnownValueError::Unhandled(unhandled) => { + ::std::rc::Rc::new( + ::simple_blob_dafny::r#_simple_dtypes_dblob_dinternaldafny_dtypes::Error::Opaque { -+ obj: ::dafny_runtime::UpcastTo::<::dafny_runtime::Object>::upcast_to( ++ obj: ::dafny_runtime::upcast_object()( + ::dafny_runtime::object::new(unhandled), + ), + }, @@ -432,10 +432,10 @@ index 00000000..ec89cbec +pub(crate) mod sealed_unhandled; diff --git b/TestModels/SimpleTypes/SimpleBlob/runtimes/rust/src/error/sealed_unhandled.rs a/TestModels/SimpleTypes/SimpleBlob/runtimes/rust/src/error/sealed_unhandled.rs new file mode 100644 -index 00000000..9d21fbd6 +index 00000000..cce22d1c --- /dev/null +++ a/TestModels/SimpleTypes/SimpleBlob/runtimes/rust/src/error/sealed_unhandled.rs -@@ -0,0 +1,22 @@ +@@ -0,0 +1,26 @@ +// Code generated by software.amazon.smithy.rust.codegen.smithy-rs. DO NOT EDIT. +/// This struct is not intended to be used. +/// @@ -458,6 +458,10 @@ index 00000000..9d21fbd6 + pub(crate) source: ::aws_smithy_runtime_api::box_error::BoxError, + pub(crate) meta: ::aws_smithy_types::error::metadata::ErrorMetadata, +} ++ ++impl ::dafny_runtime::UpcastObject for Unhandled { ++ ::dafny_runtime::UpcastObjectFn!(dyn ::std::any::Any); ++} diff --git b/TestModels/SimpleTypes/SimpleBlob/runtimes/rust/src/lib.rs a/TestModels/SimpleTypes/SimpleBlob/runtimes/rust/src/lib.rs new file mode 100644 index 00000000..f9167684 diff --git a/TestModels/SimpleTypes/SimpleBoolean/codegen-patches/rust/dafny-4.5.0.patch b/TestModels/SimpleTypes/SimpleBoolean/codegen-patches/rust/dafny-4.5.0.patch index cd1e67bae9..9973c302c6 100644 --- a/TestModels/SimpleTypes/SimpleBoolean/codegen-patches/rust/dafny-4.5.0.patch +++ b/TestModels/SimpleTypes/SimpleBoolean/codegen-patches/rust/dafny-4.5.0.patch @@ -1,6 +1,6 @@ diff --git b/TestModels/SimpleTypes/SimpleBoolean/runtimes/rust/src/client.rs a/TestModels/SimpleTypes/SimpleBoolean/runtimes/rust/src/client.rs new file mode 100644 -index 00000000..5170a9ce +index 00000000..89478da5 --- /dev/null +++ a/TestModels/SimpleTypes/SimpleBoolean/runtimes/rust/src/client.rs @@ -0,0 +1,37 @@ @@ -35,7 +35,7 @@ index 00000000..5170a9ce + )); + } + Ok(Self { -+ dafny_client: ::dafny_runtime::UpcastTo::>::upcast_to(inner.Extract()), ++ dafny_client: ::dafny_runtime::upcast_object()(inner.Extract()) + }) + } +} @@ -72,7 +72,7 @@ index 00000000..c1acac7b +pub mod simple_boolean_config; diff --git b/TestModels/SimpleTypes/SimpleBoolean/runtimes/rust/src/conversions/get_boolean.rs a/TestModels/SimpleTypes/SimpleBoolean/runtimes/rust/src/conversions/get_boolean.rs new file mode 100644 -index 00000000..6f9f1b3c +index 00000000..065d3ad3 --- /dev/null +++ a/TestModels/SimpleTypes/SimpleBoolean/runtimes/rust/src/conversions/get_boolean.rs @@ -0,0 +1,32 @@ @@ -86,7 +86,7 @@ index 00000000..6f9f1b3c +) -> ::std::rc::Rc<::simple_boolean_dafny::r#_simple_dtypes_dboolean_dinternaldafny_dtypes::Error> { + match value { + crate::operation::get_boolean::GetBooleanError::Unhandled(unhandled) => -+ ::std::rc::Rc::new(::simple_boolean_dafny::r#_simple_dtypes_dboolean_dinternaldafny_dtypes::Error::Opaque { obj: ::dafny_runtime::UpcastTo::<::dafny_runtime::Object>::upcast_to(::dafny_runtime::object::new(unhandled)) }) ++ ::std::rc::Rc::new(::simple_boolean_dafny::r#_simple_dtypes_dboolean_dinternaldafny_dtypes::Error::Opaque { obj: ::dafny_runtime::upcast_object()(::dafny_runtime::object::new(unhandled)) }) + } +} + @@ -250,10 +250,14 @@ index 00000000..ec89cbec +pub(crate) mod sealed_unhandled; diff --git b/TestModels/SimpleTypes/SimpleBoolean/runtimes/rust/src/error/sealed_unhandled.rs a/TestModels/SimpleTypes/SimpleBoolean/runtimes/rust/src/error/sealed_unhandled.rs new file mode 100644 -index 00000000..9d21fbd6 +index 00000000..4d66eb2e --- /dev/null +++ a/TestModels/SimpleTypes/SimpleBoolean/runtimes/rust/src/error/sealed_unhandled.rs -@@ -0,0 +1,22 @@ +@@ -0,0 +1,30 @@ ++use std::any::Any; ++ ++use dafny_runtime::UpcastObject; ++ +// Code generated by software.amazon.smithy.rust.codegen.smithy-rs. DO NOT EDIT. +/// This struct is not intended to be used. +/// @@ -276,6 +280,11 @@ index 00000000..9d21fbd6 + pub(crate) source: ::aws_smithy_runtime_api::box_error::BoxError, + pub(crate) meta: ::aws_smithy_types::error::metadata::ErrorMetadata, +} ++ ++impl UpcastObject for Unhandled { ++ ::dafny_runtime::UpcastObjectFn!(dyn ::std::any::Any); ++} +\ No newline at end of file diff --git b/TestModels/SimpleTypes/SimpleBoolean/runtimes/rust/src/lib.rs a/TestModels/SimpleTypes/SimpleBoolean/runtimes/rust/src/lib.rs new file mode 100644 index 00000000..1d16c191 diff --git a/TestModels/SimpleTypes/SimpleDouble/codegen-patches/rust/dafny-4.5.0.patch b/TestModels/SimpleTypes/SimpleDouble/codegen-patches/rust/dafny-4.5.0.patch index 68c50b6ecd..6ac6210b5a 100644 --- a/TestModels/SimpleTypes/SimpleDouble/codegen-patches/rust/dafny-4.5.0.patch +++ b/TestModels/SimpleTypes/SimpleDouble/codegen-patches/rust/dafny-4.5.0.patch @@ -1,6 +1,6 @@ diff --git b/TestModels/SimpleTypes/SimpleDouble/runtimes/rust/src/client.rs a/TestModels/SimpleTypes/SimpleDouble/runtimes/rust/src/client.rs new file mode 100644 -index 00000000..49a87808 +index 00000000..34c9f354 --- /dev/null +++ a/TestModels/SimpleTypes/SimpleDouble/runtimes/rust/src/client.rs @@ -0,0 +1,37 @@ @@ -35,7 +35,7 @@ index 00000000..49a87808 + )); + } + Ok(Self { -+ dafny_client: ::dafny_runtime::UpcastTo::>::upcast_to(inner.Extract()), ++ dafny_client: ::dafny_runtime::upcast_object()(inner.Extract()), + }) + } +} @@ -72,7 +72,7 @@ index 00000000..08430ee3 +pub mod simple_double_config; diff --git b/TestModels/SimpleTypes/SimpleDouble/runtimes/rust/src/conversions/get_double.rs a/TestModels/SimpleTypes/SimpleDouble/runtimes/rust/src/conversions/get_double.rs new file mode 100644 -index 00000000..f3d619f5 +index 00000000..9befae93 --- /dev/null +++ a/TestModels/SimpleTypes/SimpleDouble/runtimes/rust/src/conversions/get_double.rs @@ -0,0 +1,33 @@ @@ -87,7 +87,7 @@ index 00000000..f3d619f5 +{ + match value { + crate::operation::get_double::GetDoubleError::Unhandled(unhandled) => -+ ::std::rc::Rc::new(::simple_double_dafny::r#_simple_dtypes_dsmithydouble_dinternaldafny_dtypes::Error::Opaque { obj: ::dafny_runtime::UpcastTo::<::dafny_runtime::Object>::upcast_to(::dafny_runtime::object::new(unhandled)) }) ++ ::std::rc::Rc::new(::simple_double_dafny::r#_simple_dtypes_dsmithydouble_dinternaldafny_dtypes::Error::Opaque { obj: ::dafny_runtime::upcast_object()(::dafny_runtime::object::new(unhandled)) }) + } +} + @@ -271,10 +271,10 @@ index 00000000..ec89cbec +pub(crate) mod sealed_unhandled; diff --git b/TestModels/SimpleTypes/SimpleDouble/runtimes/rust/src/error/sealed_unhandled.rs a/TestModels/SimpleTypes/SimpleDouble/runtimes/rust/src/error/sealed_unhandled.rs new file mode 100644 -index 00000000..9d21fbd6 +index 00000000..cce22d1c --- /dev/null +++ a/TestModels/SimpleTypes/SimpleDouble/runtimes/rust/src/error/sealed_unhandled.rs -@@ -0,0 +1,22 @@ +@@ -0,0 +1,26 @@ +// Code generated by software.amazon.smithy.rust.codegen.smithy-rs. DO NOT EDIT. +/// This struct is not intended to be used. +/// @@ -297,6 +297,10 @@ index 00000000..9d21fbd6 + pub(crate) source: ::aws_smithy_runtime_api::box_error::BoxError, + pub(crate) meta: ::aws_smithy_types::error::metadata::ErrorMetadata, +} ++ ++impl ::dafny_runtime::UpcastObject for Unhandled { ++ ::dafny_runtime::UpcastObjectFn!(dyn ::std::any::Any); ++} diff --git b/TestModels/SimpleTypes/SimpleDouble/runtimes/rust/src/lib.rs a/TestModels/SimpleTypes/SimpleDouble/runtimes/rust/src/lib.rs new file mode 100644 index 00000000..fd5ed298 diff --git a/TestModels/SimpleTypes/SimpleEnum/codegen-patches/rust/dafny-4.5.0.patch b/TestModels/SimpleTypes/SimpleEnum/codegen-patches/rust/dafny-4.5.0.patch index 89ed2b0aca..2e4232f962 100644 --- a/TestModels/SimpleTypes/SimpleEnum/codegen-patches/rust/dafny-4.5.0.patch +++ b/TestModels/SimpleTypes/SimpleEnum/codegen-patches/rust/dafny-4.5.0.patch @@ -1,6 +1,6 @@ diff --git b/TestModels/SimpleTypes/SimpleEnum/runtimes/rust/src/client.rs a/TestModels/SimpleTypes/SimpleEnum/runtimes/rust/src/client.rs new file mode 100644 -index 00000000..de79713c +index 00000000..d1fd739c --- /dev/null +++ a/TestModels/SimpleTypes/SimpleEnum/runtimes/rust/src/client.rs @@ -0,0 +1,41 @@ @@ -35,7 +35,7 @@ index 00000000..de79713c + )); + } + Ok(Self { -+ dafny_client: ::dafny_runtime::UpcastTo::>::upcast_to(inner.Extract()), ++ dafny_client: ::dafny_runtime::upcast_object()(inner.Extract()), + }) + } +} @@ -153,7 +153,7 @@ index 00000000..7361ee56 +pub mod simple_enum_shape; diff --git b/TestModels/SimpleTypes/SimpleEnum/runtimes/rust/src/conversions/get_enum.rs a/TestModels/SimpleTypes/SimpleEnum/runtimes/rust/src/conversions/get_enum.rs new file mode 100644 -index 00000000..99364fbd +index 00000000..a33e611a --- /dev/null +++ a/TestModels/SimpleTypes/SimpleEnum/runtimes/rust/src/conversions/get_enum.rs @@ -0,0 +1,32 @@ @@ -167,7 +167,7 @@ index 00000000..99364fbd +) -> ::std::rc::Rc<::simple_enum_dafny::r#_simple_dtypes_dsmithyenum_dinternaldafny_dtypes::Error> { + match value { + crate::operation::get_enum::GetEnumError::Unhandled(unhandled) => -+ ::std::rc::Rc::new(::simple_enum_dafny::r#_simple_dtypes_dsmithyenum_dinternaldafny_dtypes::Error::Opaque { obj: ::dafny_runtime::UpcastTo::<::dafny_runtime::Object>::upcast_to(::dafny_runtime::object::new(unhandled)) }) ++ ::std::rc::Rc::new(::simple_enum_dafny::r#_simple_dtypes_dsmithyenum_dinternaldafny_dtypes::Error::Opaque { obj: ::dafny_runtime::upcast_object()(::dafny_runtime::object::new(unhandled)) }) + } +} + @@ -293,7 +293,7 @@ index 00000000..eb974472 +} diff --git b/TestModels/SimpleTypes/SimpleEnum/runtimes/rust/src/conversions/get_enum_first_known_value_test.rs a/TestModels/SimpleTypes/SimpleEnum/runtimes/rust/src/conversions/get_enum_first_known_value_test.rs new file mode 100644 -index 00000000..017185b7 +index 00000000..6806b7be --- /dev/null +++ a/TestModels/SimpleTypes/SimpleEnum/runtimes/rust/src/conversions/get_enum_first_known_value_test.rs @@ -0,0 +1,32 @@ @@ -307,7 +307,7 @@ index 00000000..017185b7 +) -> ::std::rc::Rc<::simple_enum_dafny::r#_simple_dtypes_dsmithyenum_dinternaldafny_dtypes::Error> { + match value { + crate::operation::get_enum_first_known_value_test::GetEnumFirstKnownValueTestError::Unhandled(unhandled) => -+ ::std::rc::Rc::new(::simple_enum_dafny::r#_simple_dtypes_dsmithyenum_dinternaldafny_dtypes::Error::Opaque { obj: ::dafny_runtime::UpcastTo::<::dafny_runtime::Object>::upcast_to(::dafny_runtime::object::new(unhandled)) }) ++ ::std::rc::Rc::new(::simple_enum_dafny::r#_simple_dtypes_dsmithyenum_dinternaldafny_dtypes::Error::Opaque { obj: ::dafny_runtime::upcast_object()(::dafny_runtime::object::new(unhandled)) }) + } +} + @@ -433,7 +433,7 @@ index 00000000..181ac629 +} diff --git b/TestModels/SimpleTypes/SimpleEnum/runtimes/rust/src/conversions/get_enum_second_known_value_test.rs a/TestModels/SimpleTypes/SimpleEnum/runtimes/rust/src/conversions/get_enum_second_known_value_test.rs new file mode 100644 -index 00000000..f9446f65 +index 00000000..0db8ed17 --- /dev/null +++ a/TestModels/SimpleTypes/SimpleEnum/runtimes/rust/src/conversions/get_enum_second_known_value_test.rs @@ -0,0 +1,32 @@ @@ -447,7 +447,7 @@ index 00000000..f9446f65 +) -> ::std::rc::Rc<::simple_enum_dafny::r#_simple_dtypes_dsmithyenum_dinternaldafny_dtypes::Error> { + match value { + crate::operation::get_enum_second_known_value_test::GetEnumSecondKnownValueTestError::Unhandled(unhandled) => -+ ::std::rc::Rc::new(::simple_enum_dafny::r#_simple_dtypes_dsmithyenum_dinternaldafny_dtypes::Error::Opaque { obj: ::dafny_runtime::UpcastTo::<::dafny_runtime::Object>::upcast_to(::dafny_runtime::object::new(unhandled)) }) ++ ::std::rc::Rc::new(::simple_enum_dafny::r#_simple_dtypes_dsmithyenum_dinternaldafny_dtypes::Error::Opaque { obj: ::dafny_runtime::upcast_object()(::dafny_runtime::object::new(unhandled)) }) + } +} + @@ -573,7 +573,7 @@ index 00000000..e5ee1acf +} diff --git b/TestModels/SimpleTypes/SimpleEnum/runtimes/rust/src/conversions/get_enum_third_known_value_test.rs a/TestModels/SimpleTypes/SimpleEnum/runtimes/rust/src/conversions/get_enum_third_known_value_test.rs new file mode 100644 -index 00000000..d1ea3635 +index 00000000..29ed2353 --- /dev/null +++ a/TestModels/SimpleTypes/SimpleEnum/runtimes/rust/src/conversions/get_enum_third_known_value_test.rs @@ -0,0 +1,32 @@ @@ -587,7 +587,7 @@ index 00000000..d1ea3635 +) -> ::std::rc::Rc<::simple_enum_dafny::r#_simple_dtypes_dsmithyenum_dinternaldafny_dtypes::Error> { + match value { + crate::operation::get_enum_third_known_value_test::GetEnumThirdKnownValueTestError::Unhandled(unhandled) => -+ ::std::rc::Rc::new(::simple_enum_dafny::r#_simple_dtypes_dsmithyenum_dinternaldafny_dtypes::Error::Opaque { obj: ::dafny_runtime::UpcastTo::<::dafny_runtime::Object>::upcast_to(::dafny_runtime::object::new(unhandled)) }) ++ ::std::rc::Rc::new(::simple_enum_dafny::r#_simple_dtypes_dsmithyenum_dinternaldafny_dtypes::Error::Opaque { obj: ::dafny_runtime::upcast_object()(::dafny_runtime::object::new(unhandled)) }) + } +} + @@ -805,10 +805,10 @@ index 00000000..ec89cbec +pub(crate) mod sealed_unhandled; diff --git b/TestModels/SimpleTypes/SimpleEnum/runtimes/rust/src/error/sealed_unhandled.rs a/TestModels/SimpleTypes/SimpleEnum/runtimes/rust/src/error/sealed_unhandled.rs new file mode 100644 -index 00000000..9d21fbd6 +index 00000000..cce22d1c --- /dev/null +++ a/TestModels/SimpleTypes/SimpleEnum/runtimes/rust/src/error/sealed_unhandled.rs -@@ -0,0 +1,22 @@ +@@ -0,0 +1,26 @@ +// Code generated by software.amazon.smithy.rust.codegen.smithy-rs. DO NOT EDIT. +/// This struct is not intended to be used. +/// @@ -831,6 +831,10 @@ index 00000000..9d21fbd6 + pub(crate) source: ::aws_smithy_runtime_api::box_error::BoxError, + pub(crate) meta: ::aws_smithy_types::error::metadata::ErrorMetadata, +} ++ ++impl ::dafny_runtime::UpcastObject for Unhandled { ++ ::dafny_runtime::UpcastObjectFn!(dyn ::std::any::Any); ++} diff --git b/TestModels/SimpleTypes/SimpleEnum/runtimes/rust/src/lib.rs a/TestModels/SimpleTypes/SimpleEnum/runtimes/rust/src/lib.rs new file mode 100644 index 00000000..2b58ee57 diff --git a/TestModels/SimpleTypes/SimpleEnumV2/codegen-patches/rust/dafny-4.5.0.patch b/TestModels/SimpleTypes/SimpleEnumV2/codegen-patches/rust/dafny-4.5.0.patch index 568af5edae..c84d993239 100644 --- a/TestModels/SimpleTypes/SimpleEnumV2/codegen-patches/rust/dafny-4.5.0.patch +++ b/TestModels/SimpleTypes/SimpleEnumV2/codegen-patches/rust/dafny-4.5.0.patch @@ -1,6 +1,6 @@ diff --git b/TestModels/SimpleTypes/SimpleEnumV2/runtimes/rust/src/client.rs a/TestModels/SimpleTypes/SimpleEnumV2/runtimes/rust/src/client.rs new file mode 100644 -index 00000000..7009f031 +index 00000000..cccf551e --- /dev/null +++ a/TestModels/SimpleTypes/SimpleEnumV2/runtimes/rust/src/client.rs @@ -0,0 +1,41 @@ @@ -35,7 +35,7 @@ index 00000000..7009f031 + )); + } + Ok(Self { -+ dafny_client: ::dafny_runtime::UpcastTo::>::upcast_to(inner.Extract()), ++ dafny_client: ::dafny_runtime::upcast_object()(inner.Extract()), + }) + } +} @@ -153,7 +153,7 @@ index 00000000..323761ef +pub mod simple_enum_v2_shape; diff --git b/TestModels/SimpleTypes/SimpleEnumV2/runtimes/rust/src/conversions/get_enum_v2.rs a/TestModels/SimpleTypes/SimpleEnumV2/runtimes/rust/src/conversions/get_enum_v2.rs new file mode 100644 -index 00000000..c018494a +index 00000000..ee62a4b2 --- /dev/null +++ a/TestModels/SimpleTypes/SimpleEnumV2/runtimes/rust/src/conversions/get_enum_v2.rs @@ -0,0 +1,37 @@ @@ -168,7 +168,7 @@ index 00000000..c018494a + match value { + crate::operation::get_enum_v2::GetEnumV2Error::Unhandled(unhandled) => ::std::rc::Rc::new( + ::simple_enum_v2_dafny::r#_simple_dtypes_denumv2_dinternaldafny_dtypes::Error::Opaque { -+ obj: ::dafny_runtime::UpcastTo::<::dafny_runtime::Object>::upcast_to( ++ obj: ::dafny_runtime::upcast_object()( + ::dafny_runtime::object::new(unhandled), + ), + }, @@ -298,7 +298,7 @@ index 00000000..9dbe77a6 +} diff --git b/TestModels/SimpleTypes/SimpleEnumV2/runtimes/rust/src/conversions/get_enum_v2_first_known_value_test.rs a/TestModels/SimpleTypes/SimpleEnumV2/runtimes/rust/src/conversions/get_enum_v2_first_known_value_test.rs new file mode 100644 -index 00000000..45440aaa +index 00000000..772c94f5 --- /dev/null +++ a/TestModels/SimpleTypes/SimpleEnumV2/runtimes/rust/src/conversions/get_enum_v2_first_known_value_test.rs @@ -0,0 +1,32 @@ @@ -312,7 +312,7 @@ index 00000000..45440aaa +) -> ::std::rc::Rc<::simple_enum_v2_dafny::r#_simple_dtypes_denumv2_dinternaldafny_dtypes::Error> { + match value { + crate::operation::get_enum_v2_first_known_value_test::GetEnumV2FirstKnownValueTestError::Unhandled(unhandled) => -+ ::std::rc::Rc::new(::simple_enum_v2_dafny::r#_simple_dtypes_denumv2_dinternaldafny_dtypes::Error::Opaque { obj: ::dafny_runtime::UpcastTo::<::dafny_runtime::Object>::upcast_to(::dafny_runtime::object::new(unhandled)) }) ++ ::std::rc::Rc::new(::simple_enum_v2_dafny::r#_simple_dtypes_denumv2_dinternaldafny_dtypes::Error::Opaque { obj: ::dafny_runtime::upcast_object()(::dafny_runtime::object::new(unhandled)) }) + } +} + @@ -442,7 +442,7 @@ index 00000000..72480cb5 +} diff --git b/TestModels/SimpleTypes/SimpleEnumV2/runtimes/rust/src/conversions/get_enum_v2_second_known_value_test.rs a/TestModels/SimpleTypes/SimpleEnumV2/runtimes/rust/src/conversions/get_enum_v2_second_known_value_test.rs new file mode 100644 -index 00000000..b3ce7158 +index 00000000..94e88a86 --- /dev/null +++ a/TestModels/SimpleTypes/SimpleEnumV2/runtimes/rust/src/conversions/get_enum_v2_second_known_value_test.rs @@ -0,0 +1,32 @@ @@ -456,7 +456,7 @@ index 00000000..b3ce7158 +) -> ::std::rc::Rc<::simple_enum_v2_dafny::r#_simple_dtypes_denumv2_dinternaldafny_dtypes::Error> { + match value { + crate::operation::get_enum_v2_second_known_value_test::GetEnumV2SecondKnownValueTestError::Unhandled(unhandled) => -+ ::std::rc::Rc::new(::simple_enum_v2_dafny::r#_simple_dtypes_denumv2_dinternaldafny_dtypes::Error::Opaque { obj: ::dafny_runtime::UpcastTo::<::dafny_runtime::Object>::upcast_to(::dafny_runtime::object::new(unhandled)) }) ++ ::std::rc::Rc::new(::simple_enum_v2_dafny::r#_simple_dtypes_denumv2_dinternaldafny_dtypes::Error::Opaque { obj: ::dafny_runtime::upcast_object()(::dafny_runtime::object::new(unhandled)) }) + } +} + @@ -586,7 +586,7 @@ index 00000000..e5799cd4 +} diff --git b/TestModels/SimpleTypes/SimpleEnumV2/runtimes/rust/src/conversions/get_enum_v2_third_known_value_test.rs a/TestModels/SimpleTypes/SimpleEnumV2/runtimes/rust/src/conversions/get_enum_v2_third_known_value_test.rs new file mode 100644 -index 00000000..c8edb2e8 +index 00000000..7176a32a --- /dev/null +++ a/TestModels/SimpleTypes/SimpleEnumV2/runtimes/rust/src/conversions/get_enum_v2_third_known_value_test.rs @@ -0,0 +1,32 @@ @@ -600,7 +600,7 @@ index 00000000..c8edb2e8 +) -> ::std::rc::Rc<::simple_enum_v2_dafny::r#_simple_dtypes_denumv2_dinternaldafny_dtypes::Error> { + match value { + crate::operation::get_enum_v2_third_known_value_test::GetEnumV2ThirdKnownValueTestError::Unhandled(unhandled) => -+ ::std::rc::Rc::new(::simple_enum_v2_dafny::r#_simple_dtypes_denumv2_dinternaldafny_dtypes::Error::Opaque { obj: ::dafny_runtime::UpcastTo::<::dafny_runtime::Object>::upcast_to(::dafny_runtime::object::new(unhandled)) }) ++ ::std::rc::Rc::new(::simple_enum_v2_dafny::r#_simple_dtypes_denumv2_dinternaldafny_dtypes::Error::Opaque { obj: ::dafny_runtime::upcast_object()(::dafny_runtime::object::new(unhandled)) }) + } +} + @@ -822,10 +822,10 @@ index 00000000..ec89cbec +pub(crate) mod sealed_unhandled; diff --git b/TestModels/SimpleTypes/SimpleEnumV2/runtimes/rust/src/error/sealed_unhandled.rs a/TestModels/SimpleTypes/SimpleEnumV2/runtimes/rust/src/error/sealed_unhandled.rs new file mode 100644 -index 00000000..9d21fbd6 +index 00000000..cce22d1c --- /dev/null +++ a/TestModels/SimpleTypes/SimpleEnumV2/runtimes/rust/src/error/sealed_unhandled.rs -@@ -0,0 +1,22 @@ +@@ -0,0 +1,26 @@ +// Code generated by software.amazon.smithy.rust.codegen.smithy-rs. DO NOT EDIT. +/// This struct is not intended to be used. +/// @@ -848,6 +848,10 @@ index 00000000..9d21fbd6 + pub(crate) source: ::aws_smithy_runtime_api::box_error::BoxError, + pub(crate) meta: ::aws_smithy_types::error::metadata::ErrorMetadata, +} ++ ++impl ::dafny_runtime::UpcastObject for Unhandled { ++ ::dafny_runtime::UpcastObjectFn!(dyn ::std::any::Any); ++} diff --git b/TestModels/SimpleTypes/SimpleEnumV2/runtimes/rust/src/lib.rs a/TestModels/SimpleTypes/SimpleEnumV2/runtimes/rust/src/lib.rs new file mode 100644 index 00000000..fd9befe3 diff --git a/TestModels/SimpleTypes/SimpleInteger/codegen-patches/rust/dafny-4.5.0.patch b/TestModels/SimpleTypes/SimpleInteger/codegen-patches/rust/dafny-4.5.0.patch index 9c0c946fc0..4e5563cec8 100644 --- a/TestModels/SimpleTypes/SimpleInteger/codegen-patches/rust/dafny-4.5.0.patch +++ b/TestModels/SimpleTypes/SimpleInteger/codegen-patches/rust/dafny-4.5.0.patch @@ -1,6 +1,6 @@ diff --git b/TestModels/SimpleTypes/SimpleInteger/runtimes/rust/src/client.rs a/TestModels/SimpleTypes/SimpleInteger/runtimes/rust/src/client.rs new file mode 100644 -index 00000000..0450cb93 +index 00000000..d5f1af42 --- /dev/null +++ a/TestModels/SimpleTypes/SimpleInteger/runtimes/rust/src/client.rs @@ -0,0 +1,39 @@ @@ -35,7 +35,7 @@ index 00000000..0450cb93 + )); + } + Ok(Self { -+ dafny_client: ::dafny_runtime::UpcastTo::>::upcast_to(inner.Extract()), ++ dafny_client: ::dafny_runtime::upcast_object()(inner.Extract()), + }) + } +} @@ -100,7 +100,7 @@ index 00000000..9d397cd0 +pub mod simple_integer_config; diff --git b/TestModels/SimpleTypes/SimpleInteger/runtimes/rust/src/conversions/get_integer.rs a/TestModels/SimpleTypes/SimpleInteger/runtimes/rust/src/conversions/get_integer.rs new file mode 100644 -index 00000000..97230cfc +index 00000000..120cac99 --- /dev/null +++ a/TestModels/SimpleTypes/SimpleInteger/runtimes/rust/src/conversions/get_integer.rs @@ -0,0 +1,32 @@ @@ -114,7 +114,7 @@ index 00000000..97230cfc +) -> ::std::rc::Rc<::simple_integer_dafny::r#_simple_dtypes_dinteger_dinternaldafny_dtypes::Error> { + match value { + crate::operation::get_integer::GetIntegerError::Unhandled(unhandled) => -+ ::std::rc::Rc::new(::simple_integer_dafny::r#_simple_dtypes_dinteger_dinternaldafny_dtypes::Error::Opaque { obj: ::dafny_runtime::UpcastTo::<::dafny_runtime::Object>::upcast_to(::dafny_runtime::object::new(unhandled)) }) ++ ::std::rc::Rc::new(::simple_integer_dafny::r#_simple_dtypes_dinteger_dinternaldafny_dtypes::Error::Opaque { obj: ::dafny_runtime::upcast_object()(::dafny_runtime::object::new(unhandled)) }) + } +} + @@ -224,7 +224,7 @@ index 00000000..b5c8ae8c +} diff --git b/TestModels/SimpleTypes/SimpleInteger/runtimes/rust/src/conversions/get_integer_known_value.rs a/TestModels/SimpleTypes/SimpleInteger/runtimes/rust/src/conversions/get_integer_known_value.rs new file mode 100644 -index 00000000..2710a5ea +index 00000000..91f83c4d --- /dev/null +++ a/TestModels/SimpleTypes/SimpleInteger/runtimes/rust/src/conversions/get_integer_known_value.rs @@ -0,0 +1,32 @@ @@ -238,7 +238,7 @@ index 00000000..2710a5ea +) -> ::std::rc::Rc<::simple_integer_dafny::r#_simple_dtypes_dinteger_dinternaldafny_dtypes::Error> { + match value { + crate::operation::get_integer_known_value::GetIntegerKnownValueError::Unhandled(unhandled) => -+ ::std::rc::Rc::new(::simple_integer_dafny::r#_simple_dtypes_dinteger_dinternaldafny_dtypes::Error::Opaque { obj: ::dafny_runtime::UpcastTo::<::dafny_runtime::Object>::upcast_to(::dafny_runtime::object::new(unhandled)) }) ++ ::std::rc::Rc::new(::simple_integer_dafny::r#_simple_dtypes_dinteger_dinternaldafny_dtypes::Error::Opaque { obj: ::dafny_runtime::upcast_object()(::dafny_runtime::object::new(unhandled)) }) + } +} + @@ -402,10 +402,10 @@ index 00000000..ec89cbec +pub(crate) mod sealed_unhandled; diff --git b/TestModels/SimpleTypes/SimpleInteger/runtimes/rust/src/error/sealed_unhandled.rs a/TestModels/SimpleTypes/SimpleInteger/runtimes/rust/src/error/sealed_unhandled.rs new file mode 100644 -index 00000000..9d21fbd6 +index 00000000..cce22d1c --- /dev/null +++ a/TestModels/SimpleTypes/SimpleInteger/runtimes/rust/src/error/sealed_unhandled.rs -@@ -0,0 +1,22 @@ +@@ -0,0 +1,26 @@ +// Code generated by software.amazon.smithy.rust.codegen.smithy-rs. DO NOT EDIT. +/// This struct is not intended to be used. +/// @@ -428,6 +428,10 @@ index 00000000..9d21fbd6 + pub(crate) source: ::aws_smithy_runtime_api::box_error::BoxError, + pub(crate) meta: ::aws_smithy_types::error::metadata::ErrorMetadata, +} ++ ++impl ::dafny_runtime::UpcastObject for Unhandled { ++ ::dafny_runtime::UpcastObjectFn!(dyn ::std::any::Any); ++} diff --git b/TestModels/SimpleTypes/SimpleInteger/runtimes/rust/src/lib.rs a/TestModels/SimpleTypes/SimpleInteger/runtimes/rust/src/lib.rs new file mode 100644 index 00000000..df9b21b8 diff --git a/TestModels/SimpleTypes/SimpleLong/codegen-patches/rust/dafny-4.5.0.patch b/TestModels/SimpleTypes/SimpleLong/codegen-patches/rust/dafny-4.5.0.patch index 29073bbaa9..90faaa841b 100644 --- a/TestModels/SimpleTypes/SimpleLong/codegen-patches/rust/dafny-4.5.0.patch +++ b/TestModels/SimpleTypes/SimpleLong/codegen-patches/rust/dafny-4.5.0.patch @@ -1,6 +1,6 @@ diff --git b/TestModels/SimpleTypes/SimpleLong/runtimes/rust/src/client.rs a/TestModels/SimpleTypes/SimpleLong/runtimes/rust/src/client.rs new file mode 100644 -index 00000000..8fb3793c +index 00000000..014f1471 --- /dev/null +++ a/TestModels/SimpleTypes/SimpleLong/runtimes/rust/src/client.rs @@ -0,0 +1,39 @@ @@ -35,7 +35,7 @@ index 00000000..8fb3793c + )); + } + Ok(Self { -+ dafny_client: ::dafny_runtime::UpcastTo::>::upcast_to(inner.Extract()), ++ dafny_client: ::dafny_runtime::upcast_object()(inner.Extract()), + }) + } +} @@ -99,7 +99,7 @@ index 00000000..4ff5bcbc +pub mod simple_long_config; diff --git b/TestModels/SimpleTypes/SimpleLong/runtimes/rust/src/conversions/get_long.rs a/TestModels/SimpleTypes/SimpleLong/runtimes/rust/src/conversions/get_long.rs new file mode 100644 -index 00000000..86e9ba5c +index 00000000..85d0d5ad --- /dev/null +++ a/TestModels/SimpleTypes/SimpleLong/runtimes/rust/src/conversions/get_long.rs @@ -0,0 +1,32 @@ @@ -113,7 +113,7 @@ index 00000000..86e9ba5c +) -> ::std::rc::Rc<::simple_long_dafny::r#_simple_dtypes_dsmithylong_dinternaldafny_dtypes::Error> { + match value { + crate::operation::get_long::GetLongError::Unhandled(unhandled) => -+ ::std::rc::Rc::new(::simple_long_dafny::r#_simple_dtypes_dsmithylong_dinternaldafny_dtypes::Error::Opaque { obj: ::dafny_runtime::UpcastTo::<::dafny_runtime::Object>::upcast_to(::dafny_runtime::object::new(unhandled)) }) ++ ::std::rc::Rc::new(::simple_long_dafny::r#_simple_dtypes_dsmithylong_dinternaldafny_dtypes::Error::Opaque { obj: ::dafny_runtime::upcast_object()(::dafny_runtime::object::new(unhandled)) }) + } +} + @@ -223,7 +223,7 @@ index 00000000..17daf271 +} diff --git b/TestModels/SimpleTypes/SimpleLong/runtimes/rust/src/conversions/get_long_known_value.rs a/TestModels/SimpleTypes/SimpleLong/runtimes/rust/src/conversions/get_long_known_value.rs new file mode 100644 -index 00000000..c34bda65 +index 00000000..63f0c943 --- /dev/null +++ a/TestModels/SimpleTypes/SimpleLong/runtimes/rust/src/conversions/get_long_known_value.rs @@ -0,0 +1,32 @@ @@ -237,7 +237,7 @@ index 00000000..c34bda65 +) -> ::std::rc::Rc<::simple_long_dafny::r#_simple_dtypes_dsmithylong_dinternaldafny_dtypes::Error> { + match value { + crate::operation::get_long_known_value::GetLongKnownValueError::Unhandled(unhandled) => -+ ::std::rc::Rc::new(::simple_long_dafny::r#_simple_dtypes_dsmithylong_dinternaldafny_dtypes::Error::Opaque { obj: ::dafny_runtime::UpcastTo::<::dafny_runtime::Object>::upcast_to(::dafny_runtime::object::new(unhandled)) }) ++ ::std::rc::Rc::new(::simple_long_dafny::r#_simple_dtypes_dsmithylong_dinternaldafny_dtypes::Error::Opaque { obj: ::dafny_runtime::upcast_object()(::dafny_runtime::object::new(unhandled)) }) + } +} + @@ -401,10 +401,10 @@ index 00000000..ec89cbec +pub(crate) mod sealed_unhandled; diff --git b/TestModels/SimpleTypes/SimpleLong/runtimes/rust/src/error/sealed_unhandled.rs a/TestModels/SimpleTypes/SimpleLong/runtimes/rust/src/error/sealed_unhandled.rs new file mode 100644 -index 00000000..9d21fbd6 +index 00000000..cce22d1c --- /dev/null +++ a/TestModels/SimpleTypes/SimpleLong/runtimes/rust/src/error/sealed_unhandled.rs -@@ -0,0 +1,22 @@ +@@ -0,0 +1,26 @@ +// Code generated by software.amazon.smithy.rust.codegen.smithy-rs. DO NOT EDIT. +/// This struct is not intended to be used. +/// @@ -427,6 +427,10 @@ index 00000000..9d21fbd6 + pub(crate) source: ::aws_smithy_runtime_api::box_error::BoxError, + pub(crate) meta: ::aws_smithy_types::error::metadata::ErrorMetadata, +} ++ ++impl ::dafny_runtime::UpcastObject for Unhandled { ++ ::dafny_runtime::UpcastObjectFn!(dyn ::std::any::Any); ++} diff --git b/TestModels/SimpleTypes/SimpleLong/runtimes/rust/src/lib.rs a/TestModels/SimpleTypes/SimpleLong/runtimes/rust/src/lib.rs new file mode 100644 index 00000000..6d112e7a diff --git a/TestModels/SimpleTypes/SimpleString/codegen-patches/rust/dafny-4.5.0.patch b/TestModels/SimpleTypes/SimpleString/codegen-patches/rust/dafny-4.5.0.patch index 777b51aea3..7421404a7a 100644 --- a/TestModels/SimpleTypes/SimpleString/codegen-patches/rust/dafny-4.5.0.patch +++ b/TestModels/SimpleTypes/SimpleString/codegen-patches/rust/dafny-4.5.0.patch @@ -1,6 +1,6 @@ diff --git b/TestModels/SimpleTypes/SimpleString/runtimes/rust/src/client.rs a/TestModels/SimpleTypes/SimpleString/runtimes/rust/src/client.rs new file mode 100644 -index 00000000..f54152e5 +index 00000000..188bbeb5 --- /dev/null +++ a/TestModels/SimpleTypes/SimpleString/runtimes/rust/src/client.rs @@ -0,0 +1,43 @@ @@ -37,7 +37,7 @@ index 00000000..f54152e5 + )); + } + Ok(Self { -+ dafny_client: ::dafny_runtime::UpcastTo::>::upcast_to(inner.Extract()), ++ dafny_client: ::dafny_runtime::upcast_object()(inner.Extract()), + }) + } +} @@ -149,7 +149,7 @@ index 00000000..0c2b4cf1 +pub mod simple_string_config; diff --git b/TestModels/SimpleTypes/SimpleString/runtimes/rust/src/conversions/get_string.rs a/TestModels/SimpleTypes/SimpleString/runtimes/rust/src/conversions/get_string.rs new file mode 100644 -index 00000000..337142c0 +index 00000000..ddd7a65e --- /dev/null +++ a/TestModels/SimpleTypes/SimpleString/runtimes/rust/src/conversions/get_string.rs @@ -0,0 +1,33 @@ @@ -164,7 +164,7 @@ index 00000000..337142c0 +{ + match value { + crate::operation::get_string::GetStringError::Unhandled(unhandled) => -+ ::std::rc::Rc::new(::simple_string_dafny::r#_simple_dtypes_dsmithystring_dinternaldafny_dtypes::Error::Opaque { obj: ::dafny_runtime::UpcastTo::<::dafny_runtime::Object>::upcast_to(::dafny_runtime::object::new(unhandled)) }) ++ ::std::rc::Rc::new(::simple_string_dafny::r#_simple_dtypes_dsmithystring_dinternaldafny_dtypes::Error::Opaque { obj: ::dafny_runtime::upcast_object()(::dafny_runtime::object::new(unhandled)) }) + } +} + @@ -284,7 +284,7 @@ index 00000000..d658997a +} diff --git b/TestModels/SimpleTypes/SimpleString/runtimes/rust/src/conversions/get_string_known_value.rs a/TestModels/SimpleTypes/SimpleString/runtimes/rust/src/conversions/get_string_known_value.rs new file mode 100644 -index 00000000..33d5010e +index 00000000..cbde58b7 --- /dev/null +++ a/TestModels/SimpleTypes/SimpleString/runtimes/rust/src/conversions/get_string_known_value.rs @@ -0,0 +1,33 @@ @@ -299,7 +299,7 @@ index 00000000..33d5010e +{ + match value { + crate::operation::get_string_known_value::GetStringKnownValueError::Unhandled(unhandled) => -+ ::std::rc::Rc::new(::simple_string_dafny::r#_simple_dtypes_dsmithystring_dinternaldafny_dtypes::Error::Opaque { obj: ::dafny_runtime::UpcastTo::<::dafny_runtime::Object>::upcast_to(::dafny_runtime::object::new(unhandled)) }) ++ ::std::rc::Rc::new(::simple_string_dafny::r#_simple_dtypes_dsmithystring_dinternaldafny_dtypes::Error::Opaque { obj: ::dafny_runtime::upcast_object()(::dafny_runtime::object::new(unhandled)) }) + } +} + @@ -419,7 +419,7 @@ index 00000000..dce554ae +} diff --git b/TestModels/SimpleTypes/SimpleString/runtimes/rust/src/conversions/get_string_utf8.rs a/TestModels/SimpleTypes/SimpleString/runtimes/rust/src/conversions/get_string_utf8.rs new file mode 100644 -index 00000000..972bf501 +index 00000000..00fa066f --- /dev/null +++ a/TestModels/SimpleTypes/SimpleString/runtimes/rust/src/conversions/get_string_utf8.rs @@ -0,0 +1,33 @@ @@ -434,7 +434,7 @@ index 00000000..972bf501 +{ + match value { + crate::operation::get_string_utf8::GetStringUTF8Error::Unhandled(unhandled) => -+ ::std::rc::Rc::new(::simple_string_dafny::r#_simple_dtypes_dsmithystring_dinternaldafny_dtypes::Error::Opaque { obj: ::dafny_runtime::UpcastTo::<::dafny_runtime::Object>::upcast_to(::dafny_runtime::object::new(unhandled)) }) ++ ::std::rc::Rc::new(::simple_string_dafny::r#_simple_dtypes_dsmithystring_dinternaldafny_dtypes::Error::Opaque { obj: ::dafny_runtime::upcast_object()(::dafny_runtime::object::new(unhandled)) }) + } +} + @@ -608,10 +608,10 @@ index 00000000..ec89cbec +pub(crate) mod sealed_unhandled; diff --git b/TestModels/SimpleTypes/SimpleString/runtimes/rust/src/error/sealed_unhandled.rs a/TestModels/SimpleTypes/SimpleString/runtimes/rust/src/error/sealed_unhandled.rs new file mode 100644 -index 00000000..9d21fbd6 +index 00000000..cce22d1c --- /dev/null +++ a/TestModels/SimpleTypes/SimpleString/runtimes/rust/src/error/sealed_unhandled.rs -@@ -0,0 +1,22 @@ +@@ -0,0 +1,26 @@ +// Code generated by software.amazon.smithy.rust.codegen.smithy-rs. DO NOT EDIT. +/// This struct is not intended to be used. +/// @@ -634,6 +634,10 @@ index 00000000..9d21fbd6 + pub(crate) source: ::aws_smithy_runtime_api::box_error::BoxError, + pub(crate) meta: ::aws_smithy_types::error::metadata::ErrorMetadata, +} ++ ++impl ::dafny_runtime::UpcastObject for Unhandled { ++ ::dafny_runtime::UpcastObjectFn!(dyn ::std::any::Any); ++} diff --git b/TestModels/SimpleTypes/SimpleString/runtimes/rust/src/lib.rs a/TestModels/SimpleTypes/SimpleString/runtimes/rust/src/lib.rs new file mode 100644 index 00000000..4315dacf diff --git a/TestModels/Union/codegen-patches/rust/dafny-4.5.0.patch b/TestModels/Union/codegen-patches/rust/dafny-4.5.0.patch index e620883540..9e1ed7ed4f 100644 --- a/TestModels/Union/codegen-patches/rust/dafny-4.5.0.patch +++ b/TestModels/Union/codegen-patches/rust/dafny-4.5.0.patch @@ -1,6 +1,6 @@ diff --git b/TestModels/Union/runtimes/rust/src/client.rs a/TestModels/Union/runtimes/rust/src/client.rs new file mode 100644 -index 00000000..058b2ed9 +index 00000000..d96f6d12 --- /dev/null +++ a/TestModels/Union/runtimes/rust/src/client.rs @@ -0,0 +1,40 @@ @@ -36,7 +36,7 @@ index 00000000..058b2ed9 + )); + } + Ok(Self { -+ dafny_client: ::dafny_runtime::UpcastTo::>::upcast_to(inner.Extract()), ++ dafny_client: ::dafny_runtime::upcast_object()(inner.Extract()), + }) + } +} @@ -102,7 +102,7 @@ index 00000000..375f610e +pub mod simple_union_config; diff --git b/TestModels/Union/runtimes/rust/src/conversions/get_known_value_union.rs a/TestModels/Union/runtimes/rust/src/conversions/get_known_value_union.rs new file mode 100644 -index 00000000..a88ee78b +index 00000000..fd4a8a05 --- /dev/null +++ a/TestModels/Union/runtimes/rust/src/conversions/get_known_value_union.rs @@ -0,0 +1,48 @@ @@ -118,7 +118,7 @@ index 00000000..a88ee78b + crate::operation::get_known_value_union::GetKnownValueUnionError::Unhandled(unhandled) => { + ::std::rc::Rc::new( + ::simple_union_dafny::r#_simple_dunion_dinternaldafny_dtypes::Error::Opaque { -+ obj: ::dafny_runtime::UpcastTo::<::dafny_runtime::Object>::upcast_to( ++ obj: ::dafny_runtime::upcast_object()( + ::dafny_runtime::object::new(unhandled), + ), + }, @@ -278,7 +278,7 @@ index 00000000..8366c01d +} diff --git b/TestModels/Union/runtimes/rust/src/conversions/get_union.rs a/TestModels/Union/runtimes/rust/src/conversions/get_union.rs new file mode 100644 -index 00000000..658f0c17 +index 00000000..7346e3dd --- /dev/null +++ a/TestModels/Union/runtimes/rust/src/conversions/get_union.rs @@ -0,0 +1,46 @@ @@ -293,7 +293,7 @@ index 00000000..658f0c17 + match value { + crate::operation::get_union::GetUnionError::Unhandled(unhandled) => ::std::rc::Rc::new( + ::simple_union_dafny::r#_simple_dunion_dinternaldafny_dtypes::Error::Opaque { -+ obj: ::dafny_runtime::UpcastTo::<::dafny_runtime::Object>::upcast_to( ++ obj: ::dafny_runtime::upcast_object()( + ::dafny_runtime::object::new(unhandled), + ), + }, @@ -514,10 +514,10 @@ index 00000000..ec89cbec +pub(crate) mod sealed_unhandled; diff --git b/TestModels/Union/runtimes/rust/src/error/sealed_unhandled.rs a/TestModels/Union/runtimes/rust/src/error/sealed_unhandled.rs new file mode 100644 -index 00000000..9d21fbd6 +index 00000000..cce22d1c --- /dev/null +++ a/TestModels/Union/runtimes/rust/src/error/sealed_unhandled.rs -@@ -0,0 +1,22 @@ +@@ -0,0 +1,26 @@ +// Code generated by software.amazon.smithy.rust.codegen.smithy-rs. DO NOT EDIT. +/// This struct is not intended to be used. +/// @@ -540,6 +540,10 @@ index 00000000..9d21fbd6 + pub(crate) source: ::aws_smithy_runtime_api::box_error::BoxError, + pub(crate) meta: ::aws_smithy_types::error::metadata::ErrorMetadata, +} ++ ++impl ::dafny_runtime::UpcastObject for Unhandled { ++ ::dafny_runtime::UpcastObjectFn!(dyn ::std::any::Any); ++} diff --git b/TestModels/Union/runtimes/rust/src/lib.rs a/TestModels/Union/runtimes/rust/src/lib.rs new file mode 100644 index 00000000..e98c995a From c902dcd80715925a3535f32ac280ae7ee0e7bd50 Mon Sep 17 00:00:00 2001 From: Robin Salkeld Date: Tue, 9 Jul 2024 15:05:35 -0700 Subject: [PATCH 25/53] Formatting --- .../main/java/software/amazon/polymorph/CodegenEngine.java | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/codegen/smithy-dafny-codegen/src/main/java/software/amazon/polymorph/CodegenEngine.java b/codegen/smithy-dafny-codegen/src/main/java/software/amazon/polymorph/CodegenEngine.java index b5a50535db..9cb8097d33 100644 --- a/codegen/smithy-dafny-codegen/src/main/java/software/amazon/polymorph/CodegenEngine.java +++ b/codegen/smithy-dafny-codegen/src/main/java/software/amazon/polymorph/CodegenEngine.java @@ -666,7 +666,9 @@ private void generateRust(final Path outputDir) { // Be sure to NOT delete src/implementation_from_dafny.rs though, // by temporarily moving it out of src/ Path outputSrcDir = outputDir.resolve("src"); - Path implementationFromDafnyPath = outputSrcDir.resolve("implementation_from_dafny.rs"); + Path implementationFromDafnyPath = outputSrcDir.resolve( + "implementation_from_dafny.rs" + ); Path tmpPath = null; try { if (Files.exists(implementationFromDafnyPath)) { From 92649e1f48570258d9e1c1bece99d14665bf9a29 Mon Sep 17 00:00:00 2001 From: Robin Salkeld Date: Tue, 9 Jul 2024 15:20:18 -0700 Subject: [PATCH 26/53] =?UTF-8?q?Don=E2=80=99t=20check=20in=20implementati?= =?UTF-8?q?on=5Ffrom=5Fdafny.rs=20any=20more?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../src/implementation_from_dafny.rs | 685 ------------------ .../rust/src/implementation_from_dafny.rs | 664 ----------------- 2 files changed, 1349 deletions(-) delete mode 100644 TestModels/SimpleTypes/SimpleBoolean/runtimes/rust/dafny_impl/src/implementation_from_dafny.rs delete mode 100644 TestModels/SimpleTypes/SimpleBoolean/runtimes/rust/src/implementation_from_dafny.rs diff --git a/TestModels/SimpleTypes/SimpleBoolean/runtimes/rust/dafny_impl/src/implementation_from_dafny.rs b/TestModels/SimpleTypes/SimpleBoolean/runtimes/rust/dafny_impl/src/implementation_from_dafny.rs deleted file mode 100644 index 6f5241225c..0000000000 --- a/TestModels/SimpleTypes/SimpleBoolean/runtimes/rust/dafny_impl/src/implementation_from_dafny.rs +++ /dev/null @@ -1,685 +0,0 @@ -#![allow(warnings, unconditional_panic)] -#![allow(nonstandard_style)] - -pub use dafny_standard_library::implementation_from_dafny::*; - -pub mod r#_simple_dtypes_dboolean_dinternaldafny_dtypes { - #[derive(PartialEq, Clone)] - pub enum DafnyCallEvent { - DafnyCallEvent { input: I, output: O }, - _PhantomVariant(::std::marker::PhantomData, ::std::marker::PhantomData), - } - - impl DafnyCallEvent { - pub fn input(&self) -> &I { - match self { - DafnyCallEvent::DafnyCallEvent { input, output } => input, - DafnyCallEvent::_PhantomVariant(..) => panic!(), - } - } - pub fn output(&self) -> &O { - match self { - DafnyCallEvent::DafnyCallEvent { input, output } => output, - DafnyCallEvent::_PhantomVariant(..) => panic!(), - } - } - } - - impl ::std::fmt::Debug - for DafnyCallEvent - { - fn fmt(&self, f: &mut ::std::fmt::Formatter) -> std::fmt::Result { - ::dafny_runtime::DafnyPrint::fmt_print(self, f, true) - } - } - - impl ::dafny_runtime::DafnyPrint - for DafnyCallEvent - { - fn fmt_print( - &self, - _formatter: &mut ::std::fmt::Formatter, - _in_seq: bool, - ) -> std::fmt::Result { - match self { - DafnyCallEvent::DafnyCallEvent { input, output } => { - write!( - _formatter, - "simple.types.boolean.internaldafny.types.DafnyCallEvent.DafnyCallEvent(" - )?; - ::dafny_runtime::DafnyPrint::fmt_print(input, _formatter, false)?; - write!(_formatter, ", ")?; - ::dafny_runtime::DafnyPrint::fmt_print(output, _formatter, false)?; - write!(_formatter, ")")?; - Ok(()) - } - DafnyCallEvent::_PhantomVariant(..) => { - panic!() - } - } - } - } - - impl Eq - for DafnyCallEvent - { - } - - impl< - I: ::dafny_runtime::DafnyType + ::std::hash::Hash, - O: ::dafny_runtime::DafnyType + ::std::hash::Hash, - > ::std::hash::Hash for DafnyCallEvent - { - fn hash<_H: ::std::hash::Hasher>(&self, _state: &mut _H) { - match self { - DafnyCallEvent::DafnyCallEvent { input, output } => { - ::std::hash::Hash::hash(input, _state); - ::std::hash::Hash::hash(output, _state) - } - DafnyCallEvent::_PhantomVariant(..) => { - panic!() - } - } - } - } - - impl< - I: ::dafny_runtime::DafnyType + ::std::default::Default, - O: ::dafny_runtime::DafnyType + ::std::default::Default, - > ::std::default::Default for DafnyCallEvent - { - fn default() -> DafnyCallEvent { - DafnyCallEvent::DafnyCallEvent { - input: ::std::default::Default::default(), - output: ::std::default::Default::default(), - } - } - } - - impl - ::std::convert::AsRef> for &DafnyCallEvent - { - fn as_ref(&self) -> Self { - self - } - } - - #[derive(PartialEq, Clone)] - pub enum GetBooleanInput { - GetBooleanInput { - value: ::std::rc::Rc>, - }, - } - - impl GetBooleanInput { - pub fn value(&self) -> &::std::rc::Rc> { - match self { - GetBooleanInput::GetBooleanInput { value } => value, - } - } - } - - impl ::std::fmt::Debug for GetBooleanInput { - fn fmt(&self, f: &mut ::std::fmt::Formatter) -> std::fmt::Result { - ::dafny_runtime::DafnyPrint::fmt_print(self, f, true) - } - } - - impl ::dafny_runtime::DafnyPrint for GetBooleanInput { - fn fmt_print( - &self, - _formatter: &mut ::std::fmt::Formatter, - _in_seq: bool, - ) -> std::fmt::Result { - match self { - GetBooleanInput::GetBooleanInput { value } => { - write!( - _formatter, - "simple.types.boolean.internaldafny.types.GetBooleanInput.GetBooleanInput(" - )?; - ::dafny_runtime::DafnyPrint::fmt_print(value, _formatter, false)?; - write!(_formatter, ")")?; - Ok(()) - } - } - } - } - - impl Eq for GetBooleanInput {} - - impl ::std::hash::Hash for GetBooleanInput { - fn hash<_H: ::std::hash::Hasher>(&self, _state: &mut _H) { - match self { - GetBooleanInput::GetBooleanInput { value } => { - ::std::hash::Hash::hash(value, _state) - } - } - } - } - - impl ::std::default::Default for GetBooleanInput { - fn default() -> GetBooleanInput { - GetBooleanInput::GetBooleanInput { - value: ::std::default::Default::default(), - } - } - } - - impl ::std::convert::AsRef for &GetBooleanInput { - fn as_ref(&self) -> Self { - self - } - } - - #[derive(PartialEq, Clone)] - pub enum GetBooleanOutput { - GetBooleanOutput { - value: ::std::rc::Rc>, - }, - } - - impl GetBooleanOutput { - pub fn value(&self) -> &::std::rc::Rc> { - match self { - GetBooleanOutput::GetBooleanOutput { value } => value, - } - } - } - - impl ::std::fmt::Debug for GetBooleanOutput { - fn fmt(&self, f: &mut ::std::fmt::Formatter) -> std::fmt::Result { - ::dafny_runtime::DafnyPrint::fmt_print(self, f, true) - } - } - - impl ::dafny_runtime::DafnyPrint for GetBooleanOutput { - fn fmt_print( - &self, - _formatter: &mut ::std::fmt::Formatter, - _in_seq: bool, - ) -> std::fmt::Result { - match self { - GetBooleanOutput::GetBooleanOutput { value } => { - write!(_formatter, "simple.types.boolean.internaldafny.types.GetBooleanOutput.GetBooleanOutput(")?; - ::dafny_runtime::DafnyPrint::fmt_print(value, _formatter, false)?; - write!(_formatter, ")")?; - Ok(()) - } - } - } - } - - impl Eq for GetBooleanOutput {} - - impl ::std::hash::Hash for GetBooleanOutput { - fn hash<_H: ::std::hash::Hasher>(&self, _state: &mut _H) { - match self { - GetBooleanOutput::GetBooleanOutput { value } => { - ::std::hash::Hash::hash(value, _state) - } - } - } - } - - impl ::std::default::Default for GetBooleanOutput { - fn default() -> GetBooleanOutput { - GetBooleanOutput::GetBooleanOutput { - value: ::std::default::Default::default(), - } - } - } - - impl ::std::convert::AsRef for &GetBooleanOutput { - fn as_ref(&self) -> Self { - self - } - } - - #[derive(PartialEq, Clone)] - pub enum SimpleBooleanConfig { - SimpleBooleanConfig {}, - } - - impl SimpleBooleanConfig {} - - impl ::std::fmt::Debug for SimpleBooleanConfig { - fn fmt(&self, f: &mut ::std::fmt::Formatter) -> std::fmt::Result { - ::dafny_runtime::DafnyPrint::fmt_print(self, f, true) - } - } - - impl ::dafny_runtime::DafnyPrint for SimpleBooleanConfig { - fn fmt_print( - &self, - _formatter: &mut ::std::fmt::Formatter, - _in_seq: bool, - ) -> std::fmt::Result { - match self { - SimpleBooleanConfig::SimpleBooleanConfig {} => { - write!(_formatter, "simple.types.boolean.internaldafny.types.SimpleBooleanConfig.SimpleBooleanConfig")?; - Ok(()) - } - } - } - } - - impl Eq for SimpleBooleanConfig {} - - impl ::std::hash::Hash for SimpleBooleanConfig { - fn hash<_H: ::std::hash::Hasher>(&self, _state: &mut _H) { - match self { - SimpleBooleanConfig::SimpleBooleanConfig {} => {} - } - } - } - - impl ::std::default::Default for SimpleBooleanConfig { - fn default() -> SimpleBooleanConfig { - SimpleBooleanConfig::SimpleBooleanConfig {} - } - } - - impl ::std::convert::AsRef for &SimpleBooleanConfig { - fn as_ref(&self) -> Self { - self - } - } - - pub struct ISimpleTypesBooleanClientCallHistory {} - - impl ISimpleTypesBooleanClientCallHistory { - pub fn _allocate_object() -> ::dafny_runtime::Object { - ::dafny_runtime::allocate_object::() - } - } - - impl ::dafny_runtime::UpcastObject - for super::r#_simple_dtypes_dboolean_dinternaldafny_dtypes::ISimpleTypesBooleanClientCallHistory { - ::dafny_runtime::UpcastObjectFn!(dyn ::std::any::Any); - } - - pub trait ISimpleTypesBooleanClient: - ::std::any::Any + ::dafny_runtime::UpcastObject - { - fn GetBoolean( - &mut self, - input: &::std::rc::Rc< - super::r#_simple_dtypes_dboolean_dinternaldafny_dtypes::GetBooleanInput, - >, - ) -> ::std::rc::Rc< - super::r#_Wrappers_Compile::Result< - ::std::rc::Rc< - super::r#_simple_dtypes_dboolean_dinternaldafny_dtypes::GetBooleanOutput, - >, - ::std::rc::Rc, - >, - >; - } - - #[derive(PartialEq, Clone)] - pub enum Error { - CollectionOfErrors { - list: ::dafny_runtime::Sequence< - ::std::rc::Rc, - >, - message: ::dafny_runtime::Sequence<::dafny_runtime::DafnyCharUTF16>, - }, - Opaque { - obj: ::dafny_runtime::Object, - }, - } - - impl Error { - pub fn list( - &self, - ) -> &::dafny_runtime::Sequence< - ::std::rc::Rc, - > { - match self { - Error::CollectionOfErrors { list, message } => list, - Error::Opaque { obj } => panic!("field does not exist on this variant"), - } - } - pub fn message(&self) -> &::dafny_runtime::Sequence<::dafny_runtime::DafnyCharUTF16> { - match self { - Error::CollectionOfErrors { list, message } => message, - Error::Opaque { obj } => panic!("field does not exist on this variant"), - } - } - pub fn obj(&self) -> &::dafny_runtime::Object { - match self { - Error::CollectionOfErrors { list, message } => { - panic!("field does not exist on this variant") - } - Error::Opaque { obj } => obj, - } - } - } - - impl ::std::fmt::Debug for Error { - fn fmt(&self, f: &mut ::std::fmt::Formatter) -> std::fmt::Result { - ::dafny_runtime::DafnyPrint::fmt_print(self, f, true) - } - } - - impl ::dafny_runtime::DafnyPrint for Error { - fn fmt_print( - &self, - _formatter: &mut ::std::fmt::Formatter, - _in_seq: bool, - ) -> std::fmt::Result { - match self { - Error::CollectionOfErrors { list, message } => { - write!( - _formatter, - "simple.types.boolean.internaldafny.types.Error.CollectionOfErrors(" - )?; - ::dafny_runtime::DafnyPrint::fmt_print(list, _formatter, false)?; - write!(_formatter, ", ")?; - ::dafny_runtime::DafnyPrint::fmt_print(message, _formatter, false)?; - write!(_formatter, ")")?; - Ok(()) - } - Error::Opaque { obj } => { - write!( - _formatter, - "simple.types.boolean.internaldafny.types.Error.Opaque(" - )?; - ::dafny_runtime::DafnyPrint::fmt_print(obj, _formatter, false)?; - write!(_formatter, ")")?; - Ok(()) - } - } - } - } - - impl Eq for Error {} - - impl ::std::hash::Hash for Error { - fn hash<_H: ::std::hash::Hasher>(&self, _state: &mut _H) { - match self { - Error::CollectionOfErrors { list, message } => { - ::std::hash::Hash::hash(list, _state); - ::std::hash::Hash::hash(message, _state) - } - Error::Opaque { obj } => ::std::hash::Hash::hash(obj, _state), - } - } - } - - impl ::std::default::Default for Error { - fn default() -> Error { - Error::CollectionOfErrors { - list: ::std::default::Default::default(), - message: ::std::default::Default::default(), - } - } - } - - impl ::std::convert::AsRef for &Error { - fn as_ref(&self) -> Self { - self - } - } - - pub type OpaqueError = - ::std::rc::Rc; -} -pub mod r#_SimpleBooleanImpl_Compile { - pub struct _default {} - - impl _default { - pub fn _allocate_object() -> ::dafny_runtime::Object { - ::dafny_runtime::allocate_object::() - } - pub fn GetBoolean( - config: &::std::rc::Rc, - input: &::std::rc::Rc< - super::r#_simple_dtypes_dboolean_dinternaldafny_dtypes::GetBooleanInput, - >, - ) -> ::std::rc::Rc< - super::r#_Wrappers_Compile::Result< - ::std::rc::Rc< - super::r#_simple_dtypes_dboolean_dinternaldafny_dtypes::GetBooleanOutput, - >, - ::std::rc::Rc, - >, - > { - let mut output = ::dafny_runtime::MaybePlacebo::<::std::rc::Rc, ::std::rc::Rc>>>::new(); - if !matches!( - input.value().as_ref(), - super::r#_Wrappers_Compile::Option::Some { .. } - ) { - panic!("Halt") - }; - if !(input.value().value().clone() == true || input.value().value().clone() == false) { - panic!("Halt") - }; - let mut res: ::std::rc::Rc = ::std::rc::Rc::new(super::r#_simple_dtypes_dboolean_dinternaldafny_dtypes::GetBooleanOutput::GetBooleanOutput { - value: input.value().clone() - }); - if !(res.value().value().clone() == true || res.value().value().clone() == false) { - panic!("Halt") - }; - if !(input.value().value().clone() == res.value().value().clone()) { - panic!("Halt") - }; - output = ::dafny_runtime::MaybePlacebo::from(::std::rc::Rc::new( - super::r#_Wrappers_Compile::Result::< - ::std::rc::Rc< - super::r#_simple_dtypes_dboolean_dinternaldafny_dtypes::GetBooleanOutput, - >, - ::std::rc::Rc, - >::Success { - value: res.clone(), - }, - )); - return output.read(); - } - } - - impl ::dafny_runtime::UpcastObject - for super::r#_SimpleBooleanImpl_Compile::_default - { - ::dafny_runtime::UpcastObjectFn!(dyn::std::any::Any); - } - - #[derive(PartialEq, Clone)] - pub enum Config { - Config {}, - } - - impl Config {} - - impl ::std::fmt::Debug for Config { - fn fmt(&self, f: &mut ::std::fmt::Formatter) -> std::fmt::Result { - ::dafny_runtime::DafnyPrint::fmt_print(self, f, true) - } - } - - impl ::dafny_runtime::DafnyPrint for Config { - fn fmt_print( - &self, - _formatter: &mut ::std::fmt::Formatter, - _in_seq: bool, - ) -> std::fmt::Result { - match self { - Config::Config {} => { - write!(_formatter, "SimpleBooleanImpl_Compile.Config.Config")?; - Ok(()) - } - } - } - } - - impl Eq for Config {} - - impl ::std::hash::Hash for Config { - fn hash<_H: ::std::hash::Hasher>(&self, _state: &mut _H) { - match self { - Config::Config {} => {} - } - } - } - - impl ::std::default::Default for Config { - fn default() -> Config { - Config::Config {} - } - } - - impl ::std::convert::AsRef for &Config { - fn as_ref(&self) -> Self { - self - } - } -} -pub mod r#_simple_dtypes_dboolean_dinternaldafny { - pub struct _default {} - - impl _default { - pub fn _allocate_object() -> ::dafny_runtime::Object { - ::dafny_runtime::allocate_object::() - } - pub fn DefaultSimpleBooleanConfig() -> ::std::rc::Rc< - super::r#_simple_dtypes_dboolean_dinternaldafny_dtypes::SimpleBooleanConfig, - > { - ::std::rc::Rc::new(super::r#_simple_dtypes_dboolean_dinternaldafny_dtypes::SimpleBooleanConfig::SimpleBooleanConfig {}) - } - pub fn SimpleBoolean( - config: &::std::rc::Rc< - super::r#_simple_dtypes_dboolean_dinternaldafny_dtypes::SimpleBooleanConfig, - >, - ) -> ::std::rc::Rc< - super::r#_Wrappers_Compile::Result< - ::dafny_runtime::Object< - super::r#_simple_dtypes_dboolean_dinternaldafny::SimpleBooleanClient, - >, - ::std::rc::Rc, - >, - > { - let mut res = ::dafny_runtime::MaybePlacebo::< - ::std::rc::Rc< - super::r#_Wrappers_Compile::Result< - ::dafny_runtime::Object< - super::r#_simple_dtypes_dboolean_dinternaldafny::SimpleBooleanClient, - >, - ::std::rc::Rc< - super::r#_simple_dtypes_dboolean_dinternaldafny_dtypes::Error, - >, - >, - >, - >::new(); - let mut client = ::dafny_runtime::MaybePlacebo::< - ::dafny_runtime::Object< - super::r#_simple_dtypes_dboolean_dinternaldafny::SimpleBooleanClient, - >, - >::new(); - let mut _nw0: ::dafny_runtime::Object = super::r#_simple_dtypes_dboolean_dinternaldafny::SimpleBooleanClient::_allocate_object(); - super::r#_simple_dtypes_dboolean_dinternaldafny::SimpleBooleanClient::_ctor( - &_nw0, - &::std::rc::Rc::new(super::r#_SimpleBooleanImpl_Compile::Config::Config {}), - ); - client = ::dafny_runtime::MaybePlacebo::from(_nw0.clone()); - res = ::dafny_runtime::MaybePlacebo::from(::std::rc::Rc::new( - super::r#_Wrappers_Compile::Result::< - ::dafny_runtime::Object< - super::r#_simple_dtypes_dboolean_dinternaldafny::SimpleBooleanClient, - >, - ::std::rc::Rc, - >::Success { - value: client.read(), - }, - )); - return res.read(); - } - pub fn CreateSuccessOfClient(client: &::dafny_runtime::Object) -> ::std::rc::Rc, ::std::rc::Rc>>{ - ::std::rc::Rc::new(super::r#_Wrappers_Compile::Result::<::dafny_runtime::Object, ::std::rc::Rc>::Success { - value: client.clone() - }) - } - pub fn CreateFailureOfError(error: &::std::rc::Rc) -> ::std::rc::Rc, ::std::rc::Rc>>{ - ::std::rc::Rc::new(super::r#_Wrappers_Compile::Result::<::dafny_runtime::Object, ::std::rc::Rc>::Failure { - error: error.clone() - }) - } - } - - impl ::dafny_runtime::UpcastObject - for super::r#_simple_dtypes_dboolean_dinternaldafny::_default - { - ::dafny_runtime::UpcastObjectFn!(dyn::std::any::Any); - } - - pub struct SimpleBooleanClient { - pub r#__i_config: ::std::rc::Rc, - } - - impl SimpleBooleanClient { - pub fn _allocate_object() -> ::dafny_runtime::Object { - ::dafny_runtime::allocate_object::() - } - pub fn _ctor( - this: &::dafny_runtime::Object< - super::r#_simple_dtypes_dboolean_dinternaldafny::SimpleBooleanClient, - >, - config: &::std::rc::Rc, - ) -> () { - let mut _set__i_config: bool = false; - ::dafny_runtime::update_field_uninit_object!( - this.clone(), - r#__i_config, - _set__i_config, - config.clone() - ); - return (); - } - pub fn config(&self) -> ::std::rc::Rc { - self.r#__i_config.clone() - } - } - - impl ::dafny_runtime::UpcastObject - for super::r#_simple_dtypes_dboolean_dinternaldafny::SimpleBooleanClient - { - ::dafny_runtime::UpcastObjectFn!(dyn::std::any::Any); - } - - impl super::r#_simple_dtypes_dboolean_dinternaldafny_dtypes::ISimpleTypesBooleanClient - for super::r#_simple_dtypes_dboolean_dinternaldafny::SimpleBooleanClient - { - fn GetBoolean( - &mut self, - input: &::std::rc::Rc< - super::r#_simple_dtypes_dboolean_dinternaldafny_dtypes::GetBooleanInput, - >, - ) -> ::std::rc::Rc< - super::r#_Wrappers_Compile::Result< - ::std::rc::Rc< - super::r#_simple_dtypes_dboolean_dinternaldafny_dtypes::GetBooleanOutput, - >, - ::std::rc::Rc, - >, - > { - let mut output = ::dafny_runtime::MaybePlacebo::<::std::rc::Rc, ::std::rc::Rc>>>::new(); - let mut _out0 = ::dafny_runtime::MaybePlacebo::<::std::rc::Rc, ::std::rc::Rc>>>::new(); - _out0 = ::dafny_runtime::MaybePlacebo::from( - super::r#_SimpleBooleanImpl_Compile::_default::GetBoolean( - &self.config().clone(), - input, - ), - ); - output = ::dafny_runtime::MaybePlacebo::from(_out0.read()); - return output.read(); - } - } - - impl - ::dafny_runtime::UpcastObject< - dyn super::r#_simple_dtypes_dboolean_dinternaldafny_dtypes::ISimpleTypesBooleanClient, - > for super::r#_simple_dtypes_dboolean_dinternaldafny::SimpleBooleanClient - { - ::dafny_runtime::UpcastObjectFn!(dyn super::r#_simple_dtypes_dboolean_dinternaldafny_dtypes::ISimpleTypesBooleanClient); - } -} -pub mod _module {} diff --git a/TestModels/SimpleTypes/SimpleBoolean/runtimes/rust/src/implementation_from_dafny.rs b/TestModels/SimpleTypes/SimpleBoolean/runtimes/rust/src/implementation_from_dafny.rs deleted file mode 100644 index 112ccaf023..0000000000 --- a/TestModels/SimpleTypes/SimpleBoolean/runtimes/rust/src/implementation_from_dafny.rs +++ /dev/null @@ -1,664 +0,0 @@ -#![allow(warnings, unconditional_panic)] -#![allow(nonstandard_style)] -pub use dafny_standard_library::implementation_from_dafny::*; - -pub mod r#_simple_dtypes_dtimestamp_dinternaldafny_dtypes { - #[derive(PartialEq, Clone)] - pub enum DafnyCallEvent { - DafnyCallEvent { input: I, output: O }, - _PhantomVariant(::std::marker::PhantomData, ::std::marker::PhantomData), - } - - impl DafnyCallEvent { - pub fn input(&self) -> &I { - match self { - DafnyCallEvent::DafnyCallEvent { input, output } => input, - DafnyCallEvent::_PhantomVariant(..) => panic!(), - } - } - pub fn output(&self) -> &O { - match self { - DafnyCallEvent::DafnyCallEvent { input, output } => output, - DafnyCallEvent::_PhantomVariant(..) => panic!(), - } - } - } - - impl ::std::fmt::Debug - for DafnyCallEvent - { - fn fmt(&self, f: &mut ::std::fmt::Formatter) -> std::fmt::Result { - ::dafny_runtime::DafnyPrint::fmt_print(self, f, true) - } - } - - impl ::dafny_runtime::DafnyPrint - for DafnyCallEvent - { - fn fmt_print( - &self, - _formatter: &mut ::std::fmt::Formatter, - _in_seq: bool, - ) -> std::fmt::Result { - match self { - DafnyCallEvent::DafnyCallEvent { input, output } => { - write!(_formatter, "r#_simple_dtypes_dtimestamp_dinternaldafny_dtypes.DafnyCallEvent.DafnyCallEvent(")?; - ::dafny_runtime::DafnyPrint::fmt_print(input, _formatter, false)?; - write!(_formatter, ", ")?; - ::dafny_runtime::DafnyPrint::fmt_print(output, _formatter, false)?; - write!(_formatter, ")")?; - Ok(()) - } - DafnyCallEvent::_PhantomVariant(..) => { - panic!() - } - } - } - } - - impl Eq - for DafnyCallEvent - { - } - - impl< - I: ::dafny_runtime::DafnyType + ::std::hash::Hash, - O: ::dafny_runtime::DafnyType + ::std::hash::Hash, - > ::std::hash::Hash for DafnyCallEvent - { - fn hash<_H: ::std::hash::Hasher>(&self, _state: &mut _H) { - match self { - DafnyCallEvent::DafnyCallEvent { input, output } => { - input.hash(_state); - output.hash(_state) - } - DafnyCallEvent::_PhantomVariant(..) => { - panic!() - } - } - } - } - - impl< - I: ::dafny_runtime::DafnyType + ::std::default::Default, - O: ::dafny_runtime::DafnyType + ::std::default::Default, - > ::std::default::Default for DafnyCallEvent - { - fn default() -> DafnyCallEvent { - DafnyCallEvent::DafnyCallEvent { - input: ::std::default::Default::default(), - output: ::std::default::Default::default(), - } - } - } - - impl - ::std::convert::AsRef> for &DafnyCallEvent - { - fn as_ref(&self) -> Self { - self - } - } - - #[derive(PartialEq, Clone)] - pub enum GetTimestampInput { - GetTimestampInput { - value: ::std::rc::Rc< - super::r#_Wrappers_Compile::Option< - ::dafny_runtime::Sequence<::dafny_runtime::DafnyCharUTF16>, - >, - >, - }, - } - - impl GetTimestampInput { - pub fn value( - &self, - ) -> &::std::rc::Rc< - super::r#_Wrappers_Compile::Option< - ::dafny_runtime::Sequence<::dafny_runtime::DafnyCharUTF16>, - >, - > { - match self { - GetTimestampInput::GetTimestampInput { value } => value, - } - } - } - - impl ::std::fmt::Debug for GetTimestampInput { - fn fmt(&self, f: &mut ::std::fmt::Formatter) -> std::fmt::Result { - ::dafny_runtime::DafnyPrint::fmt_print(self, f, true) - } - } - - impl ::dafny_runtime::DafnyPrint for GetTimestampInput { - fn fmt_print( - &self, - _formatter: &mut ::std::fmt::Formatter, - _in_seq: bool, - ) -> std::fmt::Result { - match self { - GetTimestampInput::GetTimestampInput { value } => { - write!(_formatter, "r#_simple_dtypes_dtimestamp_dinternaldafny_dtypes.GetTimestampInput.GetTimestampInput(")?; - ::dafny_runtime::DafnyPrint::fmt_print(value, _formatter, false)?; - write!(_formatter, ")")?; - Ok(()) - } - } - } - } - - impl Eq for GetTimestampInput {} - - impl ::std::hash::Hash for GetTimestampInput { - fn hash<_H: ::std::hash::Hasher>(&self, _state: &mut _H) { - match self { - GetTimestampInput::GetTimestampInput { value } => value.hash(_state), - } - } - } - - impl ::std::default::Default for GetTimestampInput { - fn default() -> GetTimestampInput { - GetTimestampInput::GetTimestampInput { - value: ::std::default::Default::default(), - } - } - } - - impl ::std::convert::AsRef for &GetTimestampInput { - fn as_ref(&self) -> Self { - self - } - } - - #[derive(PartialEq, Clone)] - pub enum GetTimestampOutput { - GetTimestampOutput { - value: ::std::rc::Rc< - super::r#_Wrappers_Compile::Option< - ::dafny_runtime::Sequence<::dafny_runtime::DafnyCharUTF16>, - >, - >, - }, - } - - impl GetTimestampOutput { - pub fn value( - &self, - ) -> &::std::rc::Rc< - super::r#_Wrappers_Compile::Option< - ::dafny_runtime::Sequence<::dafny_runtime::DafnyCharUTF16>, - >, - > { - match self { - GetTimestampOutput::GetTimestampOutput { value } => value, - } - } - } - - impl ::std::fmt::Debug for GetTimestampOutput { - fn fmt(&self, f: &mut ::std::fmt::Formatter) -> std::fmt::Result { - ::dafny_runtime::DafnyPrint::fmt_print(self, f, true) - } - } - - impl ::dafny_runtime::DafnyPrint for GetTimestampOutput { - fn fmt_print( - &self, - _formatter: &mut ::std::fmt::Formatter, - _in_seq: bool, - ) -> std::fmt::Result { - match self { - GetTimestampOutput::GetTimestampOutput { value } => { - write!(_formatter, "r#_simple_dtypes_dtimestamp_dinternaldafny_dtypes.GetTimestampOutput.GetTimestampOutput(")?; - ::dafny_runtime::DafnyPrint::fmt_print(value, _formatter, false)?; - write!(_formatter, ")")?; - Ok(()) - } - } - } - } - - impl Eq for GetTimestampOutput {} - - impl ::std::hash::Hash for GetTimestampOutput { - fn hash<_H: ::std::hash::Hasher>(&self, _state: &mut _H) { - match self { - GetTimestampOutput::GetTimestampOutput { value } => value.hash(_state), - } - } - } - - impl ::std::default::Default for GetTimestampOutput { - fn default() -> GetTimestampOutput { - GetTimestampOutput::GetTimestampOutput { - value: ::std::default::Default::default(), - } - } - } - - impl ::std::convert::AsRef for &GetTimestampOutput { - fn as_ref(&self) -> Self { - self - } - } - - #[derive(PartialEq, Clone)] - pub enum SimpleTimestampConfig { - SimpleTimestampConfig {}, - } - - impl SimpleTimestampConfig {} - - impl ::std::fmt::Debug for SimpleTimestampConfig { - fn fmt(&self, f: &mut ::std::fmt::Formatter) -> std::fmt::Result { - ::dafny_runtime::DafnyPrint::fmt_print(self, f, true) - } - } - - impl ::dafny_runtime::DafnyPrint for SimpleTimestampConfig { - fn fmt_print( - &self, - _formatter: &mut ::std::fmt::Formatter, - _in_seq: bool, - ) -> std::fmt::Result { - match self { - SimpleTimestampConfig::SimpleTimestampConfig {} => { - write!(_formatter, "r#_simple_dtypes_dtimestamp_dinternaldafny_dtypes.SimpleTimestampConfig.SimpleTimestampConfig")?; - Ok(()) - } - } - } - } - - impl Eq for SimpleTimestampConfig {} - - impl ::std::hash::Hash for SimpleTimestampConfig { - fn hash<_H: ::std::hash::Hasher>(&self, _state: &mut _H) { - match self { - SimpleTimestampConfig::SimpleTimestampConfig {} => {} - } - } - } - - impl ::std::default::Default for SimpleTimestampConfig { - fn default() -> SimpleTimestampConfig { - SimpleTimestampConfig::SimpleTimestampConfig {} - } - } - - impl ::std::convert::AsRef for &SimpleTimestampConfig { - fn as_ref(&self) -> Self { - self - } - } - - pub struct ISimpleTypesTimestampClientCallHistory {} - - impl ISimpleTypesTimestampClientCallHistory { - pub fn _allocate_rcmut() -> ::dafny_runtime::Object { - ::dafny_runtime::allocate_rcmut::() - } - } - - pub trait ISimpleTypesTimestampClient { - fn GetTimestamp( - &mut self, - input: &::std::rc::Rc< - super::r#_simple_dtypes_dtimestamp_dinternaldafny_dtypes::GetTimestampInput, - >, - ) -> ::std::rc::Rc< - super::r#_Wrappers_Compile::Result< - ::std::rc::Rc< - super::r#_simple_dtypes_dtimestamp_dinternaldafny_dtypes::GetTimestampOutput, - >, - ::std::rc::Rc, - >, - >; - } - - #[derive(PartialEq, Clone)] - pub enum Error { - CollectionOfErrors { - list: ::dafny_runtime::Sequence< - ::std::rc::Rc, - >, - message: ::dafny_runtime::Sequence<::dafny_runtime::DafnyCharUTF16>, - }, - Opaque { - obj: ::dafny_runtime::Object, - }, - } - - impl Error { - pub fn list( - &self, - ) -> &::dafny_runtime::Sequence< - ::std::rc::Rc, - > { - match self { - Error::CollectionOfErrors { list, message } => list, - Error::Opaque { obj } => panic!("field does not exist on this variant"), - } - } - pub fn message(&self) -> &::dafny_runtime::Sequence<::dafny_runtime::DafnyCharUTF16> { - match self { - Error::CollectionOfErrors { list, message } => message, - Error::Opaque { obj } => panic!("field does not exist on this variant"), - } - } - pub fn obj(&self) -> &::dafny_runtime::Object { - match self { - Error::CollectionOfErrors { list, message } => { - panic!("field does not exist on this variant") - } - Error::Opaque { obj } => obj, - } - } - } - - impl ::std::fmt::Debug for Error { - fn fmt(&self, f: &mut ::std::fmt::Formatter) -> std::fmt::Result { - ::dafny_runtime::DafnyPrint::fmt_print(self, f, true) - } - } - - impl ::dafny_runtime::DafnyPrint for Error { - fn fmt_print( - &self, - _formatter: &mut ::std::fmt::Formatter, - _in_seq: bool, - ) -> std::fmt::Result { - match self { - Error::CollectionOfErrors { list, message } => { - write!(_formatter, "r#_simple_dtypes_dtimestamp_dinternaldafny_dtypes.Error.CollectionOfErrors(")?; - ::dafny_runtime::DafnyPrint::fmt_print(list, _formatter, false)?; - write!(_formatter, ", ")?; - ::dafny_runtime::DafnyPrint::fmt_print(message, _formatter, false)?; - write!(_formatter, ")")?; - Ok(()) - } - Error::Opaque { obj } => { - write!( - _formatter, - "r#_simple_dtypes_dtimestamp_dinternaldafny_dtypes.Error.Opaque(" - )?; - ::dafny_runtime::DafnyPrint::fmt_print(obj, _formatter, false)?; - write!(_formatter, ")")?; - Ok(()) - } - } - } - } - - impl Eq for Error {} - - impl ::std::hash::Hash for Error { - fn hash<_H: ::std::hash::Hasher>(&self, _state: &mut _H) { - match self { - Error::CollectionOfErrors { list, message } => { - list.hash(_state); - message.hash(_state) - } - Error::Opaque { obj } => obj.hash(_state), - } - } - } - - impl ::std::default::Default for Error { - fn default() -> Error { - Error::CollectionOfErrors { - list: ::std::default::Default::default(), - message: ::std::default::Default::default(), - } - } - } - - impl ::std::convert::AsRef for &Error { - fn as_ref(&self) -> Self { - self - } - } - - pub type OpaqueError = - ::std::rc::Rc; -} -pub mod r#_SimpleTypesTimestampImpl_Compile { - pub struct _default {} - - impl _default { - pub fn _allocate_rcmut() -> ::dafny_runtime::Object { - ::dafny_runtime::allocate_rcmut::() - } - pub fn GetTimestamp( - config: &::std::rc::Rc, - input: &::std::rc::Rc< - super::r#_simple_dtypes_dtimestamp_dinternaldafny_dtypes::GetTimestampInput, - >, - ) -> ::std::rc::Rc< - super::r#_Wrappers_Compile::Result< - ::std::rc::Rc< - super::r#_simple_dtypes_dtimestamp_dinternaldafny_dtypes::GetTimestampOutput, - >, - ::std::rc::Rc, - >, - > { -<<<<<<<< HEAD:TestModels/SimpleTypes/SimpleBoolean/runtimes/rust/src/implementation_from_dafny.rs - let mut output = ::dafny_runtime::MaybePlacebo::<::std::rc::Rc, ::std::rc::Rc>>>::new(); - if !matches!( - input.value().as_ref(), - super::r#_Wrappers_Compile::Option::Some { .. } - ) { - panic!("Halt") - }; - if !(input.value().value().clone() == true || input.value().value().clone() == false) { - panic!("Halt") - }; - let mut res: ::std::rc::Rc = ::std::rc::Rc::new(super::r#_simple_dtypes_dboolean_dinternaldafny_dtypes::GetBooleanOutput::GetBooleanOutput { -======== - let mut output = ::dafny_runtime::MaybePlacebo::<::std::rc::Rc, ::std::rc::Rc>>>::new(); - let mut res: ::std::rc::Rc = ::std::rc::Rc::new(super::r#_simple_dtypes_dtimestamp_dinternaldafny_dtypes::GetTimestampOutput::GetTimestampOutput { ->>>>>>>> c902dcd80715925a3535f32ac280ae7ee0e7bd50:TestModels/SimpleTypes/SimpleTimestamp/runtimes/rust/dafny_impl/src/implementation_from_dafny.rs - value: input.value().clone() - }); - res = ::std::rc::Rc::new(super::r#_simple_dtypes_dtimestamp_dinternaldafny_dtypes::GetTimestampOutput::GetTimestampOutput { - value: input.value().clone() - }); -<<<<<<<< HEAD:TestModels/SimpleTypes/SimpleBoolean/runtimes/rust/src/implementation_from_dafny.rs - if !(res.value().value().clone() == true || res.value().value().clone() == false) { - panic!("Halt") - }; - if !(input.value().value().clone() == res.value().value().clone()) { - panic!("Halt") - }; - output = ::dafny_runtime::MaybePlacebo::from(::std::rc::Rc::new( - super::r#_Wrappers_Compile::Result::< - ::std::rc::Rc< - super::r#_simple_dtypes_dboolean_dinternaldafny_dtypes::GetBooleanOutput, - >, - ::std::rc::Rc, - >::Success { - value: res.clone(), - }, - )); -======== - output = ::dafny_runtime::MaybePlacebo::from(::std::rc::Rc::new(super::r#_Wrappers_Compile::Result::<::std::rc::Rc, ::std::rc::Rc>::Success { - value: res.clone() - })); ->>>>>>>> c902dcd80715925a3535f32ac280ae7ee0e7bd50:TestModels/SimpleTypes/SimpleTimestamp/runtimes/rust/dafny_impl/src/implementation_from_dafny.rs - return output.read(); - return output.read(); - } - } - - #[derive(PartialEq, Clone)] - pub enum Config { - Config {}, - } - - impl Config {} - - impl ::std::fmt::Debug for Config { - fn fmt(&self, f: &mut ::std::fmt::Formatter) -> std::fmt::Result { - ::dafny_runtime::DafnyPrint::fmt_print(self, f, true) - } - } - - impl ::dafny_runtime::DafnyPrint for Config { - fn fmt_print( - &self, - _formatter: &mut ::std::fmt::Formatter, - _in_seq: bool, - ) -> std::fmt::Result { - match self { - Config::Config {} => { - write!( - _formatter, - "r#_SimpleTypesTimestampImpl_Compile.Config.Config" - )?; - Ok(()) - } - } - } - } - - impl Eq for Config {} - - impl ::std::hash::Hash for Config { - fn hash<_H: ::std::hash::Hasher>(&self, _state: &mut _H) { - match self { - Config::Config {} => {} - } - } - } - - impl ::std::default::Default for Config { - fn default() -> Config { - Config::Config {} - } - } - - impl ::std::convert::AsRef for &Config { - fn as_ref(&self) -> Self { - self - } - } -} -pub mod r#_simple_dtypes_dtimestamp_dinternaldafny { - pub struct _default {} - - impl _default { - pub fn _allocate_rcmut() -> ::dafny_runtime::Object { - ::dafny_runtime::allocate_rcmut::() - } - pub fn DefaultSimpleTimestampConfig() -> ::std::rc::Rc< - super::r#_simple_dtypes_dtimestamp_dinternaldafny_dtypes::SimpleTimestampConfig, - > { - ::std::rc::Rc::new(super::r#_simple_dtypes_dtimestamp_dinternaldafny_dtypes::SimpleTimestampConfig::SimpleTimestampConfig {}) - } - pub fn SimpleTimestamp( - config: &::std::rc::Rc< - super::r#_simple_dtypes_dtimestamp_dinternaldafny_dtypes::SimpleTimestampConfig, - >, - ) -> ::std::rc::Rc< - super::r#_Wrappers_Compile::Result< - ::dafny_runtime::Object< - super::r#_simple_dtypes_dtimestamp_dinternaldafny::SimpleTimestampClient, - >, - ::std::rc::Rc, - >, - > { - let mut res = ::dafny_runtime::MaybePlacebo::<::std::rc::Rc, ::std::rc::Rc>>>::new(); - let mut client = ::dafny_runtime::MaybePlacebo::< - ::dafny_runtime::Object< - super::r#_simple_dtypes_dtimestamp_dinternaldafny::SimpleTimestampClient, - >, - >::new(); - let mut _nw0: ::dafny_runtime::Object = super::r#_simple_dtypes_dtimestamp_dinternaldafny::SimpleTimestampClient::_allocate_rcmut(); - super::r#_simple_dtypes_dtimestamp_dinternaldafny::SimpleTimestampClient::_ctor( - &_nw0, - &::std::rc::Rc::new(super::r#_SimpleTypesTimestampImpl_Compile::Config::Config {}), - ); - client = ::dafny_runtime::MaybePlacebo::from(_nw0.clone()); - res = ::dafny_runtime::MaybePlacebo::from(::std::rc::Rc::new( - super::r#_Wrappers_Compile::Result::< - ::dafny_runtime::Object< - super::r#_simple_dtypes_dtimestamp_dinternaldafny::SimpleTimestampClient, - >, - ::std::rc::Rc, - >::Success { - value: client.read(), - }, - )); - return res.read(); - return res.read(); - } - pub fn CreateSuccessOfClient(client: &::dafny_runtime::Object) -> ::std::rc::Rc, ::std::rc::Rc>>{ - ::std::rc::Rc::new(super::r#_Wrappers_Compile::Result::<::dafny_runtime::Object, ::std::rc::Rc>::Success { - value: client.clone() - }) - } - pub fn CreateFailureOfError(error: &::std::rc::Rc) -> ::std::rc::Rc, ::std::rc::Rc>>{ - ::std::rc::Rc::new(super::r#_Wrappers_Compile::Result::<::dafny_runtime::Object, ::std::rc::Rc>::Failure { - error: error.clone() - }) - } - } - - pub struct SimpleTimestampClient { - pub r#__i_config: ::std::rc::Rc, - } - - impl SimpleTimestampClient { - pub fn _allocate_rcmut() -> ::dafny_runtime::Object { - ::dafny_runtime::allocate_rcmut::() - } - pub fn _ctor( - this: &::dafny_runtime::Object, - config: &::std::rc::Rc, - ) -> () { - let mut _set__i_config: bool = false; - ::dafny_runtime::update_field_uninit_rcmut!( - this.clone(), - r#__i_config, - _set__i_config, - config.clone() - ); - return (); - } - pub fn config(&self) -> ::std::rc::Rc { - self.r#__i_config.clone() - } - } - - impl super::r#_simple_dtypes_dtimestamp_dinternaldafny_dtypes::ISimpleTypesTimestampClient - for super::r#_simple_dtypes_dtimestamp_dinternaldafny::SimpleTimestampClient - { - fn GetTimestamp( - &mut self, - input: &::std::rc::Rc< - super::r#_simple_dtypes_dtimestamp_dinternaldafny_dtypes::GetTimestampInput, - >, - ) -> ::std::rc::Rc< - super::r#_Wrappers_Compile::Result< - ::std::rc::Rc< - super::r#_simple_dtypes_dtimestamp_dinternaldafny_dtypes::GetTimestampOutput, - >, - ::std::rc::Rc, - >, - > { - let mut output = ::dafny_runtime::MaybePlacebo::<::std::rc::Rc, ::std::rc::Rc>>>::new(); - let mut _out0 = ::dafny_runtime::MaybePlacebo::<::std::rc::Rc, ::std::rc::Rc>>>::new(); - _out0 = ::dafny_runtime::MaybePlacebo::from( - super::r#_SimpleTypesTimestampImpl_Compile::_default::GetTimestamp( - &self.config(), - input, - ), - ); - output = ::dafny_runtime::MaybePlacebo::from(_out0.read()); - return output.read(); - } - } -} -pub mod _module {} From 63f9c3b360269973b9da125b1cbfa5840e3ddadb Mon Sep 17 00:00:00 2001 From: Robin Salkeld Date: Tue, 9 Jul 2024 15:30:55 -0700 Subject: [PATCH 27/53] Mostly fix things up post-merge --- .../SimpleBoolean/runtimes/rust/src/client.rs | 6 +- .../rust/src/conversions/get_boolean.rs | 8 +- .../runtimes/rust/tests/tests_from_dafny.rs | 146 ++++++++---------- .../rust/tests/tests_from_dafny/_wrapped.rs | 7 + 4 files changed, 81 insertions(+), 86 deletions(-) diff --git a/TestModels/SimpleTypes/SimpleBoolean/runtimes/rust/src/client.rs b/TestModels/SimpleTypes/SimpleBoolean/runtimes/rust/src/client.rs index 89478da537..7a4f6c0423 100644 --- a/TestModels/SimpleTypes/SimpleBoolean/runtimes/rust/src/client.rs +++ b/TestModels/SimpleTypes/SimpleBoolean/runtimes/rust/src/client.rs @@ -4,7 +4,7 @@ use aws_smithy_types::error::operation::BuildError; #[derive(::std::clone::Clone, ::std::fmt::Debug)] pub struct Client { - pub(crate) dafny_client: ::dafny_runtime::Object + pub(crate) dafny_client: ::dafny_runtime::Object } impl Client { @@ -14,12 +14,12 @@ impl Client { conf: crate::types::simple_boolean_config::SimpleBooleanConfig, ) -> Result { let inner = - ::simple_boolean_dafny::_simple_dtypes_dboolean_dinternaldafny::_default::SimpleBoolean( + crate::implementation_from_dafny::_simple_dtypes_dboolean_dinternaldafny::_default::SimpleBoolean( &crate::conversions::simple_boolean_config::_simple_boolean_config::to_dafny(conf), ); if matches!( inner.as_ref(), - ::simple_boolean_dafny::_Wrappers_Compile::Result::Failure { .. } + crate::implementation_from_dafny::_Wrappers_Compile::Result::Failure { .. } ) { // TODO: convert error - the potential types are not modeled! return Err(BuildError::other( diff --git a/TestModels/SimpleTypes/SimpleBoolean/runtimes/rust/src/conversions/get_boolean.rs b/TestModels/SimpleTypes/SimpleBoolean/runtimes/rust/src/conversions/get_boolean.rs index 065d3ad3c7..d4f59b2fc0 100644 --- a/TestModels/SimpleTypes/SimpleBoolean/runtimes/rust/src/conversions/get_boolean.rs +++ b/TestModels/SimpleTypes/SimpleBoolean/runtimes/rust/src/conversions/get_boolean.rs @@ -5,21 +5,21 @@ use std::any::Any; #[allow(dead_code)] pub fn to_dafny_error( value: crate::operation::get_boolean::GetBooleanError, -) -> ::std::rc::Rc<::simple_boolean_dafny::r#_simple_dtypes_dboolean_dinternaldafny_dtypes::Error> { +) -> ::std::rc::Rc { match value { crate::operation::get_boolean::GetBooleanError::Unhandled(unhandled) => - ::std::rc::Rc::new(::simple_boolean_dafny::r#_simple_dtypes_dboolean_dinternaldafny_dtypes::Error::Opaque { obj: ::dafny_runtime::upcast_object()(::dafny_runtime::object::new(unhandled)) }) + ::std::rc::Rc::new(crate::implementation_from_dafny::r#_simple_dtypes_dboolean_dinternaldafny_dtypes::Error::Opaque { obj: ::dafny_runtime::upcast_object()(::dafny_runtime::object::new(unhandled)) }) } } #[allow(dead_code)] pub fn from_dafny_error( dafny_value: ::std::rc::Rc< - ::simple_boolean_dafny::r#_simple_dtypes_dboolean_dinternaldafny_dtypes::Error, + crate::implementation_from_dafny::r#_simple_dtypes_dboolean_dinternaldafny_dtypes::Error, >, ) -> crate::operation::get_boolean::GetBooleanError { // TODO: Losing information here, but we have to figure out how to wrap an arbitrary Dafny value as std::error::Error - if matches!(&dafny_value.as_ref(), ::simple_boolean_dafny::r#_simple_dtypes_dboolean_dinternaldafny_dtypes::Error::CollectionOfErrors { .. }) { + if matches!(&dafny_value.as_ref(), crate::implementation_from_dafny::r#_simple_dtypes_dboolean_dinternaldafny_dtypes::Error::CollectionOfErrors { .. }) { let error_message = "TODO: can't get message yet"; crate::operation::get_boolean::GetBooleanError::generic(::aws_smithy_types::error::metadata::ErrorMetadata::builder().message(error_message).build()) } else { diff --git a/TestModels/SimpleTypes/SimpleBoolean/runtimes/rust/tests/tests_from_dafny.rs b/TestModels/SimpleTypes/SimpleBoolean/runtimes/rust/tests/tests_from_dafny.rs index abc7273e8b..3304d282b1 100644 --- a/TestModels/SimpleTypes/SimpleBoolean/runtimes/rust/tests/tests_from_dafny.rs +++ b/TestModels/SimpleTypes/SimpleBoolean/runtimes/rust/tests/tests_from_dafny.rs @@ -3,12 +3,13 @@ use simple_boolean::implementation_from_dafny::*; use simple_boolean::*; mod _wrapped; + pub mod r#_simple_dtypes_dboolean_dinternaldafny_dwrapped { pub struct _default {} impl _default { - pub fn _allocate_rcmut() -> ::dafny_runtime::Object { - ::dafny_runtime::allocate_rcmut::() + pub fn _allocate_object() -> ::dafny_runtime::Object { + ::dafny_runtime::allocate_object::() } pub fn WrappedDefaultSimpleBooleanConfig() -> ::std::rc::Rc< super::r#_simple_dtypes_dboolean_dinternaldafny_dtypes::SimpleBooleanConfig, @@ -16,20 +17,21 @@ pub mod r#_simple_dtypes_dboolean_dinternaldafny_dwrapped { ::std::rc::Rc::new(super::r#_simple_dtypes_dboolean_dinternaldafny_dtypes::SimpleBooleanConfig::SimpleBooleanConfig {}) } } + + impl ::dafny_runtime::UpcastObject + for super::r#_simple_dtypes_dboolean_dinternaldafny_dwrapped::_default + { + ::dafny_runtime::UpcastObjectFn!(dyn::std::any::Any); + } } pub mod r#_SimpleBooleanImplTest_Compile { pub struct _default {} impl _default { - pub fn _allocate_rcmut() -> ::dafny_runtime::Object { - ::dafny_runtime::allocate_rcmut::() + pub fn _allocate_object() -> ::dafny_runtime::Object { + ::dafny_runtime::allocate_object::() } pub fn GetBooleanTrue() -> () { - let mut client = ::dafny_runtime::MaybePlacebo::< - ::dafny_runtime::Object< - super::r#_simple_dtypes_dboolean_dinternaldafny::SimpleBooleanClient, - >, - >::new(); let mut valueOrError0 = ::dafny_runtime::MaybePlacebo::< ::std::rc::Rc< super::r#_Wrappers_Compile::Result< @@ -59,18 +61,13 @@ pub mod r#_SimpleBooleanImplTest_Compile { if !(!valueOrError0.read().IsFailure()) { panic!("Halt") }; - client = ::dafny_runtime::MaybePlacebo::from( - valueOrError0.read().Extract().clone(), /* Coercion from T to ::dafny_runtime::Object not yet implemented */ - ); - super::r#_SimpleBooleanImplTest_Compile::_default::TestGetBooleanTrue(&::dafny_runtime::UpcastTo::<::dafny_runtime::Object>::upcast_to(client.read())); + let mut client: ::dafny_runtime::Object< + super::r#_simple_dtypes_dboolean_dinternaldafny::SimpleBooleanClient, + > = valueOrError0.read().Extract(); + super::r#_SimpleBooleanImplTest_Compile::_default::TestGetBooleanTrue(&::dafny_runtime::upcast_object::()(client.clone())); return (); } pub fn GetBooleanFalse() -> () { - let mut client = ::dafny_runtime::MaybePlacebo::< - ::dafny_runtime::Object< - super::r#_simple_dtypes_dboolean_dinternaldafny::SimpleBooleanClient, - >, - >::new(); let mut valueOrError0 = ::dafny_runtime::MaybePlacebo::< ::std::rc::Rc< super::r#_Wrappers_Compile::Result< @@ -100,23 +97,18 @@ pub mod r#_SimpleBooleanImplTest_Compile { if !(!valueOrError0.read().IsFailure()) { panic!("Halt") }; - client = ::dafny_runtime::MaybePlacebo::from( - valueOrError0.read().Extract().clone(), /* Coercion from T to ::dafny_runtime::Object not yet implemented */ - ); - super::r#_SimpleBooleanImplTest_Compile::_default::TestGetBooleanFalse(&::dafny_runtime::UpcastTo::<::dafny_runtime::Object>::upcast_to(client.read())); + let mut client: ::dafny_runtime::Object< + super::r#_simple_dtypes_dboolean_dinternaldafny::SimpleBooleanClient, + > = valueOrError0.read().Extract(); + super::r#_SimpleBooleanImplTest_Compile::_default::TestGetBooleanFalse(&::dafny_runtime::upcast_object::()(client.clone())); return (); } pub fn TestGetBooleanTrue( client: &::dafny_runtime::Object, ) -> () { - let mut ret = ::dafny_runtime::MaybePlacebo::< - ::std::rc::Rc< - super::r#_simple_dtypes_dboolean_dinternaldafny_dtypes::GetBooleanOutput, - >, - >::new(); let mut valueOrError0 = ::dafny_runtime::MaybePlacebo::<::std::rc::Rc, ::std::rc::Rc>>>::new(); let mut _out2 = ::dafny_runtime::MaybePlacebo::<::std::rc::Rc, ::std::rc::Rc>>>::new(); - _out2 = ::dafny_runtime::MaybePlacebo::from(::dafny_runtime::md!(client.clone()).GetBoolean(&::std::rc::Rc::new(super::r#_simple_dtypes_dboolean_dinternaldafny_dtypes::GetBooleanInput::GetBooleanInput { + _out2 = ::dafny_runtime::MaybePlacebo::from(super::r#_simple_dtypes_dboolean_dinternaldafny_dtypes::ISimpleTypesBooleanClient::GetBoolean(::dafny_runtime::md!(client.clone()), &::std::rc::Rc::new(super::r#_simple_dtypes_dboolean_dinternaldafny_dtypes::GetBooleanInput::GetBooleanInput { value: ::std::rc::Rc::new(super::r#_Wrappers_Compile::Option::::Some { value: true }) @@ -125,30 +117,21 @@ pub mod r#_SimpleBooleanImplTest_Compile { if !(!valueOrError0.read().IsFailure()) { panic!("Halt") }; - ret = ::dafny_runtime::MaybePlacebo::from( - valueOrError0.read().Extract(), /* Coercion from T to ::std::rc::Rc not yet implemented */ - ); - if !((ret.read().value().UnwrapOr( - &false, /* Coercion from bool to T not yet implemented */ - )/* Coercion from T to bool not yet implemented */) - == true) - { + let mut ret: ::std::rc::Rc< + super::r#_simple_dtypes_dboolean_dinternaldafny_dtypes::GetBooleanOutput, + > = valueOrError0.read().Extract(); + if !(ret.value().UnwrapOr(&false) == true) { panic!("Halt") }; - print!("{}", ::dafny_runtime::DafnyPrintWrapper(&ret.read())); + print!("{}", ::dafny_runtime::DafnyPrintWrapper(&ret)); return (); } pub fn TestGetBooleanFalse( client: &::dafny_runtime::Object, ) -> () { - let mut ret = ::dafny_runtime::MaybePlacebo::< - ::std::rc::Rc< - super::r#_simple_dtypes_dboolean_dinternaldafny_dtypes::GetBooleanOutput, - >, - >::new(); let mut valueOrError0 = ::dafny_runtime::MaybePlacebo::<::std::rc::Rc, ::std::rc::Rc>>>::new(); let mut _out3 = ::dafny_runtime::MaybePlacebo::<::std::rc::Rc, ::std::rc::Rc>>>::new(); - _out3 = ::dafny_runtime::MaybePlacebo::from(::dafny_runtime::md!(client.clone()).GetBoolean(&::std::rc::Rc::new(super::r#_simple_dtypes_dboolean_dinternaldafny_dtypes::GetBooleanInput::GetBooleanInput { + _out3 = ::dafny_runtime::MaybePlacebo::from(super::r#_simple_dtypes_dboolean_dinternaldafny_dtypes::ISimpleTypesBooleanClient::GetBoolean(::dafny_runtime::md!(client.clone()), &::std::rc::Rc::new(super::r#_simple_dtypes_dboolean_dinternaldafny_dtypes::GetBooleanInput::GetBooleanInput { value: ::std::rc::Rc::new(super::r#_Wrappers_Compile::Option::::Some { value: false }) @@ -157,30 +140,31 @@ pub mod r#_SimpleBooleanImplTest_Compile { if !(!valueOrError0.read().IsFailure()) { panic!("Halt") }; - ret = ::dafny_runtime::MaybePlacebo::from( - valueOrError0.read().Extract(), /* Coercion from T to ::std::rc::Rc not yet implemented */ - ); - if !((ret.read().value().UnwrapOr( - &true, /* Coercion from bool to T not yet implemented */ - )/* Coercion from T to bool not yet implemented */) - == false) - { + let mut ret: ::std::rc::Rc< + super::r#_simple_dtypes_dboolean_dinternaldafny_dtypes::GetBooleanOutput, + > = valueOrError0.read().Extract(); + if !(ret.value().UnwrapOr(&true) == false) { panic!("Halt") }; - print!("{}", ::dafny_runtime::DafnyPrintWrapper(&ret.read())); + print!("{}", ::dafny_runtime::DafnyPrintWrapper(&ret)); return (); } } + + impl ::dafny_runtime::UpcastObject + for super::r#_SimpleBooleanImplTest_Compile::_default + { + ::dafny_runtime::UpcastObjectFn!(dyn::std::any::Any); + } } pub mod r#_WrappedSimpleTypesBooleanTest_Compile { pub struct _default {} impl _default { - pub fn _allocate_rcmut() -> ::dafny_runtime::Object { - ::dafny_runtime::allocate_rcmut::() + pub fn _allocate_object() -> ::dafny_runtime::Object { + ::dafny_runtime::allocate_object::() } pub fn GetBooleanTrue() -> () { - let mut client = ::dafny_runtime::MaybePlacebo::<::dafny_runtime::Object>::new(); let mut valueOrError0 = ::dafny_runtime::MaybePlacebo::<::std::rc::Rc, ::std::rc::Rc>>>::new(); let mut _out4 = ::dafny_runtime::MaybePlacebo::<::std::rc::Rc, ::std::rc::Rc>>>::new(); _out4 = ::dafny_runtime::MaybePlacebo::from(super::r#_simple_dtypes_dboolean_dinternaldafny_dwrapped::_default::WrappedSimpleBoolean(&super::r#_simple_dtypes_dboolean_dinternaldafny_dwrapped::_default::WrappedDefaultSimpleBooleanConfig())); @@ -188,14 +172,11 @@ pub mod r#_WrappedSimpleTypesBooleanTest_Compile { if !(!valueOrError0.read().IsFailure()) { panic!("Halt") }; - client = ::dafny_runtime::MaybePlacebo::from( - valueOrError0.read().Extract().clone(), /* Coercion from T to ::dafny_runtime::Object not yet implemented */ - ); - super::r#_SimpleBooleanImplTest_Compile::_default::TestGetBooleanTrue(&client.read()); + let mut client: ::dafny_runtime::Object = valueOrError0.read().Extract(); + super::r#_SimpleBooleanImplTest_Compile::_default::TestGetBooleanTrue(&client); return (); } pub fn GetBooleanFalse() -> () { - let mut client = ::dafny_runtime::MaybePlacebo::<::dafny_runtime::Object>::new(); let mut valueOrError0 = ::dafny_runtime::MaybePlacebo::<::std::rc::Rc, ::std::rc::Rc>>>::new(); let mut _out5 = ::dafny_runtime::MaybePlacebo::<::std::rc::Rc, ::std::rc::Rc>>>::new(); _out5 = ::dafny_runtime::MaybePlacebo::from(super::r#_simple_dtypes_dboolean_dinternaldafny_dwrapped::_default::WrappedSimpleBoolean(&super::r#_simple_dtypes_dboolean_dinternaldafny_dwrapped::_default::WrappedDefaultSimpleBooleanConfig())); @@ -203,78 +184,81 @@ pub mod r#_WrappedSimpleTypesBooleanTest_Compile { if !(!valueOrError0.read().IsFailure()) { panic!("Halt") }; - client = ::dafny_runtime::MaybePlacebo::from( - valueOrError0.read().Extract().clone(), /* Coercion from T to ::dafny_runtime::Object not yet implemented */ - ); - super::r#_SimpleBooleanImplTest_Compile::_default::TestGetBooleanFalse(&client.read()); + let mut client: ::dafny_runtime::Object = valueOrError0.read().Extract(); + super::r#_SimpleBooleanImplTest_Compile::_default::TestGetBooleanFalse(&client); return (); } } + + impl ::dafny_runtime::UpcastObject + for super::r#_WrappedSimpleTypesBooleanTest_Compile::_default + { + ::dafny_runtime::UpcastObjectFn!(dyn::std::any::Any); + } } pub mod _module { pub struct _default {} impl _default { - pub fn _allocate_rcmut() -> ::dafny_runtime::Object { - ::dafny_runtime::allocate_rcmut::() + pub fn _allocate_object() -> ::dafny_runtime::Object { + ::dafny_runtime::allocate_object::() } pub fn _Test__Main_() -> () { let mut success: bool = true; - success = true; print!( "{}", ::dafny_runtime::DafnyPrintWrapper(&::dafny_runtime::string_utf16_of( - "SimpleBooleanImplTest.GetBooleanTrue: " + r#"SimpleBooleanImplTest.GetBooleanTrue: "# )) ); super::r#_SimpleBooleanImplTest_Compile::_default::GetBooleanTrue(); print!( "{}", ::dafny_runtime::DafnyPrintWrapper(&::dafny_runtime::string_utf16_of( - "PASSED -" + r#"PASSED +"# )) ); print!( "{}", ::dafny_runtime::DafnyPrintWrapper(&::dafny_runtime::string_utf16_of( - "SimpleBooleanImplTest.GetBooleanFalse: " + r#"SimpleBooleanImplTest.GetBooleanFalse: "# )) ); super::r#_SimpleBooleanImplTest_Compile::_default::GetBooleanFalse(); print!( "{}", ::dafny_runtime::DafnyPrintWrapper(&::dafny_runtime::string_utf16_of( - "PASSED -" + r#"PASSED +"# )) ); print!( "{}", ::dafny_runtime::DafnyPrintWrapper(&::dafny_runtime::string_utf16_of( - "WrappedSimpleTypesBooleanTest.GetBooleanTrue: " + r#"WrappedSimpleTypesBooleanTest.GetBooleanTrue: "# )) ); super::r#_WrappedSimpleTypesBooleanTest_Compile::_default::GetBooleanTrue(); print!( "{}", ::dafny_runtime::DafnyPrintWrapper(&::dafny_runtime::string_utf16_of( - "PASSED -" + r#"PASSED +"# )) ); print!( "{}", ::dafny_runtime::DafnyPrintWrapper(&::dafny_runtime::string_utf16_of( - "WrappedSimpleTypesBooleanTest.GetBooleanFalse: " + r#"WrappedSimpleTypesBooleanTest.GetBooleanFalse: "# )) ); super::r#_WrappedSimpleTypesBooleanTest_Compile::_default::GetBooleanFalse(); print!( "{}", ::dafny_runtime::DafnyPrintWrapper(&::dafny_runtime::string_utf16_of( - "PASSED -" + r#"PASSED +"# )) ); if !success { @@ -283,6 +267,10 @@ pub mod _module { return (); } } + + impl ::dafny_runtime::UpcastObject for super::_module::_default { + ::dafny_runtime::UpcastObjectFn!(dyn::std::any::Any); + } } fn main() { _module::_default::_Test__Main_(); diff --git a/TestModels/SimpleTypes/SimpleBoolean/runtimes/rust/tests/tests_from_dafny/_wrapped.rs b/TestModels/SimpleTypes/SimpleBoolean/runtimes/rust/tests/tests_from_dafny/_wrapped.rs index 14279d3d61..9eede19f89 100644 --- a/TestModels/SimpleTypes/SimpleBoolean/runtimes/rust/tests/tests_from_dafny/_wrapped.rs +++ b/TestModels/SimpleTypes/SimpleBoolean/runtimes/rust/tests/tests_from_dafny/_wrapped.rs @@ -1,11 +1,18 @@ +use std::any::Any; + use crate::tests_from_dafny::*; use aws_smithy_types::error::operation::BuildError; +use dafny_runtime::UpcastObject; use simple_boolean::*; struct WrappedClient { wrapped: Client, } +impl UpcastObject for WrappedClient { + ::dafny_runtime::UpcastObjectFn!(dyn ::std::any::Any); +} + impl super::r#_simple_dtypes_dboolean_dinternaldafny_dtypes::ISimpleTypesBooleanClient for WrappedClient { From a3eee3fe22808532541c366978b814952d04434f Mon Sep 17 00:00:00 2001 From: Robin Salkeld Date: Tue, 9 Jul 2024 15:58:43 -0700 Subject: [PATCH 28/53] Fix file layout --- .../rust/tests/{tests_from_dafny.rs => tests_from_dafny/mod.rs} | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename TestModels/SimpleTypes/SimpleBoolean/runtimes/rust/tests/{tests_from_dafny.rs => tests_from_dafny/mod.rs} (100%) diff --git a/TestModels/SimpleTypes/SimpleBoolean/runtimes/rust/tests/tests_from_dafny.rs b/TestModels/SimpleTypes/SimpleBoolean/runtimes/rust/tests/tests_from_dafny/mod.rs similarity index 100% rename from TestModels/SimpleTypes/SimpleBoolean/runtimes/rust/tests/tests_from_dafny.rs rename to TestModels/SimpleTypes/SimpleBoolean/runtimes/rust/tests/tests_from_dafny/mod.rs From b8ab3629658f588ef9e3cddf7c238ec8c2baf64d Mon Sep 17 00:00:00 2001 From: Robin Salkeld Date: Wed, 10 Jul 2024 10:05:52 -0700 Subject: [PATCH 29/53] update patch file --- .../codegen-patches/rust/dafny-4.5.0.patch | 86 ++++++++++--------- 1 file changed, 45 insertions(+), 41 deletions(-) diff --git a/TestModels/SimpleTypes/SimpleBoolean/codegen-patches/rust/dafny-4.5.0.patch b/TestModels/SimpleTypes/SimpleBoolean/codegen-patches/rust/dafny-4.5.0.patch index 9973c302c6..276705969b 100644 --- a/TestModels/SimpleTypes/SimpleBoolean/codegen-patches/rust/dafny-4.5.0.patch +++ b/TestModels/SimpleTypes/SimpleBoolean/codegen-patches/rust/dafny-4.5.0.patch @@ -1,6 +1,6 @@ diff --git b/TestModels/SimpleTypes/SimpleBoolean/runtimes/rust/src/client.rs a/TestModels/SimpleTypes/SimpleBoolean/runtimes/rust/src/client.rs new file mode 100644 -index 00000000..89478da5 +index 00000000..7a4f6c04 --- /dev/null +++ a/TestModels/SimpleTypes/SimpleBoolean/runtimes/rust/src/client.rs @@ -0,0 +1,37 @@ @@ -10,7 +10,7 @@ index 00000000..89478da5 + +#[derive(::std::clone::Clone, ::std::fmt::Debug)] +pub struct Client { -+ pub(crate) dafny_client: ::dafny_runtime::Object ++ pub(crate) dafny_client: ::dafny_runtime::Object +} + +impl Client { @@ -20,12 +20,12 @@ index 00000000..89478da5 + conf: crate::types::simple_boolean_config::SimpleBooleanConfig, + ) -> Result { + let inner = -+ ::simple_boolean_dafny::_simple_dtypes_dboolean_dinternaldafny::_default::SimpleBoolean( ++ crate::implementation_from_dafny::_simple_dtypes_dboolean_dinternaldafny::_default::SimpleBoolean( + &crate::conversions::simple_boolean_config::_simple_boolean_config::to_dafny(conf), + ); + if matches!( + inner.as_ref(), -+ ::simple_boolean_dafny::_Wrappers_Compile::Result::Failure { .. } ++ crate::implementation_from_dafny::_Wrappers_Compile::Result::Failure { .. } + ) { + // TODO: convert error - the potential types are not modeled! + return Err(BuildError::other( @@ -72,7 +72,7 @@ index 00000000..c1acac7b +pub mod simple_boolean_config; diff --git b/TestModels/SimpleTypes/SimpleBoolean/runtimes/rust/src/conversions/get_boolean.rs a/TestModels/SimpleTypes/SimpleBoolean/runtimes/rust/src/conversions/get_boolean.rs new file mode 100644 -index 00000000..065d3ad3 +index 00000000..d4f59b2f --- /dev/null +++ a/TestModels/SimpleTypes/SimpleBoolean/runtimes/rust/src/conversions/get_boolean.rs @@ -0,0 +1,32 @@ @@ -83,21 +83,21 @@ index 00000000..065d3ad3 +#[allow(dead_code)] +pub fn to_dafny_error( + value: crate::operation::get_boolean::GetBooleanError, -+) -> ::std::rc::Rc<::simple_boolean_dafny::r#_simple_dtypes_dboolean_dinternaldafny_dtypes::Error> { ++) -> ::std::rc::Rc { + match value { + crate::operation::get_boolean::GetBooleanError::Unhandled(unhandled) => -+ ::std::rc::Rc::new(::simple_boolean_dafny::r#_simple_dtypes_dboolean_dinternaldafny_dtypes::Error::Opaque { obj: ::dafny_runtime::upcast_object()(::dafny_runtime::object::new(unhandled)) }) ++ ::std::rc::Rc::new(crate::implementation_from_dafny::r#_simple_dtypes_dboolean_dinternaldafny_dtypes::Error::Opaque { obj: ::dafny_runtime::upcast_object()(::dafny_runtime::object::new(unhandled)) }) + } +} + +#[allow(dead_code)] +pub fn from_dafny_error( + dafny_value: ::std::rc::Rc< -+ ::simple_boolean_dafny::r#_simple_dtypes_dboolean_dinternaldafny_dtypes::Error, ++ crate::implementation_from_dafny::r#_simple_dtypes_dboolean_dinternaldafny_dtypes::Error, + >, +) -> crate::operation::get_boolean::GetBooleanError { + // TODO: Losing information here, but we have to figure out how to wrap an arbitrary Dafny value as std::error::Error -+ if matches!(&dafny_value.as_ref(), ::simple_boolean_dafny::r#_simple_dtypes_dboolean_dinternaldafny_dtypes::Error::CollectionOfErrors { .. }) { ++ if matches!(&dafny_value.as_ref(), crate::implementation_from_dafny::r#_simple_dtypes_dboolean_dinternaldafny_dtypes::Error::CollectionOfErrors { .. }) { + let error_message = "TODO: can't get message yet"; + crate::operation::get_boolean::GetBooleanError::generic(::aws_smithy_types::error::metadata::ErrorMetadata::builder().message(error_message).build()) + } else { @@ -110,7 +110,7 @@ index 00000000..065d3ad3 +pub mod _get_boolean_output; diff --git b/TestModels/SimpleTypes/SimpleBoolean/runtimes/rust/src/conversions/get_boolean/_get_boolean_input.rs a/TestModels/SimpleTypes/SimpleBoolean/runtimes/rust/src/conversions/get_boolean/_get_boolean_input.rs new file mode 100644 -index 00000000..efd9d5f8 +index 00000000..27e4ef74 --- /dev/null +++ a/TestModels/SimpleTypes/SimpleBoolean/runtimes/rust/src/conversions/get_boolean/_get_boolean_input.rs @@ -0,0 +1,37 @@ @@ -119,13 +119,13 @@ index 00000000..efd9d5f8 +pub fn to_dafny( + value: crate::operation::get_boolean::GetBooleanInput, +) -> ::std::rc::Rc< -+ ::simple_boolean_dafny::r#_simple_dtypes_dboolean_dinternaldafny_dtypes::GetBooleanInput, ++ crate::implementation_from_dafny::r#_simple_dtypes_dboolean_dinternaldafny_dtypes::GetBooleanInput, +> { + let dafny_value = match value.value { -+ Some(b) => ::simple_boolean_dafny::_Wrappers_Compile::Option::Some { value: b }, -+ None => ::simple_boolean_dafny::_Wrappers_Compile::Option::None {}, ++ Some(b) => crate::implementation_from_dafny::_Wrappers_Compile::Option::Some { value: b }, ++ None => crate::implementation_from_dafny::_Wrappers_Compile::Option::None {}, + }; -+ ::std::rc::Rc::new(::simple_boolean_dafny::r#_simple_dtypes_dboolean_dinternaldafny_dtypes::GetBooleanInput::GetBooleanInput { ++ ::std::rc::Rc::new(crate::implementation_from_dafny::r#_simple_dtypes_dboolean_dinternaldafny_dtypes::GetBooleanInput::GetBooleanInput { + value: ::std::rc::Rc::new(dafny_value) + }) +} @@ -133,17 +133,17 @@ index 00000000..efd9d5f8 +#[allow(dead_code)] +pub fn from_dafny( + dafny_value: ::std::rc::Rc< -+ ::simple_boolean_dafny::r#_simple_dtypes_dboolean_dinternaldafny_dtypes::GetBooleanInput, ++ crate::implementation_from_dafny::r#_simple_dtypes_dboolean_dinternaldafny_dtypes::GetBooleanInput, + >, +) -> crate::operation::get_boolean::GetBooleanInput { + let value = if matches!( + dafny_value.value().as_ref(), -+ ::simple_boolean_dafny::_Wrappers_Compile::Option::Some { .. } ++ crate::implementation_from_dafny::_Wrappers_Compile::Option::Some { .. } + ) { + Some(dafny_value.value().Extract()) + } else if matches!( + dafny_value.value().as_ref(), -+ ::simple_boolean_dafny::_Wrappers_Compile::Option::None { .. } ++ crate::implementation_from_dafny::_Wrappers_Compile::Option::None { .. } + ) { + None + } else { @@ -153,7 +153,7 @@ index 00000000..efd9d5f8 +} diff --git b/TestModels/SimpleTypes/SimpleBoolean/runtimes/rust/src/conversions/get_boolean/_get_boolean_output.rs a/TestModels/SimpleTypes/SimpleBoolean/runtimes/rust/src/conversions/get_boolean/_get_boolean_output.rs new file mode 100644 -index 00000000..4b9dec69 +index 00000000..719f9692 --- /dev/null +++ a/TestModels/SimpleTypes/SimpleBoolean/runtimes/rust/src/conversions/get_boolean/_get_boolean_output.rs @@ -0,0 +1,37 @@ @@ -162,13 +162,13 @@ index 00000000..4b9dec69 +pub fn to_dafny( + value: crate::operation::get_boolean::GetBooleanOutput, +) -> ::std::rc::Rc< -+ ::simple_boolean_dafny::r#_simple_dtypes_dboolean_dinternaldafny_dtypes::GetBooleanOutput, ++ crate::implementation_from_dafny::r#_simple_dtypes_dboolean_dinternaldafny_dtypes::GetBooleanOutput, +> { + let dafny_value = match value.value { -+ Some(b) => ::simple_boolean_dafny::_Wrappers_Compile::Option::Some { value: b }, -+ None => ::simple_boolean_dafny::_Wrappers_Compile::Option::None {}, ++ Some(b) => crate::implementation_from_dafny::_Wrappers_Compile::Option::Some { value: b }, ++ None => crate::implementation_from_dafny::_Wrappers_Compile::Option::None {}, + }; -+ ::std::rc::Rc::new(::simple_boolean_dafny::r#_simple_dtypes_dboolean_dinternaldafny_dtypes::GetBooleanOutput::GetBooleanOutput { ++ ::std::rc::Rc::new(crate::implementation_from_dafny::r#_simple_dtypes_dboolean_dinternaldafny_dtypes::GetBooleanOutput::GetBooleanOutput { + value: ::std::rc::Rc::new(dafny_value) + }) +} @@ -176,17 +176,17 @@ index 00000000..4b9dec69 +#[allow(dead_code)] +pub fn from_dafny( + dafny_value: ::std::rc::Rc< -+ ::simple_boolean_dafny::r#_simple_dtypes_dboolean_dinternaldafny_dtypes::GetBooleanOutput, ++ crate::implementation_from_dafny::r#_simple_dtypes_dboolean_dinternaldafny_dtypes::GetBooleanOutput, + >, +) -> crate::operation::get_boolean::GetBooleanOutput { + let value = if matches!( + dafny_value.value().as_ref(), -+ ::simple_boolean_dafny::_Wrappers_Compile::Option::Some { .. } ++ crate::implementation_from_dafny::_Wrappers_Compile::Option::Some { .. } + ) { + Some(dafny_value.value().Extract()) + } else if matches!( + dafny_value.value().as_ref(), -+ ::simple_boolean_dafny::_Wrappers_Compile::Option::None { .. } ++ crate::implementation_from_dafny::_Wrappers_Compile::Option::None { .. } + ) { + None + } else { @@ -205,25 +205,27 @@ index 00000000..371a47e5 +pub mod _simple_boolean_config; diff --git b/TestModels/SimpleTypes/SimpleBoolean/runtimes/rust/src/conversions/simple_boolean_config/_simple_boolean_config.rs a/TestModels/SimpleTypes/SimpleBoolean/runtimes/rust/src/conversions/simple_boolean_config/_simple_boolean_config.rs new file mode 100644 -index 00000000..6c7dc176 +index 00000000..a19536aa --- /dev/null +++ a/TestModels/SimpleTypes/SimpleBoolean/runtimes/rust/src/conversions/simple_boolean_config/_simple_boolean_config.rs -@@ -0,0 +1,19 @@ +@@ -0,0 +1,21 @@ ++use dafny_standard_library::implementation_from_dafny; ++ +// Code generated by software.amazon.smithy.rust.codegen.smithy-rs. DO NOT EDIT. +#[allow(dead_code)] + +pub fn to_dafny( + value: crate::types::simple_boolean_config::SimpleBooleanConfig, +) -> ::std::rc::Rc< -+ ::simple_boolean_dafny::_simple_dtypes_dboolean_dinternaldafny_dtypes::SimpleBooleanConfig, ++ crate::implementation_from_dafny::_simple_dtypes_dboolean_dinternaldafny_dtypes::SimpleBooleanConfig, +> { -+ ::std::rc::Rc::new(::simple_boolean_dafny::r#_simple_dtypes_dboolean_dinternaldafny_dtypes::SimpleBooleanConfig::SimpleBooleanConfig {}) ++ ::std::rc::Rc::new(crate::implementation_from_dafny::r#_simple_dtypes_dboolean_dinternaldafny_dtypes::SimpleBooleanConfig::SimpleBooleanConfig {}) +} + +#[allow(dead_code)] +pub fn from_dafny( + dafny_value: ::std::rc::Rc< -+ ::simple_boolean_dafny::r#_simple_dtypes_dboolean_dinternaldafny_dtypes::SimpleBooleanConfig, ++ crate::implementation_from_dafny::r#_simple_dtypes_dboolean_dinternaldafny_dtypes::SimpleBooleanConfig, + >, +) -> crate::types::simple_boolean_config::SimpleBooleanConfig { + crate::types::simple_boolean_config::SimpleBooleanConfig {} @@ -287,10 +289,10 @@ index 00000000..4d66eb2e \ No newline at end of file diff --git b/TestModels/SimpleTypes/SimpleBoolean/runtimes/rust/src/lib.rs a/TestModels/SimpleTypes/SimpleBoolean/runtimes/rust/src/lib.rs new file mode 100644 -index 00000000..1d16c191 +index 00000000..118aa67e --- /dev/null +++ a/TestModels/SimpleTypes/SimpleBoolean/runtimes/rust/src/lib.rs -@@ -0,0 +1,17 @@ +@@ -0,0 +1,19 @@ +#![allow(deprecated)] + +// Code generated by software.amazon.smithy.rust.codegen.smithy-rs. DO NOT EDIT. @@ -304,7 +306,9 @@ index 00000000..1d16c191 +/// All operations that this crate can perform. +pub mod operation; + -+mod conversions; ++pub mod conversions; ++ ++pub mod implementation_from_dafny; + +pub use client::Client; +pub use types::simple_boolean_config::SimpleBooleanConfig; @@ -320,7 +324,7 @@ index 00000000..eb38b9f1 +pub mod get_boolean; diff --git b/TestModels/SimpleTypes/SimpleBoolean/runtimes/rust/src/operation/get_boolean.rs a/TestModels/SimpleTypes/SimpleBoolean/runtimes/rust/src/operation/get_boolean.rs new file mode 100644 -index 00000000..96381e1d +index 00000000..bb1fb9f8 --- /dev/null +++ a/TestModels/SimpleTypes/SimpleBoolean/runtimes/rust/src/operation/get_boolean.rs @@ -0,0 +1,145 @@ @@ -334,7 +338,7 @@ index 00000000..96381e1d + pub fn new() -> Self { + Self + } -+ pub(crate) async fn send( ++ pub fn send( + client: &crate::client::Client, + input: crate::operation::get_boolean::GetBooleanInput, + ) -> ::std::result::Result< @@ -346,7 +350,7 @@ index 00000000..96381e1d + ::dafny_runtime::md!(client.dafny_client.clone()).GetBoolean(&inner_input); + if matches!( + inner_result.as_ref(), -+ ::simple_boolean_dafny::r#_Wrappers_Compile::Result::Success { .. } ++ crate::implementation_from_dafny::r#_Wrappers_Compile::Result::Success { .. } + ) { + Ok( + crate::conversions::get_boolean::_get_boolean_output::from_dafny( @@ -601,7 +605,7 @@ index 00000000..d2943f38 +} diff --git b/TestModels/SimpleTypes/SimpleBoolean/runtimes/rust/src/operation/get_boolean/builders.rs a/TestModels/SimpleTypes/SimpleBoolean/runtimes/rust/src/operation/get_boolean/builders.rs new file mode 100644 -index 00000000..e672a270 +index 00000000..b30d9072 --- /dev/null +++ a/TestModels/SimpleTypes/SimpleBoolean/runtimes/rust/src/operation/get_boolean/builders.rs @@ -0,0 +1,72 @@ @@ -612,7 +616,7 @@ index 00000000..e672a270 + +impl GetBooleanInputBuilder { + /// Sends a request with this input using the given client. -+ pub async fn send_with( ++ pub fn send_with( + self, + client: &crate::Client, + ) -> ::std::result::Result< @@ -621,7 +625,7 @@ index 00000000..e672a270 + > { + let mut fluent_builder = client.get_boolean(); + fluent_builder.inner = self; -+ fluent_builder.send().await ++ fluent_builder.send() + } +} +/// Fluent builder constructing a request to `GetBoolean`. @@ -644,7 +648,7 @@ index 00000000..e672a270 + &self.inner + } + /// Sends the request and returns the response. -+ pub async fn send( ++ pub fn send( + self, + ) -> ::std::result::Result< + crate::operation::get_boolean::GetBooleanOutput, @@ -659,7 +663,7 @@ index 00000000..e672a270 + // Vanilla smithy-rs uses SdkError::construction_failure, + // but we aren't using SdkError. + .map_err(crate::operation::get_boolean::GetBooleanError::unhandled)?; -+ crate::operation::get_boolean::GetBoolean::send(&self.client, input).await ++ crate::operation::get_boolean::GetBoolean::send(&self.client, input) + } + + #[allow(missing_docs)] // documentation missing in model From 42ab1157093480afe6912d81414c902e6bd124fc Mon Sep 17 00:00:00 2001 From: Robin Salkeld Date: Wed, 10 Jul 2024 10:07:40 -0700 Subject: [PATCH 30/53] Add tests_from_dafny.rs so we can patch --- .../runtimes/rust/tests/tests_from_dafny.rs | 274 ++++++++++++++++++ 1 file changed, 274 insertions(+) create mode 100644 TestModels/SimpleTypes/SimpleBoolean/runtimes/rust/tests/tests_from_dafny.rs diff --git a/TestModels/SimpleTypes/SimpleBoolean/runtimes/rust/tests/tests_from_dafny.rs b/TestModels/SimpleTypes/SimpleBoolean/runtimes/rust/tests/tests_from_dafny.rs new file mode 100644 index 0000000000..ce6d90a2ef --- /dev/null +++ b/TestModels/SimpleTypes/SimpleBoolean/runtimes/rust/tests/tests_from_dafny.rs @@ -0,0 +1,274 @@ +#![allow(warnings, unconditional_panic)] +#![allow(nonstandard_style)] + +pub mod r#_simple_dtypes_dboolean_dinternaldafny_dwrapped { + pub struct _default {} + + impl _default { + pub fn _allocate_object() -> ::dafny_runtime::Object { + ::dafny_runtime::allocate_object::() + } + pub fn WrappedDefaultSimpleBooleanConfig() -> ::std::rc::Rc< + super::r#_simple_dtypes_dboolean_dinternaldafny_dtypes::SimpleBooleanConfig, + > { + ::std::rc::Rc::new(super::r#_simple_dtypes_dboolean_dinternaldafny_dtypes::SimpleBooleanConfig::SimpleBooleanConfig {}) + } + } + + impl ::dafny_runtime::UpcastObject + for super::r#_simple_dtypes_dboolean_dinternaldafny_dwrapped::_default + { + ::dafny_runtime::UpcastObjectFn!(dyn::std::any::Any); + } +} +pub mod r#_SimpleBooleanImplTest_Compile { + pub struct _default {} + + impl _default { + pub fn _allocate_object() -> ::dafny_runtime::Object { + ::dafny_runtime::allocate_object::() + } + pub fn GetBooleanTrue() -> () { + let mut valueOrError0 = ::dafny_runtime::MaybePlacebo::< + ::std::rc::Rc< + super::r#_Wrappers_Compile::Result< + ::dafny_runtime::Object< + super::r#_simple_dtypes_dboolean_dinternaldafny::SimpleBooleanClient, + >, + ::std::rc::Rc< + super::r#_simple_dtypes_dboolean_dinternaldafny_dtypes::Error, + >, + >, + >, + >::new(); + let mut _out0 = ::dafny_runtime::MaybePlacebo::< + ::std::rc::Rc< + super::r#_Wrappers_Compile::Result< + ::dafny_runtime::Object< + super::r#_simple_dtypes_dboolean_dinternaldafny::SimpleBooleanClient, + >, + ::std::rc::Rc< + super::r#_simple_dtypes_dboolean_dinternaldafny_dtypes::Error, + >, + >, + >, + >::new(); + _out0 = ::dafny_runtime::MaybePlacebo::from(super::r#_simple_dtypes_dboolean_dinternaldafny::_default::SimpleBoolean(&super::r#_simple_dtypes_dboolean_dinternaldafny::_default::DefaultSimpleBooleanConfig())); + valueOrError0 = ::dafny_runtime::MaybePlacebo::from(_out0.read()); + if !(!valueOrError0.read().IsFailure()) { + panic!("Halt") + }; + let mut client: ::dafny_runtime::Object< + super::r#_simple_dtypes_dboolean_dinternaldafny::SimpleBooleanClient, + > = valueOrError0.read().Extract(); + super::r#_SimpleBooleanImplTest_Compile::_default::TestGetBooleanTrue(&::dafny_runtime::upcast_object::()(client.clone())); + return (); + } + pub fn GetBooleanFalse() -> () { + let mut valueOrError0 = ::dafny_runtime::MaybePlacebo::< + ::std::rc::Rc< + super::r#_Wrappers_Compile::Result< + ::dafny_runtime::Object< + super::r#_simple_dtypes_dboolean_dinternaldafny::SimpleBooleanClient, + >, + ::std::rc::Rc< + super::r#_simple_dtypes_dboolean_dinternaldafny_dtypes::Error, + >, + >, + >, + >::new(); + let mut _out1 = ::dafny_runtime::MaybePlacebo::< + ::std::rc::Rc< + super::r#_Wrappers_Compile::Result< + ::dafny_runtime::Object< + super::r#_simple_dtypes_dboolean_dinternaldafny::SimpleBooleanClient, + >, + ::std::rc::Rc< + super::r#_simple_dtypes_dboolean_dinternaldafny_dtypes::Error, + >, + >, + >, + >::new(); + _out1 = ::dafny_runtime::MaybePlacebo::from(super::r#_simple_dtypes_dboolean_dinternaldafny::_default::SimpleBoolean(&super::r#_simple_dtypes_dboolean_dinternaldafny::_default::DefaultSimpleBooleanConfig())); + valueOrError0 = ::dafny_runtime::MaybePlacebo::from(_out1.read()); + if !(!valueOrError0.read().IsFailure()) { + panic!("Halt") + }; + let mut client: ::dafny_runtime::Object< + super::r#_simple_dtypes_dboolean_dinternaldafny::SimpleBooleanClient, + > = valueOrError0.read().Extract(); + super::r#_SimpleBooleanImplTest_Compile::_default::TestGetBooleanFalse(&::dafny_runtime::upcast_object::()(client.clone())); + return (); + } + pub fn TestGetBooleanTrue( + client: &::dafny_runtime::Object, + ) -> () { + let mut valueOrError0 = ::dafny_runtime::MaybePlacebo::<::std::rc::Rc, ::std::rc::Rc>>>::new(); + let mut _out2 = ::dafny_runtime::MaybePlacebo::<::std::rc::Rc, ::std::rc::Rc>>>::new(); + _out2 = ::dafny_runtime::MaybePlacebo::from(super::r#_simple_dtypes_dboolean_dinternaldafny_dtypes::ISimpleTypesBooleanClient::GetBoolean(::dafny_runtime::md!(client.clone()), &::std::rc::Rc::new(super::r#_simple_dtypes_dboolean_dinternaldafny_dtypes::GetBooleanInput::GetBooleanInput { + value: ::std::rc::Rc::new(super::r#_Wrappers_Compile::Option::::Some { + value: true + }) + }))); + valueOrError0 = ::dafny_runtime::MaybePlacebo::from(_out2.read()); + if !(!valueOrError0.read().IsFailure()) { + panic!("Halt") + }; + let mut ret: ::std::rc::Rc< + super::r#_simple_dtypes_dboolean_dinternaldafny_dtypes::GetBooleanOutput, + > = valueOrError0.read().Extract(); + if !(ret.value().UnwrapOr(&false) == true) { + panic!("Halt") + }; + print!("{}", ::dafny_runtime::DafnyPrintWrapper(&ret)); + return (); + } + pub fn TestGetBooleanFalse( + client: &::dafny_runtime::Object, + ) -> () { + let mut valueOrError0 = ::dafny_runtime::MaybePlacebo::<::std::rc::Rc, ::std::rc::Rc>>>::new(); + let mut _out3 = ::dafny_runtime::MaybePlacebo::<::std::rc::Rc, ::std::rc::Rc>>>::new(); + _out3 = ::dafny_runtime::MaybePlacebo::from(super::r#_simple_dtypes_dboolean_dinternaldafny_dtypes::ISimpleTypesBooleanClient::GetBoolean(::dafny_runtime::md!(client.clone()), &::std::rc::Rc::new(super::r#_simple_dtypes_dboolean_dinternaldafny_dtypes::GetBooleanInput::GetBooleanInput { + value: ::std::rc::Rc::new(super::r#_Wrappers_Compile::Option::::Some { + value: false + }) + }))); + valueOrError0 = ::dafny_runtime::MaybePlacebo::from(_out3.read()); + if !(!valueOrError0.read().IsFailure()) { + panic!("Halt") + }; + let mut ret: ::std::rc::Rc< + super::r#_simple_dtypes_dboolean_dinternaldafny_dtypes::GetBooleanOutput, + > = valueOrError0.read().Extract(); + if !(ret.value().UnwrapOr(&true) == false) { + panic!("Halt") + }; + print!("{}", ::dafny_runtime::DafnyPrintWrapper(&ret)); + return (); + } + } + + impl ::dafny_runtime::UpcastObject + for super::r#_SimpleBooleanImplTest_Compile::_default + { + ::dafny_runtime::UpcastObjectFn!(dyn::std::any::Any); + } +} +pub mod r#_WrappedSimpleTypesBooleanTest_Compile { + pub struct _default {} + + impl _default { + pub fn _allocate_object() -> ::dafny_runtime::Object { + ::dafny_runtime::allocate_object::() + } + pub fn GetBooleanTrue() -> () { + let mut valueOrError0 = ::dafny_runtime::MaybePlacebo::<::std::rc::Rc, ::std::rc::Rc>>>::new(); + let mut _out4 = ::dafny_runtime::MaybePlacebo::<::std::rc::Rc, ::std::rc::Rc>>>::new(); + _out4 = ::dafny_runtime::MaybePlacebo::from(super::r#_simple_dtypes_dboolean_dinternaldafny_dwrapped::_default::WrappedSimpleBoolean(&super::r#_simple_dtypes_dboolean_dinternaldafny_dwrapped::_default::WrappedDefaultSimpleBooleanConfig())); + valueOrError0 = ::dafny_runtime::MaybePlacebo::from(_out4.read()); + if !(!valueOrError0.read().IsFailure()) { + panic!("Halt") + }; + let mut client: ::dafny_runtime::Object = valueOrError0.read().Extract(); + super::r#_SimpleBooleanImplTest_Compile::_default::TestGetBooleanTrue(&client); + return (); + } + pub fn GetBooleanFalse() -> () { + let mut valueOrError0 = ::dafny_runtime::MaybePlacebo::<::std::rc::Rc, ::std::rc::Rc>>>::new(); + let mut _out5 = ::dafny_runtime::MaybePlacebo::<::std::rc::Rc, ::std::rc::Rc>>>::new(); + _out5 = ::dafny_runtime::MaybePlacebo::from(super::r#_simple_dtypes_dboolean_dinternaldafny_dwrapped::_default::WrappedSimpleBoolean(&super::r#_simple_dtypes_dboolean_dinternaldafny_dwrapped::_default::WrappedDefaultSimpleBooleanConfig())); + valueOrError0 = ::dafny_runtime::MaybePlacebo::from(_out5.read()); + if !(!valueOrError0.read().IsFailure()) { + panic!("Halt") + }; + let mut client: ::dafny_runtime::Object = valueOrError0.read().Extract(); + super::r#_SimpleBooleanImplTest_Compile::_default::TestGetBooleanFalse(&client); + return (); + } + } + + impl ::dafny_runtime::UpcastObject + for super::r#_WrappedSimpleTypesBooleanTest_Compile::_default + { + ::dafny_runtime::UpcastObjectFn!(dyn::std::any::Any); + } +} +pub mod _module { + pub struct _default {} + + impl _default { + pub fn _allocate_object() -> ::dafny_runtime::Object { + ::dafny_runtime::allocate_object::() + } + pub fn _Test__Main_() -> () { + let mut success: bool = true; + print!( + "{}", + ::dafny_runtime::DafnyPrintWrapper(&::dafny_runtime::string_utf16_of( + r#"SimpleBooleanImplTest.GetBooleanTrue: "# + )) + ); + super::r#_SimpleBooleanImplTest_Compile::_default::GetBooleanTrue(); + print!( + "{}", + ::dafny_runtime::DafnyPrintWrapper(&::dafny_runtime::string_utf16_of( + r#"PASSED +"# + )) + ); + print!( + "{}", + ::dafny_runtime::DafnyPrintWrapper(&::dafny_runtime::string_utf16_of( + r#"SimpleBooleanImplTest.GetBooleanFalse: "# + )) + ); + super::r#_SimpleBooleanImplTest_Compile::_default::GetBooleanFalse(); + print!( + "{}", + ::dafny_runtime::DafnyPrintWrapper(&::dafny_runtime::string_utf16_of( + r#"PASSED +"# + )) + ); + print!( + "{}", + ::dafny_runtime::DafnyPrintWrapper(&::dafny_runtime::string_utf16_of( + r#"WrappedSimpleTypesBooleanTest.GetBooleanTrue: "# + )) + ); + super::r#_WrappedSimpleTypesBooleanTest_Compile::_default::GetBooleanTrue(); + print!( + "{}", + ::dafny_runtime::DafnyPrintWrapper(&::dafny_runtime::string_utf16_of( + r#"PASSED +"# + )) + ); + print!( + "{}", + ::dafny_runtime::DafnyPrintWrapper(&::dafny_runtime::string_utf16_of( + r#"WrappedSimpleTypesBooleanTest.GetBooleanFalse: "# + )) + ); + super::r#_WrappedSimpleTypesBooleanTest_Compile::_default::GetBooleanFalse(); + print!( + "{}", + ::dafny_runtime::DafnyPrintWrapper(&::dafny_runtime::string_utf16_of( + r#"PASSED +"# + )) + ); + if !success { + panic!("Halt") + }; + return (); + } + } + + impl ::dafny_runtime::UpcastObject for super::_module::_default { + ::dafny_runtime::UpcastObjectFn!(dyn::std::any::Any); + } +} +fn main() { + _module::_default::_Test__Main_(); +} From d880bdebfeab9f5722120182b89b77b5a06fc5cb Mon Sep 17 00:00:00 2001 From: Robin Salkeld Date: Wed, 10 Jul 2024 10:09:09 -0700 Subject: [PATCH 31/53] Remove wrong file --- .../runtimes/rust/tests/tests_from_dafny.rs | 274 ------------------ 1 file changed, 274 deletions(-) delete mode 100644 TestModels/SimpleTypes/SimpleBoolean/runtimes/rust/tests/tests_from_dafny.rs diff --git a/TestModels/SimpleTypes/SimpleBoolean/runtimes/rust/tests/tests_from_dafny.rs b/TestModels/SimpleTypes/SimpleBoolean/runtimes/rust/tests/tests_from_dafny.rs deleted file mode 100644 index ce6d90a2ef..0000000000 --- a/TestModels/SimpleTypes/SimpleBoolean/runtimes/rust/tests/tests_from_dafny.rs +++ /dev/null @@ -1,274 +0,0 @@ -#![allow(warnings, unconditional_panic)] -#![allow(nonstandard_style)] - -pub mod r#_simple_dtypes_dboolean_dinternaldafny_dwrapped { - pub struct _default {} - - impl _default { - pub fn _allocate_object() -> ::dafny_runtime::Object { - ::dafny_runtime::allocate_object::() - } - pub fn WrappedDefaultSimpleBooleanConfig() -> ::std::rc::Rc< - super::r#_simple_dtypes_dboolean_dinternaldafny_dtypes::SimpleBooleanConfig, - > { - ::std::rc::Rc::new(super::r#_simple_dtypes_dboolean_dinternaldafny_dtypes::SimpleBooleanConfig::SimpleBooleanConfig {}) - } - } - - impl ::dafny_runtime::UpcastObject - for super::r#_simple_dtypes_dboolean_dinternaldafny_dwrapped::_default - { - ::dafny_runtime::UpcastObjectFn!(dyn::std::any::Any); - } -} -pub mod r#_SimpleBooleanImplTest_Compile { - pub struct _default {} - - impl _default { - pub fn _allocate_object() -> ::dafny_runtime::Object { - ::dafny_runtime::allocate_object::() - } - pub fn GetBooleanTrue() -> () { - let mut valueOrError0 = ::dafny_runtime::MaybePlacebo::< - ::std::rc::Rc< - super::r#_Wrappers_Compile::Result< - ::dafny_runtime::Object< - super::r#_simple_dtypes_dboolean_dinternaldafny::SimpleBooleanClient, - >, - ::std::rc::Rc< - super::r#_simple_dtypes_dboolean_dinternaldafny_dtypes::Error, - >, - >, - >, - >::new(); - let mut _out0 = ::dafny_runtime::MaybePlacebo::< - ::std::rc::Rc< - super::r#_Wrappers_Compile::Result< - ::dafny_runtime::Object< - super::r#_simple_dtypes_dboolean_dinternaldafny::SimpleBooleanClient, - >, - ::std::rc::Rc< - super::r#_simple_dtypes_dboolean_dinternaldafny_dtypes::Error, - >, - >, - >, - >::new(); - _out0 = ::dafny_runtime::MaybePlacebo::from(super::r#_simple_dtypes_dboolean_dinternaldafny::_default::SimpleBoolean(&super::r#_simple_dtypes_dboolean_dinternaldafny::_default::DefaultSimpleBooleanConfig())); - valueOrError0 = ::dafny_runtime::MaybePlacebo::from(_out0.read()); - if !(!valueOrError0.read().IsFailure()) { - panic!("Halt") - }; - let mut client: ::dafny_runtime::Object< - super::r#_simple_dtypes_dboolean_dinternaldafny::SimpleBooleanClient, - > = valueOrError0.read().Extract(); - super::r#_SimpleBooleanImplTest_Compile::_default::TestGetBooleanTrue(&::dafny_runtime::upcast_object::()(client.clone())); - return (); - } - pub fn GetBooleanFalse() -> () { - let mut valueOrError0 = ::dafny_runtime::MaybePlacebo::< - ::std::rc::Rc< - super::r#_Wrappers_Compile::Result< - ::dafny_runtime::Object< - super::r#_simple_dtypes_dboolean_dinternaldafny::SimpleBooleanClient, - >, - ::std::rc::Rc< - super::r#_simple_dtypes_dboolean_dinternaldafny_dtypes::Error, - >, - >, - >, - >::new(); - let mut _out1 = ::dafny_runtime::MaybePlacebo::< - ::std::rc::Rc< - super::r#_Wrappers_Compile::Result< - ::dafny_runtime::Object< - super::r#_simple_dtypes_dboolean_dinternaldafny::SimpleBooleanClient, - >, - ::std::rc::Rc< - super::r#_simple_dtypes_dboolean_dinternaldafny_dtypes::Error, - >, - >, - >, - >::new(); - _out1 = ::dafny_runtime::MaybePlacebo::from(super::r#_simple_dtypes_dboolean_dinternaldafny::_default::SimpleBoolean(&super::r#_simple_dtypes_dboolean_dinternaldafny::_default::DefaultSimpleBooleanConfig())); - valueOrError0 = ::dafny_runtime::MaybePlacebo::from(_out1.read()); - if !(!valueOrError0.read().IsFailure()) { - panic!("Halt") - }; - let mut client: ::dafny_runtime::Object< - super::r#_simple_dtypes_dboolean_dinternaldafny::SimpleBooleanClient, - > = valueOrError0.read().Extract(); - super::r#_SimpleBooleanImplTest_Compile::_default::TestGetBooleanFalse(&::dafny_runtime::upcast_object::()(client.clone())); - return (); - } - pub fn TestGetBooleanTrue( - client: &::dafny_runtime::Object, - ) -> () { - let mut valueOrError0 = ::dafny_runtime::MaybePlacebo::<::std::rc::Rc, ::std::rc::Rc>>>::new(); - let mut _out2 = ::dafny_runtime::MaybePlacebo::<::std::rc::Rc, ::std::rc::Rc>>>::new(); - _out2 = ::dafny_runtime::MaybePlacebo::from(super::r#_simple_dtypes_dboolean_dinternaldafny_dtypes::ISimpleTypesBooleanClient::GetBoolean(::dafny_runtime::md!(client.clone()), &::std::rc::Rc::new(super::r#_simple_dtypes_dboolean_dinternaldafny_dtypes::GetBooleanInput::GetBooleanInput { - value: ::std::rc::Rc::new(super::r#_Wrappers_Compile::Option::::Some { - value: true - }) - }))); - valueOrError0 = ::dafny_runtime::MaybePlacebo::from(_out2.read()); - if !(!valueOrError0.read().IsFailure()) { - panic!("Halt") - }; - let mut ret: ::std::rc::Rc< - super::r#_simple_dtypes_dboolean_dinternaldafny_dtypes::GetBooleanOutput, - > = valueOrError0.read().Extract(); - if !(ret.value().UnwrapOr(&false) == true) { - panic!("Halt") - }; - print!("{}", ::dafny_runtime::DafnyPrintWrapper(&ret)); - return (); - } - pub fn TestGetBooleanFalse( - client: &::dafny_runtime::Object, - ) -> () { - let mut valueOrError0 = ::dafny_runtime::MaybePlacebo::<::std::rc::Rc, ::std::rc::Rc>>>::new(); - let mut _out3 = ::dafny_runtime::MaybePlacebo::<::std::rc::Rc, ::std::rc::Rc>>>::new(); - _out3 = ::dafny_runtime::MaybePlacebo::from(super::r#_simple_dtypes_dboolean_dinternaldafny_dtypes::ISimpleTypesBooleanClient::GetBoolean(::dafny_runtime::md!(client.clone()), &::std::rc::Rc::new(super::r#_simple_dtypes_dboolean_dinternaldafny_dtypes::GetBooleanInput::GetBooleanInput { - value: ::std::rc::Rc::new(super::r#_Wrappers_Compile::Option::::Some { - value: false - }) - }))); - valueOrError0 = ::dafny_runtime::MaybePlacebo::from(_out3.read()); - if !(!valueOrError0.read().IsFailure()) { - panic!("Halt") - }; - let mut ret: ::std::rc::Rc< - super::r#_simple_dtypes_dboolean_dinternaldafny_dtypes::GetBooleanOutput, - > = valueOrError0.read().Extract(); - if !(ret.value().UnwrapOr(&true) == false) { - panic!("Halt") - }; - print!("{}", ::dafny_runtime::DafnyPrintWrapper(&ret)); - return (); - } - } - - impl ::dafny_runtime::UpcastObject - for super::r#_SimpleBooleanImplTest_Compile::_default - { - ::dafny_runtime::UpcastObjectFn!(dyn::std::any::Any); - } -} -pub mod r#_WrappedSimpleTypesBooleanTest_Compile { - pub struct _default {} - - impl _default { - pub fn _allocate_object() -> ::dafny_runtime::Object { - ::dafny_runtime::allocate_object::() - } - pub fn GetBooleanTrue() -> () { - let mut valueOrError0 = ::dafny_runtime::MaybePlacebo::<::std::rc::Rc, ::std::rc::Rc>>>::new(); - let mut _out4 = ::dafny_runtime::MaybePlacebo::<::std::rc::Rc, ::std::rc::Rc>>>::new(); - _out4 = ::dafny_runtime::MaybePlacebo::from(super::r#_simple_dtypes_dboolean_dinternaldafny_dwrapped::_default::WrappedSimpleBoolean(&super::r#_simple_dtypes_dboolean_dinternaldafny_dwrapped::_default::WrappedDefaultSimpleBooleanConfig())); - valueOrError0 = ::dafny_runtime::MaybePlacebo::from(_out4.read()); - if !(!valueOrError0.read().IsFailure()) { - panic!("Halt") - }; - let mut client: ::dafny_runtime::Object = valueOrError0.read().Extract(); - super::r#_SimpleBooleanImplTest_Compile::_default::TestGetBooleanTrue(&client); - return (); - } - pub fn GetBooleanFalse() -> () { - let mut valueOrError0 = ::dafny_runtime::MaybePlacebo::<::std::rc::Rc, ::std::rc::Rc>>>::new(); - let mut _out5 = ::dafny_runtime::MaybePlacebo::<::std::rc::Rc, ::std::rc::Rc>>>::new(); - _out5 = ::dafny_runtime::MaybePlacebo::from(super::r#_simple_dtypes_dboolean_dinternaldafny_dwrapped::_default::WrappedSimpleBoolean(&super::r#_simple_dtypes_dboolean_dinternaldafny_dwrapped::_default::WrappedDefaultSimpleBooleanConfig())); - valueOrError0 = ::dafny_runtime::MaybePlacebo::from(_out5.read()); - if !(!valueOrError0.read().IsFailure()) { - panic!("Halt") - }; - let mut client: ::dafny_runtime::Object = valueOrError0.read().Extract(); - super::r#_SimpleBooleanImplTest_Compile::_default::TestGetBooleanFalse(&client); - return (); - } - } - - impl ::dafny_runtime::UpcastObject - for super::r#_WrappedSimpleTypesBooleanTest_Compile::_default - { - ::dafny_runtime::UpcastObjectFn!(dyn::std::any::Any); - } -} -pub mod _module { - pub struct _default {} - - impl _default { - pub fn _allocate_object() -> ::dafny_runtime::Object { - ::dafny_runtime::allocate_object::() - } - pub fn _Test__Main_() -> () { - let mut success: bool = true; - print!( - "{}", - ::dafny_runtime::DafnyPrintWrapper(&::dafny_runtime::string_utf16_of( - r#"SimpleBooleanImplTest.GetBooleanTrue: "# - )) - ); - super::r#_SimpleBooleanImplTest_Compile::_default::GetBooleanTrue(); - print!( - "{}", - ::dafny_runtime::DafnyPrintWrapper(&::dafny_runtime::string_utf16_of( - r#"PASSED -"# - )) - ); - print!( - "{}", - ::dafny_runtime::DafnyPrintWrapper(&::dafny_runtime::string_utf16_of( - r#"SimpleBooleanImplTest.GetBooleanFalse: "# - )) - ); - super::r#_SimpleBooleanImplTest_Compile::_default::GetBooleanFalse(); - print!( - "{}", - ::dafny_runtime::DafnyPrintWrapper(&::dafny_runtime::string_utf16_of( - r#"PASSED -"# - )) - ); - print!( - "{}", - ::dafny_runtime::DafnyPrintWrapper(&::dafny_runtime::string_utf16_of( - r#"WrappedSimpleTypesBooleanTest.GetBooleanTrue: "# - )) - ); - super::r#_WrappedSimpleTypesBooleanTest_Compile::_default::GetBooleanTrue(); - print!( - "{}", - ::dafny_runtime::DafnyPrintWrapper(&::dafny_runtime::string_utf16_of( - r#"PASSED -"# - )) - ); - print!( - "{}", - ::dafny_runtime::DafnyPrintWrapper(&::dafny_runtime::string_utf16_of( - r#"WrappedSimpleTypesBooleanTest.GetBooleanFalse: "# - )) - ); - super::r#_WrappedSimpleTypesBooleanTest_Compile::_default::GetBooleanFalse(); - print!( - "{}", - ::dafny_runtime::DafnyPrintWrapper(&::dafny_runtime::string_utf16_of( - r#"PASSED -"# - )) - ); - if !success { - panic!("Halt") - }; - return (); - } - } - - impl ::dafny_runtime::UpcastObject for super::_module::_default { - ::dafny_runtime::UpcastObjectFn!(dyn::std::any::Any); - } -} -fn main() { - _module::_default::_Test__Main_(); -} From a8f1580575eb25fbcc638936491dca6a24243dcc Mon Sep 17 00:00:00 2001 From: Robin Salkeld Date: Wed, 10 Jul 2024 10:10:12 -0700 Subject: [PATCH 32/53] Patch test files as well for now --- .../codegen-patches/rust/dafny-4.5.0.patch | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/TestModels/SimpleTypes/SimpleBoolean/codegen-patches/rust/dafny-4.5.0.patch b/TestModels/SimpleTypes/SimpleBoolean/codegen-patches/rust/dafny-4.5.0.patch index 276705969b..77ad551803 100644 --- a/TestModels/SimpleTypes/SimpleBoolean/codegen-patches/rust/dafny-4.5.0.patch +++ b/TestModels/SimpleTypes/SimpleBoolean/codegen-patches/rust/dafny-4.5.0.patch @@ -723,3 +723,16 @@ index 00000000..6bf027f6 + ::std::result::Result::Ok(SimpleBooleanConfig {}) + } +} +diff --git b/TestModels/SimpleTypes/SimpleBoolean/runtimes/rust/tests/tests_from_dafny/mod.rs a/TestModels/SimpleTypes/SimpleBoolean/runtimes/rust/tests/tests_from_dafny/mod.rs +index ce6d90a2..3304d282 100644 +--- b/TestModels/SimpleTypes/SimpleBoolean/runtimes/rust/tests/tests_from_dafny/mod.rs ++++ a/TestModels/SimpleTypes/SimpleBoolean/runtimes/rust/tests/tests_from_dafny/mod.rs +@@ -1,5 +1,8 @@ + #![allow(warnings, unconditional_panic)] + #![allow(nonstandard_style)] ++use simple_boolean::implementation_from_dafny::*; ++use simple_boolean::*; ++mod _wrapped; + + pub mod r#_simple_dtypes_dboolean_dinternaldafny_dwrapped { + pub struct _default {} From fc033dbefd33f6f8bde77bb857941b9720bb1f13 Mon Sep 17 00:00:00 2001 From: Robin Salkeld Date: Wed, 10 Jul 2024 11:00:18 -0700 Subject: [PATCH 33/53] Undo dafny_impl change --- SmithyDafnyMakefile.mk | 11 +++---- .../SimpleBoolean/runtimes/rust/Cargo.toml | 1 + .../runtimes/rust/dafny_impl/Cargo.toml | 13 ++++++++ .../SimpleBoolean/runtimes/rust/src/client.rs | 6 ++-- .../rust/src/conversions/get_boolean.rs | 8 ++--- .../get_boolean/_get_boolean_input.rs | 14 ++++----- .../get_boolean/_get_boolean_output.rs | 14 ++++----- .../_simple_boolean_config.rs | 6 ++-- .../SimpleBoolean/runtimes/rust/src/lib.rs | 2 -- .../rust/src/operation/get_boolean.rs | 2 +- .../rust/tests/tests_from_dafny/_wrapped.rs | 30 +++++++++---------- .../rust/tests/tests_from_dafny/mod.rs | 2 +- 12 files changed, 61 insertions(+), 48 deletions(-) create mode 100644 TestModels/SimpleTypes/SimpleBoolean/runtimes/rust/dafny_impl/Cargo.toml diff --git a/SmithyDafnyMakefile.mk b/SmithyDafnyMakefile.mk index 6dd117c983..cb3aa66465 100644 --- a/SmithyDafnyMakefile.mk +++ b/SmithyDafnyMakefile.mk @@ -535,16 +535,17 @@ transpile_dependencies_rust: LANG=rust transpile_dependencies_rust: transpile_dependencies _mv_implementation_rust: - rm -f runtimes/rust/src/implementation_from_dafny.rs + rm -rf runtimes/rust/dafny_impl/src + mkdir -p runtimes/rust/dafny_impl/src # TODO: Currently need to insert an import of the the StandardLibrary. python -c "import sys; data = sys.stdin.buffer.read(); sys.stdout.buffer.write(data.replace(b'\npub mod', b'\npub use dafny_standard_library::implementation_from_dafny::*;\n\npub mod', 1) if b'\npub mod' in data else data)" \ - < implementation_from_dafny-rust/src/implementation_from_dafny.rs > runtimes/rust/src/implementation_from_dafny.rs - rustfmt runtimes/rust/src/implementation_from_dafny.rs + < implementation_from_dafny-rust/src/implementation_from_dafny.rs > runtimes/rust/dafny_impl/src/implementation_from_dafny.rs + rustfmt runtimes/rust/dafny_impl/src/implementation_from_dafny.rs rm -rf implementation_from_dafny-rust _mv_test_rust: rm -f runtimes/rust/tests/tests_from_dafny.rs - mv tests_from_dafny-rust/src/tests_from_dafny.rs runtimes/rust/tests/tests_from_dafny.rs - rustfmt runtimes/rust/tests/tests_from_dafny.rs + mv tests_from_dafny-rust/src/tests_from_dafny.rs runtimes/rust/tests/tests_from_dafny/mod.rs + rustfmt runtimes/rust/tests/tests_from_dafny/mod.rs rm -rf tests_from_dafny-rust build_rust: diff --git a/TestModels/SimpleTypes/SimpleBoolean/runtimes/rust/Cargo.toml b/TestModels/SimpleTypes/SimpleBoolean/runtimes/rust/Cargo.toml index e05d9345f3..8cc533de4f 100644 --- a/TestModels/SimpleTypes/SimpleBoolean/runtimes/rust/Cargo.toml +++ b/TestModels/SimpleTypes/SimpleBoolean/runtimes/rust/Cargo.toml @@ -11,6 +11,7 @@ aws-smithy-runtime-api = {version = "1.7.0", features = ["client"] } aws-smithy-types = "1.2.0" dafny_runtime = { path = "../../../../dafny-dependencies/dafny_runtime_rust"} dafny_standard_library = { path = "../../../../dafny-dependencies/StandardLibrary/runtimes/rust"} +simple_boolean_dafny = { path = "./dafny_impl"} [dev-dependencies.tokio] version = "1.26.0" diff --git a/TestModels/SimpleTypes/SimpleBoolean/runtimes/rust/dafny_impl/Cargo.toml b/TestModels/SimpleTypes/SimpleBoolean/runtimes/rust/dafny_impl/Cargo.toml new file mode 100644 index 0000000000..31b603eef1 --- /dev/null +++ b/TestModels/SimpleTypes/SimpleBoolean/runtimes/rust/dafny_impl/Cargo.toml @@ -0,0 +1,13 @@ +[package] +name = "simple_boolean_dafny" +version = "0.1.0" +edition = "2021" + +# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html + +[dependencies] +dafny_runtime = { path = "../../../../../dafny-dependencies/dafny_runtime_rust"} +dafny_standard_library = { path = "../../../../../dafny-dependencies/StandardLibrary/runtimes/rust"} + +[lib] +path = "src/implementation_from_dafny.rs" \ No newline at end of file diff --git a/TestModels/SimpleTypes/SimpleBoolean/runtimes/rust/src/client.rs b/TestModels/SimpleTypes/SimpleBoolean/runtimes/rust/src/client.rs index 7a4f6c0423..89478da537 100644 --- a/TestModels/SimpleTypes/SimpleBoolean/runtimes/rust/src/client.rs +++ b/TestModels/SimpleTypes/SimpleBoolean/runtimes/rust/src/client.rs @@ -4,7 +4,7 @@ use aws_smithy_types::error::operation::BuildError; #[derive(::std::clone::Clone, ::std::fmt::Debug)] pub struct Client { - pub(crate) dafny_client: ::dafny_runtime::Object + pub(crate) dafny_client: ::dafny_runtime::Object } impl Client { @@ -14,12 +14,12 @@ impl Client { conf: crate::types::simple_boolean_config::SimpleBooleanConfig, ) -> Result { let inner = - crate::implementation_from_dafny::_simple_dtypes_dboolean_dinternaldafny::_default::SimpleBoolean( + ::simple_boolean_dafny::_simple_dtypes_dboolean_dinternaldafny::_default::SimpleBoolean( &crate::conversions::simple_boolean_config::_simple_boolean_config::to_dafny(conf), ); if matches!( inner.as_ref(), - crate::implementation_from_dafny::_Wrappers_Compile::Result::Failure { .. } + ::simple_boolean_dafny::_Wrappers_Compile::Result::Failure { .. } ) { // TODO: convert error - the potential types are not modeled! return Err(BuildError::other( diff --git a/TestModels/SimpleTypes/SimpleBoolean/runtimes/rust/src/conversions/get_boolean.rs b/TestModels/SimpleTypes/SimpleBoolean/runtimes/rust/src/conversions/get_boolean.rs index d4f59b2fc0..b98bc0577a 100644 --- a/TestModels/SimpleTypes/SimpleBoolean/runtimes/rust/src/conversions/get_boolean.rs +++ b/TestModels/SimpleTypes/SimpleBoolean/runtimes/rust/src/conversions/get_boolean.rs @@ -5,21 +5,21 @@ use std::any::Any; #[allow(dead_code)] pub fn to_dafny_error( value: crate::operation::get_boolean::GetBooleanError, -) -> ::std::rc::Rc { +) -> ::std::rc::Rc<::simple_boolean_dafny::r#_simple_dtypes_dboolean_dinternaldafny_dtypes::Error> { match value { crate::operation::get_boolean::GetBooleanError::Unhandled(unhandled) => - ::std::rc::Rc::new(crate::implementation_from_dafny::r#_simple_dtypes_dboolean_dinternaldafny_dtypes::Error::Opaque { obj: ::dafny_runtime::upcast_object()(::dafny_runtime::object::new(unhandled)) }) + ::std::rc::Rc::new(::simple_boolean_dafny::r#_simple_dtypes_dboolean_dinternaldafny_dtypes::Error::Opaque { obj: ::dafny_runtime::upcast_object()(::dafny_runtime::object::new(unhandled)) }) } } #[allow(dead_code)] pub fn from_dafny_error( dafny_value: ::std::rc::Rc< - crate::implementation_from_dafny::r#_simple_dtypes_dboolean_dinternaldafny_dtypes::Error, + ::simple_boolean_dafny::r#_simple_dtypes_dboolean_dinternaldafny_dtypes::Error, >, ) -> crate::operation::get_boolean::GetBooleanError { // TODO: Losing information here, but we have to figure out how to wrap an arbitrary Dafny value as std::error::Error - if matches!(&dafny_value.as_ref(), crate::implementation_from_dafny::r#_simple_dtypes_dboolean_dinternaldafny_dtypes::Error::CollectionOfErrors { .. }) { + if matches!(&dafny_value.as_ref(), ::simple_boolean_dafny::r#_simple_dtypes_dboolean_dinternaldafny_dtypes::Error::CollectionOfErrors { .. }) { let error_message = "TODO: can't get message yet"; crate::operation::get_boolean::GetBooleanError::generic(::aws_smithy_types::error::metadata::ErrorMetadata::builder().message(error_message).build()) } else { diff --git a/TestModels/SimpleTypes/SimpleBoolean/runtimes/rust/src/conversions/get_boolean/_get_boolean_input.rs b/TestModels/SimpleTypes/SimpleBoolean/runtimes/rust/src/conversions/get_boolean/_get_boolean_input.rs index 27e4ef748c..efd9d5f83b 100644 --- a/TestModels/SimpleTypes/SimpleBoolean/runtimes/rust/src/conversions/get_boolean/_get_boolean_input.rs +++ b/TestModels/SimpleTypes/SimpleBoolean/runtimes/rust/src/conversions/get_boolean/_get_boolean_input.rs @@ -3,13 +3,13 @@ pub fn to_dafny( value: crate::operation::get_boolean::GetBooleanInput, ) -> ::std::rc::Rc< - crate::implementation_from_dafny::r#_simple_dtypes_dboolean_dinternaldafny_dtypes::GetBooleanInput, + ::simple_boolean_dafny::r#_simple_dtypes_dboolean_dinternaldafny_dtypes::GetBooleanInput, > { let dafny_value = match value.value { - Some(b) => crate::implementation_from_dafny::_Wrappers_Compile::Option::Some { value: b }, - None => crate::implementation_from_dafny::_Wrappers_Compile::Option::None {}, + Some(b) => ::simple_boolean_dafny::_Wrappers_Compile::Option::Some { value: b }, + None => ::simple_boolean_dafny::_Wrappers_Compile::Option::None {}, }; - ::std::rc::Rc::new(crate::implementation_from_dafny::r#_simple_dtypes_dboolean_dinternaldafny_dtypes::GetBooleanInput::GetBooleanInput { + ::std::rc::Rc::new(::simple_boolean_dafny::r#_simple_dtypes_dboolean_dinternaldafny_dtypes::GetBooleanInput::GetBooleanInput { value: ::std::rc::Rc::new(dafny_value) }) } @@ -17,17 +17,17 @@ pub fn to_dafny( #[allow(dead_code)] pub fn from_dafny( dafny_value: ::std::rc::Rc< - crate::implementation_from_dafny::r#_simple_dtypes_dboolean_dinternaldafny_dtypes::GetBooleanInput, + ::simple_boolean_dafny::r#_simple_dtypes_dboolean_dinternaldafny_dtypes::GetBooleanInput, >, ) -> crate::operation::get_boolean::GetBooleanInput { let value = if matches!( dafny_value.value().as_ref(), - crate::implementation_from_dafny::_Wrappers_Compile::Option::Some { .. } + ::simple_boolean_dafny::_Wrappers_Compile::Option::Some { .. } ) { Some(dafny_value.value().Extract()) } else if matches!( dafny_value.value().as_ref(), - crate::implementation_from_dafny::_Wrappers_Compile::Option::None { .. } + ::simple_boolean_dafny::_Wrappers_Compile::Option::None { .. } ) { None } else { diff --git a/TestModels/SimpleTypes/SimpleBoolean/runtimes/rust/src/conversions/get_boolean/_get_boolean_output.rs b/TestModels/SimpleTypes/SimpleBoolean/runtimes/rust/src/conversions/get_boolean/_get_boolean_output.rs index 719f9692fb..4b9dec69dd 100644 --- a/TestModels/SimpleTypes/SimpleBoolean/runtimes/rust/src/conversions/get_boolean/_get_boolean_output.rs +++ b/TestModels/SimpleTypes/SimpleBoolean/runtimes/rust/src/conversions/get_boolean/_get_boolean_output.rs @@ -3,13 +3,13 @@ pub fn to_dafny( value: crate::operation::get_boolean::GetBooleanOutput, ) -> ::std::rc::Rc< - crate::implementation_from_dafny::r#_simple_dtypes_dboolean_dinternaldafny_dtypes::GetBooleanOutput, + ::simple_boolean_dafny::r#_simple_dtypes_dboolean_dinternaldafny_dtypes::GetBooleanOutput, > { let dafny_value = match value.value { - Some(b) => crate::implementation_from_dafny::_Wrappers_Compile::Option::Some { value: b }, - None => crate::implementation_from_dafny::_Wrappers_Compile::Option::None {}, + Some(b) => ::simple_boolean_dafny::_Wrappers_Compile::Option::Some { value: b }, + None => ::simple_boolean_dafny::_Wrappers_Compile::Option::None {}, }; - ::std::rc::Rc::new(crate::implementation_from_dafny::r#_simple_dtypes_dboolean_dinternaldafny_dtypes::GetBooleanOutput::GetBooleanOutput { + ::std::rc::Rc::new(::simple_boolean_dafny::r#_simple_dtypes_dboolean_dinternaldafny_dtypes::GetBooleanOutput::GetBooleanOutput { value: ::std::rc::Rc::new(dafny_value) }) } @@ -17,17 +17,17 @@ pub fn to_dafny( #[allow(dead_code)] pub fn from_dafny( dafny_value: ::std::rc::Rc< - crate::implementation_from_dafny::r#_simple_dtypes_dboolean_dinternaldafny_dtypes::GetBooleanOutput, + ::simple_boolean_dafny::r#_simple_dtypes_dboolean_dinternaldafny_dtypes::GetBooleanOutput, >, ) -> crate::operation::get_boolean::GetBooleanOutput { let value = if matches!( dafny_value.value().as_ref(), - crate::implementation_from_dafny::_Wrappers_Compile::Option::Some { .. } + ::simple_boolean_dafny::_Wrappers_Compile::Option::Some { .. } ) { Some(dafny_value.value().Extract()) } else if matches!( dafny_value.value().as_ref(), - crate::implementation_from_dafny::_Wrappers_Compile::Option::None { .. } + ::simple_boolean_dafny::_Wrappers_Compile::Option::None { .. } ) { None } else { diff --git a/TestModels/SimpleTypes/SimpleBoolean/runtimes/rust/src/conversions/simple_boolean_config/_simple_boolean_config.rs b/TestModels/SimpleTypes/SimpleBoolean/runtimes/rust/src/conversions/simple_boolean_config/_simple_boolean_config.rs index a19536aa3a..7ef6a6cbff 100644 --- a/TestModels/SimpleTypes/SimpleBoolean/runtimes/rust/src/conversions/simple_boolean_config/_simple_boolean_config.rs +++ b/TestModels/SimpleTypes/SimpleBoolean/runtimes/rust/src/conversions/simple_boolean_config/_simple_boolean_config.rs @@ -6,15 +6,15 @@ use dafny_standard_library::implementation_from_dafny; pub fn to_dafny( value: crate::types::simple_boolean_config::SimpleBooleanConfig, ) -> ::std::rc::Rc< - crate::implementation_from_dafny::_simple_dtypes_dboolean_dinternaldafny_dtypes::SimpleBooleanConfig, + ::simple_boolean_dafny::_simple_dtypes_dboolean_dinternaldafny_dtypes::SimpleBooleanConfig, > { - ::std::rc::Rc::new(crate::implementation_from_dafny::r#_simple_dtypes_dboolean_dinternaldafny_dtypes::SimpleBooleanConfig::SimpleBooleanConfig {}) + ::std::rc::Rc::new(::simple_boolean_dafny::r#_simple_dtypes_dboolean_dinternaldafny_dtypes::SimpleBooleanConfig::SimpleBooleanConfig {}) } #[allow(dead_code)] pub fn from_dafny( dafny_value: ::std::rc::Rc< - crate::implementation_from_dafny::r#_simple_dtypes_dboolean_dinternaldafny_dtypes::SimpleBooleanConfig, + ::simple_boolean_dafny::r#_simple_dtypes_dboolean_dinternaldafny_dtypes::SimpleBooleanConfig, >, ) -> crate::types::simple_boolean_config::SimpleBooleanConfig { crate::types::simple_boolean_config::SimpleBooleanConfig {} diff --git a/TestModels/SimpleTypes/SimpleBoolean/runtimes/rust/src/lib.rs b/TestModels/SimpleTypes/SimpleBoolean/runtimes/rust/src/lib.rs index 118aa67ed6..445a4fe060 100644 --- a/TestModels/SimpleTypes/SimpleBoolean/runtimes/rust/src/lib.rs +++ b/TestModels/SimpleTypes/SimpleBoolean/runtimes/rust/src/lib.rs @@ -13,7 +13,5 @@ pub mod operation; pub mod conversions; -pub mod implementation_from_dafny; - pub use client::Client; pub use types::simple_boolean_config::SimpleBooleanConfig; diff --git a/TestModels/SimpleTypes/SimpleBoolean/runtimes/rust/src/operation/get_boolean.rs b/TestModels/SimpleTypes/SimpleBoolean/runtimes/rust/src/operation/get_boolean.rs index bb1fb9f8f1..638abe840d 100644 --- a/TestModels/SimpleTypes/SimpleBoolean/runtimes/rust/src/operation/get_boolean.rs +++ b/TestModels/SimpleTypes/SimpleBoolean/runtimes/rust/src/operation/get_boolean.rs @@ -20,7 +20,7 @@ impl GetBoolean { ::dafny_runtime::md!(client.dafny_client.clone()).GetBoolean(&inner_input); if matches!( inner_result.as_ref(), - crate::implementation_from_dafny::r#_Wrappers_Compile::Result::Success { .. } + ::simple_boolean_dafny::r#_Wrappers_Compile::Result::Success { .. } ) { Ok( crate::conversions::get_boolean::_get_boolean_output::from_dafny( diff --git a/TestModels/SimpleTypes/SimpleBoolean/runtimes/rust/tests/tests_from_dafny/_wrapped.rs b/TestModels/SimpleTypes/SimpleBoolean/runtimes/rust/tests/tests_from_dafny/_wrapped.rs index 9eede19f89..5988b6bc17 100644 --- a/TestModels/SimpleTypes/SimpleBoolean/runtimes/rust/tests/tests_from_dafny/_wrapped.rs +++ b/TestModels/SimpleTypes/SimpleBoolean/runtimes/rust/tests/tests_from_dafny/_wrapped.rs @@ -13,20 +13,20 @@ impl UpcastObject for WrappedClient { ::dafny_runtime::UpcastObjectFn!(dyn ::std::any::Any); } -impl super::r#_simple_dtypes_dboolean_dinternaldafny_dtypes::ISimpleTypesBooleanClient +impl ::simple_boolean_dafny::r#_simple_dtypes_dboolean_dinternaldafny_dtypes::ISimpleTypesBooleanClient for WrappedClient { fn GetBoolean( &mut self, input: &std::rc::Rc< - implementation_from_dafny::r#_simple_dtypes_dboolean_dinternaldafny_dtypes::GetBooleanInput, + ::simple_boolean_dafny::r#_simple_dtypes_dboolean_dinternaldafny_dtypes::GetBooleanInput, >, ) -> std::rc::Rc< - implementation_from_dafny::r#_Wrappers_Compile::Result< + ::simple_boolean_dafny::r#_Wrappers_Compile::Result< std::rc::Rc< - implementation_from_dafny::r#_simple_dtypes_dboolean_dinternaldafny_dtypes::GetBooleanOutput, + ::simple_boolean_dafny::r#_simple_dtypes_dboolean_dinternaldafny_dtypes::GetBooleanOutput, >, - std::rc::Rc, + std::rc::Rc<::simple_boolean_dafny::r#_simple_dtypes_dboolean_dinternaldafny_dtypes::Error>, >, >{ let inner_input = @@ -34,12 +34,12 @@ impl super::r#_simple_dtypes_dboolean_dinternaldafny_dtypes::ISimpleTypesBoolean let result = crate::operation::get_boolean::GetBoolean::send(&self.wrapped, inner_input); match result { Err(error) => ::std::rc::Rc::new( - crate::implementation_from_dafny::_Wrappers_Compile::Result::Failure { + ::simple_boolean_dafny::_Wrappers_Compile::Result::Failure { error: crate::conversions::get_boolean::to_dafny_error(error), }, ), Ok(client) => ::std::rc::Rc::new( - crate::implementation_from_dafny::_Wrappers_Compile::Result::Success { + ::simple_boolean_dafny::_Wrappers_Compile::Result::Success { value: crate::conversions::get_boolean::_get_boolean_output::to_dafny(client), }, ), @@ -49,10 +49,10 @@ impl super::r#_simple_dtypes_dboolean_dinternaldafny_dtypes::ISimpleTypesBoolean impl r#_simple_dtypes_dboolean_dinternaldafny_dwrapped::_default { pub fn WrappedSimpleBoolean(config: &::std::rc::Rc< - super::r#_simple_dtypes_dboolean_dinternaldafny_dtypes::SimpleBooleanConfig, - >) -> ::std::rc::Rc, - ::std::rc::Rc + ::simple_boolean_dafny::r#_simple_dtypes_dboolean_dinternaldafny_dtypes::SimpleBooleanConfig, + >) -> ::std::rc::Rc<::simple_boolean_dafny::r#_Wrappers_Compile::Result< + ::dafny_runtime::Object, + ::std::rc::Rc<::simple_boolean_dafny::r#_simple_dtypes_dboolean_dinternaldafny_dtypes::Error> >>{ let result = Client::from_conf( simple_boolean::conversions::simple_boolean_config::_simple_boolean_config::from_dafny( @@ -66,9 +66,9 @@ impl r#_simple_dtypes_dboolean_dinternaldafny_dwrapped::_default { ::std::cell::UnsafeCell::new(error), ))); ::std::rc::Rc::new( - crate::implementation_from_dafny::_Wrappers_Compile::Result::Failure { + ::simple_boolean_dafny::_Wrappers_Compile::Result::Failure { error: ::std::rc::Rc::new( - super::r#_simple_dtypes_dboolean_dinternaldafny_dtypes::Error::Opaque { + ::simple_boolean_dafny::r#_simple_dtypes_dboolean_dinternaldafny_dtypes::Error::Opaque { obj: error_obj, }, ), @@ -79,11 +79,11 @@ impl r#_simple_dtypes_dboolean_dinternaldafny_dwrapped::_default { let wrap = WrappedClient { wrapped: client.clone(), }; - let inner: ::std::rc::Rc<::std::cell::UnsafeCell> + let inner: ::std::rc::Rc<::std::cell::UnsafeCell> = ::std::rc::Rc::new(::std::cell::UnsafeCell::new(wrap)); ::std::rc::Rc::new( - crate::implementation_from_dafny::_Wrappers_Compile::Result::Success { + ::simple_boolean_dafny::_Wrappers_Compile::Result::Success { value: ::dafny_runtime::Object(Some(inner)), }, ) diff --git a/TestModels/SimpleTypes/SimpleBoolean/runtimes/rust/tests/tests_from_dafny/mod.rs b/TestModels/SimpleTypes/SimpleBoolean/runtimes/rust/tests/tests_from_dafny/mod.rs index 3304d282b1..7f1ba03179 100644 --- a/TestModels/SimpleTypes/SimpleBoolean/runtimes/rust/tests/tests_from_dafny/mod.rs +++ b/TestModels/SimpleTypes/SimpleBoolean/runtimes/rust/tests/tests_from_dafny/mod.rs @@ -1,6 +1,6 @@ #![allow(warnings, unconditional_panic)] #![allow(nonstandard_style)] -use simple_boolean::implementation_from_dafny::*; +use ::simple_boolean_dafny::*; use simple_boolean::*; mod _wrapped; From c4d3b28d384a00280040f1fca864497a37d8b2ce Mon Sep 17 00:00:00 2001 From: Robin Salkeld Date: Wed, 10 Jul 2024 11:06:29 -0700 Subject: [PATCH 34/53] Update patch --- .../codegen-patches/rust/dafny-4.5.0.patch | 81 ++++++++----------- 1 file changed, 33 insertions(+), 48 deletions(-) diff --git a/TestModels/SimpleTypes/SimpleBoolean/codegen-patches/rust/dafny-4.5.0.patch b/TestModels/SimpleTypes/SimpleBoolean/codegen-patches/rust/dafny-4.5.0.patch index 77ad551803..d9f09af9a2 100644 --- a/TestModels/SimpleTypes/SimpleBoolean/codegen-patches/rust/dafny-4.5.0.patch +++ b/TestModels/SimpleTypes/SimpleBoolean/codegen-patches/rust/dafny-4.5.0.patch @@ -1,6 +1,6 @@ diff --git b/TestModels/SimpleTypes/SimpleBoolean/runtimes/rust/src/client.rs a/TestModels/SimpleTypes/SimpleBoolean/runtimes/rust/src/client.rs new file mode 100644 -index 00000000..7a4f6c04 +index 00000000..89478da5 --- /dev/null +++ a/TestModels/SimpleTypes/SimpleBoolean/runtimes/rust/src/client.rs @@ -0,0 +1,37 @@ @@ -10,7 +10,7 @@ index 00000000..7a4f6c04 + +#[derive(::std::clone::Clone, ::std::fmt::Debug)] +pub struct Client { -+ pub(crate) dafny_client: ::dafny_runtime::Object ++ pub(crate) dafny_client: ::dafny_runtime::Object +} + +impl Client { @@ -20,12 +20,12 @@ index 00000000..7a4f6c04 + conf: crate::types::simple_boolean_config::SimpleBooleanConfig, + ) -> Result { + let inner = -+ crate::implementation_from_dafny::_simple_dtypes_dboolean_dinternaldafny::_default::SimpleBoolean( ++ ::simple_boolean_dafny::_simple_dtypes_dboolean_dinternaldafny::_default::SimpleBoolean( + &crate::conversions::simple_boolean_config::_simple_boolean_config::to_dafny(conf), + ); + if matches!( + inner.as_ref(), -+ crate::implementation_from_dafny::_Wrappers_Compile::Result::Failure { .. } ++ ::simple_boolean_dafny::_Wrappers_Compile::Result::Failure { .. } + ) { + // TODO: convert error - the potential types are not modeled! + return Err(BuildError::other( @@ -72,7 +72,7 @@ index 00000000..c1acac7b +pub mod simple_boolean_config; diff --git b/TestModels/SimpleTypes/SimpleBoolean/runtimes/rust/src/conversions/get_boolean.rs a/TestModels/SimpleTypes/SimpleBoolean/runtimes/rust/src/conversions/get_boolean.rs new file mode 100644 -index 00000000..d4f59b2f +index 00000000..b98bc057 --- /dev/null +++ a/TestModels/SimpleTypes/SimpleBoolean/runtimes/rust/src/conversions/get_boolean.rs @@ -0,0 +1,32 @@ @@ -83,21 +83,21 @@ index 00000000..d4f59b2f +#[allow(dead_code)] +pub fn to_dafny_error( + value: crate::operation::get_boolean::GetBooleanError, -+) -> ::std::rc::Rc { ++) -> ::std::rc::Rc<::simple_boolean_dafny::r#_simple_dtypes_dboolean_dinternaldafny_dtypes::Error> { + match value { + crate::operation::get_boolean::GetBooleanError::Unhandled(unhandled) => -+ ::std::rc::Rc::new(crate::implementation_from_dafny::r#_simple_dtypes_dboolean_dinternaldafny_dtypes::Error::Opaque { obj: ::dafny_runtime::upcast_object()(::dafny_runtime::object::new(unhandled)) }) ++ ::std::rc::Rc::new(::simple_boolean_dafny::r#_simple_dtypes_dboolean_dinternaldafny_dtypes::Error::Opaque { obj: ::dafny_runtime::upcast_object()(::dafny_runtime::object::new(unhandled)) }) + } +} + +#[allow(dead_code)] +pub fn from_dafny_error( + dafny_value: ::std::rc::Rc< -+ crate::implementation_from_dafny::r#_simple_dtypes_dboolean_dinternaldafny_dtypes::Error, ++ ::simple_boolean_dafny::r#_simple_dtypes_dboolean_dinternaldafny_dtypes::Error, + >, +) -> crate::operation::get_boolean::GetBooleanError { + // TODO: Losing information here, but we have to figure out how to wrap an arbitrary Dafny value as std::error::Error -+ if matches!(&dafny_value.as_ref(), crate::implementation_from_dafny::r#_simple_dtypes_dboolean_dinternaldafny_dtypes::Error::CollectionOfErrors { .. }) { ++ if matches!(&dafny_value.as_ref(), ::simple_boolean_dafny::r#_simple_dtypes_dboolean_dinternaldafny_dtypes::Error::CollectionOfErrors { .. }) { + let error_message = "TODO: can't get message yet"; + crate::operation::get_boolean::GetBooleanError::generic(::aws_smithy_types::error::metadata::ErrorMetadata::builder().message(error_message).build()) + } else { @@ -110,7 +110,7 @@ index 00000000..d4f59b2f +pub mod _get_boolean_output; diff --git b/TestModels/SimpleTypes/SimpleBoolean/runtimes/rust/src/conversions/get_boolean/_get_boolean_input.rs a/TestModels/SimpleTypes/SimpleBoolean/runtimes/rust/src/conversions/get_boolean/_get_boolean_input.rs new file mode 100644 -index 00000000..27e4ef74 +index 00000000..efd9d5f8 --- /dev/null +++ a/TestModels/SimpleTypes/SimpleBoolean/runtimes/rust/src/conversions/get_boolean/_get_boolean_input.rs @@ -0,0 +1,37 @@ @@ -119,13 +119,13 @@ index 00000000..27e4ef74 +pub fn to_dafny( + value: crate::operation::get_boolean::GetBooleanInput, +) -> ::std::rc::Rc< -+ crate::implementation_from_dafny::r#_simple_dtypes_dboolean_dinternaldafny_dtypes::GetBooleanInput, ++ ::simple_boolean_dafny::r#_simple_dtypes_dboolean_dinternaldafny_dtypes::GetBooleanInput, +> { + let dafny_value = match value.value { -+ Some(b) => crate::implementation_from_dafny::_Wrappers_Compile::Option::Some { value: b }, -+ None => crate::implementation_from_dafny::_Wrappers_Compile::Option::None {}, ++ Some(b) => ::simple_boolean_dafny::_Wrappers_Compile::Option::Some { value: b }, ++ None => ::simple_boolean_dafny::_Wrappers_Compile::Option::None {}, + }; -+ ::std::rc::Rc::new(crate::implementation_from_dafny::r#_simple_dtypes_dboolean_dinternaldafny_dtypes::GetBooleanInput::GetBooleanInput { ++ ::std::rc::Rc::new(::simple_boolean_dafny::r#_simple_dtypes_dboolean_dinternaldafny_dtypes::GetBooleanInput::GetBooleanInput { + value: ::std::rc::Rc::new(dafny_value) + }) +} @@ -133,17 +133,17 @@ index 00000000..27e4ef74 +#[allow(dead_code)] +pub fn from_dafny( + dafny_value: ::std::rc::Rc< -+ crate::implementation_from_dafny::r#_simple_dtypes_dboolean_dinternaldafny_dtypes::GetBooleanInput, ++ ::simple_boolean_dafny::r#_simple_dtypes_dboolean_dinternaldafny_dtypes::GetBooleanInput, + >, +) -> crate::operation::get_boolean::GetBooleanInput { + let value = if matches!( + dafny_value.value().as_ref(), -+ crate::implementation_from_dafny::_Wrappers_Compile::Option::Some { .. } ++ ::simple_boolean_dafny::_Wrappers_Compile::Option::Some { .. } + ) { + Some(dafny_value.value().Extract()) + } else if matches!( + dafny_value.value().as_ref(), -+ crate::implementation_from_dafny::_Wrappers_Compile::Option::None { .. } ++ ::simple_boolean_dafny::_Wrappers_Compile::Option::None { .. } + ) { + None + } else { @@ -153,7 +153,7 @@ index 00000000..27e4ef74 +} diff --git b/TestModels/SimpleTypes/SimpleBoolean/runtimes/rust/src/conversions/get_boolean/_get_boolean_output.rs a/TestModels/SimpleTypes/SimpleBoolean/runtimes/rust/src/conversions/get_boolean/_get_boolean_output.rs new file mode 100644 -index 00000000..719f9692 +index 00000000..4b9dec69 --- /dev/null +++ a/TestModels/SimpleTypes/SimpleBoolean/runtimes/rust/src/conversions/get_boolean/_get_boolean_output.rs @@ -0,0 +1,37 @@ @@ -162,13 +162,13 @@ index 00000000..719f9692 +pub fn to_dafny( + value: crate::operation::get_boolean::GetBooleanOutput, +) -> ::std::rc::Rc< -+ crate::implementation_from_dafny::r#_simple_dtypes_dboolean_dinternaldafny_dtypes::GetBooleanOutput, ++ ::simple_boolean_dafny::r#_simple_dtypes_dboolean_dinternaldafny_dtypes::GetBooleanOutput, +> { + let dafny_value = match value.value { -+ Some(b) => crate::implementation_from_dafny::_Wrappers_Compile::Option::Some { value: b }, -+ None => crate::implementation_from_dafny::_Wrappers_Compile::Option::None {}, ++ Some(b) => ::simple_boolean_dafny::_Wrappers_Compile::Option::Some { value: b }, ++ None => ::simple_boolean_dafny::_Wrappers_Compile::Option::None {}, + }; -+ ::std::rc::Rc::new(crate::implementation_from_dafny::r#_simple_dtypes_dboolean_dinternaldafny_dtypes::GetBooleanOutput::GetBooleanOutput { ++ ::std::rc::Rc::new(::simple_boolean_dafny::r#_simple_dtypes_dboolean_dinternaldafny_dtypes::GetBooleanOutput::GetBooleanOutput { + value: ::std::rc::Rc::new(dafny_value) + }) +} @@ -176,17 +176,17 @@ index 00000000..719f9692 +#[allow(dead_code)] +pub fn from_dafny( + dafny_value: ::std::rc::Rc< -+ crate::implementation_from_dafny::r#_simple_dtypes_dboolean_dinternaldafny_dtypes::GetBooleanOutput, ++ ::simple_boolean_dafny::r#_simple_dtypes_dboolean_dinternaldafny_dtypes::GetBooleanOutput, + >, +) -> crate::operation::get_boolean::GetBooleanOutput { + let value = if matches!( + dafny_value.value().as_ref(), -+ crate::implementation_from_dafny::_Wrappers_Compile::Option::Some { .. } ++ ::simple_boolean_dafny::_Wrappers_Compile::Option::Some { .. } + ) { + Some(dafny_value.value().Extract()) + } else if matches!( + dafny_value.value().as_ref(), -+ crate::implementation_from_dafny::_Wrappers_Compile::Option::None { .. } ++ ::simple_boolean_dafny::_Wrappers_Compile::Option::None { .. } + ) { + None + } else { @@ -205,7 +205,7 @@ index 00000000..371a47e5 +pub mod _simple_boolean_config; diff --git b/TestModels/SimpleTypes/SimpleBoolean/runtimes/rust/src/conversions/simple_boolean_config/_simple_boolean_config.rs a/TestModels/SimpleTypes/SimpleBoolean/runtimes/rust/src/conversions/simple_boolean_config/_simple_boolean_config.rs new file mode 100644 -index 00000000..a19536aa +index 00000000..7ef6a6cb --- /dev/null +++ a/TestModels/SimpleTypes/SimpleBoolean/runtimes/rust/src/conversions/simple_boolean_config/_simple_boolean_config.rs @@ -0,0 +1,21 @@ @@ -217,15 +217,15 @@ index 00000000..a19536aa +pub fn to_dafny( + value: crate::types::simple_boolean_config::SimpleBooleanConfig, +) -> ::std::rc::Rc< -+ crate::implementation_from_dafny::_simple_dtypes_dboolean_dinternaldafny_dtypes::SimpleBooleanConfig, ++ ::simple_boolean_dafny::_simple_dtypes_dboolean_dinternaldafny_dtypes::SimpleBooleanConfig, +> { -+ ::std::rc::Rc::new(crate::implementation_from_dafny::r#_simple_dtypes_dboolean_dinternaldafny_dtypes::SimpleBooleanConfig::SimpleBooleanConfig {}) ++ ::std::rc::Rc::new(::simple_boolean_dafny::r#_simple_dtypes_dboolean_dinternaldafny_dtypes::SimpleBooleanConfig::SimpleBooleanConfig {}) +} + +#[allow(dead_code)] +pub fn from_dafny( + dafny_value: ::std::rc::Rc< -+ crate::implementation_from_dafny::r#_simple_dtypes_dboolean_dinternaldafny_dtypes::SimpleBooleanConfig, ++ ::simple_boolean_dafny::r#_simple_dtypes_dboolean_dinternaldafny_dtypes::SimpleBooleanConfig, + >, +) -> crate::types::simple_boolean_config::SimpleBooleanConfig { + crate::types::simple_boolean_config::SimpleBooleanConfig {} @@ -289,10 +289,10 @@ index 00000000..4d66eb2e \ No newline at end of file diff --git b/TestModels/SimpleTypes/SimpleBoolean/runtimes/rust/src/lib.rs a/TestModels/SimpleTypes/SimpleBoolean/runtimes/rust/src/lib.rs new file mode 100644 -index 00000000..118aa67e +index 00000000..445a4fe0 --- /dev/null +++ a/TestModels/SimpleTypes/SimpleBoolean/runtimes/rust/src/lib.rs -@@ -0,0 +1,19 @@ +@@ -0,0 +1,17 @@ +#![allow(deprecated)] + +// Code generated by software.amazon.smithy.rust.codegen.smithy-rs. DO NOT EDIT. @@ -308,8 +308,6 @@ index 00000000..118aa67e + +pub mod conversions; + -+pub mod implementation_from_dafny; -+ +pub use client::Client; +pub use types::simple_boolean_config::SimpleBooleanConfig; diff --git b/TestModels/SimpleTypes/SimpleBoolean/runtimes/rust/src/operation.rs a/TestModels/SimpleTypes/SimpleBoolean/runtimes/rust/src/operation.rs @@ -324,7 +322,7 @@ index 00000000..eb38b9f1 +pub mod get_boolean; diff --git b/TestModels/SimpleTypes/SimpleBoolean/runtimes/rust/src/operation/get_boolean.rs a/TestModels/SimpleTypes/SimpleBoolean/runtimes/rust/src/operation/get_boolean.rs new file mode 100644 -index 00000000..bb1fb9f8 +index 00000000..638abe84 --- /dev/null +++ a/TestModels/SimpleTypes/SimpleBoolean/runtimes/rust/src/operation/get_boolean.rs @@ -0,0 +1,145 @@ @@ -350,7 +348,7 @@ index 00000000..bb1fb9f8 + ::dafny_runtime::md!(client.dafny_client.clone()).GetBoolean(&inner_input); + if matches!( + inner_result.as_ref(), -+ crate::implementation_from_dafny::r#_Wrappers_Compile::Result::Success { .. } ++ ::simple_boolean_dafny::r#_Wrappers_Compile::Result::Success { .. } + ) { + Ok( + crate::conversions::get_boolean::_get_boolean_output::from_dafny( @@ -723,16 +721,3 @@ index 00000000..6bf027f6 + ::std::result::Result::Ok(SimpleBooleanConfig {}) + } +} -diff --git b/TestModels/SimpleTypes/SimpleBoolean/runtimes/rust/tests/tests_from_dafny/mod.rs a/TestModels/SimpleTypes/SimpleBoolean/runtimes/rust/tests/tests_from_dafny/mod.rs -index ce6d90a2..3304d282 100644 ---- b/TestModels/SimpleTypes/SimpleBoolean/runtimes/rust/tests/tests_from_dafny/mod.rs -+++ a/TestModels/SimpleTypes/SimpleBoolean/runtimes/rust/tests/tests_from_dafny/mod.rs -@@ -1,5 +1,8 @@ - #![allow(warnings, unconditional_panic)] - #![allow(nonstandard_style)] -+use simple_boolean::implementation_from_dafny::*; -+use simple_boolean::*; -+mod _wrapped; - - pub mod r#_simple_dtypes_dboolean_dinternaldafny_dwrapped { - pub struct _default {} From 1833dbbe47e577516f40fee3c00597aba0c59831 Mon Sep 17 00:00:00 2001 From: Robin Salkeld Date: Wed, 10 Jul 2024 11:17:00 -0700 Subject: [PATCH 35/53] Makefile fixes --- SmithyDafnyMakefile.mk | 3 ++- TestModels/SharedMakefile.mk | 4 ++-- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/SmithyDafnyMakefile.mk b/SmithyDafnyMakefile.mk index cb3aa66465..4b95994104 100644 --- a/SmithyDafnyMakefile.mk +++ b/SmithyDafnyMakefile.mk @@ -543,7 +543,8 @@ _mv_implementation_rust: rustfmt runtimes/rust/dafny_impl/src/implementation_from_dafny.rs rm -rf implementation_from_dafny-rust _mv_test_rust: - rm -f runtimes/rust/tests/tests_from_dafny.rs + rm -f runtimes/rust/tests/tests_from_dafny/mod.rs + mkdir -p runtimes/rust/tests/tests_from_dafny mv tests_from_dafny-rust/src/tests_from_dafny.rs runtimes/rust/tests/tests_from_dafny/mod.rs rustfmt runtimes/rust/tests/tests_from_dafny/mod.rs rm -rf tests_from_dafny-rust diff --git a/TestModels/SharedMakefile.mk b/TestModels/SharedMakefile.mk index 4cb2257c64..b5892fdaa2 100644 --- a/TestModels/SharedMakefile.mk +++ b/TestModels/SharedMakefile.mk @@ -74,5 +74,5 @@ _polymorph_rust: OUTPUT_RUST=--output-rust $(LIBRARY_ROOT)/runtimes/rust _polymorph_rust: INPUT_DAFNY=\ --include-dafny $(PROJECT_ROOT)/$(STD_LIBRARY)/src/Index.dfy _polymorph_rust: _polymorph -_polymorph_rust: OUTPUT_RUST_WRAPPED=--output-rust $(LIBRARY_ROOT)/runtimes/rust -_polymorph_rust: _polymorph_wrapped +# _polymorph_rust: OUTPUT_RUST_WRAPPED=--output-rust $(LIBRARY_ROOT)/runtimes/rust +# _polymorph_rust: _polymorph_wrapped From 7c490e115789220fe1c34c890ec097dd3cb41ce1 Mon Sep 17 00:00:00 2001 From: Robin Salkeld Date: Wed, 10 Jul 2024 11:25:44 -0700 Subject: [PATCH 36/53] update patch --- .../codegen-patches/rust/dafny-4.5.0.patch | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/TestModels/SimpleTypes/SimpleBoolean/codegen-patches/rust/dafny-4.5.0.patch b/TestModels/SimpleTypes/SimpleBoolean/codegen-patches/rust/dafny-4.5.0.patch index d9f09af9a2..9e97d2e220 100644 --- a/TestModels/SimpleTypes/SimpleBoolean/codegen-patches/rust/dafny-4.5.0.patch +++ b/TestModels/SimpleTypes/SimpleBoolean/codegen-patches/rust/dafny-4.5.0.patch @@ -721,3 +721,16 @@ index 00000000..6bf027f6 + ::std::result::Result::Ok(SimpleBooleanConfig {}) + } +} +diff --git b/TestModels/SimpleTypes/SimpleBoolean/runtimes/rust/tests/tests_from_dafny/mod.rs a/TestModels/SimpleTypes/SimpleBoolean/runtimes/rust/tests/tests_from_dafny/mod.rs +index ce6d90a2..7f1ba031 100644 +--- b/TestModels/SimpleTypes/SimpleBoolean/runtimes/rust/tests/tests_from_dafny/mod.rs ++++ a/TestModels/SimpleTypes/SimpleBoolean/runtimes/rust/tests/tests_from_dafny/mod.rs +@@ -1,5 +1,8 @@ + #![allow(warnings, unconditional_panic)] + #![allow(nonstandard_style)] ++use ::simple_boolean_dafny::*; ++use simple_boolean::*; ++mod _wrapped; + + pub mod r#_simple_dtypes_dboolean_dinternaldafny_dwrapped { + pub struct _default {} From 08c8af81106aaed0cc26cc4d85e808911e3b3f87 Mon Sep 17 00:00:00 2001 From: Robin Salkeld Date: Wed, 10 Jul 2024 11:26:49 -0700 Subject: [PATCH 37/53] Formatting --- .../src/main/java/software/amazon/polymorph/CodegenEngine.java | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/codegen/smithy-dafny-codegen/src/main/java/software/amazon/polymorph/CodegenEngine.java b/codegen/smithy-dafny-codegen/src/main/java/software/amazon/polymorph/CodegenEngine.java index 934f5fb14e..82abf4c8ef 100644 --- a/codegen/smithy-dafny-codegen/src/main/java/software/amazon/polymorph/CodegenEngine.java +++ b/codegen/smithy-dafny-codegen/src/main/java/software/amazon/polymorph/CodegenEngine.java @@ -6,9 +6,8 @@ import com.google.common.base.Strings; import com.google.common.collect.ImmutableMap; import com.google.common.collect.Streams; - -import java.io.File; import com.squareup.javapoet.ClassName; +import java.io.File; import java.io.IOException; import java.io.UncheckedIOException; import java.nio.file.Files; From dbf1849297ff9e9749ecb6345fe32a7f6b8d2b47 Mon Sep 17 00:00:00 2001 From: Robin Salkeld Date: Wed, 10 Jul 2024 13:41:57 -0700 Subject: [PATCH 38/53] Fix StandardLibrary --- .../StandardLibrary/Makefile | 6 - .../StandardLibrary/runtimes/rust/src/lib.rs | 296 +----- .../rust/tests/standard_library_tests.rs | 7 + .../rust/tests/tests_from_dafny/mod.rs | 919 ++++++++++++++++++ .../StandardLibrary/src_for_rust/Index.dfy | 10 - .../StandardLibrary/test_for_rust/Index.dfy | 5 - 6 files changed, 927 insertions(+), 316 deletions(-) create mode 100644 TestModels/dafny-dependencies/StandardLibrary/runtimes/rust/tests/standard_library_tests.rs create mode 100644 TestModels/dafny-dependencies/StandardLibrary/runtimes/rust/tests/tests_from_dafny/mod.rs delete mode 100644 TestModels/dafny-dependencies/StandardLibrary/src_for_rust/Index.dfy delete mode 100644 TestModels/dafny-dependencies/StandardLibrary/test_for_rust/Index.dfy diff --git a/TestModels/dafny-dependencies/StandardLibrary/Makefile b/TestModels/dafny-dependencies/StandardLibrary/Makefile index 3dcd26f9c1..b1dd89a26e 100644 --- a/TestModels/dafny-dependencies/StandardLibrary/Makefile +++ b/TestModels/dafny-dependencies/StandardLibrary/Makefile @@ -67,8 +67,6 @@ transpile_java: | transpile_implementation_java transpile_test_java # StandardLibrary as a dependency transpile_rust: | transpile_implementation_rust -RUST_TEST_INDEX=test_for_rust - # Override the targets to relocate translated Rust code directly into the main crate, # instead of the dafny_impl sub-crate. # We also don't want to delete the src directory since we have an extern in there too. @@ -76,10 +74,6 @@ _mv_implementation_rust: mv implementation_from_dafny-rust/src/implementation_from_dafny.rs runtimes/rust/src/implementation_from_dafny.rs rustfmt runtimes/rust/src/implementation_from_dafny.rs rm -rf implementation_from_dafny-rust -_mv_test_rust: - mv tests_from_dafny-rust/src/tests_from_dafny.rs runtimes/rust/tests/tests_from_dafny.rs - rustfmt runtimes/rust/tests/tests_from_dafny.rs - rm -rf tests_from_dafny-rust transpile_dependencies: echo "Skipping transpile_dependencies for StandardLibrary" diff --git a/TestModels/dafny-dependencies/StandardLibrary/runtimes/rust/src/lib.rs b/TestModels/dafny-dependencies/StandardLibrary/runtimes/rust/src/lib.rs index 4b9fb6f84f..12cdf22190 100644 --- a/TestModels/dafny-dependencies/StandardLibrary/runtimes/rust/src/lib.rs +++ b/TestModels/dafny-dependencies/StandardLibrary/runtimes/rust/src/lib.rs @@ -1,298 +1,4 @@ #[allow(non_snake_case)] pub mod UTF8; pub mod conversion; -pub mod implementation_from_dafny; - -#[cfg(test)] -#[allow(non_snake_case)] -mod TestUTF8 { - use super::*; - #[test] - fn TestEncodeHappyCase() { - let unicodeString = ::dafny_runtime::string_utf16_of("abc\u{0306}\u{01FD}\u{03B2}"); - let expectedBytes = - dafny_runtime::seq![0x61, 0x62, 0x63, 0xCC, 0x86, 0xC7, 0xBD, 0xCE, 0xB2]; - let _r = implementation_from_dafny::UTF8::_default::Encode(&unicodeString); - if _r.IsFailure() { - panic!("Encode failed"); - } - let encoded = _r.Extract(); - assert_eq!(expectedBytes, encoded); - } - - #[test] - fn TestEncodeInvalidUnicode() { - let invalidUnicode = ::dafny_runtime::seq![ - ::dafny_runtime::DafnyCharUTF16('a' as u16), - ::dafny_runtime::DafnyCharUTF16('b' as u16), - ::dafny_runtime::DafnyCharUTF16('c' as u16), - ::dafny_runtime::DafnyCharUTF16(0xD800) - ]; - let encoded = implementation_from_dafny::UTF8::_default::Encode(&invalidUnicode); - assert!(encoded.IsFailure()); - } - - #[test] - fn TestDecodeHappyCase() { - let unicodeBytes = - ::dafny_runtime::seq![0x61, 0x62, 0x63, 0xCC, 0x86, 0xC7, 0xBD, 0xCE, 0xB2]; - assert!( - implementation_from_dafny::UTF8::_default::Uses2Bytes( - &::dafny_runtime::seq![0xC7 as u8, 0xBD as u8, 0xCE as u8, 0xB2 as u8] - ) - ); - assert_eq!( - ::dafny_runtime::seq![0xC7 as u8, 0xBD as u8, 0xCE as u8, 0xB2 as u8], - unicodeBytes.slice(&::dafny_runtime::int!(5), &::dafny_runtime::int!(9)) - ); - assert!( - implementation_from_dafny::UTF8::_default::ValidUTF8Range( - &unicodeBytes, - &::dafny_runtime::int!(7), - &::dafny_runtime::int!(9) - ) - ); - assert!( - implementation_from_dafny::UTF8::_default::ValidUTF8Range( - &unicodeBytes, - &::dafny_runtime::int!(0), - &::dafny_runtime::int!(9) - ) - ); - let expectedString = ::dafny_runtime::string_utf16_of("abc\u{0306}\u{01FD}\u{03B2}"); - let _r = implementation_from_dafny::UTF8::_default::Decode(&unicodeBytes); - if _r.IsFailure() { - panic!("Decode failed"); - } - let decoded = _r.Extract(); - assert_eq!(expectedString, decoded); - } - - #[test] - fn TestDecodeInvalidUnicode() { - let invalidUnicode = ::dafny_runtime::seq![ - 0x61 as u8, 0x62 as u8, 0x63 as u8, 0xED as u8, 0xA0 as u8, 0x80 as u8 - ]; - let _r = implementation_from_dafny::UTF8::_default::Decode(&invalidUnicode); - assert!(_r.IsFailure()); - } - - #[test] - fn Test1Byte() { - // Null - let mut decoded = ::dafny_runtime::string_utf16_of("\u{0000}"); - let mut _r = implementation_from_dafny::UTF8::_default::Encode(&decoded); - assert!(!_r.IsFailure()); - let mut encoded = _r.Extract(); - assert_eq!(::dafny_runtime::seq![0x00 as u8], encoded); - assert!(implementation_from_dafny::UTF8::_default::Uses1Byte(&encoded)); - let mut _r2 = implementation_from_dafny::UTF8::_default::Decode(&encoded); - assert!(!_r2.IsFailure()); - let mut redecoded = _r2.Extract(); - assert_eq!(decoded, redecoded); - - // Space - decoded = ::dafny_runtime::string_utf16_of(" "); - _r = implementation_from_dafny::UTF8::_default::Encode(&decoded); - assert!(!_r.IsFailure()); - encoded = _r.Extract(); - assert_eq!(::dafny_runtime::seq![0x20 as u8], encoded); - assert!(implementation_from_dafny::UTF8::_default::Uses1Byte(&encoded)); - _r2 = implementation_from_dafny::UTF8::_default::Decode(&encoded); - assert!(!_r2.IsFailure()); - redecoded = _r2.Extract(); - assert_eq!(decoded, redecoded); - - decoded = ::dafny_runtime::string_utf16_of("$"); - _r = implementation_from_dafny::UTF8::_default::Encode(&decoded); - assert!(!_r.IsFailure()); - encoded = _r.Extract(); - assert_eq!(::dafny_runtime::seq![0x24 as u8], encoded); - assert!(implementation_from_dafny::UTF8::_default::Uses1Byte(&encoded)); - _r2 = implementation_from_dafny::UTF8::_default::Decode(&encoded); - assert!(!_r2.IsFailure()); - redecoded = _r2.Extract(); - assert_eq!(decoded, redecoded); - - decoded = ::dafny_runtime::string_utf16_of("0"); - _r = implementation_from_dafny::UTF8::_default::Encode(&decoded); - assert!(!_r.IsFailure()); - encoded = _r.Extract(); - assert_eq!(::dafny_runtime::seq![0x30 as u8], encoded); - assert!(implementation_from_dafny::UTF8::_default::Uses1Byte(&encoded)); - _r2 = implementation_from_dafny::UTF8::_default::Decode(&encoded); - assert!(!_r2.IsFailure()); - redecoded = _r2.Extract(); - assert_eq!(decoded, redecoded); - decoded = ::dafny_runtime::string_utf16_of("A"); - _r = implementation_from_dafny::UTF8::_default::Encode(&decoded); - assert!(!_r.IsFailure()); - encoded = _r.Extract(); - assert_eq!(::dafny_runtime::seq![0x41 as u8], encoded); - assert!(implementation_from_dafny::UTF8::_default::Uses1Byte(&encoded)); - _r2 = implementation_from_dafny::UTF8::_default::Decode(&encoded); - assert!(!_r2.IsFailure()); - redecoded = _r2.Extract(); - assert_eq!(decoded, redecoded); - decoded = ::dafny_runtime::string_utf16_of("a"); - _r = implementation_from_dafny::UTF8::_default::Encode(&decoded); - assert!(!_r.IsFailure()); - encoded = _r.Extract(); - assert_eq!(::dafny_runtime::seq![0x61 as u8], encoded); - assert!(implementation_from_dafny::UTF8::_default::Uses1Byte(&encoded)); - _r2 = implementation_from_dafny::UTF8::_default::Decode(&encoded); - assert!(!_r2.IsFailure()); - redecoded = _r2.Extract(); - assert_eq!(decoded, redecoded); - } - - #[test] - fn Test2Bytes() { - let mut decoded = ::dafny_runtime::string_utf16_of("\u{00A3}"); - let mut _r = implementation_from_dafny::UTF8::_default::Encode(&decoded); - assert!(!_r.IsFailure()); - let mut encoded = _r.Extract(); - assert_eq!(::dafny_runtime::seq![0xC2 as u8, 0xA3 as u8], encoded); - assert!(implementation_from_dafny::UTF8::_default::Uses2Bytes(&encoded)); - let mut _r2 = implementation_from_dafny::UTF8::_default::Decode(&encoded); - assert!(!_r2.IsFailure()); - let mut redecoded = _r2.Extract(); - assert_eq!(decoded, redecoded); - decoded = ::dafny_runtime::string_utf16_of("\u{00A9}"); - _r = implementation_from_dafny::UTF8::_default::Encode(&decoded); - assert!(!_r.IsFailure()); - encoded = _r.Extract(); - assert_eq!(::dafny_runtime::seq![0xC2 as u8, 0xA9 as u8], encoded); - assert!(implementation_from_dafny::UTF8::_default::Uses2Bytes(&encoded)); - _r2 = implementation_from_dafny::UTF8::_default::Decode(&encoded); - assert!(!_r2.IsFailure()); - redecoded = _r2.Extract(); - assert_eq!(decoded, redecoded); - decoded = ::dafny_runtime::string_utf16_of("\u{00AE}"); - _r = implementation_from_dafny::UTF8::_default::Encode(&decoded); - assert!(!_r.IsFailure()); - encoded = _r.Extract(); - assert_eq!(::dafny_runtime::seq![0xC2 as u8, 0xAE as u8], encoded); - assert!(implementation_from_dafny::UTF8::_default::Uses2Bytes(&encoded)); - _r2 = implementation_from_dafny::UTF8::_default::Decode(&encoded); - assert!(!_r2.IsFailure()); - redecoded = _r2.Extract(); - assert_eq!(decoded, redecoded); - decoded = ::dafny_runtime::string_utf16_of("\u{03C0}"); - _r = implementation_from_dafny::UTF8::_default::Encode(&decoded); - assert!(!_r.IsFailure()); - encoded = _r.Extract(); - assert_eq!(::dafny_runtime::seq![0xCF as u8, 0x80 as u8], encoded); - assert!(implementation_from_dafny::UTF8::_default::Uses2Bytes(&encoded)); - _r2 = implementation_from_dafny::UTF8::_default::Decode(&encoded); - assert!(!_r2.IsFailure()); - redecoded = _r2.Extract(); - assert_eq!(decoded, redecoded); - } - - #[test] - fn Test3Bytes() { - let mut decoded = ::dafny_runtime::string_utf16_of("\u{2386}"); - let mut _r = implementation_from_dafny::UTF8::_default::Encode(&decoded); - assert!(!_r.IsFailure()); - let mut encoded = _r.Extract(); - assert_eq!( - ::dafny_runtime::seq![0xE2 as u8, 0x8E as u8, 0x86 as u8], - encoded - ); - assert!(implementation_from_dafny::UTF8::_default::Uses3Bytes(&encoded)); - let mut _r2 = implementation_from_dafny::UTF8::_default::Decode(&encoded); - assert!(!_r2.IsFailure()); - let mut redecoded = _r2.Extract(); - assert_eq!(decoded, redecoded); - decoded = ::dafny_runtime::string_utf16_of("\u{2387}"); - _r = implementation_from_dafny::UTF8::_default::Encode(&decoded); - assert!(!_r.IsFailure()); - encoded = _r.Extract(); - assert_eq!( - ::dafny_runtime::seq![0xE2 as u8, 0x8E as u8, 0x87 as u8], - encoded - ); - assert!(implementation_from_dafny::UTF8::_default::Uses3Bytes(&encoded)); - _r2 = implementation_from_dafny::UTF8::_default::Decode(&encoded); - assert!(!_r2.IsFailure()); - redecoded = _r2.Extract(); - assert_eq!(decoded, redecoded); - decoded = ::dafny_runtime::string_utf16_of("\u{231B}"); - _r = implementation_from_dafny::UTF8::_default::Encode(&decoded); - assert!(!_r.IsFailure()); - encoded = _r.Extract(); - assert_eq!( - ::dafny_runtime::seq![0xE2 as u8, 0x8C as u8, 0x9B as u8], - encoded - ); - assert!(implementation_from_dafny::UTF8::_default::Uses3Bytes(&encoded)); - _r2 = implementation_from_dafny::UTF8::_default::Decode(&encoded); - assert!(!_r2.IsFailure()); - redecoded = _r2.Extract(); - assert_eq!(decoded, redecoded); - decoded = ::dafny_runtime::string_utf16_of("\u{1D78}"); - _r = implementation_from_dafny::UTF8::_default::Encode(&decoded); - assert!(!_r.IsFailure()); - encoded = _r.Extract(); - assert_eq!( - ::dafny_runtime::seq![0xE1 as u8, 0xB5 as u8, 0xB8 as u8], - encoded - ); - assert!(implementation_from_dafny::UTF8::_default::Uses3Bytes(&encoded)); - _r2 = implementation_from_dafny::UTF8::_default::Decode(&encoded); - assert!(!_r2.IsFailure()); - redecoded = _r2.Extract(); - assert_eq!(decoded, redecoded); - decoded = ::dafny_runtime::string_utf16_of("\u{732B}"); - _r = implementation_from_dafny::UTF8::_default::Encode(&decoded); - assert!(!_r.IsFailure()); - encoded = _r.Extract(); - assert_eq!( - ::dafny_runtime::seq![0xE7 as u8, 0x8C as u8, 0xAB as u8], - encoded - ); - assert!(implementation_from_dafny::UTF8::_default::Uses3Bytes(&encoded)); - _r2 = implementation_from_dafny::UTF8::_default::Decode(&encoded); - assert!(!_r2.IsFailure()); - redecoded = _r2.Extract(); - assert_eq!(decoded, redecoded); - } - - #[test] - fn Test4Bytes() { - let mut decoded = ::dafny_runtime::seq![ - ::dafny_runtime::DafnyCharUTF16(0xD808), - ::dafny_runtime::DafnyCharUTF16(0xDC00) - ]; - let mut _r = implementation_from_dafny::UTF8::_default::Encode(&decoded); - println!( - "{}", - ::dafny_runtime::DafnyPrintWrapper(&_r.as_ref().clone()) - ); - assert!(!_r.IsFailure()); - let mut encoded = _r.Extract(); - assert_eq!( - ::dafny_runtime::seq![0xF0 as u8, 0x92 as u8, 0x80 as u8, 0x80 as u8], - encoded - ); - assert!(implementation_from_dafny::UTF8::_default::Uses4Bytes(&encoded)); - let mut _r2 = implementation_from_dafny::UTF8::_default::Decode(&encoded); - assert!(!_r2.IsFailure()); - let mut redecoded = _r2.Extract(); - assert_eq!(decoded, redecoded); - decoded = ::dafny_runtime::string_utf16_of("\u{1D7C1}"); - _r = implementation_from_dafny::UTF8::_default::Encode(&decoded); - assert!(!_r.IsFailure()); - encoded = _r.Extract(); - assert_eq!( - ::dafny_runtime::seq![0xF0 as u8, 0x9D as u8, 0x9F as u8, 0x81 as u8], - encoded - ); - assert!(implementation_from_dafny::UTF8::_default::Uses4Bytes(&encoded)); - _r2 = implementation_from_dafny::UTF8::_default::Decode(&encoded); - assert!(!_r2.IsFailure()); - redecoded = _r2.Extract(); - assert_eq!(decoded, redecoded); - } -} +pub mod implementation_from_dafny; \ No newline at end of file diff --git a/TestModels/dafny-dependencies/StandardLibrary/runtimes/rust/tests/standard_library_tests.rs b/TestModels/dafny-dependencies/StandardLibrary/runtimes/rust/tests/standard_library_tests.rs new file mode 100644 index 0000000000..fe1c0f50e8 --- /dev/null +++ b/TestModels/dafny-dependencies/StandardLibrary/runtimes/rust/tests/standard_library_tests.rs @@ -0,0 +1,7 @@ + +mod tests_from_dafny; + +#[test] +fn dafny_tests() { + crate::tests_from_dafny::_module::_default::_Test__Main_() +} diff --git a/TestModels/dafny-dependencies/StandardLibrary/runtimes/rust/tests/tests_from_dafny/mod.rs b/TestModels/dafny-dependencies/StandardLibrary/runtimes/rust/tests/tests_from_dafny/mod.rs new file mode 100644 index 0000000000..c4a1c20ff2 --- /dev/null +++ b/TestModels/dafny-dependencies/StandardLibrary/runtimes/rust/tests/tests_from_dafny/mod.rs @@ -0,0 +1,919 @@ +#![allow(warnings, unconditional_panic)] +#![allow(nonstandard_style)] +use ::dafny_standard_library::implementation_from_dafny::*; + +pub mod r#_TestUTF8_Compile { + pub struct _default {} + + impl _default { + pub fn _allocate_object() -> ::dafny_runtime::Object { + ::dafny_runtime::allocate_object::() + } + pub fn TestEncodeHappyCase() -> () { + let mut unicodeString: ::dafny_runtime::Sequence<::dafny_runtime::DafnyCharUTF16> = ::dafny_runtime::seq![ + ::dafny_runtime::DafnyCharUTF16(97 as u16), + ::dafny_runtime::DafnyCharUTF16(98 as u16), + ::dafny_runtime::DafnyCharUTF16(99 as u16), + ::dafny_runtime::DafnyCharUTF16(774 as u16), + ::dafny_runtime::DafnyCharUTF16(509 as u16), + ::dafny_runtime::DafnyCharUTF16(946 as u16) + ]; + let mut expectedBytes: ::dafny_runtime::Sequence = + ::dafny_runtime::seq![97, 98, 99, 204, 134, 199, 189, 206, 178]; + let mut valueOrError0 = ::dafny_runtime::MaybePlacebo::< + ::std::rc::Rc< + super::r#_Wrappers_Compile::Result< + super::UTF8::ValidUTF8Bytes, + ::dafny_runtime::Sequence<::dafny_runtime::DafnyCharUTF16>, + >, + >, + >::new(); + valueOrError0 = + ::dafny_runtime::MaybePlacebo::from(super::UTF8::_default::Encode(&unicodeString)); + if !(!valueOrError0.read().IsFailure()) { + panic!("Halt") + }; + let mut encoded: super::UTF8::ValidUTF8Bytes = valueOrError0.read().Extract(); + if !(expectedBytes.clone() == encoded.clone()) { + panic!("Halt") + }; + return (); + } + pub fn TestEncodeInvalidUnicode() -> () { + let mut invalidUnicode: ::dafny_runtime::Sequence<::dafny_runtime::DafnyCharUTF16> = ::dafny_runtime::seq![ + ::dafny_runtime::DafnyCharUTF16(97 as u16), + ::dafny_runtime::DafnyCharUTF16(98 as u16), + ::dafny_runtime::DafnyCharUTF16(99 as u16), + ::dafny_runtime::DafnyCharUTF16(55296 as u16) + ]; + let mut encoded: ::std::rc::Rc< + super::r#_Wrappers_Compile::Result< + super::UTF8::ValidUTF8Bytes, + ::dafny_runtime::Sequence<::dafny_runtime::DafnyCharUTF16>, + >, + > = super::UTF8::_default::Encode(&invalidUnicode); + if !matches!( + (&encoded).as_ref(), + super::r#_Wrappers_Compile::Result::Failure { .. } + ) { + panic!("Halt") + }; + return (); + } + pub fn TestDecodeHappyCase() -> () { + let mut unicodeBytes: ::dafny_runtime::Sequence = + ::dafny_runtime::seq![97, 98, 99, 204, 134, 199, 189, 206, 178]; + let mut expectedString: ::dafny_runtime::Sequence<::dafny_runtime::DafnyCharUTF16> = ::dafny_runtime::seq![ + ::dafny_runtime::DafnyCharUTF16(97 as u16), + ::dafny_runtime::DafnyCharUTF16(98 as u16), + ::dafny_runtime::DafnyCharUTF16(99 as u16), + ::dafny_runtime::DafnyCharUTF16(774 as u16), + ::dafny_runtime::DafnyCharUTF16(509 as u16), + ::dafny_runtime::DafnyCharUTF16(946 as u16) + ]; + let mut valueOrError0 = ::dafny_runtime::MaybePlacebo::< + ::std::rc::Rc< + super::r#_Wrappers_Compile::Result< + ::dafny_runtime::Sequence<::dafny_runtime::DafnyCharUTF16>, + ::dafny_runtime::Sequence<::dafny_runtime::DafnyCharUTF16>, + >, + >, + >::new(); + valueOrError0 = + ::dafny_runtime::MaybePlacebo::from(super::UTF8::_default::Decode(&unicodeBytes)); + if !(!valueOrError0.read().IsFailure()) { + panic!("Halt") + }; + let mut decoded: ::dafny_runtime::Sequence<::dafny_runtime::DafnyCharUTF16> = + valueOrError0.read().Extract(); + if !(expectedString.clone() == decoded.clone()) { + panic!("Halt") + }; + return (); + } + pub fn TestDecodeInvalidUnicode() -> () { + let mut invalidUnicode: ::dafny_runtime::Sequence = + ::dafny_runtime::seq![97, 98, 99, 237, 160, 128]; + if !(!super::UTF8::_default::ValidUTF8Seq(&invalidUnicode)) { + panic!("Halt") + }; + if !matches!( + (&super::UTF8::_default::Decode(&invalidUnicode)).as_ref(), + super::r#_Wrappers_Compile::Result::Failure { .. } + ) { + panic!("Halt") + }; + return (); + } + pub fn Test1Byte() -> () { + let mut decoded: ::dafny_runtime::Sequence<::dafny_runtime::DafnyCharUTF16> = + ::dafny_runtime::seq![::dafny_runtime::DafnyCharUTF16(0 as u16)]; + let mut valueOrError0 = ::dafny_runtime::MaybePlacebo::< + ::std::rc::Rc< + super::r#_Wrappers_Compile::Result< + super::UTF8::ValidUTF8Bytes, + ::dafny_runtime::Sequence<::dafny_runtime::DafnyCharUTF16>, + >, + >, + >::new(); + valueOrError0 = + ::dafny_runtime::MaybePlacebo::from(super::UTF8::_default::Encode(&decoded)); + if !(!valueOrError0.read().IsFailure()) { + panic!("Halt") + }; + let mut encoded: super::UTF8::ValidUTF8Bytes = valueOrError0.read().Extract(); + if !(::dafny_runtime::seq![0] == encoded.clone()) { + panic!("Halt") + }; + if !super::UTF8::_default::Uses1Byte(&encoded) { + panic!("Halt") + }; + let mut valueOrError1 = ::dafny_runtime::MaybePlacebo::< + ::std::rc::Rc< + super::r#_Wrappers_Compile::Result< + ::dafny_runtime::Sequence<::dafny_runtime::DafnyCharUTF16>, + ::dafny_runtime::Sequence<::dafny_runtime::DafnyCharUTF16>, + >, + >, + >::new(); + valueOrError1 = + ::dafny_runtime::MaybePlacebo::from(super::UTF8::_default::Decode(&encoded)); + if !(!valueOrError1.read().IsFailure()) { + panic!("Halt") + }; + let mut redecoded: ::dafny_runtime::Sequence<::dafny_runtime::DafnyCharUTF16> = + valueOrError1.read().Extract(); + if !(decoded.clone() == redecoded.clone()) { + panic!("Halt") + }; + decoded = ::dafny_runtime::seq![::dafny_runtime::DafnyCharUTF16(32 as u16)]; + let mut valueOrError2 = ::dafny_runtime::MaybePlacebo::< + ::std::rc::Rc< + super::r#_Wrappers_Compile::Result< + super::UTF8::ValidUTF8Bytes, + ::dafny_runtime::Sequence<::dafny_runtime::DafnyCharUTF16>, + >, + >, + >::new(); + valueOrError2 = + ::dafny_runtime::MaybePlacebo::from(super::UTF8::_default::Encode(&decoded)); + if !(!valueOrError2.read().IsFailure()) { + panic!("Halt") + }; + encoded = valueOrError2.read().Extract(); + if !(::dafny_runtime::seq![32] == encoded.clone()) { + panic!("Halt") + }; + if !super::UTF8::_default::Uses1Byte(&encoded) { + panic!("Halt") + }; + let mut valueOrError3 = ::dafny_runtime::MaybePlacebo::< + ::std::rc::Rc< + super::r#_Wrappers_Compile::Result< + ::dafny_runtime::Sequence<::dafny_runtime::DafnyCharUTF16>, + ::dafny_runtime::Sequence<::dafny_runtime::DafnyCharUTF16>, + >, + >, + >::new(); + valueOrError3 = + ::dafny_runtime::MaybePlacebo::from(super::UTF8::_default::Decode(&encoded)); + if !(!valueOrError3.read().IsFailure()) { + panic!("Halt") + }; + redecoded = valueOrError3.read().Extract(); + if !(decoded.clone() == redecoded.clone()) { + panic!("Halt") + }; + decoded = ::dafny_runtime::string_utf16_of("$"); + let mut valueOrError4 = ::dafny_runtime::MaybePlacebo::< + ::std::rc::Rc< + super::r#_Wrappers_Compile::Result< + super::UTF8::ValidUTF8Bytes, + ::dafny_runtime::Sequence<::dafny_runtime::DafnyCharUTF16>, + >, + >, + >::new(); + valueOrError4 = + ::dafny_runtime::MaybePlacebo::from(super::UTF8::_default::Encode(&decoded)); + if !(!valueOrError4.read().IsFailure()) { + panic!("Halt") + }; + encoded = valueOrError4.read().Extract(); + if !(::dafny_runtime::seq![36] == encoded.clone()) { + panic!("Halt") + }; + if !super::UTF8::_default::Uses1Byte(&encoded) { + panic!("Halt") + }; + let mut valueOrError5 = ::dafny_runtime::MaybePlacebo::< + ::std::rc::Rc< + super::r#_Wrappers_Compile::Result< + ::dafny_runtime::Sequence<::dafny_runtime::DafnyCharUTF16>, + ::dafny_runtime::Sequence<::dafny_runtime::DafnyCharUTF16>, + >, + >, + >::new(); + valueOrError5 = + ::dafny_runtime::MaybePlacebo::from(super::UTF8::_default::Decode(&encoded)); + if !(!valueOrError5.read().IsFailure()) { + panic!("Halt") + }; + redecoded = valueOrError5.read().Extract(); + if !(decoded.clone() == redecoded.clone()) { + panic!("Halt") + }; + decoded = ::dafny_runtime::string_utf16_of("0"); + let mut valueOrError6 = ::dafny_runtime::MaybePlacebo::< + ::std::rc::Rc< + super::r#_Wrappers_Compile::Result< + super::UTF8::ValidUTF8Bytes, + ::dafny_runtime::Sequence<::dafny_runtime::DafnyCharUTF16>, + >, + >, + >::new(); + valueOrError6 = + ::dafny_runtime::MaybePlacebo::from(super::UTF8::_default::Encode(&decoded)); + if !(!valueOrError6.read().IsFailure()) { + panic!("Halt") + }; + encoded = valueOrError6.read().Extract(); + if !(::dafny_runtime::seq![48] == encoded.clone()) { + panic!("Halt") + }; + if !super::UTF8::_default::Uses1Byte(&encoded) { + panic!("Halt") + }; + let mut valueOrError7 = ::dafny_runtime::MaybePlacebo::< + ::std::rc::Rc< + super::r#_Wrappers_Compile::Result< + ::dafny_runtime::Sequence<::dafny_runtime::DafnyCharUTF16>, + ::dafny_runtime::Sequence<::dafny_runtime::DafnyCharUTF16>, + >, + >, + >::new(); + valueOrError7 = + ::dafny_runtime::MaybePlacebo::from(super::UTF8::_default::Decode(&encoded)); + if !(!valueOrError7.read().IsFailure()) { + panic!("Halt") + }; + redecoded = valueOrError7.read().Extract(); + if !(decoded.clone() == redecoded.clone()) { + panic!("Halt") + }; + decoded = ::dafny_runtime::string_utf16_of("A"); + let mut valueOrError8 = ::dafny_runtime::MaybePlacebo::< + ::std::rc::Rc< + super::r#_Wrappers_Compile::Result< + super::UTF8::ValidUTF8Bytes, + ::dafny_runtime::Sequence<::dafny_runtime::DafnyCharUTF16>, + >, + >, + >::new(); + valueOrError8 = + ::dafny_runtime::MaybePlacebo::from(super::UTF8::_default::Encode(&decoded)); + if !(!valueOrError8.read().IsFailure()) { + panic!("Halt") + }; + encoded = valueOrError8.read().Extract(); + if !(::dafny_runtime::seq![65] == encoded.clone()) { + panic!("Halt") + }; + if !super::UTF8::_default::Uses1Byte(&encoded) { + panic!("Halt") + }; + let mut valueOrError9 = ::dafny_runtime::MaybePlacebo::< + ::std::rc::Rc< + super::r#_Wrappers_Compile::Result< + ::dafny_runtime::Sequence<::dafny_runtime::DafnyCharUTF16>, + ::dafny_runtime::Sequence<::dafny_runtime::DafnyCharUTF16>, + >, + >, + >::new(); + valueOrError9 = + ::dafny_runtime::MaybePlacebo::from(super::UTF8::_default::Decode(&encoded)); + if !(!valueOrError9.read().IsFailure()) { + panic!("Halt") + }; + redecoded = valueOrError9.read().Extract(); + if !(decoded.clone() == redecoded.clone()) { + panic!("Halt") + }; + decoded = ::dafny_runtime::string_utf16_of("a"); + let mut valueOrError10 = ::dafny_runtime::MaybePlacebo::< + ::std::rc::Rc< + super::r#_Wrappers_Compile::Result< + super::UTF8::ValidUTF8Bytes, + ::dafny_runtime::Sequence<::dafny_runtime::DafnyCharUTF16>, + >, + >, + >::new(); + valueOrError10 = + ::dafny_runtime::MaybePlacebo::from(super::UTF8::_default::Encode(&decoded)); + if !(!valueOrError10.read().IsFailure()) { + panic!("Halt") + }; + encoded = valueOrError10.read().Extract(); + if !(::dafny_runtime::seq![97] == encoded.clone()) { + panic!("Halt") + }; + if !super::UTF8::_default::Uses1Byte(&encoded) { + panic!("Halt") + }; + let mut valueOrError11 = ::dafny_runtime::MaybePlacebo::< + ::std::rc::Rc< + super::r#_Wrappers_Compile::Result< + ::dafny_runtime::Sequence<::dafny_runtime::DafnyCharUTF16>, + ::dafny_runtime::Sequence<::dafny_runtime::DafnyCharUTF16>, + >, + >, + >::new(); + valueOrError11 = + ::dafny_runtime::MaybePlacebo::from(super::UTF8::_default::Decode(&encoded)); + if !(!valueOrError11.read().IsFailure()) { + panic!("Halt") + }; + redecoded = valueOrError11.read().Extract(); + if !(decoded.clone() == redecoded.clone()) { + panic!("Halt") + }; + return (); + } + pub fn Test2Bytes() -> () { + let mut decoded: ::dafny_runtime::Sequence<::dafny_runtime::DafnyCharUTF16> = + ::dafny_runtime::seq![::dafny_runtime::DafnyCharUTF16(163 as u16)]; + let mut valueOrError0 = ::dafny_runtime::MaybePlacebo::< + ::std::rc::Rc< + super::r#_Wrappers_Compile::Result< + super::UTF8::ValidUTF8Bytes, + ::dafny_runtime::Sequence<::dafny_runtime::DafnyCharUTF16>, + >, + >, + >::new(); + valueOrError0 = + ::dafny_runtime::MaybePlacebo::from(super::UTF8::_default::Encode(&decoded)); + if !(!valueOrError0.read().IsFailure()) { + panic!("Halt") + }; + let mut encoded: super::UTF8::ValidUTF8Bytes = valueOrError0.read().Extract(); + if !(::dafny_runtime::seq![194, 163] == encoded.clone()) { + panic!("Halt") + }; + if !super::UTF8::_default::Uses2Bytes(&encoded) { + panic!("Halt") + }; + let mut valueOrError1 = ::dafny_runtime::MaybePlacebo::< + ::std::rc::Rc< + super::r#_Wrappers_Compile::Result< + ::dafny_runtime::Sequence<::dafny_runtime::DafnyCharUTF16>, + ::dafny_runtime::Sequence<::dafny_runtime::DafnyCharUTF16>, + >, + >, + >::new(); + valueOrError1 = + ::dafny_runtime::MaybePlacebo::from(super::UTF8::_default::Decode(&encoded)); + if !(!valueOrError1.read().IsFailure()) { + panic!("Halt") + }; + let mut redecoded: ::dafny_runtime::Sequence<::dafny_runtime::DafnyCharUTF16> = + valueOrError1.read().Extract(); + if !(decoded.clone() == redecoded.clone()) { + panic!("Halt") + }; + decoded = ::dafny_runtime::seq![::dafny_runtime::DafnyCharUTF16(169 as u16)]; + let mut valueOrError2 = ::dafny_runtime::MaybePlacebo::< + ::std::rc::Rc< + super::r#_Wrappers_Compile::Result< + super::UTF8::ValidUTF8Bytes, + ::dafny_runtime::Sequence<::dafny_runtime::DafnyCharUTF16>, + >, + >, + >::new(); + valueOrError2 = + ::dafny_runtime::MaybePlacebo::from(super::UTF8::_default::Encode(&decoded)); + if !(!valueOrError2.read().IsFailure()) { + panic!("Halt") + }; + encoded = valueOrError2.read().Extract(); + if !(::dafny_runtime::seq![194, 169] == encoded.clone()) { + panic!("Halt") + }; + if !super::UTF8::_default::Uses2Bytes(&encoded) { + panic!("Halt") + }; + let mut valueOrError3 = ::dafny_runtime::MaybePlacebo::< + ::std::rc::Rc< + super::r#_Wrappers_Compile::Result< + ::dafny_runtime::Sequence<::dafny_runtime::DafnyCharUTF16>, + ::dafny_runtime::Sequence<::dafny_runtime::DafnyCharUTF16>, + >, + >, + >::new(); + valueOrError3 = + ::dafny_runtime::MaybePlacebo::from(super::UTF8::_default::Decode(&encoded)); + if !(!valueOrError3.read().IsFailure()) { + panic!("Halt") + }; + redecoded = valueOrError3.read().Extract(); + if !(decoded.clone() == redecoded.clone()) { + panic!("Halt") + }; + decoded = ::dafny_runtime::seq![::dafny_runtime::DafnyCharUTF16(174 as u16)]; + let mut valueOrError4 = ::dafny_runtime::MaybePlacebo::< + ::std::rc::Rc< + super::r#_Wrappers_Compile::Result< + super::UTF8::ValidUTF8Bytes, + ::dafny_runtime::Sequence<::dafny_runtime::DafnyCharUTF16>, + >, + >, + >::new(); + valueOrError4 = + ::dafny_runtime::MaybePlacebo::from(super::UTF8::_default::Encode(&decoded)); + if !(!valueOrError4.read().IsFailure()) { + panic!("Halt") + }; + encoded = valueOrError4.read().Extract(); + if !(::dafny_runtime::seq![194, 174] == encoded.clone()) { + panic!("Halt") + }; + if !super::UTF8::_default::Uses2Bytes(&encoded) { + panic!("Halt") + }; + let mut valueOrError5 = ::dafny_runtime::MaybePlacebo::< + ::std::rc::Rc< + super::r#_Wrappers_Compile::Result< + ::dafny_runtime::Sequence<::dafny_runtime::DafnyCharUTF16>, + ::dafny_runtime::Sequence<::dafny_runtime::DafnyCharUTF16>, + >, + >, + >::new(); + valueOrError5 = + ::dafny_runtime::MaybePlacebo::from(super::UTF8::_default::Decode(&encoded)); + if !(!valueOrError5.read().IsFailure()) { + panic!("Halt") + }; + redecoded = valueOrError5.read().Extract(); + if !(decoded.clone() == redecoded.clone()) { + panic!("Halt") + }; + decoded = ::dafny_runtime::seq![::dafny_runtime::DafnyCharUTF16(960 as u16)]; + let mut valueOrError6 = ::dafny_runtime::MaybePlacebo::< + ::std::rc::Rc< + super::r#_Wrappers_Compile::Result< + super::UTF8::ValidUTF8Bytes, + ::dafny_runtime::Sequence<::dafny_runtime::DafnyCharUTF16>, + >, + >, + >::new(); + valueOrError6 = + ::dafny_runtime::MaybePlacebo::from(super::UTF8::_default::Encode(&decoded)); + if !(!valueOrError6.read().IsFailure()) { + panic!("Halt") + }; + encoded = valueOrError6.read().Extract(); + if !(::dafny_runtime::seq![207, 128] == encoded.clone()) { + panic!("Halt") + }; + if !super::UTF8::_default::Uses2Bytes(&encoded) { + panic!("Halt") + }; + let mut valueOrError7 = ::dafny_runtime::MaybePlacebo::< + ::std::rc::Rc< + super::r#_Wrappers_Compile::Result< + ::dafny_runtime::Sequence<::dafny_runtime::DafnyCharUTF16>, + ::dafny_runtime::Sequence<::dafny_runtime::DafnyCharUTF16>, + >, + >, + >::new(); + valueOrError7 = + ::dafny_runtime::MaybePlacebo::from(super::UTF8::_default::Decode(&encoded)); + if !(!valueOrError7.read().IsFailure()) { + panic!("Halt") + }; + redecoded = valueOrError7.read().Extract(); + if !(decoded.clone() == redecoded.clone()) { + panic!("Halt") + }; + return (); + } + pub fn Test3Bytes() -> () { + let mut decoded: ::dafny_runtime::Sequence<::dafny_runtime::DafnyCharUTF16> = + ::dafny_runtime::seq![::dafny_runtime::DafnyCharUTF16(9094 as u16)]; + let mut valueOrError0 = ::dafny_runtime::MaybePlacebo::< + ::std::rc::Rc< + super::r#_Wrappers_Compile::Result< + super::UTF8::ValidUTF8Bytes, + ::dafny_runtime::Sequence<::dafny_runtime::DafnyCharUTF16>, + >, + >, + >::new(); + valueOrError0 = + ::dafny_runtime::MaybePlacebo::from(super::UTF8::_default::Encode(&decoded)); + if !(!valueOrError0.read().IsFailure()) { + panic!("Halt") + }; + let mut encoded: super::UTF8::ValidUTF8Bytes = valueOrError0.read().Extract(); + if !(::dafny_runtime::seq![226, 142, 134] == encoded.clone()) { + panic!("Halt") + }; + if !super::UTF8::_default::Uses3Bytes(&encoded) { + panic!("Halt") + }; + let mut valueOrError1 = ::dafny_runtime::MaybePlacebo::< + ::std::rc::Rc< + super::r#_Wrappers_Compile::Result< + ::dafny_runtime::Sequence<::dafny_runtime::DafnyCharUTF16>, + ::dafny_runtime::Sequence<::dafny_runtime::DafnyCharUTF16>, + >, + >, + >::new(); + valueOrError1 = + ::dafny_runtime::MaybePlacebo::from(super::UTF8::_default::Decode(&encoded)); + if !(!valueOrError1.read().IsFailure()) { + panic!("Halt") + }; + let mut redecoded: ::dafny_runtime::Sequence<::dafny_runtime::DafnyCharUTF16> = + valueOrError1.read().Extract(); + if !(decoded.clone() == redecoded.clone()) { + panic!("Halt") + }; + decoded = ::dafny_runtime::seq![::dafny_runtime::DafnyCharUTF16(9095 as u16)]; + let mut valueOrError2 = ::dafny_runtime::MaybePlacebo::< + ::std::rc::Rc< + super::r#_Wrappers_Compile::Result< + super::UTF8::ValidUTF8Bytes, + ::dafny_runtime::Sequence<::dafny_runtime::DafnyCharUTF16>, + >, + >, + >::new(); + valueOrError2 = + ::dafny_runtime::MaybePlacebo::from(super::UTF8::_default::Encode(&decoded)); + if !(!valueOrError2.read().IsFailure()) { + panic!("Halt") + }; + encoded = valueOrError2.read().Extract(); + if !(::dafny_runtime::seq![226, 142, 135] == encoded.clone()) { + panic!("Halt") + }; + if !super::UTF8::_default::Uses3Bytes(&encoded) { + panic!("Halt") + }; + let mut valueOrError3 = ::dafny_runtime::MaybePlacebo::< + ::std::rc::Rc< + super::r#_Wrappers_Compile::Result< + ::dafny_runtime::Sequence<::dafny_runtime::DafnyCharUTF16>, + ::dafny_runtime::Sequence<::dafny_runtime::DafnyCharUTF16>, + >, + >, + >::new(); + valueOrError3 = + ::dafny_runtime::MaybePlacebo::from(super::UTF8::_default::Decode(&encoded)); + if !(!valueOrError3.read().IsFailure()) { + panic!("Halt") + }; + redecoded = valueOrError3.read().Extract(); + if !(decoded.clone() == redecoded.clone()) { + panic!("Halt") + }; + decoded = ::dafny_runtime::seq![::dafny_runtime::DafnyCharUTF16(8987 as u16)]; + let mut valueOrError4 = ::dafny_runtime::MaybePlacebo::< + ::std::rc::Rc< + super::r#_Wrappers_Compile::Result< + super::UTF8::ValidUTF8Bytes, + ::dafny_runtime::Sequence<::dafny_runtime::DafnyCharUTF16>, + >, + >, + >::new(); + valueOrError4 = + ::dafny_runtime::MaybePlacebo::from(super::UTF8::_default::Encode(&decoded)); + if !(!valueOrError4.read().IsFailure()) { + panic!("Halt") + }; + encoded = valueOrError4.read().Extract(); + if !(::dafny_runtime::seq![226, 140, 155] == encoded.clone()) { + panic!("Halt") + }; + if !super::UTF8::_default::Uses3Bytes(&encoded) { + panic!("Halt") + }; + let mut valueOrError5 = ::dafny_runtime::MaybePlacebo::< + ::std::rc::Rc< + super::r#_Wrappers_Compile::Result< + ::dafny_runtime::Sequence<::dafny_runtime::DafnyCharUTF16>, + ::dafny_runtime::Sequence<::dafny_runtime::DafnyCharUTF16>, + >, + >, + >::new(); + valueOrError5 = + ::dafny_runtime::MaybePlacebo::from(super::UTF8::_default::Decode(&encoded)); + if !(!valueOrError5.read().IsFailure()) { + panic!("Halt") + }; + redecoded = valueOrError5.read().Extract(); + if !(decoded.clone() == redecoded.clone()) { + panic!("Halt") + }; + decoded = ::dafny_runtime::seq![::dafny_runtime::DafnyCharUTF16(7544 as u16)]; + let mut valueOrError6 = ::dafny_runtime::MaybePlacebo::< + ::std::rc::Rc< + super::r#_Wrappers_Compile::Result< + super::UTF8::ValidUTF8Bytes, + ::dafny_runtime::Sequence<::dafny_runtime::DafnyCharUTF16>, + >, + >, + >::new(); + valueOrError6 = + ::dafny_runtime::MaybePlacebo::from(super::UTF8::_default::Encode(&decoded)); + if !(!valueOrError6.read().IsFailure()) { + panic!("Halt") + }; + encoded = valueOrError6.read().Extract(); + if !(::dafny_runtime::seq![225, 181, 184] == encoded.clone()) { + panic!("Halt") + }; + if !super::UTF8::_default::Uses3Bytes(&encoded) { + panic!("Halt") + }; + let mut valueOrError7 = ::dafny_runtime::MaybePlacebo::< + ::std::rc::Rc< + super::r#_Wrappers_Compile::Result< + ::dafny_runtime::Sequence<::dafny_runtime::DafnyCharUTF16>, + ::dafny_runtime::Sequence<::dafny_runtime::DafnyCharUTF16>, + >, + >, + >::new(); + valueOrError7 = + ::dafny_runtime::MaybePlacebo::from(super::UTF8::_default::Decode(&encoded)); + if !(!valueOrError7.read().IsFailure()) { + panic!("Halt") + }; + redecoded = valueOrError7.read().Extract(); + if !(decoded.clone() == redecoded.clone()) { + panic!("Halt") + }; + decoded = ::dafny_runtime::seq![::dafny_runtime::DafnyCharUTF16(29483 as u16)]; + let mut valueOrError8 = ::dafny_runtime::MaybePlacebo::< + ::std::rc::Rc< + super::r#_Wrappers_Compile::Result< + super::UTF8::ValidUTF8Bytes, + ::dafny_runtime::Sequence<::dafny_runtime::DafnyCharUTF16>, + >, + >, + >::new(); + valueOrError8 = + ::dafny_runtime::MaybePlacebo::from(super::UTF8::_default::Encode(&decoded)); + if !(!valueOrError8.read().IsFailure()) { + panic!("Halt") + }; + encoded = valueOrError8.read().Extract(); + if !(::dafny_runtime::seq![231, 140, 171] == encoded.clone()) { + panic!("Halt") + }; + if !super::UTF8::_default::Uses3Bytes(&encoded) { + panic!("Halt") + }; + let mut valueOrError9 = ::dafny_runtime::MaybePlacebo::< + ::std::rc::Rc< + super::r#_Wrappers_Compile::Result< + ::dafny_runtime::Sequence<::dafny_runtime::DafnyCharUTF16>, + ::dafny_runtime::Sequence<::dafny_runtime::DafnyCharUTF16>, + >, + >, + >::new(); + valueOrError9 = + ::dafny_runtime::MaybePlacebo::from(super::UTF8::_default::Decode(&encoded)); + if !(!valueOrError9.read().IsFailure()) { + panic!("Halt") + }; + redecoded = valueOrError9.read().Extract(); + if !(decoded.clone() == redecoded.clone()) { + panic!("Halt") + }; + return (); + } + pub fn Test4Bytes() -> () { + let mut decoded: ::dafny_runtime::Sequence<::dafny_runtime::DafnyCharUTF16> = ::dafny_runtime::seq![ + ::dafny_runtime::DafnyCharUTF16(55304 as u16), + ::dafny_runtime::DafnyCharUTF16(56320 as u16) + ]; + let mut valueOrError0 = ::dafny_runtime::MaybePlacebo::< + ::std::rc::Rc< + super::r#_Wrappers_Compile::Result< + super::UTF8::ValidUTF8Bytes, + ::dafny_runtime::Sequence<::dafny_runtime::DafnyCharUTF16>, + >, + >, + >::new(); + valueOrError0 = + ::dafny_runtime::MaybePlacebo::from(super::UTF8::_default::Encode(&decoded)); + if !(!valueOrError0.read().IsFailure()) { + panic!("Halt") + }; + let mut encoded: super::UTF8::ValidUTF8Bytes = valueOrError0.read().Extract(); + if !(::dafny_runtime::seq![240, 146, 128, 128] == encoded.clone()) { + panic!("Halt") + }; + if !super::UTF8::_default::Uses4Bytes(&encoded) { + panic!("Halt") + }; + let mut valueOrError1 = ::dafny_runtime::MaybePlacebo::< + ::std::rc::Rc< + super::r#_Wrappers_Compile::Result< + ::dafny_runtime::Sequence<::dafny_runtime::DafnyCharUTF16>, + ::dafny_runtime::Sequence<::dafny_runtime::DafnyCharUTF16>, + >, + >, + >::new(); + valueOrError1 = + ::dafny_runtime::MaybePlacebo::from(super::UTF8::_default::Decode(&encoded)); + if !(!valueOrError1.read().IsFailure()) { + panic!("Halt") + }; + let mut redecoded: ::dafny_runtime::Sequence<::dafny_runtime::DafnyCharUTF16> = + valueOrError1.read().Extract(); + if !(decoded.clone() == redecoded.clone()) { + panic!("Halt") + }; + decoded = ::dafny_runtime::seq![ + ::dafny_runtime::DafnyCharUTF16(55349 as u16), + ::dafny_runtime::DafnyCharUTF16(57281 as u16) + ]; + let mut valueOrError2 = ::dafny_runtime::MaybePlacebo::< + ::std::rc::Rc< + super::r#_Wrappers_Compile::Result< + super::UTF8::ValidUTF8Bytes, + ::dafny_runtime::Sequence<::dafny_runtime::DafnyCharUTF16>, + >, + >, + >::new(); + valueOrError2 = + ::dafny_runtime::MaybePlacebo::from(super::UTF8::_default::Encode(&decoded)); + if !(!valueOrError2.read().IsFailure()) { + panic!("Halt") + }; + encoded = valueOrError2.read().Extract(); + if !(::dafny_runtime::seq![240, 157, 159, 129] == encoded.clone()) { + panic!("Halt") + }; + if !super::UTF8::_default::Uses4Bytes(&encoded) { + panic!("Halt") + }; + let mut valueOrError3 = ::dafny_runtime::MaybePlacebo::< + ::std::rc::Rc< + super::r#_Wrappers_Compile::Result< + ::dafny_runtime::Sequence<::dafny_runtime::DafnyCharUTF16>, + ::dafny_runtime::Sequence<::dafny_runtime::DafnyCharUTF16>, + >, + >, + >::new(); + valueOrError3 = + ::dafny_runtime::MaybePlacebo::from(super::UTF8::_default::Decode(&encoded)); + if !(!valueOrError3.read().IsFailure()) { + panic!("Halt") + }; + redecoded = valueOrError3.read().Extract(); + if !(decoded.clone() == redecoded.clone()) { + panic!("Halt") + }; + return (); + } + } + + impl ::dafny_runtime::UpcastObject for super::r#_TestUTF8_Compile::_default { + ::dafny_runtime::UpcastObjectFn!(dyn::std::any::Any); + } +} +pub mod _module { + pub struct _default {} + + impl _default { + pub fn _allocate_object() -> ::dafny_runtime::Object { + ::dafny_runtime::allocate_object::() + } + pub fn _Test__Main_() -> () { + let mut success: bool = true; + print!( + "{}", + ::dafny_runtime::DafnyPrintWrapper(&::dafny_runtime::string_utf16_of( + r#"TestUTF8.TestEncodeHappyCase: "# + )) + ); + super::r#_TestUTF8_Compile::_default::TestEncodeHappyCase(); + print!( + "{}", + ::dafny_runtime::DafnyPrintWrapper(&::dafny_runtime::string_utf16_of( + r#"PASSED +"# + )) + ); + print!( + "{}", + ::dafny_runtime::DafnyPrintWrapper(&::dafny_runtime::string_utf16_of( + r#"TestUTF8.TestEncodeInvalidUnicode: "# + )) + ); + super::r#_TestUTF8_Compile::_default::TestEncodeInvalidUnicode(); + print!( + "{}", + ::dafny_runtime::DafnyPrintWrapper(&::dafny_runtime::string_utf16_of( + r#"PASSED +"# + )) + ); + print!( + "{}", + ::dafny_runtime::DafnyPrintWrapper(&::dafny_runtime::string_utf16_of( + r#"TestUTF8.TestDecodeHappyCase: "# + )) + ); + super::r#_TestUTF8_Compile::_default::TestDecodeHappyCase(); + print!( + "{}", + ::dafny_runtime::DafnyPrintWrapper(&::dafny_runtime::string_utf16_of( + r#"PASSED +"# + )) + ); + print!( + "{}", + ::dafny_runtime::DafnyPrintWrapper(&::dafny_runtime::string_utf16_of( + r#"TestUTF8.TestDecodeInvalidUnicode: "# + )) + ); + super::r#_TestUTF8_Compile::_default::TestDecodeInvalidUnicode(); + print!( + "{}", + ::dafny_runtime::DafnyPrintWrapper(&::dafny_runtime::string_utf16_of( + r#"PASSED +"# + )) + ); + print!( + "{}", + ::dafny_runtime::DafnyPrintWrapper(&::dafny_runtime::string_utf16_of( + r#"TestUTF8.Test1Byte: "# + )) + ); + super::r#_TestUTF8_Compile::_default::Test1Byte(); + print!( + "{}", + ::dafny_runtime::DafnyPrintWrapper(&::dafny_runtime::string_utf16_of( + r#"PASSED +"# + )) + ); + print!( + "{}", + ::dafny_runtime::DafnyPrintWrapper(&::dafny_runtime::string_utf16_of( + r#"TestUTF8.Test2Bytes: "# + )) + ); + super::r#_TestUTF8_Compile::_default::Test2Bytes(); + print!( + "{}", + ::dafny_runtime::DafnyPrintWrapper(&::dafny_runtime::string_utf16_of( + r#"PASSED +"# + )) + ); + print!( + "{}", + ::dafny_runtime::DafnyPrintWrapper(&::dafny_runtime::string_utf16_of( + r#"TestUTF8.Test3Bytes: "# + )) + ); + super::r#_TestUTF8_Compile::_default::Test3Bytes(); + print!( + "{}", + ::dafny_runtime::DafnyPrintWrapper(&::dafny_runtime::string_utf16_of( + r#"PASSED +"# + )) + ); + print!( + "{}", + ::dafny_runtime::DafnyPrintWrapper(&::dafny_runtime::string_utf16_of( + r#"TestUTF8.Test4Bytes: "# + )) + ); + super::r#_TestUTF8_Compile::_default::Test4Bytes(); + print!( + "{}", + ::dafny_runtime::DafnyPrintWrapper(&::dafny_runtime::string_utf16_of( + r#"PASSED +"# + )) + ); + if !success { + panic!("Halt") + }; + return (); + } + } + + impl ::dafny_runtime::UpcastObject for super::_module::_default { + ::dafny_runtime::UpcastObjectFn!(dyn::std::any::Any); + } +} +fn main() { + _module::_default::_Test__Main_(); +} diff --git a/TestModels/dafny-dependencies/StandardLibrary/src_for_rust/Index.dfy b/TestModels/dafny-dependencies/StandardLibrary/src_for_rust/Index.dfy deleted file mode 100644 index 0d6989a8a3..0000000000 --- a/TestModels/dafny-dependencies/StandardLibrary/src_for_rust/Index.dfy +++ /dev/null @@ -1,10 +0,0 @@ -// Copyright Amazon.com Inc. or its affiliates. All Rights Reserved. -// SPDX-License-Identifier: Apache-2.0 - -// Filtering to the subset of code that Dafny Rust code generation -// currently supports. - -// Only building UInt.dfy in Rust to start because other files use unsupported features -// (e.g. the variance specifiers in Option<+T>). -// This scope should be expanded over time. -include "../src/UInt.dfy" diff --git a/TestModels/dafny-dependencies/StandardLibrary/test_for_rust/Index.dfy b/TestModels/dafny-dependencies/StandardLibrary/test_for_rust/Index.dfy deleted file mode 100644 index 20e627c96f..0000000000 --- a/TestModels/dafny-dependencies/StandardLibrary/test_for_rust/Index.dfy +++ /dev/null @@ -1,5 +0,0 @@ -// Copyright Amazon.com Inc. or its affiliates. All Rights Reserved. -// SPDX-License-Identifier: Apache-2.0 - -// Filtering to the subset of code that Dafny Rust code generation -// currently supports. From 9d7f3071b0e969d17fee72acf1721b763e45bfd0 Mon Sep 17 00:00:00 2001 From: Robin Salkeld Date: Wed, 10 Jul 2024 13:43:49 -0700 Subject: [PATCH 39/53] remove tokio --- .../SimpleBoolean/runtimes/rust/Cargo.toml | 4 ---- .../runtimes/rust/tests/simple_boolean_test.rs | 12 ++++++------ 2 files changed, 6 insertions(+), 10 deletions(-) diff --git a/TestModels/SimpleTypes/SimpleBoolean/runtimes/rust/Cargo.toml b/TestModels/SimpleTypes/SimpleBoolean/runtimes/rust/Cargo.toml index 8cc533de4f..1c96c523e0 100644 --- a/TestModels/SimpleTypes/SimpleBoolean/runtimes/rust/Cargo.toml +++ b/TestModels/SimpleTypes/SimpleBoolean/runtimes/rust/Cargo.toml @@ -12,7 +12,3 @@ aws-smithy-types = "1.2.0" dafny_runtime = { path = "../../../../dafny-dependencies/dafny_runtime_rust"} dafny_standard_library = { path = "../../../../dafny-dependencies/StandardLibrary/runtimes/rust"} simple_boolean_dafny = { path = "./dafny_impl"} - -[dev-dependencies.tokio] -version = "1.26.0" -features = ["full"] diff --git a/TestModels/SimpleTypes/SimpleBoolean/runtimes/rust/tests/simple_boolean_test.rs b/TestModels/SimpleTypes/SimpleBoolean/runtimes/rust/tests/simple_boolean_test.rs index 83dcad65b1..22aa75b70b 100644 --- a/TestModels/SimpleTypes/SimpleBoolean/runtimes/rust/tests/simple_boolean_test.rs +++ b/TestModels/SimpleTypes/SimpleBoolean/runtimes/rust/tests/simple_boolean_test.rs @@ -24,8 +24,8 @@ mod tests_from_dafny; print ret; } } */ -#[tokio::test] -async fn test_get_boolean_true() { +#[test] +fn test_get_boolean_true() { let result = client().get_boolean().value(true).send(); let output = result.unwrap(); let value = output.value().unwrap(); @@ -42,8 +42,8 @@ async fn test_get_boolean_true() { print ret; } } */ -#[tokio::test] -async fn test_get_boolean_false() { +#[test] +fn test_get_boolean_false() { let result = client().get_boolean().value(false).send(); let output = result.unwrap(); let value = output.value().unwrap(); @@ -55,7 +55,7 @@ pub fn client() -> Client { Client::from_conf(config).unwrap() } -#[tokio::test] -async fn dafny_tests() { +#[test] +fn dafny_tests() { crate::tests_from_dafny::_module::_default::_Test__Main_() } From dc638a4c2442e4fe0e6c443cf4164132c354ed95 Mon Sep 17 00:00:00 2001 From: Robin Salkeld Date: Wed, 10 Jul 2024 13:45:41 -0700 Subject: [PATCH 40/53] update patch --- .../codegen-patches/rust/dafny-4.5.0.patch | 310 +----------------- 1 file changed, 14 insertions(+), 296 deletions(-) diff --git a/TestModels/dafny-dependencies/StandardLibrary/codegen-patches/rust/dafny-4.5.0.patch b/TestModels/dafny-dependencies/StandardLibrary/codegen-patches/rust/dafny-4.5.0.patch index d211904690..4a401b093c 100644 --- a/TestModels/dafny-dependencies/StandardLibrary/codegen-patches/rust/dafny-4.5.0.patch +++ b/TestModels/dafny-dependencies/StandardLibrary/codegen-patches/rust/dafny-4.5.0.patch @@ -184,305 +184,23 @@ index 00000000..3b7c2e76 +} diff --git b/TestModels/dafny-dependencies/StandardLibrary/runtimes/rust/src/lib.rs a/TestModels/dafny-dependencies/StandardLibrary/runtimes/rust/src/lib.rs new file mode 100644 -index 00000000..4b9fb6f8 +index 00000000..12cdf221 --- /dev/null +++ a/TestModels/dafny-dependencies/StandardLibrary/runtimes/rust/src/lib.rs -@@ -0,0 +1,298 @@ +@@ -0,0 +1,4 @@ +#[allow(non_snake_case)] +pub mod UTF8; +pub mod conversion; +pub mod implementation_from_dafny; -+ -+#[cfg(test)] -+#[allow(non_snake_case)] -+mod TestUTF8 { -+ use super::*; -+ #[test] -+ fn TestEncodeHappyCase() { -+ let unicodeString = ::dafny_runtime::string_utf16_of("abc\u{0306}\u{01FD}\u{03B2}"); -+ let expectedBytes = -+ dafny_runtime::seq![0x61, 0x62, 0x63, 0xCC, 0x86, 0xC7, 0xBD, 0xCE, 0xB2]; -+ let _r = implementation_from_dafny::UTF8::_default::Encode(&unicodeString); -+ if _r.IsFailure() { -+ panic!("Encode failed"); -+ } -+ let encoded = _r.Extract(); -+ assert_eq!(expectedBytes, encoded); -+ } -+ -+ #[test] -+ fn TestEncodeInvalidUnicode() { -+ let invalidUnicode = ::dafny_runtime::seq![ -+ ::dafny_runtime::DafnyCharUTF16('a' as u16), -+ ::dafny_runtime::DafnyCharUTF16('b' as u16), -+ ::dafny_runtime::DafnyCharUTF16('c' as u16), -+ ::dafny_runtime::DafnyCharUTF16(0xD800) -+ ]; -+ let encoded = implementation_from_dafny::UTF8::_default::Encode(&invalidUnicode); -+ assert!(encoded.IsFailure()); -+ } -+ -+ #[test] -+ fn TestDecodeHappyCase() { -+ let unicodeBytes = -+ ::dafny_runtime::seq![0x61, 0x62, 0x63, 0xCC, 0x86, 0xC7, 0xBD, 0xCE, 0xB2]; -+ assert!( -+ implementation_from_dafny::UTF8::_default::Uses2Bytes( -+ &::dafny_runtime::seq![0xC7 as u8, 0xBD as u8, 0xCE as u8, 0xB2 as u8] -+ ) -+ ); -+ assert_eq!( -+ ::dafny_runtime::seq![0xC7 as u8, 0xBD as u8, 0xCE as u8, 0xB2 as u8], -+ unicodeBytes.slice(&::dafny_runtime::int!(5), &::dafny_runtime::int!(9)) -+ ); -+ assert!( -+ implementation_from_dafny::UTF8::_default::ValidUTF8Range( -+ &unicodeBytes, -+ &::dafny_runtime::int!(7), -+ &::dafny_runtime::int!(9) -+ ) -+ ); -+ assert!( -+ implementation_from_dafny::UTF8::_default::ValidUTF8Range( -+ &unicodeBytes, -+ &::dafny_runtime::int!(0), -+ &::dafny_runtime::int!(9) -+ ) -+ ); -+ let expectedString = ::dafny_runtime::string_utf16_of("abc\u{0306}\u{01FD}\u{03B2}"); -+ let _r = implementation_from_dafny::UTF8::_default::Decode(&unicodeBytes); -+ if _r.IsFailure() { -+ panic!("Decode failed"); -+ } -+ let decoded = _r.Extract(); -+ assert_eq!(expectedString, decoded); -+ } -+ -+ #[test] -+ fn TestDecodeInvalidUnicode() { -+ let invalidUnicode = ::dafny_runtime::seq![ -+ 0x61 as u8, 0x62 as u8, 0x63 as u8, 0xED as u8, 0xA0 as u8, 0x80 as u8 -+ ]; -+ let _r = implementation_from_dafny::UTF8::_default::Decode(&invalidUnicode); -+ assert!(_r.IsFailure()); -+ } -+ -+ #[test] -+ fn Test1Byte() { -+ // Null -+ let mut decoded = ::dafny_runtime::string_utf16_of("\u{0000}"); -+ let mut _r = implementation_from_dafny::UTF8::_default::Encode(&decoded); -+ assert!(!_r.IsFailure()); -+ let mut encoded = _r.Extract(); -+ assert_eq!(::dafny_runtime::seq![0x00 as u8], encoded); -+ assert!(implementation_from_dafny::UTF8::_default::Uses1Byte(&encoded)); -+ let mut _r2 = implementation_from_dafny::UTF8::_default::Decode(&encoded); -+ assert!(!_r2.IsFailure()); -+ let mut redecoded = _r2.Extract(); -+ assert_eq!(decoded, redecoded); -+ -+ // Space -+ decoded = ::dafny_runtime::string_utf16_of(" "); -+ _r = implementation_from_dafny::UTF8::_default::Encode(&decoded); -+ assert!(!_r.IsFailure()); -+ encoded = _r.Extract(); -+ assert_eq!(::dafny_runtime::seq![0x20 as u8], encoded); -+ assert!(implementation_from_dafny::UTF8::_default::Uses1Byte(&encoded)); -+ _r2 = implementation_from_dafny::UTF8::_default::Decode(&encoded); -+ assert!(!_r2.IsFailure()); -+ redecoded = _r2.Extract(); -+ assert_eq!(decoded, redecoded); -+ -+ decoded = ::dafny_runtime::string_utf16_of("$"); -+ _r = implementation_from_dafny::UTF8::_default::Encode(&decoded); -+ assert!(!_r.IsFailure()); -+ encoded = _r.Extract(); -+ assert_eq!(::dafny_runtime::seq![0x24 as u8], encoded); -+ assert!(implementation_from_dafny::UTF8::_default::Uses1Byte(&encoded)); -+ _r2 = implementation_from_dafny::UTF8::_default::Decode(&encoded); -+ assert!(!_r2.IsFailure()); -+ redecoded = _r2.Extract(); -+ assert_eq!(decoded, redecoded); -+ -+ decoded = ::dafny_runtime::string_utf16_of("0"); -+ _r = implementation_from_dafny::UTF8::_default::Encode(&decoded); -+ assert!(!_r.IsFailure()); -+ encoded = _r.Extract(); -+ assert_eq!(::dafny_runtime::seq![0x30 as u8], encoded); -+ assert!(implementation_from_dafny::UTF8::_default::Uses1Byte(&encoded)); -+ _r2 = implementation_from_dafny::UTF8::_default::Decode(&encoded); -+ assert!(!_r2.IsFailure()); -+ redecoded = _r2.Extract(); -+ assert_eq!(decoded, redecoded); -+ decoded = ::dafny_runtime::string_utf16_of("A"); -+ _r = implementation_from_dafny::UTF8::_default::Encode(&decoded); -+ assert!(!_r.IsFailure()); -+ encoded = _r.Extract(); -+ assert_eq!(::dafny_runtime::seq![0x41 as u8], encoded); -+ assert!(implementation_from_dafny::UTF8::_default::Uses1Byte(&encoded)); -+ _r2 = implementation_from_dafny::UTF8::_default::Decode(&encoded); -+ assert!(!_r2.IsFailure()); -+ redecoded = _r2.Extract(); -+ assert_eq!(decoded, redecoded); -+ decoded = ::dafny_runtime::string_utf16_of("a"); -+ _r = implementation_from_dafny::UTF8::_default::Encode(&decoded); -+ assert!(!_r.IsFailure()); -+ encoded = _r.Extract(); -+ assert_eq!(::dafny_runtime::seq![0x61 as u8], encoded); -+ assert!(implementation_from_dafny::UTF8::_default::Uses1Byte(&encoded)); -+ _r2 = implementation_from_dafny::UTF8::_default::Decode(&encoded); -+ assert!(!_r2.IsFailure()); -+ redecoded = _r2.Extract(); -+ assert_eq!(decoded, redecoded); -+ } -+ -+ #[test] -+ fn Test2Bytes() { -+ let mut decoded = ::dafny_runtime::string_utf16_of("\u{00A3}"); -+ let mut _r = implementation_from_dafny::UTF8::_default::Encode(&decoded); -+ assert!(!_r.IsFailure()); -+ let mut encoded = _r.Extract(); -+ assert_eq!(::dafny_runtime::seq![0xC2 as u8, 0xA3 as u8], encoded); -+ assert!(implementation_from_dafny::UTF8::_default::Uses2Bytes(&encoded)); -+ let mut _r2 = implementation_from_dafny::UTF8::_default::Decode(&encoded); -+ assert!(!_r2.IsFailure()); -+ let mut redecoded = _r2.Extract(); -+ assert_eq!(decoded, redecoded); -+ decoded = ::dafny_runtime::string_utf16_of("\u{00A9}"); -+ _r = implementation_from_dafny::UTF8::_default::Encode(&decoded); -+ assert!(!_r.IsFailure()); -+ encoded = _r.Extract(); -+ assert_eq!(::dafny_runtime::seq![0xC2 as u8, 0xA9 as u8], encoded); -+ assert!(implementation_from_dafny::UTF8::_default::Uses2Bytes(&encoded)); -+ _r2 = implementation_from_dafny::UTF8::_default::Decode(&encoded); -+ assert!(!_r2.IsFailure()); -+ redecoded = _r2.Extract(); -+ assert_eq!(decoded, redecoded); -+ decoded = ::dafny_runtime::string_utf16_of("\u{00AE}"); -+ _r = implementation_from_dafny::UTF8::_default::Encode(&decoded); -+ assert!(!_r.IsFailure()); -+ encoded = _r.Extract(); -+ assert_eq!(::dafny_runtime::seq![0xC2 as u8, 0xAE as u8], encoded); -+ assert!(implementation_from_dafny::UTF8::_default::Uses2Bytes(&encoded)); -+ _r2 = implementation_from_dafny::UTF8::_default::Decode(&encoded); -+ assert!(!_r2.IsFailure()); -+ redecoded = _r2.Extract(); -+ assert_eq!(decoded, redecoded); -+ decoded = ::dafny_runtime::string_utf16_of("\u{03C0}"); -+ _r = implementation_from_dafny::UTF8::_default::Encode(&decoded); -+ assert!(!_r.IsFailure()); -+ encoded = _r.Extract(); -+ assert_eq!(::dafny_runtime::seq![0xCF as u8, 0x80 as u8], encoded); -+ assert!(implementation_from_dafny::UTF8::_default::Uses2Bytes(&encoded)); -+ _r2 = implementation_from_dafny::UTF8::_default::Decode(&encoded); -+ assert!(!_r2.IsFailure()); -+ redecoded = _r2.Extract(); -+ assert_eq!(decoded, redecoded); -+ } -+ -+ #[test] -+ fn Test3Bytes() { -+ let mut decoded = ::dafny_runtime::string_utf16_of("\u{2386}"); -+ let mut _r = implementation_from_dafny::UTF8::_default::Encode(&decoded); -+ assert!(!_r.IsFailure()); -+ let mut encoded = _r.Extract(); -+ assert_eq!( -+ ::dafny_runtime::seq![0xE2 as u8, 0x8E as u8, 0x86 as u8], -+ encoded -+ ); -+ assert!(implementation_from_dafny::UTF8::_default::Uses3Bytes(&encoded)); -+ let mut _r2 = implementation_from_dafny::UTF8::_default::Decode(&encoded); -+ assert!(!_r2.IsFailure()); -+ let mut redecoded = _r2.Extract(); -+ assert_eq!(decoded, redecoded); -+ decoded = ::dafny_runtime::string_utf16_of("\u{2387}"); -+ _r = implementation_from_dafny::UTF8::_default::Encode(&decoded); -+ assert!(!_r.IsFailure()); -+ encoded = _r.Extract(); -+ assert_eq!( -+ ::dafny_runtime::seq![0xE2 as u8, 0x8E as u8, 0x87 as u8], -+ encoded -+ ); -+ assert!(implementation_from_dafny::UTF8::_default::Uses3Bytes(&encoded)); -+ _r2 = implementation_from_dafny::UTF8::_default::Decode(&encoded); -+ assert!(!_r2.IsFailure()); -+ redecoded = _r2.Extract(); -+ assert_eq!(decoded, redecoded); -+ decoded = ::dafny_runtime::string_utf16_of("\u{231B}"); -+ _r = implementation_from_dafny::UTF8::_default::Encode(&decoded); -+ assert!(!_r.IsFailure()); -+ encoded = _r.Extract(); -+ assert_eq!( -+ ::dafny_runtime::seq![0xE2 as u8, 0x8C as u8, 0x9B as u8], -+ encoded -+ ); -+ assert!(implementation_from_dafny::UTF8::_default::Uses3Bytes(&encoded)); -+ _r2 = implementation_from_dafny::UTF8::_default::Decode(&encoded); -+ assert!(!_r2.IsFailure()); -+ redecoded = _r2.Extract(); -+ assert_eq!(decoded, redecoded); -+ decoded = ::dafny_runtime::string_utf16_of("\u{1D78}"); -+ _r = implementation_from_dafny::UTF8::_default::Encode(&decoded); -+ assert!(!_r.IsFailure()); -+ encoded = _r.Extract(); -+ assert_eq!( -+ ::dafny_runtime::seq![0xE1 as u8, 0xB5 as u8, 0xB8 as u8], -+ encoded -+ ); -+ assert!(implementation_from_dafny::UTF8::_default::Uses3Bytes(&encoded)); -+ _r2 = implementation_from_dafny::UTF8::_default::Decode(&encoded); -+ assert!(!_r2.IsFailure()); -+ redecoded = _r2.Extract(); -+ assert_eq!(decoded, redecoded); -+ decoded = ::dafny_runtime::string_utf16_of("\u{732B}"); -+ _r = implementation_from_dafny::UTF8::_default::Encode(&decoded); -+ assert!(!_r.IsFailure()); -+ encoded = _r.Extract(); -+ assert_eq!( -+ ::dafny_runtime::seq![0xE7 as u8, 0x8C as u8, 0xAB as u8], -+ encoded -+ ); -+ assert!(implementation_from_dafny::UTF8::_default::Uses3Bytes(&encoded)); -+ _r2 = implementation_from_dafny::UTF8::_default::Decode(&encoded); -+ assert!(!_r2.IsFailure()); -+ redecoded = _r2.Extract(); -+ assert_eq!(decoded, redecoded); -+ } -+ -+ #[test] -+ fn Test4Bytes() { -+ let mut decoded = ::dafny_runtime::seq![ -+ ::dafny_runtime::DafnyCharUTF16(0xD808), -+ ::dafny_runtime::DafnyCharUTF16(0xDC00) -+ ]; -+ let mut _r = implementation_from_dafny::UTF8::_default::Encode(&decoded); -+ println!( -+ "{}", -+ ::dafny_runtime::DafnyPrintWrapper(&_r.as_ref().clone()) -+ ); -+ assert!(!_r.IsFailure()); -+ let mut encoded = _r.Extract(); -+ assert_eq!( -+ ::dafny_runtime::seq![0xF0 as u8, 0x92 as u8, 0x80 as u8, 0x80 as u8], -+ encoded -+ ); -+ assert!(implementation_from_dafny::UTF8::_default::Uses4Bytes(&encoded)); -+ let mut _r2 = implementation_from_dafny::UTF8::_default::Decode(&encoded); -+ assert!(!_r2.IsFailure()); -+ let mut redecoded = _r2.Extract(); -+ assert_eq!(decoded, redecoded); -+ decoded = ::dafny_runtime::string_utf16_of("\u{1D7C1}"); -+ _r = implementation_from_dafny::UTF8::_default::Encode(&decoded); -+ assert!(!_r.IsFailure()); -+ encoded = _r.Extract(); -+ assert_eq!( -+ ::dafny_runtime::seq![0xF0 as u8, 0x9D as u8, 0x9F as u8, 0x81 as u8], -+ encoded -+ ); -+ assert!(implementation_from_dafny::UTF8::_default::Uses4Bytes(&encoded)); -+ _r2 = implementation_from_dafny::UTF8::_default::Decode(&encoded); -+ assert!(!_r2.IsFailure()); -+ redecoded = _r2.Extract(); -+ assert_eq!(decoded, redecoded); -+ } -+} +\ No newline at end of file +diff --git b/TestModels/dafny-dependencies/StandardLibrary/runtimes/rust/tests/tests_from_dafny/mod.rs a/TestModels/dafny-dependencies/StandardLibrary/runtimes/rust/tests/tests_from_dafny/mod.rs +index 20caf2dd..c4a1c20f 100644 +--- b/TestModels/dafny-dependencies/StandardLibrary/runtimes/rust/tests/tests_from_dafny/mod.rs ++++ a/TestModels/dafny-dependencies/StandardLibrary/runtimes/rust/tests/tests_from_dafny/mod.rs +@@ -1,5 +1,6 @@ + #![allow(warnings, unconditional_panic)] + #![allow(nonstandard_style)] ++use ::dafny_standard_library::implementation_from_dafny::*; + + pub mod r#_TestUTF8_Compile { + pub struct _default {} From 7f0fde8142932f73cea53136b9dc5f8a24b9c90b Mon Sep 17 00:00:00 2001 From: Robin Salkeld Date: Wed, 10 Jul 2024 13:55:01 -0700 Subject: [PATCH 41/53] Unused import --- .../src/main/java/software/amazon/polymorph/CodegenEngine.java | 1 - 1 file changed, 1 deletion(-) diff --git a/codegen/smithy-dafny-codegen/src/main/java/software/amazon/polymorph/CodegenEngine.java b/codegen/smithy-dafny-codegen/src/main/java/software/amazon/polymorph/CodegenEngine.java index 82abf4c8ef..9cb8097d33 100644 --- a/codegen/smithy-dafny-codegen/src/main/java/software/amazon/polymorph/CodegenEngine.java +++ b/codegen/smithy-dafny-codegen/src/main/java/software/amazon/polymorph/CodegenEngine.java @@ -7,7 +7,6 @@ import com.google.common.collect.ImmutableMap; import com.google.common.collect.Streams; import com.squareup.javapoet.ClassName; -import java.io.File; import java.io.IOException; import java.io.UncheckedIOException; import java.nio.file.Files; From 6e6635b0bb6e387303727c97d5be10a0be780bf2 Mon Sep 17 00:00:00 2001 From: Robin Salkeld Date: Wed, 10 Jul 2024 13:56:17 -0700 Subject: [PATCH 42/53] stdlib Makefile fix --- TestModels/dafny-dependencies/StandardLibrary/Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/TestModels/dafny-dependencies/StandardLibrary/Makefile b/TestModels/dafny-dependencies/StandardLibrary/Makefile index b1dd89a26e..1e8efe7e96 100644 --- a/TestModels/dafny-dependencies/StandardLibrary/Makefile +++ b/TestModels/dafny-dependencies/StandardLibrary/Makefile @@ -65,7 +65,7 @@ transpile_java: | transpile_implementation_java transpile_test_java # Override SharedMakefile's transpile_java to not transpile # StandardLibrary as a dependency -transpile_rust: | transpile_implementation_rust +transpile_rust: | transpile_implementation_rust transpile_test_rust # Override the targets to relocate translated Rust code directly into the main crate, # instead of the dafny_impl sub-crate. From 44bd95347cba1b0147805d053491dbbe2c9e36c5 Mon Sep 17 00:00:00 2001 From: Robin Salkeld Date: Wed, 10 Jul 2024 14:42:15 -0700 Subject: [PATCH 43/53] Makefile comment --- TestModels/SharedMakefile.mk | 2 ++ 1 file changed, 2 insertions(+) diff --git a/TestModels/SharedMakefile.mk b/TestModels/SharedMakefile.mk index b5892fdaa2..975ba217aa 100644 --- a/TestModels/SharedMakefile.mk +++ b/TestModels/SharedMakefile.mk @@ -74,5 +74,7 @@ _polymorph_rust: OUTPUT_RUST=--output-rust $(LIBRARY_ROOT)/runtimes/rust _polymorph_rust: INPUT_DAFNY=\ --include-dafny $(PROJECT_ROOT)/$(STD_LIBRARY)/src/Index.dfy _polymorph_rust: _polymorph +# TODO: This doesn't yet work for Rust because we are patching transpiled code, +# so this target will complain about "patch does not apply" because it was already applied. # _polymorph_rust: OUTPUT_RUST_WRAPPED=--output-rust $(LIBRARY_ROOT)/runtimes/rust # _polymorph_rust: _polymorph_wrapped From ad467d0d4782fdff0f82b2ef44fba37a98b25dc4 Mon Sep 17 00:00:00 2001 From: Robin Salkeld Date: Wed, 10 Jul 2024 15:00:43 -0700 Subject: [PATCH 44/53] Fix issue with stdlib patch not applying --- SmithyDafnyMakefile.mk | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/SmithyDafnyMakefile.mk b/SmithyDafnyMakefile.mk index 4b95994104..0d4cf146de 100644 --- a/SmithyDafnyMakefile.mk +++ b/SmithyDafnyMakefile.mk @@ -252,6 +252,10 @@ transpile_dependencies: $(if $(strip $(STD_LIBRARY)), $(MAKE) -C $(PROJECT_ROOT)/$(STD_LIBRARY) transpile_implementation_$(LANG), ) $(patsubst %, $(MAKE) -C $(PROJECT_ROOT)/% transpile_implementation_$(LANG);, $(PROJECT_DEPENDENCIES)) +transpile_dependencies_test: + $(if $(strip $(STD_LIBRARY)), $(MAKE) -C $(PROJECT_ROOT)/$(STD_LIBRARY) transpile_test_$(LANG), ) + $(patsubst %, $(MAKE) -C $(PROJECT_ROOT)/% transpile_test_$(LANG);, $(PROJECT_DEPENDENCIES)) + ########################## Code-Gen targets # The OUTPUT variables are created this way @@ -512,7 +516,11 @@ test_java: ########################## Rust targets -transpile_rust: | transpile_implementation_rust transpile_test_rust transpile_dependencies_rust +# Note that transpile_dependencies_test_rust is necessary +# only because we are patching test code in the StandardLibrary, +# so we don't transpile that code then the recursive call to polymorph_rust +# on the StandardLibrary will fail because the patch does not apply. +transpile_rust: | transpile_implementation_rust transpile_test_rust transpile_dependencies_rust transpile_dependencies_test_rust transpile_implementation_rust: TARGET=rs transpile_implementation_rust: OUT=implementation_from_dafny @@ -534,6 +542,9 @@ transpile_test_rust: _transpile_test_all _mv_test_rust transpile_dependencies_rust: LANG=rust transpile_dependencies_rust: transpile_dependencies +transpile_dependencies_test_rust: LANG=rust +transpile_dependencies_test_rust: transpile_dependencies_test + _mv_implementation_rust: rm -rf runtimes/rust/dafny_impl/src mkdir -p runtimes/rust/dafny_impl/src From a815731ceaf83ffad21606bca24b3843de483c2f Mon Sep 17 00:00:00 2001 From: Robin Salkeld Date: Thu, 11 Jul 2024 11:52:22 -0700 Subject: [PATCH 45/53] Partial change to put async back --- .../SimpleBoolean/runtimes/rust/Cargo.toml | 4 ++++ .../runtimes/rust/src/operation/get_boolean.rs | 2 +- .../rust/src/operation/get_boolean/builders.rs | 8 ++++---- .../runtimes/rust/tests/simple_boolean_test.rs | 12 ++++++------ .../runtimes/rust/tests/tests_from_dafny/_wrapped.rs | 7 ++++++- 5 files changed, 21 insertions(+), 12 deletions(-) diff --git a/TestModels/SimpleTypes/SimpleBoolean/runtimes/rust/Cargo.toml b/TestModels/SimpleTypes/SimpleBoolean/runtimes/rust/Cargo.toml index 1c96c523e0..199aad3acb 100644 --- a/TestModels/SimpleTypes/SimpleBoolean/runtimes/rust/Cargo.toml +++ b/TestModels/SimpleTypes/SimpleBoolean/runtimes/rust/Cargo.toml @@ -12,3 +12,7 @@ aws-smithy-types = "1.2.0" dafny_runtime = { path = "../../../../dafny-dependencies/dafny_runtime_rust"} dafny_standard_library = { path = "../../../../dafny-dependencies/StandardLibrary/runtimes/rust"} simple_boolean_dafny = { path = "./dafny_impl"} + +[dev-dependencies.tokio] +version = "1.26.0" +features = ["full"] \ No newline at end of file diff --git a/TestModels/SimpleTypes/SimpleBoolean/runtimes/rust/src/operation/get_boolean.rs b/TestModels/SimpleTypes/SimpleBoolean/runtimes/rust/src/operation/get_boolean.rs index 638abe840d..1784adba81 100644 --- a/TestModels/SimpleTypes/SimpleBoolean/runtimes/rust/src/operation/get_boolean.rs +++ b/TestModels/SimpleTypes/SimpleBoolean/runtimes/rust/src/operation/get_boolean.rs @@ -8,7 +8,7 @@ impl GetBoolean { pub fn new() -> Self { Self } - pub fn send( + pub async fn send( client: &crate::client::Client, input: crate::operation::get_boolean::GetBooleanInput, ) -> ::std::result::Result< diff --git a/TestModels/SimpleTypes/SimpleBoolean/runtimes/rust/src/operation/get_boolean/builders.rs b/TestModels/SimpleTypes/SimpleBoolean/runtimes/rust/src/operation/get_boolean/builders.rs index b30d907271..e672a27053 100644 --- a/TestModels/SimpleTypes/SimpleBoolean/runtimes/rust/src/operation/get_boolean/builders.rs +++ b/TestModels/SimpleTypes/SimpleBoolean/runtimes/rust/src/operation/get_boolean/builders.rs @@ -5,7 +5,7 @@ pub use crate::operation::get_boolean::_get_boolean_input::GetBooleanInputBuilde impl GetBooleanInputBuilder { /// Sends a request with this input using the given client. - pub fn send_with( + pub async fn send_with( self, client: &crate::Client, ) -> ::std::result::Result< @@ -14,7 +14,7 @@ impl GetBooleanInputBuilder { > { let mut fluent_builder = client.get_boolean(); fluent_builder.inner = self; - fluent_builder.send() + fluent_builder.send().await } } /// Fluent builder constructing a request to `GetBoolean`. @@ -37,7 +37,7 @@ impl GetBooleanFluentBuilder { &self.inner } /// Sends the request and returns the response. - pub fn send( + pub async fn send( self, ) -> ::std::result::Result< crate::operation::get_boolean::GetBooleanOutput, @@ -52,7 +52,7 @@ impl GetBooleanFluentBuilder { // Vanilla smithy-rs uses SdkError::construction_failure, // but we aren't using SdkError. .map_err(crate::operation::get_boolean::GetBooleanError::unhandled)?; - crate::operation::get_boolean::GetBoolean::send(&self.client, input) + crate::operation::get_boolean::GetBoolean::send(&self.client, input).await } #[allow(missing_docs)] // documentation missing in model diff --git a/TestModels/SimpleTypes/SimpleBoolean/runtimes/rust/tests/simple_boolean_test.rs b/TestModels/SimpleTypes/SimpleBoolean/runtimes/rust/tests/simple_boolean_test.rs index 22aa75b70b..9dc7b5d32b 100644 --- a/TestModels/SimpleTypes/SimpleBoolean/runtimes/rust/tests/simple_boolean_test.rs +++ b/TestModels/SimpleTypes/SimpleBoolean/runtimes/rust/tests/simple_boolean_test.rs @@ -24,9 +24,9 @@ mod tests_from_dafny; print ret; } } */ -#[test] -fn test_get_boolean_true() { - let result = client().get_boolean().value(true).send(); +#[tokio::test] +async fn test_get_boolean_true() { + let result = client().get_boolean().value(true).send().await; let output = result.unwrap(); let value = output.value().unwrap(); assert!(value); @@ -42,9 +42,9 @@ fn test_get_boolean_true() { print ret; } } */ -#[test] -fn test_get_boolean_false() { - let result = client().get_boolean().value(false).send(); +#[tokio::test] +async fn test_get_boolean_false() { + let result = client().get_boolean().value(false).send().await; let output = result.unwrap(); let value = output.value().unwrap(); assert!(!value); diff --git a/TestModels/SimpleTypes/SimpleBoolean/runtimes/rust/tests/tests_from_dafny/_wrapped.rs b/TestModels/SimpleTypes/SimpleBoolean/runtimes/rust/tests/tests_from_dafny/_wrapped.rs index 5988b6bc17..20e90bce5f 100644 --- a/TestModels/SimpleTypes/SimpleBoolean/runtimes/rust/tests/tests_from_dafny/_wrapped.rs +++ b/TestModels/SimpleTypes/SimpleBoolean/runtimes/rust/tests/tests_from_dafny/_wrapped.rs @@ -4,9 +4,14 @@ use crate::tests_from_dafny::*; use aws_smithy_types::error::operation::BuildError; use dafny_runtime::UpcastObject; use simple_boolean::*; +use tokio::runtime::Runtime; struct WrappedClient { wrapped: Client, + + /// A `current_thread` runtime for executing operations on the + /// asynchronous client in a blocking manner. + rt: Runtime } impl UpcastObject for WrappedClient { @@ -31,7 +36,7 @@ impl ::simple_boolean_dafny::r#_simple_dtypes_dboolean_dinternaldafny_dtypes::IS >{ let inner_input = crate::conversions::get_boolean::_get_boolean_input::from_dafny(input.clone()); - let result = crate::operation::get_boolean::GetBoolean::send(&self.wrapped, inner_input); + let result = self.rt.block_on(crate::operation::get_boolean::GetBoolean::send(&self.wrapped, inner_input)); match result { Err(error) => ::std::rc::Rc::new( ::simple_boolean_dafny::_Wrappers_Compile::Result::Failure { From 5ef3220f73a3b32b79d6549e7afbc664fda9a749 Mon Sep 17 00:00:00 2001 From: Robin Salkeld Date: Thu, 11 Jul 2024 12:01:48 -0700 Subject: [PATCH 46/53] Working but messy as hell --- .../rust/tests/tests_from_dafny/_wrapped.rs | 25 +++++++++++++++++++ 1 file changed, 25 insertions(+) diff --git a/TestModels/SimpleTypes/SimpleBoolean/runtimes/rust/tests/tests_from_dafny/_wrapped.rs b/TestModels/SimpleTypes/SimpleBoolean/runtimes/rust/tests/tests_from_dafny/_wrapped.rs index 20e90bce5f..3c857c6e9f 100644 --- a/TestModels/SimpleTypes/SimpleBoolean/runtimes/rust/tests/tests_from_dafny/_wrapped.rs +++ b/TestModels/SimpleTypes/SimpleBoolean/runtimes/rust/tests/tests_from_dafny/_wrapped.rs @@ -59,6 +59,13 @@ impl r#_simple_dtypes_dboolean_dinternaldafny_dwrapped::_default { ::dafny_runtime::Object, ::std::rc::Rc<::simple_boolean_dafny::r#_simple_dtypes_dboolean_dinternaldafny_dtypes::Error> >>{ + let rt_result = tokio::runtime::Builder::new_current_thread() + .enable_all() + .build(); + if rt_result.is_err() { + return ::std::rc::Rc::new(to_opaque_error_result(rt_result.err().unwrap())); + } + let rt = rt_result.unwrap(); let result = Client::from_conf( simple_boolean::conversions::simple_boolean_config::_simple_boolean_config::from_dafny( config.clone(), @@ -83,6 +90,7 @@ impl r#_simple_dtypes_dboolean_dinternaldafny_dwrapped::_default { Ok(client) => { let wrap = WrappedClient { wrapped: client.clone(), + rt }; let inner: ::std::rc::Rc<::std::cell::UnsafeCell> = ::std::rc::Rc::new(::std::cell::UnsafeCell::new(wrap)); @@ -96,3 +104,20 @@ impl r#_simple_dtypes_dboolean_dinternaldafny_dwrapped::_default { } } } + +fn to_opaque_error_result(error: std::io::Error) -> ::simple_boolean_dafny::r#_Wrappers_Compile::Result< +::dafny_runtime::Object, +::std::rc::Rc<::simple_boolean_dafny::r#_simple_dtypes_dboolean_dinternaldafny_dtypes::Error> +> { + let error_obj: ::dafny_runtime::Object = + ::dafny_runtime::Object(Some(::std::rc::Rc::new( + ::std::cell::UnsafeCell::new(error), + ))); + simple_boolean_dafny::_Wrappers_Compile::Result::Failure { + error: ::std::rc::Rc::new( + ::simple_boolean_dafny::r#_simple_dtypes_dboolean_dinternaldafny_dtypes::Error::Opaque { + obj: error_obj, + }, + ), + } +} \ No newline at end of file From 222c26406cbecb4e57fa00e830d2e7550ba89b3e Mon Sep 17 00:00:00 2001 From: Robin Salkeld Date: Thu, 11 Jul 2024 12:15:27 -0700 Subject: [PATCH 47/53] Update patch file --- .../codegen-patches/rust/dafny-4.5.0.patch | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/TestModels/SimpleTypes/SimpleBoolean/codegen-patches/rust/dafny-4.5.0.patch b/TestModels/SimpleTypes/SimpleBoolean/codegen-patches/rust/dafny-4.5.0.patch index 9e97d2e220..1cb08ac318 100644 --- a/TestModels/SimpleTypes/SimpleBoolean/codegen-patches/rust/dafny-4.5.0.patch +++ b/TestModels/SimpleTypes/SimpleBoolean/codegen-patches/rust/dafny-4.5.0.patch @@ -322,7 +322,7 @@ index 00000000..eb38b9f1 +pub mod get_boolean; diff --git b/TestModels/SimpleTypes/SimpleBoolean/runtimes/rust/src/operation/get_boolean.rs a/TestModels/SimpleTypes/SimpleBoolean/runtimes/rust/src/operation/get_boolean.rs new file mode 100644 -index 00000000..638abe84 +index 00000000..1784adba --- /dev/null +++ a/TestModels/SimpleTypes/SimpleBoolean/runtimes/rust/src/operation/get_boolean.rs @@ -0,0 +1,145 @@ @@ -336,7 +336,7 @@ index 00000000..638abe84 + pub fn new() -> Self { + Self + } -+ pub fn send( ++ pub async fn send( + client: &crate::client::Client, + input: crate::operation::get_boolean::GetBooleanInput, + ) -> ::std::result::Result< @@ -603,7 +603,7 @@ index 00000000..d2943f38 +} diff --git b/TestModels/SimpleTypes/SimpleBoolean/runtimes/rust/src/operation/get_boolean/builders.rs a/TestModels/SimpleTypes/SimpleBoolean/runtimes/rust/src/operation/get_boolean/builders.rs new file mode 100644 -index 00000000..b30d9072 +index 00000000..e672a270 --- /dev/null +++ a/TestModels/SimpleTypes/SimpleBoolean/runtimes/rust/src/operation/get_boolean/builders.rs @@ -0,0 +1,72 @@ @@ -614,7 +614,7 @@ index 00000000..b30d9072 + +impl GetBooleanInputBuilder { + /// Sends a request with this input using the given client. -+ pub fn send_with( ++ pub async fn send_with( + self, + client: &crate::Client, + ) -> ::std::result::Result< @@ -623,7 +623,7 @@ index 00000000..b30d9072 + > { + let mut fluent_builder = client.get_boolean(); + fluent_builder.inner = self; -+ fluent_builder.send() ++ fluent_builder.send().await + } +} +/// Fluent builder constructing a request to `GetBoolean`. @@ -646,7 +646,7 @@ index 00000000..b30d9072 + &self.inner + } + /// Sends the request and returns the response. -+ pub fn send( ++ pub async fn send( + self, + ) -> ::std::result::Result< + crate::operation::get_boolean::GetBooleanOutput, @@ -661,7 +661,7 @@ index 00000000..b30d9072 + // Vanilla smithy-rs uses SdkError::construction_failure, + // but we aren't using SdkError. + .map_err(crate::operation::get_boolean::GetBooleanError::unhandled)?; -+ crate::operation::get_boolean::GetBoolean::send(&self.client, input) ++ crate::operation::get_boolean::GetBoolean::send(&self.client, input).await + } + + #[allow(missing_docs)] // documentation missing in model From 7c06d328fda8fe7c3e2618d972a166ac43bd6871 Mon Sep 17 00:00:00 2001 From: Robin Salkeld Date: Fri, 12 Jul 2024 10:14:53 -0700 Subject: [PATCH 48/53] Moved wrapped client into src, guarded by wrapped-client feature --- .../SimpleBoolean/runtimes/rust/Cargo.toml | 8 +- .../SimpleBoolean/runtimes/rust/src/lib.rs | 5 +- .../rust/src/operation/get_boolean.rs | 2 +- .../runtimes/rust/src/wrapped.rs | 1 + .../runtimes/rust/src/wrapped/client.rs | 118 ++++++++++++++++ .../rust/tests/tests_from_dafny/_wrapped.rs | 127 ++---------------- 6 files changed, 139 insertions(+), 122 deletions(-) create mode 100644 TestModels/SimpleTypes/SimpleBoolean/runtimes/rust/src/wrapped.rs create mode 100644 TestModels/SimpleTypes/SimpleBoolean/runtimes/rust/src/wrapped/client.rs diff --git a/TestModels/SimpleTypes/SimpleBoolean/runtimes/rust/Cargo.toml b/TestModels/SimpleTypes/SimpleBoolean/runtimes/rust/Cargo.toml index 199aad3acb..5dbdc056eb 100644 --- a/TestModels/SimpleTypes/SimpleBoolean/runtimes/rust/Cargo.toml +++ b/TestModels/SimpleTypes/SimpleBoolean/runtimes/rust/Cargo.toml @@ -5,6 +5,9 @@ edition = "2021" # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html +[features] +wrapped-client = [] + [dependencies] aws-smithy-runtime = {version = "1.6.0", features = ["client"] } aws-smithy-runtime-api = {version = "1.7.0", features = ["client"] } @@ -13,6 +16,9 @@ dafny_runtime = { path = "../../../../dafny-dependencies/dafny_runtime_rust"} dafny_standard_library = { path = "../../../../dafny-dependencies/StandardLibrary/runtimes/rust"} simple_boolean_dafny = { path = "./dafny_impl"} -[dev-dependencies.tokio] +[dev-dependencies] +simple_boolean = { path = ".", features = ["wrapped-client"] } + +[dependencies.tokio] version = "1.26.0" features = ["full"] \ No newline at end of file diff --git a/TestModels/SimpleTypes/SimpleBoolean/runtimes/rust/src/lib.rs b/TestModels/SimpleTypes/SimpleBoolean/runtimes/rust/src/lib.rs index 445a4fe060..53977d7d61 100644 --- a/TestModels/SimpleTypes/SimpleBoolean/runtimes/rust/src/lib.rs +++ b/TestModels/SimpleTypes/SimpleBoolean/runtimes/rust/src/lib.rs @@ -11,7 +11,10 @@ pub mod error; /// All operations that this crate can perform. pub mod operation; -pub mod conversions; +mod conversions; + +#[cfg(feature = "wrapped-client")] +pub mod wrapped; pub use client::Client; pub use types::simple_boolean_config::SimpleBooleanConfig; diff --git a/TestModels/SimpleTypes/SimpleBoolean/runtimes/rust/src/operation/get_boolean.rs b/TestModels/SimpleTypes/SimpleBoolean/runtimes/rust/src/operation/get_boolean.rs index 1784adba81..96381e1da6 100644 --- a/TestModels/SimpleTypes/SimpleBoolean/runtimes/rust/src/operation/get_boolean.rs +++ b/TestModels/SimpleTypes/SimpleBoolean/runtimes/rust/src/operation/get_boolean.rs @@ -8,7 +8,7 @@ impl GetBoolean { pub fn new() -> Self { Self } - pub async fn send( + pub(crate) async fn send( client: &crate::client::Client, input: crate::operation::get_boolean::GetBooleanInput, ) -> ::std::result::Result< diff --git a/TestModels/SimpleTypes/SimpleBoolean/runtimes/rust/src/wrapped.rs b/TestModels/SimpleTypes/SimpleBoolean/runtimes/rust/src/wrapped.rs new file mode 100644 index 0000000000..3935517663 --- /dev/null +++ b/TestModels/SimpleTypes/SimpleBoolean/runtimes/rust/src/wrapped.rs @@ -0,0 +1 @@ +pub mod client; \ No newline at end of file diff --git a/TestModels/SimpleTypes/SimpleBoolean/runtimes/rust/src/wrapped/client.rs b/TestModels/SimpleTypes/SimpleBoolean/runtimes/rust/src/wrapped/client.rs new file mode 100644 index 0000000000..9ab30e66cb --- /dev/null +++ b/TestModels/SimpleTypes/SimpleBoolean/runtimes/rust/src/wrapped/client.rs @@ -0,0 +1,118 @@ +use tokio::runtime::Runtime; + +pub struct Client { + wrapped: crate::client::Client, + + /// A `current_thread` runtime for executing operations on the + /// asynchronous client in a blocking manner. + rt: Runtime +} + +impl dafny_runtime::UpcastObject for Client { + ::dafny_runtime::UpcastObjectFn!(dyn ::std::any::Any); +} + +impl Client { + pub fn from_conf(config: &::std::rc::Rc< + ::simple_boolean_dafny::r#_simple_dtypes_dboolean_dinternaldafny_dtypes::SimpleBooleanConfig, + >) -> ::std::rc::Rc<::simple_boolean_dafny::r#_Wrappers_Compile::Result< + ::dafny_runtime::Object, + ::std::rc::Rc<::simple_boolean_dafny::r#_simple_dtypes_dboolean_dinternaldafny_dtypes::Error> +>> { + let rt_result = tokio::runtime::Builder::new_current_thread() + .enable_all() + .build(); + if rt_result.is_err() { + return ::std::rc::Rc::new(to_opaque_error_result(rt_result.err().unwrap())); + } + let rt = rt_result.unwrap(); + let result = crate::client::Client::from_conf( + crate::conversions::simple_boolean_config::_simple_boolean_config::from_dafny( + config.clone(), + ), + ); + match result { + Err(error) => { + let error_obj: ::dafny_runtime::Object = + ::dafny_runtime::Object(Some(::std::rc::Rc::new( + ::std::cell::UnsafeCell::new(error), + ))); + ::std::rc::Rc::new( + ::simple_boolean_dafny::_Wrappers_Compile::Result::Failure { + error: ::std::rc::Rc::new( + ::simple_boolean_dafny::r#_simple_dtypes_dboolean_dinternaldafny_dtypes::Error::Opaque { + obj: error_obj, + }, + ), + }, + ) + } + Ok(client) => { + let wrap = crate::wrapped::client::Client { + wrapped: client.clone(), + rt + }; + let inner: ::std::rc::Rc<::std::cell::UnsafeCell> + = ::std::rc::Rc::new(::std::cell::UnsafeCell::new(wrap)); + + ::std::rc::Rc::new( + ::simple_boolean_dafny::_Wrappers_Compile::Result::Success { + value: ::dafny_runtime::Object(Some(inner)), + }, + ) + } + } + } +} + + +fn to_opaque_error_result(error: std::io::Error) -> ::simple_boolean_dafny::r#_Wrappers_Compile::Result< +::dafny_runtime::Object, +::std::rc::Rc<::simple_boolean_dafny::r#_simple_dtypes_dboolean_dinternaldafny_dtypes::Error> +> { +let error_obj: ::dafny_runtime::Object = + ::dafny_runtime::Object(Some(::std::rc::Rc::new( + ::std::cell::UnsafeCell::new(error), + ))); + simple_boolean_dafny::_Wrappers_Compile::Result::Failure { + error: ::std::rc::Rc::new( + ::simple_boolean_dafny::r#_simple_dtypes_dboolean_dinternaldafny_dtypes::Error::Opaque { + obj: error_obj, + }, + ), + } +} + +impl ::simple_boolean_dafny::r#_simple_dtypes_dboolean_dinternaldafny_dtypes::ISimpleTypesBooleanClient + for Client +{ + fn GetBoolean( + &mut self, + input: &std::rc::Rc< + ::simple_boolean_dafny::r#_simple_dtypes_dboolean_dinternaldafny_dtypes::GetBooleanInput, + >, + ) -> std::rc::Rc< + ::simple_boolean_dafny::r#_Wrappers_Compile::Result< + std::rc::Rc< + ::simple_boolean_dafny::r#_simple_dtypes_dboolean_dinternaldafny_dtypes::GetBooleanOutput, + >, + std::rc::Rc<::simple_boolean_dafny::r#_simple_dtypes_dboolean_dinternaldafny_dtypes::Error>, + >, + >{ + let inner_input = + crate::conversions::get_boolean::_get_boolean_input::from_dafny(input.clone()); + let result = self.rt.block_on(crate::operation::get_boolean::GetBoolean::send(&self.wrapped, inner_input)); + match result { + Err(error) => ::std::rc::Rc::new( + ::simple_boolean_dafny::_Wrappers_Compile::Result::Failure { + error: crate::conversions::get_boolean::to_dafny_error(error), + }, + ), + Ok(client) => ::std::rc::Rc::new( + ::simple_boolean_dafny::_Wrappers_Compile::Result::Success { + value: crate::conversions::get_boolean::_get_boolean_output::to_dafny(client), + }, + ), + } + } +} diff --git a/TestModels/SimpleTypes/SimpleBoolean/runtimes/rust/tests/tests_from_dafny/_wrapped.rs b/TestModels/SimpleTypes/SimpleBoolean/runtimes/rust/tests/tests_from_dafny/_wrapped.rs index 3c857c6e9f..ba1e652043 100644 --- a/TestModels/SimpleTypes/SimpleBoolean/runtimes/rust/tests/tests_from_dafny/_wrapped.rs +++ b/TestModels/SimpleTypes/SimpleBoolean/runtimes/rust/tests/tests_from_dafny/_wrapped.rs @@ -1,123 +1,12 @@ -use std::any::Any; - use crate::tests_from_dafny::*; -use aws_smithy_types::error::operation::BuildError; -use dafny_runtime::UpcastObject; -use simple_boolean::*; -use tokio::runtime::Runtime; - -struct WrappedClient { - wrapped: Client, - - /// A `current_thread` runtime for executing operations on the - /// asynchronous client in a blocking manner. - rt: Runtime -} - -impl UpcastObject for WrappedClient { - ::dafny_runtime::UpcastObjectFn!(dyn ::std::any::Any); -} - -impl ::simple_boolean_dafny::r#_simple_dtypes_dboolean_dinternaldafny_dtypes::ISimpleTypesBooleanClient - for WrappedClient -{ - fn GetBoolean( - &mut self, - input: &std::rc::Rc< - ::simple_boolean_dafny::r#_simple_dtypes_dboolean_dinternaldafny_dtypes::GetBooleanInput, - >, - ) -> std::rc::Rc< - ::simple_boolean_dafny::r#_Wrappers_Compile::Result< - std::rc::Rc< - ::simple_boolean_dafny::r#_simple_dtypes_dboolean_dinternaldafny_dtypes::GetBooleanOutput, - >, - std::rc::Rc<::simple_boolean_dafny::r#_simple_dtypes_dboolean_dinternaldafny_dtypes::Error>, - >, - >{ - let inner_input = - crate::conversions::get_boolean::_get_boolean_input::from_dafny(input.clone()); - let result = self.rt.block_on(crate::operation::get_boolean::GetBoolean::send(&self.wrapped, inner_input)); - match result { - Err(error) => ::std::rc::Rc::new( - ::simple_boolean_dafny::_Wrappers_Compile::Result::Failure { - error: crate::conversions::get_boolean::to_dafny_error(error), - }, - ), - Ok(client) => ::std::rc::Rc::new( - ::simple_boolean_dafny::_Wrappers_Compile::Result::Success { - value: crate::conversions::get_boolean::_get_boolean_output::to_dafny(client), - }, - ), - } - } -} impl r#_simple_dtypes_dboolean_dinternaldafny_dwrapped::_default { - pub fn WrappedSimpleBoolean(config: &::std::rc::Rc< - ::simple_boolean_dafny::r#_simple_dtypes_dboolean_dinternaldafny_dtypes::SimpleBooleanConfig, - >) -> ::std::rc::Rc<::simple_boolean_dafny::r#_Wrappers_Compile::Result< - ::dafny_runtime::Object, - ::std::rc::Rc<::simple_boolean_dafny::r#_simple_dtypes_dboolean_dinternaldafny_dtypes::Error> - >>{ - let rt_result = tokio::runtime::Builder::new_current_thread() - .enable_all() - .build(); - if rt_result.is_err() { - return ::std::rc::Rc::new(to_opaque_error_result(rt_result.err().unwrap())); - } - let rt = rt_result.unwrap(); - let result = Client::from_conf( - simple_boolean::conversions::simple_boolean_config::_simple_boolean_config::from_dafny( - config.clone(), - ), - ); - match result { - Err(error) => { - let error_obj: ::dafny_runtime::Object = - ::dafny_runtime::Object(Some(::std::rc::Rc::new( - ::std::cell::UnsafeCell::new(error), - ))); - ::std::rc::Rc::new( - ::simple_boolean_dafny::_Wrappers_Compile::Result::Failure { - error: ::std::rc::Rc::new( - ::simple_boolean_dafny::r#_simple_dtypes_dboolean_dinternaldafny_dtypes::Error::Opaque { - obj: error_obj, - }, - ), - }, - ) - } - Ok(client) => { - let wrap = WrappedClient { - wrapped: client.clone(), - rt - }; - let inner: ::std::rc::Rc<::std::cell::UnsafeCell> - = ::std::rc::Rc::new(::std::cell::UnsafeCell::new(wrap)); - - ::std::rc::Rc::new( - ::simple_boolean_dafny::_Wrappers_Compile::Result::Success { - value: ::dafny_runtime::Object(Some(inner)), - }, - ) - } - } - } + pub fn WrappedSimpleBoolean(config: &::std::rc::Rc< + ::simple_boolean_dafny::r#_simple_dtypes_dboolean_dinternaldafny_dtypes::SimpleBooleanConfig, + >) -> ::std::rc::Rc<::simple_boolean_dafny::r#_Wrappers_Compile::Result< + ::dafny_runtime::Object, + ::std::rc::Rc<::simple_boolean_dafny::r#_simple_dtypes_dboolean_dinternaldafny_dtypes::Error> + >>{ + crate::wrapped::client::Client::from_conf(config) + } } - -fn to_opaque_error_result(error: std::io::Error) -> ::simple_boolean_dafny::r#_Wrappers_Compile::Result< -::dafny_runtime::Object, -::std::rc::Rc<::simple_boolean_dafny::r#_simple_dtypes_dboolean_dinternaldafny_dtypes::Error> -> { - let error_obj: ::dafny_runtime::Object = - ::dafny_runtime::Object(Some(::std::rc::Rc::new( - ::std::cell::UnsafeCell::new(error), - ))); - simple_boolean_dafny::_Wrappers_Compile::Result::Failure { - error: ::std::rc::Rc::new( - ::simple_boolean_dafny::r#_simple_dtypes_dboolean_dinternaldafny_dtypes::Error::Opaque { - obj: error_obj, - }, - ), - } -} \ No newline at end of file From 5a1e67d06828cdde850258e3ee772f7049bdd1a8 Mon Sep 17 00:00:00 2001 From: Robin Salkeld Date: Fri, 12 Jul 2024 10:16:51 -0700 Subject: [PATCH 49/53] Cleanup --- .../SimpleBoolean/runtimes/rust/src/conversions/get_boolean.rs | 2 +- .../conversions/simple_boolean_config/_simple_boolean_config.rs | 2 -- 2 files changed, 1 insertion(+), 3 deletions(-) diff --git a/TestModels/SimpleTypes/SimpleBoolean/runtimes/rust/src/conversions/get_boolean.rs b/TestModels/SimpleTypes/SimpleBoolean/runtimes/rust/src/conversions/get_boolean.rs index b98bc0577a..065d3ad3c7 100644 --- a/TestModels/SimpleTypes/SimpleBoolean/runtimes/rust/src/conversions/get_boolean.rs +++ b/TestModels/SimpleTypes/SimpleBoolean/runtimes/rust/src/conversions/get_boolean.rs @@ -15,7 +15,7 @@ pub fn to_dafny_error( #[allow(dead_code)] pub fn from_dafny_error( dafny_value: ::std::rc::Rc< - ::simple_boolean_dafny::r#_simple_dtypes_dboolean_dinternaldafny_dtypes::Error, + ::simple_boolean_dafny::r#_simple_dtypes_dboolean_dinternaldafny_dtypes::Error, >, ) -> crate::operation::get_boolean::GetBooleanError { // TODO: Losing information here, but we have to figure out how to wrap an arbitrary Dafny value as std::error::Error diff --git a/TestModels/SimpleTypes/SimpleBoolean/runtimes/rust/src/conversions/simple_boolean_config/_simple_boolean_config.rs b/TestModels/SimpleTypes/SimpleBoolean/runtimes/rust/src/conversions/simple_boolean_config/_simple_boolean_config.rs index 7ef6a6cbff..6c7dc1765f 100644 --- a/TestModels/SimpleTypes/SimpleBoolean/runtimes/rust/src/conversions/simple_boolean_config/_simple_boolean_config.rs +++ b/TestModels/SimpleTypes/SimpleBoolean/runtimes/rust/src/conversions/simple_boolean_config/_simple_boolean_config.rs @@ -1,5 +1,3 @@ -use dafny_standard_library::implementation_from_dafny; - // Code generated by software.amazon.smithy.rust.codegen.smithy-rs. DO NOT EDIT. #[allow(dead_code)] From e729474549ef6c21d27284fddb5e84778284277f Mon Sep 17 00:00:00 2001 From: Robin Salkeld Date: Fri, 12 Jul 2024 10:18:38 -0700 Subject: [PATCH 50/53] Update patch file --- .../codegen-patches/rust/dafny-4.5.0.patch | 179 +++++++++++++++--- 1 file changed, 155 insertions(+), 24 deletions(-) diff --git a/TestModels/SimpleTypes/SimpleBoolean/codegen-patches/rust/dafny-4.5.0.patch b/TestModels/SimpleTypes/SimpleBoolean/codegen-patches/rust/dafny-4.5.0.patch index 1cb08ac318..8d94f5341e 100644 --- a/TestModels/SimpleTypes/SimpleBoolean/codegen-patches/rust/dafny-4.5.0.patch +++ b/TestModels/SimpleTypes/SimpleBoolean/codegen-patches/rust/dafny-4.5.0.patch @@ -1,3 +1,14 @@ +diff --git b/TestModels/SimpleTypes/SimpleBoolean/runtimes/rust/dafny_impl/Cargo.toml a/TestModels/SimpleTypes/SimpleBoolean/runtimes/rust/dafny_impl/Cargo.toml +index a7f8568c..31b603ee 100644 +--- b/TestModels/SimpleTypes/SimpleBoolean/runtimes/rust/dafny_impl/Cargo.toml ++++ a/TestModels/SimpleTypes/SimpleBoolean/runtimes/rust/dafny_impl/Cargo.toml +@@ -10,4 +10,4 @@ dafny_runtime = { path = "../../../../../dafny-dependencies/dafny_runtime_rust"} + dafny_standard_library = { path = "../../../../../dafny-dependencies/StandardLibrary/runtimes/rust"} + + [lib] +-path = "src/implementation_from_dafny.rs" ++path = "src/implementation_from_dafny.rs" +\ No newline at end of file diff --git b/TestModels/SimpleTypes/SimpleBoolean/runtimes/rust/src/client.rs a/TestModels/SimpleTypes/SimpleBoolean/runtimes/rust/src/client.rs new file mode 100644 index 00000000..89478da5 @@ -72,7 +83,7 @@ index 00000000..c1acac7b +pub mod simple_boolean_config; diff --git b/TestModels/SimpleTypes/SimpleBoolean/runtimes/rust/src/conversions/get_boolean.rs a/TestModels/SimpleTypes/SimpleBoolean/runtimes/rust/src/conversions/get_boolean.rs new file mode 100644 -index 00000000..b98bc057 +index 00000000..065d3ad3 --- /dev/null +++ a/TestModels/SimpleTypes/SimpleBoolean/runtimes/rust/src/conversions/get_boolean.rs @@ -0,0 +1,32 @@ @@ -93,7 +104,7 @@ index 00000000..b98bc057 +#[allow(dead_code)] +pub fn from_dafny_error( + dafny_value: ::std::rc::Rc< -+ ::simple_boolean_dafny::r#_simple_dtypes_dboolean_dinternaldafny_dtypes::Error, ++ ::simple_boolean_dafny::r#_simple_dtypes_dboolean_dinternaldafny_dtypes::Error, + >, +) -> crate::operation::get_boolean::GetBooleanError { + // TODO: Losing information here, but we have to figure out how to wrap an arbitrary Dafny value as std::error::Error @@ -205,12 +216,10 @@ index 00000000..371a47e5 +pub mod _simple_boolean_config; diff --git b/TestModels/SimpleTypes/SimpleBoolean/runtimes/rust/src/conversions/simple_boolean_config/_simple_boolean_config.rs a/TestModels/SimpleTypes/SimpleBoolean/runtimes/rust/src/conversions/simple_boolean_config/_simple_boolean_config.rs new file mode 100644 -index 00000000..7ef6a6cb +index 00000000..6c7dc176 --- /dev/null +++ a/TestModels/SimpleTypes/SimpleBoolean/runtimes/rust/src/conversions/simple_boolean_config/_simple_boolean_config.rs -@@ -0,0 +1,21 @@ -+use dafny_standard_library::implementation_from_dafny; -+ +@@ -0,0 +1,19 @@ +// Code generated by software.amazon.smithy.rust.codegen.smithy-rs. DO NOT EDIT. +#[allow(dead_code)] + @@ -289,10 +298,10 @@ index 00000000..4d66eb2e \ No newline at end of file diff --git b/TestModels/SimpleTypes/SimpleBoolean/runtimes/rust/src/lib.rs a/TestModels/SimpleTypes/SimpleBoolean/runtimes/rust/src/lib.rs new file mode 100644 -index 00000000..445a4fe0 +index 00000000..53977d7d --- /dev/null +++ a/TestModels/SimpleTypes/SimpleBoolean/runtimes/rust/src/lib.rs -@@ -0,0 +1,17 @@ +@@ -0,0 +1,20 @@ +#![allow(deprecated)] + +// Code generated by software.amazon.smithy.rust.codegen.smithy-rs. DO NOT EDIT. @@ -306,7 +315,10 @@ index 00000000..445a4fe0 +/// All operations that this crate can perform. +pub mod operation; + -+pub mod conversions; ++mod conversions; ++ ++#[cfg(feature = "wrapped-client")] ++pub mod wrapped; + +pub use client::Client; +pub use types::simple_boolean_config::SimpleBooleanConfig; @@ -322,7 +334,7 @@ index 00000000..eb38b9f1 +pub mod get_boolean; diff --git b/TestModels/SimpleTypes/SimpleBoolean/runtimes/rust/src/operation/get_boolean.rs a/TestModels/SimpleTypes/SimpleBoolean/runtimes/rust/src/operation/get_boolean.rs new file mode 100644 -index 00000000..1784adba +index 00000000..96381e1d --- /dev/null +++ a/TestModels/SimpleTypes/SimpleBoolean/runtimes/rust/src/operation/get_boolean.rs @@ -0,0 +1,145 @@ @@ -336,7 +348,7 @@ index 00000000..1784adba + pub fn new() -> Self { + Self + } -+ pub async fn send( ++ pub(crate) async fn send( + client: &crate::client::Client, + input: crate::operation::get_boolean::GetBooleanInput, + ) -> ::std::result::Result< @@ -721,16 +733,135 @@ index 00000000..6bf027f6 + ::std::result::Result::Ok(SimpleBooleanConfig {}) + } +} -diff --git b/TestModels/SimpleTypes/SimpleBoolean/runtimes/rust/tests/tests_from_dafny/mod.rs a/TestModels/SimpleTypes/SimpleBoolean/runtimes/rust/tests/tests_from_dafny/mod.rs -index ce6d90a2..7f1ba031 100644 ---- b/TestModels/SimpleTypes/SimpleBoolean/runtimes/rust/tests/tests_from_dafny/mod.rs -+++ a/TestModels/SimpleTypes/SimpleBoolean/runtimes/rust/tests/tests_from_dafny/mod.rs -@@ -1,5 +1,8 @@ - #![allow(warnings, unconditional_panic)] - #![allow(nonstandard_style)] -+use ::simple_boolean_dafny::*; -+use simple_boolean::*; -+mod _wrapped; - - pub mod r#_simple_dtypes_dboolean_dinternaldafny_dwrapped { - pub struct _default {} +diff --git b/TestModels/SimpleTypes/SimpleBoolean/runtimes/rust/src/wrapped.rs a/TestModels/SimpleTypes/SimpleBoolean/runtimes/rust/src/wrapped.rs +new file mode 100644 +index 00000000..39355176 +--- /dev/null ++++ a/TestModels/SimpleTypes/SimpleBoolean/runtimes/rust/src/wrapped.rs +@@ -0,0 +1 @@ ++pub mod client; +\ No newline at end of file +diff --git b/TestModels/SimpleTypes/SimpleBoolean/runtimes/rust/src/wrapped/client.rs a/TestModels/SimpleTypes/SimpleBoolean/runtimes/rust/src/wrapped/client.rs +new file mode 100644 +index 00000000..9ab30e66 +--- /dev/null ++++ a/TestModels/SimpleTypes/SimpleBoolean/runtimes/rust/src/wrapped/client.rs +@@ -0,0 +1,118 @@ ++use tokio::runtime::Runtime; ++ ++pub struct Client { ++ wrapped: crate::client::Client, ++ ++ /// A `current_thread` runtime for executing operations on the ++ /// asynchronous client in a blocking manner. ++ rt: Runtime ++} ++ ++impl dafny_runtime::UpcastObject for Client { ++ ::dafny_runtime::UpcastObjectFn!(dyn ::std::any::Any); ++} ++ ++impl Client { ++ pub fn from_conf(config: &::std::rc::Rc< ++ ::simple_boolean_dafny::r#_simple_dtypes_dboolean_dinternaldafny_dtypes::SimpleBooleanConfig, ++ >) -> ::std::rc::Rc<::simple_boolean_dafny::r#_Wrappers_Compile::Result< ++ ::dafny_runtime::Object, ++ ::std::rc::Rc<::simple_boolean_dafny::r#_simple_dtypes_dboolean_dinternaldafny_dtypes::Error> ++>> { ++ let rt_result = tokio::runtime::Builder::new_current_thread() ++ .enable_all() ++ .build(); ++ if rt_result.is_err() { ++ return ::std::rc::Rc::new(to_opaque_error_result(rt_result.err().unwrap())); ++ } ++ let rt = rt_result.unwrap(); ++ let result = crate::client::Client::from_conf( ++ crate::conversions::simple_boolean_config::_simple_boolean_config::from_dafny( ++ config.clone(), ++ ), ++ ); ++ match result { ++ Err(error) => { ++ let error_obj: ::dafny_runtime::Object = ++ ::dafny_runtime::Object(Some(::std::rc::Rc::new( ++ ::std::cell::UnsafeCell::new(error), ++ ))); ++ ::std::rc::Rc::new( ++ ::simple_boolean_dafny::_Wrappers_Compile::Result::Failure { ++ error: ::std::rc::Rc::new( ++ ::simple_boolean_dafny::r#_simple_dtypes_dboolean_dinternaldafny_dtypes::Error::Opaque { ++ obj: error_obj, ++ }, ++ ), ++ }, ++ ) ++ } ++ Ok(client) => { ++ let wrap = crate::wrapped::client::Client { ++ wrapped: client.clone(), ++ rt ++ }; ++ let inner: ::std::rc::Rc<::std::cell::UnsafeCell> ++ = ::std::rc::Rc::new(::std::cell::UnsafeCell::new(wrap)); ++ ++ ::std::rc::Rc::new( ++ ::simple_boolean_dafny::_Wrappers_Compile::Result::Success { ++ value: ::dafny_runtime::Object(Some(inner)), ++ }, ++ ) ++ } ++ } ++ } ++} ++ ++ ++fn to_opaque_error_result(error: std::io::Error) -> ::simple_boolean_dafny::r#_Wrappers_Compile::Result< ++::dafny_runtime::Object, ++::std::rc::Rc<::simple_boolean_dafny::r#_simple_dtypes_dboolean_dinternaldafny_dtypes::Error> ++> { ++let error_obj: ::dafny_runtime::Object = ++ ::dafny_runtime::Object(Some(::std::rc::Rc::new( ++ ::std::cell::UnsafeCell::new(error), ++ ))); ++ simple_boolean_dafny::_Wrappers_Compile::Result::Failure { ++ error: ::std::rc::Rc::new( ++ ::simple_boolean_dafny::r#_simple_dtypes_dboolean_dinternaldafny_dtypes::Error::Opaque { ++ obj: error_obj, ++ }, ++ ), ++ } ++} ++ ++impl ::simple_boolean_dafny::r#_simple_dtypes_dboolean_dinternaldafny_dtypes::ISimpleTypesBooleanClient ++ for Client ++{ ++ fn GetBoolean( ++ &mut self, ++ input: &std::rc::Rc< ++ ::simple_boolean_dafny::r#_simple_dtypes_dboolean_dinternaldafny_dtypes::GetBooleanInput, ++ >, ++ ) -> std::rc::Rc< ++ ::simple_boolean_dafny::r#_Wrappers_Compile::Result< ++ std::rc::Rc< ++ ::simple_boolean_dafny::r#_simple_dtypes_dboolean_dinternaldafny_dtypes::GetBooleanOutput, ++ >, ++ std::rc::Rc<::simple_boolean_dafny::r#_simple_dtypes_dboolean_dinternaldafny_dtypes::Error>, ++ >, ++ >{ ++ let inner_input = ++ crate::conversions::get_boolean::_get_boolean_input::from_dafny(input.clone()); ++ let result = self.rt.block_on(crate::operation::get_boolean::GetBoolean::send(&self.wrapped, inner_input)); ++ match result { ++ Err(error) => ::std::rc::Rc::new( ++ ::simple_boolean_dafny::_Wrappers_Compile::Result::Failure { ++ error: crate::conversions::get_boolean::to_dafny_error(error), ++ }, ++ ), ++ Ok(client) => ::std::rc::Rc::new( ++ ::simple_boolean_dafny::_Wrappers_Compile::Result::Success { ++ value: crate::conversions::get_boolean::_get_boolean_output::to_dafny(client), ++ }, ++ ), ++ } ++ } ++} From af0663bb2405313adc4223a2ff9fec6064bc1105 Mon Sep 17 00:00:00 2001 From: Robin Salkeld Date: Fri, 12 Jul 2024 13:19:37 -0700 Subject: [PATCH 51/53] Clean up wrapped client code --- .../runtimes/rust/src/conversions.rs | 2 + .../runtimes/rust/src/conversions/error.rs | 30 +++++++ .../runtimes/rust/src/wrapped/client.rs | 86 ++++++------------- .../runtimes/rust/src/conversion.rs | 31 +++++++ 4 files changed, 91 insertions(+), 58 deletions(-) create mode 100644 TestModels/SimpleTypes/SimpleBoolean/runtimes/rust/src/conversions/error.rs diff --git a/TestModels/SimpleTypes/SimpleBoolean/runtimes/rust/src/conversions.rs b/TestModels/SimpleTypes/SimpleBoolean/runtimes/rust/src/conversions.rs index c1acac7b26..86f8789139 100644 --- a/TestModels/SimpleTypes/SimpleBoolean/runtimes/rust/src/conversions.rs +++ b/TestModels/SimpleTypes/SimpleBoolean/runtimes/rust/src/conversions.rs @@ -2,3 +2,5 @@ pub mod get_boolean; pub mod simple_boolean_config; + +pub(crate) mod error; \ No newline at end of file diff --git a/TestModels/SimpleTypes/SimpleBoolean/runtimes/rust/src/conversions/error.rs b/TestModels/SimpleTypes/SimpleBoolean/runtimes/rust/src/conversions/error.rs new file mode 100644 index 0000000000..d6fd32b76a --- /dev/null +++ b/TestModels/SimpleTypes/SimpleBoolean/runtimes/rust/src/conversions/error.rs @@ -0,0 +1,30 @@ +/// Wraps up an arbitrary Rust Error value as a Dafny Error +pub fn to_opaque_error(value: E) -> + ::std::rc::Rc<::simple_boolean_dafny::r#_simple_dtypes_dboolean_dinternaldafny_dtypes::Error> +{ + let error_obj: ::dafny_runtime::Object = + ::dafny_runtime::Object(Some(::std::rc::Rc::new( + ::std::cell::UnsafeCell::new(value), + ))); + ::std::rc::Rc::new( + ::simple_boolean_dafny::r#_simple_dtypes_dboolean_dinternaldafny_dtypes::Error::Opaque { + obj: error_obj, + }, + ) +} + +/// Wraps up an arbitrary Rust Error value as a Dafny Result.Failure +pub fn to_opaque_error_result(value: E) -> + ::std::rc::Rc< + dafny_standard_library::implementation_from_dafny::_Wrappers_Compile::Result< + T, + ::std::rc::Rc<::simple_boolean_dafny::r#_simple_dtypes_dboolean_dinternaldafny_dtypes::Error> + > + > +{ + ::std::rc::Rc::new( + dafny_standard_library::implementation_from_dafny::_Wrappers_Compile::Result::Failure { + error: to_opaque_error(value) + } + ) +} \ No newline at end of file diff --git a/TestModels/SimpleTypes/SimpleBoolean/runtimes/rust/src/wrapped/client.rs b/TestModels/SimpleTypes/SimpleBoolean/runtimes/rust/src/wrapped/client.rs index 9ab30e66cb..49c75f767a 100644 --- a/TestModels/SimpleTypes/SimpleBoolean/runtimes/rust/src/wrapped/client.rs +++ b/TestModels/SimpleTypes/SimpleBoolean/runtimes/rust/src/wrapped/client.rs @@ -8,6 +8,10 @@ pub struct Client { rt: Runtime } +impl dafny_runtime::UpcastObject for Client { + ::dafny_runtime::UpcastObjectFn!(dyn ::simple_boolean_dafny::r#_simple_dtypes_dboolean_dinternaldafny_dtypes::ISimpleTypesBooleanClient); +} + impl dafny_runtime::UpcastObject for Client { ::dafny_runtime::UpcastObjectFn!(dyn ::std::any::Any); } @@ -15,71 +19,37 @@ impl dafny_runtime::UpcastObject for Client { impl Client { pub fn from_conf(config: &::std::rc::Rc< ::simple_boolean_dafny::r#_simple_dtypes_dboolean_dinternaldafny_dtypes::SimpleBooleanConfig, - >) -> ::std::rc::Rc<::simple_boolean_dafny::r#_Wrappers_Compile::Result< + >) -> +::std::rc::Rc<::simple_boolean_dafny::r#_Wrappers_Compile::Result< ::dafny_runtime::Object, ::std::rc::Rc<::simple_boolean_dafny::r#_simple_dtypes_dboolean_dinternaldafny_dtypes::Error> >> { let rt_result = tokio::runtime::Builder::new_current_thread() .enable_all() .build(); - if rt_result.is_err() { - return ::std::rc::Rc::new(to_opaque_error_result(rt_result.err().unwrap())); - } - let rt = rt_result.unwrap(); - let result = crate::client::Client::from_conf( - crate::conversions::simple_boolean_config::_simple_boolean_config::from_dafny( - config.clone(), - ), - ); - match result { - Err(error) => { - let error_obj: ::dafny_runtime::Object = - ::dafny_runtime::Object(Some(::std::rc::Rc::new( - ::std::cell::UnsafeCell::new(error), - ))); - ::std::rc::Rc::new( - ::simple_boolean_dafny::_Wrappers_Compile::Result::Failure { - error: ::std::rc::Rc::new( - ::simple_boolean_dafny::r#_simple_dtypes_dboolean_dinternaldafny_dtypes::Error::Opaque { - obj: error_obj, - }, - ), - }, - ) - } - Ok(client) => { - let wrap = crate::wrapped::client::Client { - wrapped: client.clone(), - rt - }; - let inner: ::std::rc::Rc<::std::cell::UnsafeCell> - = ::std::rc::Rc::new(::std::cell::UnsafeCell::new(wrap)); - - ::std::rc::Rc::new( - ::simple_boolean_dafny::_Wrappers_Compile::Result::Success { - value: ::dafny_runtime::Object(Some(inner)), - }, - ) - } - } - } -} - - -fn to_opaque_error_result(error: std::io::Error) -> ::simple_boolean_dafny::r#_Wrappers_Compile::Result< -::dafny_runtime::Object, -::std::rc::Rc<::simple_boolean_dafny::r#_simple_dtypes_dboolean_dinternaldafny_dtypes::Error> -> { -let error_obj: ::dafny_runtime::Object = - ::dafny_runtime::Object(Some(::std::rc::Rc::new( - ::std::cell::UnsafeCell::new(error), - ))); - simple_boolean_dafny::_Wrappers_Compile::Result::Failure { - error: ::std::rc::Rc::new( - ::simple_boolean_dafny::r#_simple_dtypes_dboolean_dinternaldafny_dtypes::Error::Opaque { - obj: error_obj, - }, + let rt = match rt_result { + Ok(x) => x, + Err(error) => return crate::conversions::error::to_opaque_error_result(error), + }; + let result = crate::client::Client::from_conf( + crate::conversions::simple_boolean_config::_simple_boolean_config::from_dafny( + config.clone(), ), + ); + match result { + Ok(client) => { + let wrap = crate::wrapped::client::Client { + wrapped: client, + rt + }; + std::rc::Rc::new( + ::simple_boolean_dafny::_Wrappers_Compile::Result::Success { + value: ::dafny_runtime::upcast_object()(::dafny_runtime::object::new(wrap)) + } + ) + }, + Err(error) => crate::conversions::error::to_opaque_error_result(error) + } } } diff --git a/TestModels/dafny-dependencies/StandardLibrary/runtimes/rust/src/conversion.rs b/TestModels/dafny-dependencies/StandardLibrary/runtimes/rust/src/conversion.rs index 3b7c2e767f..a6a27f6f6c 100644 --- a/TestModels/dafny-dependencies/StandardLibrary/runtimes/rust/src/conversion.rs +++ b/TestModels/dafny-dependencies/StandardLibrary/runtimes/rust/src/conversion.rs @@ -102,3 +102,34 @@ pub fn oblob_from_dafny( None } } + +pub fn result_from_dafny( + input: ::std::rc::Rc<_Wrappers_Compile::Result>, + converter_t: fn(&T) -> TR, + converter_e: fn(&E) -> ER, +) -> Result { + match &*input { + _Wrappers_Compile::Result::Success { value } => Ok(converter_t(value)), + _Wrappers_Compile::Result::Failure { error } => Err(converter_e(error)), + _Wrappers_Compile::Result::_PhantomVariant(_, _) => panic!(), + } +} + +pub fn result_to_dafny( + input: Result, + converter_t: fn(&TR) -> T, + converter_e: fn(&ER) -> E, +) -> ::std::rc::Rc<_Wrappers_Compile::Result> { + match input { + Ok(value) => ::std::rc::Rc::new( + _Wrappers_Compile::Result::Success { + value: converter_t(&value) + } + ), + Err(error) => ::std::rc::Rc::new( + _Wrappers_Compile::Result::Failure { + error: converter_e(&error) + } + ), + } +} \ No newline at end of file From 6bccce8abf6bd75e12e59bb046c79d961eff7c60 Mon Sep 17 00:00:00 2001 From: Robin Salkeld Date: Fri, 12 Jul 2024 13:21:20 -0700 Subject: [PATCH 52/53] update patch files --- .../codegen-patches/rust/dafny-4.5.0.patch | 145 +++++++++--------- .../codegen-patches/rust/dafny-4.5.0.patch | 36 ++++- 2 files changed, 106 insertions(+), 75 deletions(-) diff --git a/TestModels/SimpleTypes/SimpleBoolean/codegen-patches/rust/dafny-4.5.0.patch b/TestModels/SimpleTypes/SimpleBoolean/codegen-patches/rust/dafny-4.5.0.patch index 8d94f5341e..961c1fd5d1 100644 --- a/TestModels/SimpleTypes/SimpleBoolean/codegen-patches/rust/dafny-4.5.0.patch +++ b/TestModels/SimpleTypes/SimpleBoolean/codegen-patches/rust/dafny-4.5.0.patch @@ -1,14 +1,3 @@ -diff --git b/TestModels/SimpleTypes/SimpleBoolean/runtimes/rust/dafny_impl/Cargo.toml a/TestModels/SimpleTypes/SimpleBoolean/runtimes/rust/dafny_impl/Cargo.toml -index a7f8568c..31b603ee 100644 ---- b/TestModels/SimpleTypes/SimpleBoolean/runtimes/rust/dafny_impl/Cargo.toml -+++ a/TestModels/SimpleTypes/SimpleBoolean/runtimes/rust/dafny_impl/Cargo.toml -@@ -10,4 +10,4 @@ dafny_runtime = { path = "../../../../../dafny-dependencies/dafny_runtime_rust"} - dafny_standard_library = { path = "../../../../../dafny-dependencies/StandardLibrary/runtimes/rust"} - - [lib] --path = "src/implementation_from_dafny.rs" -+path = "src/implementation_from_dafny.rs" -\ No newline at end of file diff --git b/TestModels/SimpleTypes/SimpleBoolean/runtimes/rust/src/client.rs a/TestModels/SimpleTypes/SimpleBoolean/runtimes/rust/src/client.rs new file mode 100644 index 00000000..89478da5 @@ -73,14 +62,54 @@ index 00000000..299b0baa +} diff --git b/TestModels/SimpleTypes/SimpleBoolean/runtimes/rust/src/conversions.rs a/TestModels/SimpleTypes/SimpleBoolean/runtimes/rust/src/conversions.rs new file mode 100644 -index 00000000..c1acac7b +index 00000000..86f87891 --- /dev/null +++ a/TestModels/SimpleTypes/SimpleBoolean/runtimes/rust/src/conversions.rs -@@ -0,0 +1,4 @@ +@@ -0,0 +1,6 @@ +// Code generated by software.amazon.smithy.rust.codegen.smithy-rs. DO NOT EDIT. +pub mod get_boolean; + +pub mod simple_boolean_config; ++ ++pub(crate) mod error; +\ No newline at end of file +diff --git b/TestModels/SimpleTypes/SimpleBoolean/runtimes/rust/src/conversions/error.rs a/TestModels/SimpleTypes/SimpleBoolean/runtimes/rust/src/conversions/error.rs +new file mode 100644 +index 00000000..d6fd32b7 +--- /dev/null ++++ a/TestModels/SimpleTypes/SimpleBoolean/runtimes/rust/src/conversions/error.rs +@@ -0,0 +1,30 @@ ++/// Wraps up an arbitrary Rust Error value as a Dafny Error ++pub fn to_opaque_error(value: E) -> ++ ::std::rc::Rc<::simple_boolean_dafny::r#_simple_dtypes_dboolean_dinternaldafny_dtypes::Error> ++{ ++ let error_obj: ::dafny_runtime::Object = ++ ::dafny_runtime::Object(Some(::std::rc::Rc::new( ++ ::std::cell::UnsafeCell::new(value), ++ ))); ++ ::std::rc::Rc::new( ++ ::simple_boolean_dafny::r#_simple_dtypes_dboolean_dinternaldafny_dtypes::Error::Opaque { ++ obj: error_obj, ++ }, ++ ) ++} ++ ++/// Wraps up an arbitrary Rust Error value as a Dafny Result.Failure ++pub fn to_opaque_error_result(value: E) -> ++ ::std::rc::Rc< ++ dafny_standard_library::implementation_from_dafny::_Wrappers_Compile::Result< ++ T, ++ ::std::rc::Rc<::simple_boolean_dafny::r#_simple_dtypes_dboolean_dinternaldafny_dtypes::Error> ++ > ++ > ++{ ++ ::std::rc::Rc::new( ++ dafny_standard_library::implementation_from_dafny::_Wrappers_Compile::Result::Failure { ++ error: to_opaque_error(value) ++ } ++ ) ++} +\ No newline at end of file diff --git b/TestModels/SimpleTypes/SimpleBoolean/runtimes/rust/src/conversions/get_boolean.rs a/TestModels/SimpleTypes/SimpleBoolean/runtimes/rust/src/conversions/get_boolean.rs new file mode 100644 index 00000000..065d3ad3 @@ -743,10 +772,10 @@ index 00000000..39355176 \ No newline at end of file diff --git b/TestModels/SimpleTypes/SimpleBoolean/runtimes/rust/src/wrapped/client.rs a/TestModels/SimpleTypes/SimpleBoolean/runtimes/rust/src/wrapped/client.rs new file mode 100644 -index 00000000..9ab30e66 +index 00000000..49c75f76 --- /dev/null +++ a/TestModels/SimpleTypes/SimpleBoolean/runtimes/rust/src/wrapped/client.rs -@@ -0,0 +1,118 @@ +@@ -0,0 +1,88 @@ +use tokio::runtime::Runtime; + +pub struct Client { @@ -757,6 +786,10 @@ index 00000000..9ab30e66 + rt: Runtime +} + ++impl dafny_runtime::UpcastObject for Client { ++ ::dafny_runtime::UpcastObjectFn!(dyn ::simple_boolean_dafny::r#_simple_dtypes_dboolean_dinternaldafny_dtypes::ISimpleTypesBooleanClient); ++} ++ +impl dafny_runtime::UpcastObject for Client { + ::dafny_runtime::UpcastObjectFn!(dyn ::std::any::Any); +} @@ -764,71 +797,37 @@ index 00000000..9ab30e66 +impl Client { + pub fn from_conf(config: &::std::rc::Rc< + ::simple_boolean_dafny::r#_simple_dtypes_dboolean_dinternaldafny_dtypes::SimpleBooleanConfig, -+ >) -> ::std::rc::Rc<::simple_boolean_dafny::r#_Wrappers_Compile::Result< ++ >) -> ++::std::rc::Rc<::simple_boolean_dafny::r#_Wrappers_Compile::Result< + ::dafny_runtime::Object, + ::std::rc::Rc<::simple_boolean_dafny::r#_simple_dtypes_dboolean_dinternaldafny_dtypes::Error> +>> { + let rt_result = tokio::runtime::Builder::new_current_thread() + .enable_all() + .build(); -+ if rt_result.is_err() { -+ return ::std::rc::Rc::new(to_opaque_error_result(rt_result.err().unwrap())); -+ } -+ let rt = rt_result.unwrap(); -+ let result = crate::client::Client::from_conf( -+ crate::conversions::simple_boolean_config::_simple_boolean_config::from_dafny( -+ config.clone(), -+ ), -+ ); -+ match result { -+ Err(error) => { -+ let error_obj: ::dafny_runtime::Object = -+ ::dafny_runtime::Object(Some(::std::rc::Rc::new( -+ ::std::cell::UnsafeCell::new(error), -+ ))); -+ ::std::rc::Rc::new( -+ ::simple_boolean_dafny::_Wrappers_Compile::Result::Failure { -+ error: ::std::rc::Rc::new( -+ ::simple_boolean_dafny::r#_simple_dtypes_dboolean_dinternaldafny_dtypes::Error::Opaque { -+ obj: error_obj, -+ }, -+ ), -+ }, -+ ) -+ } -+ Ok(client) => { -+ let wrap = crate::wrapped::client::Client { -+ wrapped: client.clone(), -+ rt -+ }; -+ let inner: ::std::rc::Rc<::std::cell::UnsafeCell> -+ = ::std::rc::Rc::new(::std::cell::UnsafeCell::new(wrap)); -+ -+ ::std::rc::Rc::new( -+ ::simple_boolean_dafny::_Wrappers_Compile::Result::Success { -+ value: ::dafny_runtime::Object(Some(inner)), -+ }, -+ ) -+ } -+ } -+ } -+} -+ -+ -+fn to_opaque_error_result(error: std::io::Error) -> ::simple_boolean_dafny::r#_Wrappers_Compile::Result< -+::dafny_runtime::Object, -+::std::rc::Rc<::simple_boolean_dafny::r#_simple_dtypes_dboolean_dinternaldafny_dtypes::Error> -+> { -+let error_obj: ::dafny_runtime::Object = -+ ::dafny_runtime::Object(Some(::std::rc::Rc::new( -+ ::std::cell::UnsafeCell::new(error), -+ ))); -+ simple_boolean_dafny::_Wrappers_Compile::Result::Failure { -+ error: ::std::rc::Rc::new( -+ ::simple_boolean_dafny::r#_simple_dtypes_dboolean_dinternaldafny_dtypes::Error::Opaque { -+ obj: error_obj, -+ }, ++ let rt = match rt_result { ++ Ok(x) => x, ++ Err(error) => return crate::conversions::error::to_opaque_error_result(error), ++ }; ++ let result = crate::client::Client::from_conf( ++ crate::conversions::simple_boolean_config::_simple_boolean_config::from_dafny( ++ config.clone(), + ), ++ ); ++ match result { ++ Ok(client) => { ++ let wrap = crate::wrapped::client::Client { ++ wrapped: client, ++ rt ++ }; ++ std::rc::Rc::new( ++ ::simple_boolean_dafny::_Wrappers_Compile::Result::Success { ++ value: ::dafny_runtime::upcast_object()(::dafny_runtime::object::new(wrap)) ++ } ++ ) ++ }, ++ Err(error) => crate::conversions::error::to_opaque_error_result(error) ++ } + } +} + diff --git a/TestModels/dafny-dependencies/StandardLibrary/codegen-patches/rust/dafny-4.5.0.patch b/TestModels/dafny-dependencies/StandardLibrary/codegen-patches/rust/dafny-4.5.0.patch index 4a401b093c..f2dc475cac 100644 --- a/TestModels/dafny-dependencies/StandardLibrary/codegen-patches/rust/dafny-4.5.0.patch +++ b/TestModels/dafny-dependencies/StandardLibrary/codegen-patches/rust/dafny-4.5.0.patch @@ -74,10 +74,10 @@ index 00000000..fb5e7bf9 \ No newline at end of file diff --git b/TestModels/dafny-dependencies/StandardLibrary/runtimes/rust/src/conversion.rs a/TestModels/dafny-dependencies/StandardLibrary/runtimes/rust/src/conversion.rs new file mode 100644 -index 00000000..3b7c2e76 +index 00000000..a6a27f6f --- /dev/null +++ a/TestModels/dafny-dependencies/StandardLibrary/runtimes/rust/src/conversion.rs -@@ -0,0 +1,104 @@ +@@ -0,0 +1,135 @@ +use crate::implementation_from_dafny::*; + +pub fn ostring_to_dafny( @@ -182,6 +182,38 @@ index 00000000..3b7c2e76 + None + } +} ++ ++pub fn result_from_dafny( ++ input: ::std::rc::Rc<_Wrappers_Compile::Result>, ++ converter_t: fn(&T) -> TR, ++ converter_e: fn(&E) -> ER, ++) -> Result { ++ match &*input { ++ _Wrappers_Compile::Result::Success { value } => Ok(converter_t(value)), ++ _Wrappers_Compile::Result::Failure { error } => Err(converter_e(error)), ++ _Wrappers_Compile::Result::_PhantomVariant(_, _) => panic!(), ++ } ++} ++ ++pub fn result_to_dafny( ++ input: Result, ++ converter_t: fn(&TR) -> T, ++ converter_e: fn(&ER) -> E, ++) -> ::std::rc::Rc<_Wrappers_Compile::Result> { ++ match input { ++ Ok(value) => ::std::rc::Rc::new( ++ _Wrappers_Compile::Result::Success { ++ value: converter_t(&value) ++ } ++ ), ++ Err(error) => ::std::rc::Rc::new( ++ _Wrappers_Compile::Result::Failure { ++ error: converter_e(&error) ++ } ++ ), ++ } ++} +\ No newline at end of file diff --git b/TestModels/dafny-dependencies/StandardLibrary/runtimes/rust/src/lib.rs a/TestModels/dafny-dependencies/StandardLibrary/runtimes/rust/src/lib.rs new file mode 100644 index 00000000..12cdf221 From 69ba35775cebe49bd639262cac98ef9f91f23416 Mon Sep 17 00:00:00 2001 From: Robin Salkeld Date: Fri, 12 Jul 2024 13:38:34 -0700 Subject: [PATCH 53/53] Fix patch --- .../codegen-patches/rust/dafny-4.5.0.patch | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/TestModels/SimpleTypes/SimpleBoolean/codegen-patches/rust/dafny-4.5.0.patch b/TestModels/SimpleTypes/SimpleBoolean/codegen-patches/rust/dafny-4.5.0.patch index 961c1fd5d1..c0f0725f06 100644 --- a/TestModels/SimpleTypes/SimpleBoolean/codegen-patches/rust/dafny-4.5.0.patch +++ b/TestModels/SimpleTypes/SimpleBoolean/codegen-patches/rust/dafny-4.5.0.patch @@ -864,3 +864,16 @@ index 00000000..49c75f76 + } + } +} +diff --git b/TestModels/SimpleTypes/SimpleBoolean/runtimes/rust/tests/tests_from_dafny/mod.rs a/TestModels/SimpleTypes/SimpleBoolean/runtimes/rust/tests/tests_from_dafny/mod.rs +index ce6d90a2..7f1ba031 100644 +--- b/TestModels/SimpleTypes/SimpleBoolean/runtimes/rust/tests/tests_from_dafny/mod.rs ++++ a/TestModels/SimpleTypes/SimpleBoolean/runtimes/rust/tests/tests_from_dafny/mod.rs +@@ -1,5 +1,8 @@ + #![allow(warnings, unconditional_panic)] + #![allow(nonstandard_style)] ++use ::simple_boolean_dafny::*; ++use simple_boolean::*; ++mod _wrapped; + + pub mod r#_simple_dtypes_dboolean_dinternaldafny_dwrapped { + pub struct _default {}