diff --git a/.circleci/config.yml b/.circleci/config.yml deleted file mode 100644 index cdc6ca70..00000000 --- a/.circleci/config.yml +++ /dev/null @@ -1,51 +0,0 @@ -version: 2 -jobs: - build: - docker: - - image: circleci/rust:latest - - steps: - - checkout - - - run: - name: setup - command: | - rustup install nightly-2019-11-25 - rustup component add rustfmt --toolchain nightly-2019-11-25 - rustup component add clippy --toolchain nightly-2019-11-25 - - - run: - name: fmt - command: | - cargo +nightly-2019-11-25 fmt --version - cargo +nightly-2019-11-25 fmt --all -- --check - - - run: - name: clippy - command: | - cargo +nightly-2019-11-25 clippy --version - cargo +nightly-2019-11-25 clippy --all -- -D warnings - - - run: - name: build - command: | - cargo --version --verbose - cargo build --all - cargo build --all --no-default-features - - - run: - name: unit tests - command: | - cargo test --all - - - run: - name: no-std tests - command: | - cd ./test_suite/derive_tests_no_std - cargo +nightly-2019-11-25 build --no-default-features - -workflows: - version: 2 - run-build: - jobs: - - build diff --git a/.github/workflows/rust.yml b/.github/workflows/rust.yml new file mode 100644 index 00000000..d4d16879 --- /dev/null +++ b/.github/workflows/rust.yml @@ -0,0 +1,48 @@ +name: Rust + +on: + push: + branches: [ master ] + pull_request: + branches: [ master ] + +jobs: + build: + + runs-on: ubuntu-latest + + steps: + - uses: actions/checkout@v2 + + - name: setup + run: | + rustup install nightly-2020-03-11 + rustup component add rustfmt --toolchain nightly-2020-03-11 + rustup component add clippy --toolchain nightly-2020-03-11 + + - name: fmt + run: | + cargo +nightly-2020-03-11 fmt --version + cargo +nightly-2020-03-11 fmt --all -- --check + + - name: clippy + run: | + cargo +nightly-2020-03-11 clippy --version + cargo +nightly-2020-03-11 clippy --all -- -D warnings + + - name: build + run: | + cargo --version --verbose + cargo build --all + cargo build --all --no-default-features + + - name: test + run: | + cargo test --all + + - name: test no-std + run: | + cd ./test_suite/derive_tests_no_std + cargo +nightly-2020-03-11 build --no-default-features + + diff --git a/.gitignore b/.gitignore index be5da9a6..9e9c63f2 100644 --- a/.gitignore +++ b/.gitignore @@ -5,3 +5,7 @@ .vscode .idea + +# Remove Cargo.lock when creating an executable, leave it for libraries +# More information here http://doc.crates.io/guide.html#cargotoml-vs-cargolock +Cargo.lock diff --git a/Cargo.lock b/Cargo.lock deleted file mode 100644 index 36b12a9d..00000000 --- a/Cargo.lock +++ /dev/null @@ -1,119 +0,0 @@ -# This file is automatically @generated by Cargo. -# It is not intended for manual editing. -[[package]] -name = "derive_more" -version = "0.99.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -dependencies = [ - "proc-macro2 1.0.6 (registry+https://github.com/rust-lang/crates.io-index)", - "quote 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)", - "syn 1.0.8 (registry+https://github.com/rust-lang/crates.io-index)", -] - -[[package]] -name = "itoa" -version = "0.4.4" -source = "registry+https://github.com/rust-lang/crates.io-index" - -[[package]] -name = "proc-macro2" -version = "1.0.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -dependencies = [ - "unicode-xid 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)", -] - -[[package]] -name = "quote" -version = "1.0.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -dependencies = [ - "proc-macro2 1.0.6 (registry+https://github.com/rust-lang/crates.io-index)", -] - -[[package]] -name = "ryu" -version = "1.0.2" -source = "registry+https://github.com/rust-lang/crates.io-index" - -[[package]] -name = "serde" -version = "1.0.102" -source = "registry+https://github.com/rust-lang/crates.io-index" -dependencies = [ - "serde_derive 1.0.102 (registry+https://github.com/rust-lang/crates.io-index)", -] - -[[package]] -name = "serde_derive" -version = "1.0.102" -source = "registry+https://github.com/rust-lang/crates.io-index" -dependencies = [ - "proc-macro2 1.0.6 (registry+https://github.com/rust-lang/crates.io-index)", - "quote 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)", - "syn 1.0.8 (registry+https://github.com/rust-lang/crates.io-index)", -] - -[[package]] -name = "serde_json" -version = "1.0.41" -source = "registry+https://github.com/rust-lang/crates.io-index" -dependencies = [ - "itoa 0.4.4 (registry+https://github.com/rust-lang/crates.io-index)", - "ryu 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)", - "serde 1.0.102 (registry+https://github.com/rust-lang/crates.io-index)", -] - -[[package]] -name = "syn" -version = "1.0.8" -source = "registry+https://github.com/rust-lang/crates.io-index" -dependencies = [ - "proc-macro2 1.0.6 (registry+https://github.com/rust-lang/crates.io-index)", - "quote 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)", - "unicode-xid 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)", -] - -[[package]] -name = "type-metadata" -version = "0.1.0" -dependencies = [ - "derive_more 0.99.1 (registry+https://github.com/rust-lang/crates.io-index)", - "serde 1.0.102 (registry+https://github.com/rust-lang/crates.io-index)", - "type-metadata-derive 0.1.0", -] - -[[package]] -name = "type-metadata-derive" -version = "0.1.0" -dependencies = [ - "proc-macro2 1.0.6 (registry+https://github.com/rust-lang/crates.io-index)", - "quote 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)", - "syn 1.0.8 (registry+https://github.com/rust-lang/crates.io-index)", -] - -[[package]] -name = "type-metadata-test-suite" -version = "0.0.0" -dependencies = [ - "serde 1.0.102 (registry+https://github.com/rust-lang/crates.io-index)", - "serde_json 1.0.41 (registry+https://github.com/rust-lang/crates.io-index)", - "type-metadata 0.1.0", -] - -[[package]] -name = "unicode-xid" -version = "0.2.0" -source = "registry+https://github.com/rust-lang/crates.io-index" - -[metadata] -"checksum derive_more 0.99.1 (registry+https://github.com/rust-lang/crates.io-index)" = "dbc39e36a9d46e24b4cadfae2920979db294d04d0cfd3a9f266e4974e1b4a015" -"checksum itoa 0.4.4 (registry+https://github.com/rust-lang/crates.io-index)" = "501266b7edd0174f8530248f87f99c88fbe60ca4ef3dd486835b8d8d53136f7f" -"checksum proc-macro2 1.0.6 (registry+https://github.com/rust-lang/crates.io-index)" = "9c9e470a8dc4aeae2dee2f335e8f533e2d4b347e1434e5671afc49b054592f27" -"checksum quote 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)" = "053a8c8bcc71fcce321828dc897a98ab9760bef03a4fc36693c231e5b3216cfe" -"checksum ryu 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)" = "bfa8506c1de11c9c4e4c38863ccbe02a305c8188e85a05a784c9e11e1c3910c8" -"checksum serde 1.0.102 (registry+https://github.com/rust-lang/crates.io-index)" = "0c4b39bd9b0b087684013a792c59e3e07a46a01d2322518d8a1104641a0b1be0" -"checksum serde_derive 1.0.102 (registry+https://github.com/rust-lang/crates.io-index)" = "ca13fc1a832f793322228923fbb3aba9f3f44444898f835d31ad1b74fa0a2bf8" -"checksum serde_json 1.0.41 (registry+https://github.com/rust-lang/crates.io-index)" = "2f72eb2a68a7dc3f9a691bfda9305a1c017a6215e5a4545c258500d2099a37c2" -"checksum syn 1.0.8 (registry+https://github.com/rust-lang/crates.io-index)" = "661641ea2aa15845cddeb97dad000d22070bb5c1fb456b96c1cba883ec691e92" -"checksum unicode-xid 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)" = "826e7639553986605ec5979c7dd957c7895e93eabed50ab2ffa7f6128a75097c" diff --git a/README.md b/README.md index 179c92aa..b2a0ebef 100644 --- a/README.md +++ b/README.md @@ -1,4 +1,4 @@ -# scale-info +#scale-info · ![build](https://github.com/paritytech/scale-info/workflows/Rust/badge.svg) Info about [SCALE](https://github.com/paritytech/parity-scale-codec) encodable Rust types. diff --git a/src/lib.rs b/src/lib.rs index 80d75c48..a94c11e9 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -76,15 +76,15 @@ extern crate alloc; /// ``` /// # use scale_info::tuple_meta_type; /// assert_eq!( -/// tuple_meta_type!(i32, [u8; 32], String), -/// { -/// use scale_info::MetaType; -/// let mut vec = Vec::new(); -/// vec.push(MetaType::new::()); -/// vec.push(MetaType::new::<[u8; 32]>()); -/// vec.push(MetaType::new::()); -/// vec -/// } +/// tuple_meta_type!(i32, [u8; 32], String), +/// { +/// use scale_info::MetaType; +/// let mut vec = Vec::new(); +/// vec.push(MetaType::new::()); +/// vec.push(MetaType::new::<[u8; 32]>()); +/// vec.push(MetaType::new::()); +/// vec +/// } /// ); /// ``` #[macro_export] diff --git a/test_suite/tests/derive.rs b/test_suite/tests/derive.rs index ef3896e3..d736d6fd 100644 --- a/test_suite/tests/derive.rs +++ b/test_suite/tests/derive.rs @@ -24,8 +24,8 @@ use alloc::{boxed::Box, vec}; use scale_info::{ tuple_meta_type, ClikeEnumVariant, EnumVariantStruct, EnumVariantTupleStruct, EnumVariantUnit, HasTypeDef, - HasTypeId, MetaType, Metadata, NamedField, Namespace, TypeDefClikeEnum, TypeDefEnum, TypeDefStruct, - TypeDefTupleStruct, TypeDefUnion, TypeId, TypeIdCustom, UnnamedField, + HasTypeId, Metadata, NamedField, Namespace, TypeDefClikeEnum, TypeDefEnum, TypeDefStruct, TypeDefTupleStruct, + TypeDefUnion, TypeId, TypeIdCustom, UnnamedField, }; fn assert_type_id(expected: E) diff --git a/test_suite/tests/json.rs b/test_suite/tests/json.rs index cd798f0c..05d97cd1 100644 --- a/test_suite/tests/json.rs +++ b/test_suite/tests/json.rs @@ -15,6 +15,7 @@ // limitations under the License. #![cfg_attr(not(feature = "std"), no_std)] +#![allow(dead_code)] #[cfg(not(feature = "std"))] extern crate alloc; @@ -22,9 +23,9 @@ extern crate alloc; #[cfg(not(feature = "std"))] use alloc::{vec, vec::Vec}; +use scale_info::{form::CompactForm, IntoCompact as _, Metadata, Registry, TypeDef, TypeId}; use serde::Serialize; use serde_json::json; -use scale_info::{form::CompactForm, IntoCompact as _, Metadata, Registry, TypeDef, TypeId}; #[derive(Serialize)] struct TypeIdDef {