From 192979ebfdda34150eae5cd2d3b6f46aff32951c Mon Sep 17 00:00:00 2001 From: J Henry Waugh Date: Tue, 8 Sep 2020 16:03:38 -0500 Subject: [PATCH 1/4] Crate workspace to include codegen --- Cargo.toml | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/Cargo.toml b/Cargo.toml index 9d989830..37f7f626 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,3 +1,9 @@ +[workspace] +members = [ + ".", + "codegen" +] + [package] name = "rhai" version = "0.18.3" From 229475caeffa202d59c3c3269c27a2e7af4e941d Mon Sep 17 00:00:00 2001 From: J Henry Waugh Date: Tue, 8 Sep 2020 16:04:04 -0500 Subject: [PATCH 2/4] Add tests fixed by workspace --- .../ui_tests/rhai_fn_non_clonable_return.rs | 27 +++++++++++++++++ .../rhai_fn_non_clonable_return.stderr | 10 +++++++ .../ui_tests/rhai_mod_non_clonable_return.rs | 29 +++++++++++++++++++ .../rhai_mod_non_clonable_return.stderr | 10 +++++++ 4 files changed, 76 insertions(+) create mode 100644 codegen/ui_tests/rhai_fn_non_clonable_return.rs create mode 100644 codegen/ui_tests/rhai_fn_non_clonable_return.stderr create mode 100644 codegen/ui_tests/rhai_mod_non_clonable_return.rs create mode 100644 codegen/ui_tests/rhai_mod_non_clonable_return.stderr diff --git a/codegen/ui_tests/rhai_fn_non_clonable_return.rs b/codegen/ui_tests/rhai_fn_non_clonable_return.rs new file mode 100644 index 00000000..e2e2d788 --- /dev/null +++ b/codegen/ui_tests/rhai_fn_non_clonable_return.rs @@ -0,0 +1,27 @@ +use rhai::plugin::*; + +struct NonClonable { + a: f32, + b: u32, + c: char, + d: bool, +} + +#[export_fn] +pub fn test_fn(input: f32) -> NonClonable { + NonClonable { + a: input, + b: 10, + c: 'a', + d: true, + } +} + +fn main() { + let n = test_fn(20.0); + if n.c == 'a' { + println!("yes"); + } else { + println!("no"); + } +} diff --git a/codegen/ui_tests/rhai_fn_non_clonable_return.stderr b/codegen/ui_tests/rhai_fn_non_clonable_return.stderr new file mode 100644 index 00000000..ebe6c264 --- /dev/null +++ b/codegen/ui_tests/rhai_fn_non_clonable_return.stderr @@ -0,0 +1,10 @@ +error[E0277]: the trait bound `NonClonable: Clone` is not satisfied + --> $DIR/rhai_fn_non_clonable_return.rs:11:8 + | +11 | pub fn test_fn(input: f32) -> NonClonable { + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ the trait `Clone` is not implemented for `NonClonable` + | + ::: $WORKSPACE/src/any.rs + | + | pub fn from(value: T) -> Self { + | ----- required by this bound in `rhai::Dynamic::from` diff --git a/codegen/ui_tests/rhai_mod_non_clonable_return.rs b/codegen/ui_tests/rhai_mod_non_clonable_return.rs new file mode 100644 index 00000000..fe8f5fff --- /dev/null +++ b/codegen/ui_tests/rhai_mod_non_clonable_return.rs @@ -0,0 +1,29 @@ +use rhai::plugin::*; + +struct NonClonable { + a: f32, + b: u32, + c: char, + d: bool, +} + +#[export_module] +pub mod test_mod { + pub fn test_fn(input: f32) -> NonClonable { + NonClonable { + a: input, + b: 10, + c: 'a', + d: true, + } + } +} + +fn main() { + let n = test_mod::test_fn(20.0); + if n.c == 'a' { + println!("yes"); + } else { + println!("no"); + } +} diff --git a/codegen/ui_tests/rhai_mod_non_clonable_return.stderr b/codegen/ui_tests/rhai_mod_non_clonable_return.stderr new file mode 100644 index 00000000..99a42bb3 --- /dev/null +++ b/codegen/ui_tests/rhai_mod_non_clonable_return.stderr @@ -0,0 +1,10 @@ +error[E0277]: the trait bound `NonClonable: Clone` is not satisfied + --> $DIR/rhai_mod_non_clonable_return.rs:12:12 + | +12 | pub fn test_fn(input: f32) -> NonClonable { + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ the trait `Clone` is not implemented for `NonClonable` + | + ::: $WORKSPACE/src/any.rs + | + | pub fn from(value: T) -> Self { + | ----- required by this bound in `rhai::Dynamic::from` From 60ecb87c5dbc877fc051c020420e8b0ca71de01e Mon Sep 17 00:00:00 2001 From: J Henry Waugh Date: Tue, 8 Sep 2020 16:17:58 -0500 Subject: [PATCH 3/4] Put no_std_test into its own empty workspace --- no_std/no_std_test/Cargo.toml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/no_std/no_std_test/Cargo.toml b/no_std/no_std_test/Cargo.toml index 56a73c1e..723cbdfc 100644 --- a/no_std/no_std_test/Cargo.toml +++ b/no_std/no_std_test/Cargo.toml @@ -1,5 +1,7 @@ cargo-features = ["named-profiles"] +[workspace] + [package] name = "no_std_test" version = "0.1.0" From e6e1362a610d779debf735215beb41f3993664d5 Mon Sep 17 00:00:00 2001 From: J Henry Waugh Date: Tue, 8 Sep 2020 16:24:08 -0500 Subject: [PATCH 4/4] Do not run all workspace tests --- .github/workflows/build.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index b5465c05..37d8c233 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -52,7 +52,7 @@ jobs: uses: actions-rs/cargo@v1 with: command: test - args: --all ${{matrix.flags}} + args: ${{matrix.flags}} # no-std builds are a bit more extensive to test no_std_build: name: NoStdBuild