-
Notifications
You must be signed in to change notification settings - Fork 30
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
ty: Make type fields public #176
Conversation
Signed-off-by: Alexandru Vasile <alexandru.vasile@parity.io>
Signed-off-by: Alexandru Vasile <alexandru.vasile@parity.io>
Signed-off-by: Alexandru Vasile <alexandru.vasile@parity.io>
I could get behind making fields public and treating them as just bundles of data; a description of the shape of a type. I wonder whether there are any forseeable reasons to keep this internal structure hidden; @ascjones perhaps you have thoughts? If we do go this route I'd also be tempted to add a The attr could look something like: #[deprecated(since = "2.5.0", note = "prefer to access the fields directly; this getter will be removed in the next major version")] That said I'd have to test where warnings will show for this, and wouldn't want warnings appearing for anybody who is only indirectly using scale-info at the latest version via some other crate (since they couldn't do anything about it). The other option is to do a major version bump and remove the getters immediately, but that would create more churn.. |
Yep indeed. Either way we pick seems solid and we'll eventually end up removing them (waiting for @ascjones to confirm this). That being said, we could remove them now and handle the breaking changes individually:
|
I'm fine with making these public. Regarding the getters, probably best to deprecate them for the least disruption, then remove for a |
Signed-off-by: Alexandru Vasile <alexandru.vasile@parity.io>
Signed-off-by: Alexandru Vasile <alexandru.vasile@parity.io>
This looks good to me! I think that |
I had a go locally and created 3 crates in 3 folders seen below. When I run temp:cargo.toml:
lib.rs pub fn add(left: usize, right: usize) -> usize {
temp2::add(left, right)
} temp2cargo.toml:
lib.rs pub fn add(left: usize, right: usize) -> usize {
temp3::add(left, right)
} temp3lib.rs #[deprecated]
pub fn add(left: usize, right: usize) -> usize {
left + right
} |
Signed-off-by: Alexandru Vasile <alexandru.vasile@parity.io>
I've had a go at this in paritytech/subxt#879. What I did there was to point scale-info to this branch in [patch.crates-io]
scale-info = { git = "https://github.com/paritytech/scale-info.git", branch = "lexnv/resolve_mut" } Warnings did appear for all subxt usages across the repo, but after fixing those individually in this commit they went away. |
I asked in the reddit and warnings apparently only show up for local crates, not those published to crates.io, so I think all is good :) |
Signed-off-by: Alexandru Vasile <alexandru.vasile@parity.io>
Subxt needs access to the types stored in the
PortableRegistry
to create a slim subset of the metadata,where the generic types of a
Type
are ignored.To achieve this, subxt will access something similar to:
registry.types.get(index).ty.type_param
.While at it, make the other fields public. The old getters are still left in place for backward compatibility.
cc @paritytech/subxt-team