Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[feature] #2004: Forbid isize and usize from becoming IntoSchema. #2173

Merged
merged 1 commit into from
May 6, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 3 additions & 0 deletions schema/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -12,3 +12,6 @@ fixnum = { version = "0.6.1", default-features = false, features = ["i64"] }

[dev-dependencies]
parity-scale-codec = { version = "2.3.1", default-features = false, features = ["derive", "full"] }
impls = { version = "=1.0.0" }

iroha_schema_gen = { version = "=2.0.0-pre-rc.4", path = "gen" }
24 changes: 24 additions & 0 deletions schema/tests/architecture-dependent.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
use impls::impls;
use iroha_schema::IntoSchema;
use parity_scale_codec::{Decode, Encode};

#[test]
fn usize_isize_not_into_schema() {
// The architecture-dependent
assert!(!impls!(usize: IntoSchema));
assert!(!impls!(isize: IntoSchema));
appetrosyan marked this conversation as resolved.
Show resolved Hide resolved

// use serde::Serialize;
//
// assert!(!impls!(usize: Serialize));
// `usize` should be `Serialize`.

// But not `Encode`/`Decode`.
assert!(!impls!(usize: Encode | Decode));
assert!(!impls!(isize: Encode | Decode));
appetrosyan marked this conversation as resolved.
Show resolved Hide resolved

// There are no other primitive architecture-dependent types, so
// as long as `IntoSchema` requires all variants and all fields to
// also be `IntoSchema`, we are guaranteed that all schema types
// are safe to exchange.
}