diff --git a/derive/src/decode.rs b/derive/src/decode.rs index 10583256..75c4b74e 100644 --- a/derive/src/decode.rs +++ b/derive/src/decode.rs @@ -90,7 +90,9 @@ pub fn quote( .map_err(|e| e.chain(#read_byte_err_msg))? { #( #recurse )* - _ => ::core::result::Result::Err(#invalid_variant_err_msg.into()), + _ => ::core::result::Result::Err( + <_ as ::core::convert::Into<_>>::into(#invalid_variant_err_msg) + ), } } diff --git a/src/bit_vec.rs b/src/bit_vec.rs index 1beca322..35d3123f 100644 --- a/src/bit_vec.rs +++ b/src/bit_vec.rs @@ -191,6 +191,10 @@ mod tests { } #[test] + // Flaky test due to: + // * https://github.com/bitvecto-rs/bitvec/issues/135 + // * https://github.com/rust-lang/miri/issues/1866 + #[cfg(not(miri))] fn bitvec_u32() { for v in &test_data!(u32) { let encoded = v.encode(); diff --git a/tests/max_encoded_len.rs b/tests/max_encoded_len.rs index b657695a..5bc199dd 100644 --- a/tests/max_encoded_len.rs +++ b/tests/max_encoded_len.rs @@ -14,7 +14,7 @@ // limitations under the License. //! Tests for MaxEncodedLen derive macro -#![cfg(feature = "derive")] +#![cfg(all(feature = "derive", feature = "max-encoded-len"))] use parity_scale_codec::{MaxEncodedLen, Compact, Encode}; diff --git a/tests/scale_codec_ui.rs b/tests/scale_codec_ui.rs new file mode 100644 index 00000000..663217f6 --- /dev/null +++ b/tests/scale_codec_ui.rs @@ -0,0 +1,22 @@ +// Copyright (C) 2020-2021 Parity Technologies (UK) Ltd. +// SPDX-License-Identifier: Apache-2.0 + +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +#[test] +#[cfg(feature = "derive")] +fn scale_codec_ui_tests() { + let t = trybuild::TestCases::new(); + t.compile_fail("tests/scale_codec_ui/*.rs"); + t.pass("tests/scale_codec_ui/pass/*.rs"); +} diff --git a/tests/scale_codec_ui/pass/decode-no-implicit-prelude.rs b/tests/scale_codec_ui/pass/decode-no-implicit-prelude.rs new file mode 100644 index 00000000..6ee5e622 --- /dev/null +++ b/tests/scale_codec_ui/pass/decode-no-implicit-prelude.rs @@ -0,0 +1,23 @@ +#![no_implicit_prelude] + +#[derive(::parity_scale_codec::Decode)] +pub struct Struct { + field_1: i8, + field_2: i16, + field_3: i32, + field_4: i64, +} + +#[derive(::parity_scale_codec::Decode)] +pub enum Enum { + Variant1, + Variant2(i8, i16, i32, i64), + Variant3 { + field_1: i8, + field_2: i16, + field_3: i32, + field_4: i64, + } +} + +fn main() {} diff --git a/tests/scale_codec_ui/pass/encode-no-implicit-prelude.rs b/tests/scale_codec_ui/pass/encode-no-implicit-prelude.rs new file mode 100644 index 00000000..a8f9d2bc --- /dev/null +++ b/tests/scale_codec_ui/pass/encode-no-implicit-prelude.rs @@ -0,0 +1,23 @@ +#![no_implicit_prelude] + +#[derive(::parity_scale_codec::Encode)] +pub struct Struct { + field_1: i8, + field_2: i16, + field_3: i32, + field_4: i64, +} + +#[derive(::parity_scale_codec::Encode)] +pub enum Enum { + Variant1, + Variant2(i8, i16, i32, i64), + Variant3 { + field_1: i8, + field_2: i16, + field_3: i32, + field_4: i64, + } +} + +fn main() {}