Skip to content

Commit

Permalink
Fix prelude imports in decode_into (#464)
Browse files Browse the repository at this point in the history
  • Loading branch information
pmikolajczyk41 authored Jul 3, 2023
1 parent 86e5162 commit a7c0049
Show file tree
Hide file tree
Showing 6 changed files with 21 additions and 8 deletions.
7 changes: 7 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,13 @@ All notable changes to this crate are documented in this file.
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
and this crate adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).

## [3.6.3] - 2023-07-03

### Fixed

- Provide full path to elements from `::core` in `Decode` derivation (caused compilation error when
`no-implicit-prelude` was used).

## [3.6.2] - 2023-06-30

### Fixed
Expand Down
4 changes: 2 additions & 2 deletions Cargo.lock

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

4 changes: 2 additions & 2 deletions Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
[package]
name = "parity-scale-codec"
description = "SCALE - Simple Concatenating Aggregated Little Endians"
version = "3.6.2"
version = "3.6.3"
authors = ["Parity Technologies <admin@parity.io>"]
license = "Apache-2.0"
repository = "https://github.com/paritytech/parity-scale-codec"
Expand All @@ -12,7 +12,7 @@ rust-version = "1.60.0"
[dependencies]
arrayvec = { version = "0.7", default-features = false }
serde = { version = "1.0.164", optional = true }
parity-scale-codec-derive = { path = "derive", version = ">= 3.6.2", default-features = false, optional = true }
parity-scale-codec-derive = { path = "derive", version = ">= 3.6.3", default-features = false, optional = true }
bitvec = { version = "1", default-features = false, features = [ "alloc" ], optional = true }
bytes = { version = "1", default-features = false, optional = true }
byte-slice-cast = { version = "1.2.2", default-features = false }
Expand Down
2 changes: 1 addition & 1 deletion derive/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
[package]
name = "parity-scale-codec-derive"
description = "Serialization and deserialization derive macro for Parity SCALE Codec"
version = "3.6.2"
version = "3.6.3"
authors = ["Parity Technologies <admin@parity.io>"]
license = "Apache-2.0"
edition = "2021"
Expand Down
6 changes: 3 additions & 3 deletions derive/src/decode.rs
Original file line number Diff line number Diff line change
Expand Up @@ -188,13 +188,13 @@ pub fn quote_decode_into(

Some(quote!{
// Just a sanity check. These should always be true and will be optimized-out.
assert_eq!(#(#sizes)*, ::core::mem::size_of::<Self>());
assert!(#(#non_zst_field_count)* <= 1);
::core::assert_eq!(#(#sizes)*, ::core::mem::size_of::<Self>());
::core::assert!(#(#non_zst_field_count)* <= 1);

#(#decode_fields)*

// SAFETY: We've successfully called `decode_into` for all of the fields.
unsafe { Ok(#crate_path::DecodeFinished::assert_decoding_finished()) }
unsafe { ::core::result::Result::Ok(#crate_path::DecodeFinished::assert_decoding_finished()) }
})
}

Expand Down
6 changes: 6 additions & 0 deletions tests/scale_codec_ui/pass/decode-no-implicit-prelude.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,12 @@ pub struct Struct {
field_4: i64,
}

#[derive(::parity_scale_codec::Decode)]
#[repr(transparent)]
struct Transparent {
a: u8
}

#[derive(::parity_scale_codec::Decode)]
#[codec(crate = ::parity_scale_codec)]
pub enum Enum {
Expand Down

0 comments on commit a7c0049

Please sign in to comment.