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

Change type id to new type id in PortableRegistry::retain(). #204

Merged
merged 3 commits into from
Mar 22, 2024
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
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,10 @@ All notable changes to this project will be documented in this file.
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).

## [2.11.1] - 2024-03-22

- Fix a bug in the `PortableRegistry::retain()` method, where a type's id field was not adjusted to the new position of the type in the retained `Vec`.

## [2.11.0] - 2024-03-12

### Added
Expand Down
2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "scale-info"
version = "2.11.0"
version = "2.11.1"
authors = ["Parity Technologies <[email protected]>"]
edition = "2021"
rust-version = "1.60.0"
Expand Down
5 changes: 5 additions & 0 deletions src/portable.rs
Original file line number Diff line number Diff line change
Expand Up @@ -181,6 +181,7 @@ impl PortableRegistry {

// Retain this type, having updated any inner IDs:
let new_id = new_types.len() as u32;
ty.id = new_id;
new_types.push(ty);
retained_mappings.insert(id, new_id);
new_id
Expand Down Expand Up @@ -549,6 +550,10 @@ mod tests {
.field_portable(|f| f.name("vec_of_u32".into()).ty(1)),
);
assert_eq!(registry.resolve(2).unwrap(), &expected_ty);

for (idx, ty) in registry.types.iter().enumerate() {
assert_eq!(idx, ty.id as usize);
}
}

#[test]
Expand Down
2 changes: 1 addition & 1 deletion test_suite/tests/ui/fail_missing_derive.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ error[E0277]: the trait bound `PawType<u16>: TypeInfo` is not satisfied
--> tests/ui/fail_missing_derive.rs:19:24
|
19 | assert_type_info::<Cat<bool, u8, u16>>();
| ^^^^^^^^^^^^^^^^^^ the trait `TypeInfo` is not implemented for `PawType<u16>`
| ^^^^^^^^^^^^^^^^^^ the trait `TypeInfo` is not implemented for `PawType<u16>`, which is required by `Cat<bool, u8, u16>: TypeInfo`
|
= help: the following other types implement trait `TypeInfo`:
bool
Expand Down
Loading