-
Notifications
You must be signed in to change notification settings - Fork 35
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
Turn the no_std feature into default-enabled std #74
Conversation
libflate_lz77/Cargo.toml
Outdated
|
||
[dev-dependencies] | ||
libflate = { path = "../", version = "1" } | ||
libflate = { path = "../", version = "1", default-features = false } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
libflate = { path = "../", version = "1", default-features = false } | |
libflate = { path = "../", version = "2", default-features = false } |
Or, just remove the version completely. Since we're using a path dependency here, the version isn't necessary.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
IIUC it's necessary for crates.io and docs.rs to have version declarations in order to build docs and run crater tests correctly
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That's usually correct, but with path dependencies you don't need to specify version. You can specify the version, but if you do, it has to match the Cargo.toml
version (meaning you would need to make the above edit).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I will be keeping both version
and path
specifiers.
with
path
dependencies you don't need to specify version
The issue is with building tests using crates.io sources, since cargo publish
packages the source of just that crate as a tarball, instead of having access to the full git repository. So, if a dependency is specified with just a path
specifier, I doubt docs.rs or crates.io-side unit tests will be able to run correctly. Cargo calls out the distinction that crates.io has here in its documentation:
The
git
orpath
dependency will be used locally (in which case theversion
is checked against the local copy), and when published to a registry like crates.io, it will use the registry version.
For an example in the wild, see serde
, which in its dev-dependencies
imports serde_derive
using both path
and version
specifiers.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
For an example in the wild, see serde, which in its dev-dependencies imports serde_derive using both path and version specifiers.
Right on, then the suggested edit should work. Necessary with the major version bump.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done. I went with the same style as writing 2.0
instead of 2
if that makes a difference to you.
Some minor edits for imports to fix There is also a needed change in a file you didn't edit, use crate::deflate::symbol::Symbol;
+ #[cfg(not(feature = "std"))]
+ use alloc::{vec, vec::Vec}; Otherwise, LGTM. Thanks for adding the example binary, and test runner! |
@kupiakos Please run both
They complete successfully with the suggested edits in this PR. |
@rmsyn PTAL at the changes. Again, my apologies on missing the @sile Can you check that the Github workflow works as intended? Not sure if @rmsyn can. |
LGTM, all the tests pass under edit: one kind of hacky way to see if test runners work is to open a PR against your fork of the repository. It should run the CI. Not a local way to run CI, but could be useful. |
@kupiakos Some CI checks have failed (in case you haven't noticed yet). |
Sorry for taking so long to get to this. It was a |
This also: - fixes the `no_std` not being enabled due to a swapped `cfg_attr`. - tests this builds with a `#![no_std]` binary. - A lot of the cfg's have been removed due to being unneeded. - adds a new dependency - updates the version to 2.0 - adds a ci command to to use cargo-no-std to check no-std Some notes on changes from sile#68: Everything in `core` is a subset of things in `std`. `core` is available in `std` environments, so if you're building a `no_std`-compatible library, it's best to import things that don't _require_ `std` from `core. core2 is also meant to be used as a `no_std` polyfill with its `std` feature. That is, you can reference `core2::io`, and if the `std` feature is enabled, it actually references `std::io`.
@sile I've confirmed CI works on my end, and have squashed all the fixup commits for a cleaner history. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM, thank you!
Thank you too, @rmsyn, for your review! |
This gets #68 over the finish line to being a functional
#![no_std]
library.This also:
no_std
not being enabled due to a swappedcfg_attr
.#![no_std]
binary.Some notes on changes from #68:
Everything in
core
is a subset of things instd
.core
is available instd
environments, so if you're building ano_std
-compatible library, it's best to import things that don't requirestd
fromcore
.core2 is also meant to be used as a
no_std
polyfill with itsstd
feature. That is, you can referencecore2::io
, and if thestd
feature is enabled, it actually referencesstd::io
.