Skip to content

Commit 63bd8de

Browse files
authored
Unrolled build for rust-lang#115247
Rollup merge of rust-lang#115247 - the8472:life-before-main, r=dtolnay Document std limitations before/after main Solves rust-lang#110708
2 parents 341ef15 + b96db22 commit 63bd8de

File tree

1 file changed

+25
-1
lines changed

1 file changed

+25
-1
lines changed

library/std/src/lib.rs

+25-1
Original file line numberDiff line numberDiff line change
@@ -152,6 +152,31 @@
152152
//! contains further primitive shared memory types, including [`atomic`] and
153153
//! [`mpsc`], which contains the channel types for message passing.
154154
//!
155+
//! # Use before and after `main()`
156+
//!
157+
//! Many parts of the standard library are expected to work before and after `main()`;
158+
//! but this is not guaranteed or ensured by tests. It is recommended that you write your own tests
159+
//! and run them on each platform you wish to support.
160+
//! This means that use of `std` before/after main, especially of features that interact with the
161+
//! OS or global state, is exempted from stability and portability guarantees and instead only
162+
//! provided on a best-effort basis. Nevertheless bug reports are appreciated.
163+
//!
164+
//! On the other hand `core` and `alloc` are most likely to work in such environments with
165+
//! the caveat that any hookable behavior such as panics, oom handling or allocators will also
166+
//! depend on the compatibility of the hooks.
167+
//!
168+
//! Some features may also behave differently outside main, e.g. stdio could become unbuffered,
169+
//! some panics might turn into aborts, backtraces might not get symbolicated or similar.
170+
//!
171+
//! Non-exhaustive list of known limitations:
172+
//!
173+
//! - after-main use of thread-locals, which also affects additional features:
174+
//! - [`thread::current()`]
175+
//! - [`thread::scope()`]
176+
//! - [`sync::mpsc`]
177+
//! - before-main stdio file descriptors are not guaranteed to be open on unix platforms
178+
//!
179+
//!
155180
//! [I/O]: io
156181
//! [`MIN`]: i32::MIN
157182
//! [`MAX`]: i32::MAX
@@ -187,7 +212,6 @@
187212
//! [rust-discord]: https://discord.gg/rust-lang
188213
//! [array]: prim@array
189214
//! [slice]: prim@slice
190-
191215
// To run std tests without x.py without ending up with two copies of std, Miri needs to be
192216
// able to "empty" this crate. See <https://github.com/rust-lang/miri-test-libstd/issues/4>.
193217
// rustc itself never sets the feature, so this line has no effect there.

0 commit comments

Comments
 (0)