Join GitHub today
GitHub is home to over 31 million developers working together to host and review code, manage projects, and build software together.
Sign up"allocator" and "nightly" features (for no_std environments) #153
Conversation
tonychain
referenced this pull request
Jul 18, 2017
Closed
no_std support (using enabled-by-default "std" feature) #135
This comment has been minimized.
This comment has been minimized.
|
Note this PR includes a commit from the |
tarcieri
reviewed
Jul 18, 2017
| @@ -70,8 +70,16 @@ | |||
|
|
|||
| #![deny(warnings, missing_docs, missing_debug_implementations)] | |||
| #![doc(html_root_url = "https://docs.rs/bytes/0.4")] | |||
| #![cfg_attr(not(feature = "std"), no_std)] | |||
| #![cfg_attr(feature = "nightly", feature(alloc))] | |||
This comment has been minimized.
This comment has been minimized.
tarcieri
Jul 18, 2017
@alexcrichton so really this is the part that requires nightly, and that's because even if I have an #[allocator] defined Box, Vec, and String do not get added to the prelude.
If they did, then we could simply have an enabled-by-default, non-nightly-dependent alloc cargo feature for gating features that depend on Box, Vec, and String.
I'm not sure how hard that would be, but I imagine it would be immensely useful for no_std users who have a heap available.
tonychain
force-pushed the
chain:alloc
branch
2 times, most recently
from
d0a74b1
to
a57e18b
Jul 18, 2017
tonychain
changed the title
"nightly" feature (for using allocation in no_std environments)
"allocator" and "nightly" features (for no_std environments)
Jul 20, 2017
tonychain
force-pushed the
chain:alloc
branch
from
a57e18b
to
e456afb
Jul 20, 2017
tonychain
reviewed
Jul 20, 2017
| @@ -98,3 +110,15 @@ pub use byteorder::{ByteOrder, BigEndian, LittleEndian}; | |||
| #[cfg(feature = "serde")] | |||
| #[doc(hidden)] | |||
| pub mod serde; | |||
|
|
|||
| /// Custom (internal-only) prelude for this module | |||
This comment has been minimized.
This comment has been minimized.
tonychain
Jul 20, 2017
Author
I made this to avoid having to individually import each of these types everywhere they're used.
Seems like a bit of a hack, but dramatically reduces the scope of what the nightly feature does which I think is nice.
It also makes this easy to change in the event the liballoc/libcollections merge is reverted
tonychain
force-pushed the
chain:alloc
branch
from
e456afb
to
041a0be
Jul 20, 2017
tonychain
added some commits
Jun 16, 2017
jbowens
force-pushed the
chain:alloc
branch
from
041a0be
to
a90575c
Nov 14, 2017
This comment has been minimized.
This comment has been minimized.
jbowens
commented
Nov 14, 2017
|
Hey @carllerche. I'd love to see |
This comment has been minimized.
This comment has been minimized.
|
Sorry to have left this without a response. I don't think we want to add a dependency (even hidden behind a feature flag) on the allocator crate as it is highly unstable. #135 is fine as an approach to support I'm going to close this for now as #135 is the preferred path forward. |
carllerche
closed this
Dec 14, 2017
tarcieri
referenced this pull request
Feb 9, 2018
Merged
"alloc" and "nightly" features (for no_std environments) #4
This comment has been minimized.
This comment has been minimized.
Ericson2314
commented
Mar 15, 2019
|
So the argument behind rust-lang/rfcs#2480 is that while |
This comment has been minimized.
This comment has been minimized.
tarcieri
commented
Mar 15, 2019
|
If rust-lang/rfcs#2480 lands, this will all work on stable. At that time I will happily revive this PR. |
This comment has been minimized.
This comment has been minimized.
Ericson2314
commented
Mar 15, 2019
•
|
@tarcieri I am commenting here and there because I both want this PR and ones like it really badly and don't want to stabilize |
This comment has been minimized.
This comment has been minimized.
|
I have seen the stable build break due to adding nightly only features guarded with a feature flag. |
tonychain commentedJul 18, 2017
•
edited
This gates all allocator-dependent features on an "allocator" feature.
It also adds a "nightly" feature which enables using the "allocator" feature in no_std environments. This requires using
#[feature(alloc)]which requires nightly.The "allocator" feature is automatically enabled when either the "std" or "nightly" features are enabled.
Travis CI is configured to check that builds succeed with both the "nightly" feature along with "std" and "nightly" in combination. To avoid the problem of nightly changes breaking the build, these combinations are specifically flagged as allowed failures in the Travis CI configuration.