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

migrate extern crate to pub use #481

Merged
merged 2 commits into from
Jan 13, 2024

Conversation

rursprung
Copy link
Contributor

extern crate is from the old rust 2015 edition. since the 2018 edition extern crate is no longer needed.
here it was used to re-export certain crates (through pub extern crate) which are being referenced mainly in macros (which is why e.g. paste is re-exported).
this can also be achieved using pub use.

avr-hal-generic internally now has to use crate::hal in some cases where it could previously just use hal as the renaming is now bound to the usage in the crate and not to the imported crate. in most cases i've just replaced hal:: usage with embedded_hal_v0:: usage since it makes it more obvious which e-h version it is about (and in the future hal should either be removed or be replaced with e-h v1.0).

note: i've explicitly dropped the re-export of ufmt as it's not used in this repository and i don't see ufmt as an integral part of these crates. consumers can (and should) just add it as their own dependency. this is a breaking change for consumers which currently do something like use avr_hal_generic::ufmt.

for external consumers nothing changes besides the removed ufmt re-export.

@rursprung
Copy link
Contributor Author

rursprung commented Dec 28, 2023

it's just something i noticed. not sure whether this PR is really worth it... feel free to close it if you prefer to keep extern crate for the time being.
i can also re-add ufmt if you prefer (i just updated the PR to make the removal a separate commit, so it's easier to just omit that one).

@rursprung rursprung force-pushed the remove-extern-crate-syntax branch from 1e7ae33 to 0673f2f Compare December 28, 2023 17:12
rursprung added a commit to rursprung/avr-hal that referenced this pull request Dec 28, 2023
there's no need for the `void` dependency anymore. accordingly it can be
removed. this will also help with implementing `embedded-hal` v1 traits
as some of them rely on (or at least have better support for)
`core::convert::Infallible`.

this is a breaking change for consumers as they have to e.g. replace
`void_unwrap()` calls with `unwrap()`.

the prelude is now no longer needed in most cases (potentally the whole
`mod prelude` could be removed in the future as it now adds little
benefit?).

note that this PR will conflict with Rahix#481; when one gets merged i'll
have to rebase the other on top of it (though it will be a fairly
trivial rebase). this is due to the fact that both modify the same lines
in a few places. merging this one here first might be easier as the
other one is smaller.
rursprung added a commit to rursprung/avr-hal that referenced this pull request Dec 28, 2023
there's no need for the `void` dependency anymore. accordingly it can be
removed. this will also help with implementing `embedded-hal` v1 traits
as some of them rely on (or at least have better support for)
`core::convert::Infallible`.

this is a breaking change for consumers as they have to e.g. replace
`void_unwrap()` calls with `unwrap()`.

the prelude is now no longer needed in most cases (potentally the whole
`mod prelude` could be removed in the future as it now adds little
benefit?).

note that this PR will conflict with Rahix#481; when one gets merged i'll
have to rebase the other on top of it (though it will be a fairly
trivial rebase). this is due to the fact that both modify the same lines
in a few places. merging this one here first might be easier as the
other one is smaller.
rursprung added a commit to rursprung/avr-hal that referenced this pull request Dec 28, 2023
there's no need for the `void` dependency anymore. accordingly it can be
removed. this will also help with implementing `embedded-hal` v1 traits
as some of them rely on (or at least have better support for)
`core::convert::Infallible`.

this is a breaking change for consumers as they have to e.g. replace
`void_unwrap()` calls with `unwrap()`.

the prelude is now no longer needed in most cases (potentally the whole
`mod prelude` could be removed in the future as it now adds little
benefit?).

note that this PR will conflict with Rahix#481; when one gets merged i'll
have to rebase the other on top of it (though it will be a fairly
trivial rebase). this is due to the fact that both modify the same lines
in a few places. merging this one here first might be easier as the
other one is smaller.
@Rahix
Copy link
Owner

Rahix commented Jan 11, 2024

👍 on switching to use, let's get rid of all that extern crate legacy cruft. Will come back to this PR after #482 is merged.

`extern crate` is from the old rust 2015 edition. since the 2018 edition
`extern crate` is no longer needed. here it was used to re-export
certain crates (through `pub extern crate`) which are being referenced
mainly in macros (which is why e.g. `paste` is re-exported). this can
also be achieved using `pub use`.

`avr-hal-generic` internally now has to use `crate::hal` in some cases
where it could previously just use `hal` as the renaming is now bound to
the usage in the crate and not to the imported crate. in most cases i've
just replaced `hal::` usage with `embedded_hal_v0::` usage since it
makes it more obvious which e-h version it is about (and in the future
`hal` should either be removed or be replaced with e-h v1.0).

for external consumers nothing changes.
note: i've explicitly dropped the re-export of `ufmt` as it's not used
in this repository* and i don't see `ufmt` as an integral part of these
crates. consumers can (and should) just add it as their own dependency.
this is a breaking change for consumers which currently do something
like `use avr_hal_generic::ufmt`.

\* clarification: `ufmt` itself is being used in some places, but the
   re-export isn't.
@Rahix Rahix force-pushed the remove-extern-crate-syntax branch from 7f171b4 to 4f0f4e6 Compare January 13, 2024 15:43
@Rahix Rahix merged commit ab3e462 into Rahix:main Jan 13, 2024
23 checks passed
@rursprung rursprung deleted the remove-extern-crate-syntax branch January 14, 2024 12:11
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.

2 participants