Add documentation for the no_std attribute#158886
Conversation
| /// the [`std`] prelude. Items like [`Option`], [`Result`], and the primitive types remain | ||
| /// available from [`core`] without any imports needed: | ||
| /// | ||
| /// ```rust,ignore (no_std) |
There was a problem hiding this comment.
No need for the ignore I think.
There was a problem hiding this comment.
I believe it is required, removing the ignore for this (and the other 2 doc-tests) yields:
---- library/core/src/attribute_docs.rs - no_std_attribute (line 364) stdout ----
error: `#[panic_handler]` function required, but not found
error: unwinding panics are not supported without std
|
= help: using nightly cargo, use -Zbuild-std with panic="abort" to avoid unwinding
= note: since the core library is usually precompiled with panic="unwind", rebuilding your crate with panic="abort" may not be enough to fix the problem
error[E0601]: `main` function not found in crate `rust_out`
--> library/core/src/attribute_docs.rs:370:2
|
370 | }
| ^ consider adding a `main` function to `library/core/src/attribute_docs.rs`
error: aborting due to 3 previous errors
For more information about this error, try `rustc --explain E0601`.
Couldn't compile the test.
\ (no newline at end of output)
---- library/core/src/attribute_docs.rs - no_std_attribute (line 364) stdout end ----
| /// use alloc::vec::Vec; | ||
| /// ``` | ||
| /// | ||
| /// A `no_std` binary also removes the startup routine and default panic handler `std` |
There was a problem hiding this comment.
This whole part is unnecessary. Also I don't understand why no_main is mentioned.
There was a problem hiding this comment.
I felt it was worth mentioning the changes if no_std is used for a binary crate; that it is required to specify a panic_handler and that the std::rt::lang_start routine is removed, leaving the binary crate without an entrypoint.
As for adding no_main, it was my way of mentioning that with no_std it is required to setup your own platform specific entrypoint. Trying to compile a no_std binary with just a panic_handler gives:
error: using `fn main` requires the standard library
|
= help: use `#![no_main]` to bypass the Rust generated entrypoint and declare a platform specific entrypoint yourself, usually with `#[no_mangle]`
There was a problem hiding this comment.
Arf, forgot about that. Sorry for the noise.
|
Reminder, once the PR becomes ready for a review, use |
|
@bors squash |
This comment has been minimized.
This comment has been minimized.
* initial writing of the `no_std` attribute * remove unnecessary `Vec` & `String` links * fix incorrect casing, remove redundant sentence, and make it more explicit talking about `alloc`
|
🔨 3 commits were squashed into da925ef. |
3d2e712 to
da925ef
Compare
|
Thanks! @bors r+ rollup |
…=GuillaumeGomez Add documentation for the `no_std` attribute Added documentation for built-in `no_std` attribute using the `#[doc(attribute = "...")]` mechanism. Part of rust-lang#157604. r? @GuillaumeGomez
…uwer Rollup of 17 pull requests Successful merges: - #158510 (Enable `static_position_independent_executables` on all gnu and musl targets) - #158541 (Move `std::io::Write` to `core::io`) - #158899 (Fix `unaligned_volatile_store` by removing `MemFlags::UNALIGNED`) - #155429 (Support `u128`/`i128` c-variadic arguments) - #156370 (Reject linked dylib EII default overrides) - #157153 (allow `Allocator`s to be used as `#[global_allocator]`s) - #158535 (Support `#[track_caller]` on EII declarations) - #158617 (allow mGCA const arguments to fall back to anon consts) - #158645 (Fix splat ICEs and ban it in closures) - #158988 (Redo `TokenStreamIter`) - #158347 (Improve generic parameters handling for #[diagnostic::on_const]) - #158722 (delegation: do not always inherit `ConstArgHasType` predicates) - #158739 (view-types: HIR lowering) - #158883 (tests: fix enum-match.rs to handle LLVM 23) - #158886 (Add documentation for the `no_std` attribute) - #158951 (Merge three `MaxUniverse`s into one) - #158961 (Reapply "LLVM 23: Run AssignGUIDPass in some places")
…=GuillaumeGomez Add documentation for the `no_std` attribute Added documentation for built-in `no_std` attribute using the `#[doc(attribute = "...")]` mechanism. Part of rust-lang#157604. r? @GuillaumeGomez
…=GuillaumeGomez Add documentation for the `no_std` attribute Added documentation for built-in `no_std` attribute using the `#[doc(attribute = "...")]` mechanism. Part of rust-lang#157604. r? @GuillaumeGomez
…=GuillaumeGomez Add documentation for the `no_std` attribute Added documentation for built-in `no_std` attribute using the `#[doc(attribute = "...")]` mechanism. Part of rust-lang#157604. r? @GuillaumeGomez
…uwer Rollup of 21 pull requests Successful merges: - #150946 (intrinsics: Add a fallback for non-const libm float functions) - #158510 (Enable `static_position_independent_executables` on all gnu and musl targets) - #158541 (Move `std::io::Write` to `core::io`) - #158899 (Fix `unaligned_volatile_store` by removing `MemFlags::UNALIGNED`) - #155429 (Support `u128`/`i128` c-variadic arguments) - #156370 (Reject linked dylib EII default overrides) - #156508 (Infer all anonymous lifetimes in assoc consts as `'static`) - #158617 (allow mGCA const arguments to fall back to anon consts) - #158645 (Fix splat ICEs and ban it in closures) - #158859 (Improve `-Zls` diagnostic message on `.rs` files) - #158988 (Redo `TokenStreamIter`) - #158347 (Improve generic parameters handling for #[diagnostic::on_const]) - #158722 (delegation: do not always inherit `ConstArgHasType` predicates) - #158739 (view-types: HIR lowering) - #158883 (tests: fix enum-match.rs to handle LLVM 23) - #158886 (Add documentation for the `no_std` attribute) - #158940 (Implement feature `char_to_u32`) - #158951 (Merge three `MaxUniverse`s into one) - #158961 (Reapply "LLVM 23: Run AssignGUIDPass in some places") - #158996 ([compiler] Implement `PartialOrd` via `Ord` for `Span` and newtype_indexes) - #159005 (Use `as_lang_item` instead of repeatedly matching)
…=GuillaumeGomez Add documentation for the `no_std` attribute Added documentation for built-in `no_std` attribute using the `#[doc(attribute = "...")]` mechanism. Part of rust-lang#157604. r? @GuillaumeGomez
…uwer Rollup of 24 pull requests Successful merges: - #150946 (intrinsics: Add a fallback for non-const libm float functions) - #158510 (Enable `static_position_independent_executables` on all gnu and musl targets) - #158541 (Move `std::io::Write` to `core::io`) - #158899 (Fix `unaligned_volatile_store` by removing `MemFlags::UNALIGNED`) - #156027 (Consider captured regions for opaque type region liveness.) - #156370 (Reject linked dylib EII default overrides) - #156508 (Infer all anonymous lifetimes in assoc consts as `'static`) - #157561 (rustdoc: do not include extra stuff in span) - #158617 (allow mGCA const arguments to fall back to anon consts) - #158645 (Fix splat ICEs and ban it in closures) - #158859 (Improve `-Zls` diagnostic message on `.rs` files) - #158988 (Redo `TokenStreamIter`) - #158347 (Improve generic parameters handling for #[diagnostic::on_const]) - #158384 (Allow BackwardIncompatibleDropHint in polonius legacy) - #158722 (delegation: do not always inherit `ConstArgHasType` predicates) - #158739 (view-types: HIR lowering) - #158877 (borrowck: Keep returned `path` from `best_blame_constraint()` consistent) - #158883 (tests: fix enum-match.rs to handle LLVM 23) - #158886 (Add documentation for the `no_std` attribute) - #158940 (Implement feature `char_to_u32`) - #158951 (Merge three `MaxUniverse`s into one) - #158961 (Reapply "LLVM 23: Run AssignGUIDPass in some places") - #158995 (Use REST API in linkchecker script) - #158996 ([compiler] Implement `PartialOrd` via `Ord` for `Span` and newtype_indexes)
…=GuillaumeGomez Add documentation for the `no_std` attribute Added documentation for built-in `no_std` attribute using the `#[doc(attribute = "...")]` mechanism. Part of rust-lang#157604. r? @GuillaumeGomez
Rollup of 24 pull requests Successful merges: - #150946 (intrinsics: Add a fallback for non-const libm float functions) - #158541 (Move `std::io::Write` to `core::io`) - #156027 (Consider captured regions for opaque type region liveness.) - #156370 (Reject linked dylib EII default overrides) - #156508 (Infer all anonymous lifetimes in assoc consts as `'static`) - #157561 (rustdoc: do not include extra stuff in span) - #158617 (allow mGCA const arguments to fall back to anon consts) - #158645 (Fix splat ICEs and ban it in closures) - #158859 (Improve `-Zls` diagnostic message on `.rs` files) - #158988 (Redo `TokenStreamIter`) - #158347 (Improve generic parameters handling for #[diagnostic::on_const]) - #158384 (Allow BackwardIncompatibleDropHint in polonius legacy) - #158722 (delegation: do not always inherit `ConstArgHasType` predicates) - #158739 (view-types: HIR lowering) - #158877 (borrowck: Keep returned `path` from `best_blame_constraint()` consistent) - #158883 (tests: fix enum-match.rs to handle LLVM 23) - #158886 (Add documentation for the `no_std` attribute) - #158940 (Implement feature `char_to_u32`) - #158951 (Merge three `MaxUniverse`s into one) - #158960 (Fix bootstrap submodule path prefix matching) - #158961 (Reapply "LLVM 23: Run AssignGUIDPass in some places") - #158995 (Use REST API in linkchecker script) - #158996 ([compiler] Implement `PartialOrd` via `Ord` for `Span` and newtype_indexes) - #159036 (bootstrap: expand '@argfile' arguments to rustc shim)
Rollup merge of #158886 - jschillem:docs-no-std-attribute, r=GuillaumeGomez Add documentation for the `no_std` attribute Added documentation for built-in `no_std` attribute using the `#[doc(attribute = "...")]` mechanism. Part of #157604. r? @GuillaumeGomez
Added documentation for built-in
no_stdattribute using the#[doc(attribute = "...")]mechanism.Part of #157604.
r? @GuillaumeGomez