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

Fix prelude imports in decode_into #464

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
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