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

Minor codegen hygiene improvements and modernizations #291

Merged
merged 6 commits into from
Sep 13, 2021

Conversation

Robbepop
Copy link
Contributor

@Robbepop Robbepop commented Sep 12, 2021

This PR fixes some minor macro hygiene issues such as ::core::marker::Sized and ::core::primitive::u8.
Also it replaces the extern crate $name as _parity_scale_codec by using the imported name:

  • For example ::scale if parity_scale_codec has been renamed to scale by the dependent crate
  • crate if the code is generated for the crate itself
  • ::parity_scale_codec for tests of the parity_scale_codec crate

This makes it easier to refactor the crate derive codegen to no longer require the extern crate specifier.
Are there reasons we are still expanding to the "extern crate" here?
We could simply use the identifier from the new parity_scale_codec_ident function prepended with :: everywhere.
It would reflect a more modern (2018+) Rust macro codegen style.
… crate name

This is either ::parity_scale_codec, crate or ::<name> where <name> refers to the name under which the parity-scale-codec crate has been imported by the dependent crate.
@Robbepop Robbepop changed the title Minor codegen improvements and modernizations Minor codegen hygiene improvements and modernizations Sep 12, 2021
@Robbepop Robbepop marked this pull request as ready for review September 12, 2021 13:30
derive/src/lib.rs Outdated Show resolved Hide resolved
@gui1117 gui1117 merged commit 4fa5ddf into master Sep 13, 2021
@gui1117 gui1117 deleted the robin-minor-improvements branch September 13, 2021 14:54
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants