-
Notifications
You must be signed in to change notification settings - Fork 12.8k
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
Tracking issue for libcore + no_std stabilization #27701
Comments
These commits move libcore into a state so that it's ready for stabilization, performing some minor cleanup: * The primitive modules for integers in the standard library were all removed from the source tree as they were just straight reexports of the libcore variants. * The `core::atomic` module now lives in `core::sync::atomic`. The `core::sync` module is otherwise empty, but ripe for expansion! * The `core::prelude::v1` module was stabilized after auditing that it is a subset of the standard library's prelude plus some primitive extension traits (char, str, and slice) * Some unstable-hacks for float parsing errors were shifted around to not use the same unstable hacks (e.g. the `flt2dec` module is now used for "privacy"). After this commit, the remaining large unstable functionality specific to libcore is: * `raw`, `intrinsics`, `nonzero`, `array`, `panicking`, `simd` -- these modules are all unstable or not reexported in the standard library, so they're just remaining in the same status quo as before * `num::Float` - this extension trait for floats needs to be audited for functionality (much of that is happening in #27823) and may also want to be renamed to `FloatExt` or `F32Ext`/`F64Ext`. * Should the extension traits for primitives be stabilized in libcore? I believe other unstable pieces are not isolated to just libcore but also affect the standard library. cc #27701
I think that all the major issues here have been resolved, so I'm nominating this for stabilization in 1.5 |
Is it possible to support multiple |
Not currently that I'm aware of at least, and that would definitely be part of the stabilization aspect of this issue. |
Idea: mark the methods on the extension traits as stable, but leave the traits themselves unstable. Works because they're in the prelude. (We did this for Not a great permanent story, but it's a place to start. |
I want to understand the story for undefined symbols before making this stable. There's a real possibility of people defining these themselves in ways that aren't forward compatible. |
This issue/feature is now entering its cycle-long FCP for stabilization in 1.5 @brson, we currently have very few undefined symbols actually:
Of these, Otherwise, the only symbols we rely on are Do you have further concerns in light of this information? |
Oh and as a further clarification that I forgot to point out, this would also involve stabilizing |
And to further refine my comment, I remember now that we have more undefined symbols on 32-bit because some 64-bit integer operations frequently require support from compiler-rt. Taking a look at the undefined symbols from
It's basically the same story here, though, nothing unexpected and I don't think we should worry about people relying on their own incorrect versions of compiler-rt intrinsics. |
Some things I noticed when I worked on adapting ring to work with I don't get why I have to use // Re-export `{mem, ptr}` from either `std` or `core` as appropriate. This
// keeps the conditional logic on one place.
#[cfg(feature = "lib_no_std")]
pub use core::{mem, ptr};
#[cfg(not(feature = "lib_no_std"))]
pub use std::{mem, ptr}; Then I refer to, e.g. Also, it is confusing to me about whether Finally, the documentation should be clearer about how to write a library that automatically works in both |
@briansmith Why not only use |
@briansmith I totally agree that we can bolster our docs in this respect! As @SimonSapin mentioned, there's actually no need to have a "dual mode" where sometimes you use Part of the pain of using Additionally, Does that help explain things? I can try to bolster up our docs on this subject before we push this over the finish line! |
When I add this to my lib.rs: #![feature(no_std)]
#![no_std] I get:
What am I doing wrong? The repo is at https://github.com/briansmith/ring, branch "no_std". |
Wow we really do need some documentation on this badly... The detailed design of If you're core-compatible you can basically rewrite all imports to be from |
OK, if I use
Why is Also, all the documentation uses |
Also, let's say my module uses |
At 1.0 we didn't inject the
Not currently, the documentation for
I think this confusion primarily stems from a lack of documentation. I think it's crucial to maintain the distinction of whether code is in a "core only" or "std only" context. It's important to know what abilities you have access to (e.g. can you do I/O?). Beyond that the structures are exactly the same, so once this piece of information is known I don't think it'll be too confusing (but it definitely needs to be explained!)
That's actually the great part! Because the standard library simply reexports everything from core, a |
I am surprised that it is so difficult to convey how confusing this is.
IMO, it would make a lot more sense to NOT have |
Here is the development mode that I see for libcore compatible libraries on crates.io:
Step #2 will likely involve making some features of the third-party library conditional on whether Step #2 will also likely involve changing some |
So There is no such thing as a
|
To be clear, getting rid of I think 1 can be refined--it's less that the silent transition from freestanding-capable to not freestanding-capable is the goal, but rather that there be only one style (a "normal form") for writing code that in principle should work free-standing. Right now there is two, with Now the elastic/subset std also means there is two ways to write such code, but at least they are equivalent in terms of the burdens they place downstream. Right now that the @SimonSapin I'd hope we'd just be stabilizing the things in core that are already stable in std. |
@SimonSapin
|
|
@Ericson2314 @alexcrichton |
@dschatzberg are you on IRC by any chance? might take a few iterations for me to express that clearly :) |
@SimonSapin Sure no cold-turkey removal, but we can deprecate it, and since it is so easy to define as a facade, it's easy to keep around without removing. The downside is more appearing fickle making such a visible change after 1.0, but it's more eye-cactching than actually heavy-weight. |
@Ericson2314 yes - same user name |
Ok, edited #27701 (comment) to hopefully clear up any confusion. |
-1 on deprecating |
"Deprecating std" isn't sufficiently well-defined at the moment, we'd need to see an RFC for it before it could be discussed seriously. |
Regardless of whether or not this RFC is accepted, I'd like to propose that the actual stabilization PR be blocked on resolving #23355 , because otherwise we'll have the compiler guiding people into wholly silly situations. |
I really like the explicit |
Actually never mind about #23355 , I just determined that it's already possible to follow rustc's advice on the stable branch to produce the silly situations that I had in mind. |
@phil-opp |
Having |
@bluss I don't completely agree. I still think it's beneficial for freestanding users to use libraries for which their use case wasn't intended. While an explicit attribute is a relatively minor change, it's still a burden on the library developer to think to do it. |
@bstrie "deprecating std" in my mind would be encouraging imports from crates behind the facade rather than std were the former is stable. Once everything is available from a crate behind the facade, then std cannot be used at all without tripping a "try use core/alloc/instead for foobar" warning. I would write an RFC for that, but I rather iron out the kinks in using the crates behind the facade exclusively first, so it's clear what we would be migrating to in the deprecate std RFC. |
Just my opinion, but deprecating or linting std is a non-starter, no use in exploring that idea. |
AFAIK the std library is more than a facade. It implements everything operating specific (like threads, files, network, etc.). So to deprecate std, we would need to move those parts to a new crate. And then the "normal" user would have to think about implementation details. For example, Hashmap is only in std (because it uses a thread local random number generator) but BTreeMap is also in collections. |
@phil-opp I'd consider finishing making std a facade a good thing whether or not we keep std. For example, embedded Systems ("internet of things") may have networking but not filesystems. As for your example, only the default hasher param uses the OS like that. I think everybody rather put HashMap in collections, and just have a wrapper type alias that adds the default hasher param in std, but there was some language restriction that prevented that. |
There are too many details to the std-as-facade/deprecating-std to propose and discuss them here in this comment section. Again, I implore those interested to write up an RFC if you wish to pursue it. |
The libs team discussed this during triage yesterday, as well as the core team two days ago, as well as the lang team a few weeks ago, and the conclusion is to stabilize. The extension traits for primitive types in libcore will be left unstable for now with stable methods (e.g. the |
Closing as this was stabilized in #30187 |
This issue is intended to represent the outstanding issues for stabilizing libcore and allowing its usage on stable Rust. There are a number of features currently associated with libcore:
core
core_char_ext
core_prelude
core_slice_ext
core_str_ext
(note that
core_float
will be handled in a separate issue)The design of libcore largely mirrors that of the standard library (good) but there are a few deviations:
core::atomic
differs fromstd::sync::atomic
nonzero
,panicking
, andarray
are publicOverall there are a number of tasks that probably need to be done before stabilizing these items:
core
needs to be agreed upon as the stable name for the libraryThe text was updated successfully, but these errors were encountered: