Replace libstd, libcore, liballoc in line comments.

This commit is contained in:
jonathanCogan 2022-10-28 16:48:00 -07:00 committed by Mara Bos
parent 72067c77bd
commit db47071df2
27 changed files with 48 additions and 48 deletions

View File

@ -23,7 +23,7 @@ extern "Rust" {
// These are the magic symbols to call the global allocator. rustc generates // These are the magic symbols to call the global allocator. rustc generates
// them to call `__rg_alloc` etc. if there is a `#[global_allocator]` attribute // them to call `__rg_alloc` etc. if there is a `#[global_allocator]` attribute
// (the code expanding that attribute macro generates those functions), or to call // (the code expanding that attribute macro generates those functions), or to call
// the default implementations in libstd (`__rdl_alloc` etc. in `library/std/src/alloc.rs`) // the default implementations in std (`__rdl_alloc` etc. in `library/std/src/alloc.rs`)
// otherwise. // otherwise.
// The rustc fork of LLVM 14 and earlier also special-cases these function names to be able to optimize them // The rustc fork of LLVM 14 and earlier also special-cases these function names to be able to optimize them
// like `malloc`, `realloc`, and `free`, respectively. // like `malloc`, `realloc`, and `free`, respectively.

View File

@ -75,7 +75,7 @@
))] ))]
#![no_std] #![no_std]
#![needs_allocator] #![needs_allocator]
// To run liballoc tests without x.py without ending up with two copies of liballoc, Miri needs to be // To run alloc tests without x.py without ending up with two copies of alloc, Miri needs to be
// able to "empty" this crate. See <https://github.com/rust-lang/miri-test-libstd/issues/4>. // able to "empty" this crate. See <https://github.com/rust-lang/miri-test-libstd/issues/4>.
// rustc itself never sets the feature, so this line has no affect there. // rustc itself never sets the feature, so this line has no affect there.
#![cfg(any(not(feature = "miri-test-libstd"), test, doctest))] #![cfg(any(not(feature = "miri-test-libstd"), test, doctest))]

View File

@ -2678,7 +2678,7 @@ impl From<&String> for String {
} }
} }
// note: test pulls in libstd, which causes errors here // note: test pulls in std, which causes errors here
#[cfg(not(test))] #[cfg(not(test))]
#[stable(feature = "string_from_box", since = "1.18.0")] #[stable(feature = "string_from_box", since = "1.18.0")]
impl From<Box<str>> for String { impl From<Box<str>> for String {

View File

@ -3191,7 +3191,7 @@ where
} }
} }
// note: test pulls in libstd, which causes errors here // note: test pulls in std, which causes errors here
#[cfg(not(test))] #[cfg(not(test))]
#[stable(feature = "vec_from_box", since = "1.18.0")] #[stable(feature = "vec_from_box", since = "1.18.0")]
impl<T, A: Allocator> From<Box<[T], A>> for Vec<T, A> { impl<T, A: Allocator> From<Box<[T], A>> for Vec<T, A> {
@ -3209,7 +3209,7 @@ impl<T, A: Allocator> From<Box<[T], A>> for Vec<T, A> {
} }
} }
// note: test pulls in libstd, which causes errors here // note: test pulls in std, which causes errors here
#[cfg(not(no_global_oom_handling))] #[cfg(not(no_global_oom_handling))]
#[cfg(not(test))] #[cfg(not(test))]
#[stable(feature = "box_from_vec", since = "1.20.0")] #[stable(feature = "box_from_vec", since = "1.20.0")]

View File

@ -32,7 +32,7 @@ fn test_btree_map() {
// spawn(f()); // spawn(f());
// } // }
// //
// where with some unintentionally overconstrained Send impls in liballoc's // where with some unintentionally overconstrained Send impls in alloc's
// internals, the future might incorrectly not be Send even though every // internals, the future might incorrectly not be Send even though every
// single type involved in the program is Send and Sync. // single type involved in the program is Send and Sync.
require_send_sync(async { require_send_sync(async {

View File

@ -1994,7 +1994,7 @@ impl<T: ?Sized> UnsafeCell<T> {
#[rustc_const_stable(feature = "const_unsafecell_get", since = "1.32.0")] #[rustc_const_stable(feature = "const_unsafecell_get", since = "1.32.0")]
pub const fn get(&self) -> *mut T { pub const fn get(&self) -> *mut T {
// We can just cast the pointer from `UnsafeCell<T>` to `T` because of // We can just cast the pointer from `UnsafeCell<T>` to `T` because of
// #[repr(transparent)]. This exploits libstd's special status, there is // #[repr(transparent)]. This exploits std's special status, there is
// no guarantee for user code that this will work in future versions of the compiler! // no guarantee for user code that this will work in future versions of the compiler!
self as *const UnsafeCell<T> as *const T as *mut T self as *const UnsafeCell<T> as *const T as *mut T
} }
@ -2052,7 +2052,7 @@ impl<T: ?Sized> UnsafeCell<T> {
#[rustc_const_stable(feature = "unsafe_cell_raw_get", since = "1.56.0")] #[rustc_const_stable(feature = "unsafe_cell_raw_get", since = "1.56.0")]
pub const fn raw_get(this: *const Self) -> *mut T { pub const fn raw_get(this: *const Self) -> *mut T {
// We can just cast the pointer from `UnsafeCell<T>` to `T` because of // We can just cast the pointer from `UnsafeCell<T>` to `T` because of
// #[repr(transparent)]. This exploits libstd's special status, there is // #[repr(transparent)]. This exploits std's special status, there is
// no guarantee for user code that this will work in future versions of the compiler! // no guarantee for user code that this will work in future versions of the compiler!
this as *const T as *mut T this as *const T as *mut T
} }

View File

@ -38,18 +38,18 @@
//! which do not trigger a panic can be assured that this function is never //! which do not trigger a panic can be assured that this function is never
//! called. The `lang` attribute is called `eh_personality`. //! called. The `lang` attribute is called `eh_personality`.
// Since libcore defines many fundamental lang items, all tests live in a // Since core defines many fundamental lang items, all tests live in a
// separate crate, libcoretest, to avoid bizarre issues. // separate crate, libcoretest, to avoid bizarre issues.
// //
// Here we explicitly #[cfg]-out this whole crate when testing. If we don't do // Here we explicitly #[cfg]-out this whole crate when testing. If we don't do
// this, both the generated test artifact and the linked libtest (which // this, both the generated test artifact and the linked libtest (which
// transitively includes libcore) will both define the same set of lang items, // transitively includes core) will both define the same set of lang items,
// and this will cause the E0152 "found duplicate lang item" error. See // and this will cause the E0152 "found duplicate lang item" error. See
// discussion in #50466 for details. // discussion in #50466 for details.
// //
// This cfg won't affect doc tests. // This cfg won't affect doc tests.
#![cfg(not(test))] #![cfg(not(test))]
// To run libcore tests without x.py without ending up with two copies of libcore, Miri needs to be // To run core tests without x.py without ending up with two copies of core, Miri needs to be
// able to "empty" this crate. See <https://github.com/rust-lang/miri-test-libstd/issues/4>. // able to "empty" this crate. See <https://github.com/rust-lang/miri-test-libstd/issues/4>.
// rustc itself never sets the feature, so this line has no affect there. // rustc itself never sets the feature, so this line has no affect there.
#![cfg(any(not(feature = "miri-test-libstd"), test, doctest))] #![cfg(any(not(feature = "miri-test-libstd"), test, doctest))]
@ -311,7 +311,7 @@ pub mod f64;
#[macro_use] #[macro_use]
pub mod num; pub mod num;
/* The libcore prelude, not as all-encompassing as the libstd prelude */ /* The core prelude, not as all-encompassing as the std prelude */
pub mod prelude; pub mod prelude;
@ -378,12 +378,12 @@ mod const_closure;
#[stable(feature = "core_primitive", since = "1.43.0")] #[stable(feature = "core_primitive", since = "1.43.0")]
pub mod primitive; pub mod primitive;
// Pull in the `core_arch` crate directly into libcore. The contents of // Pull in the `core_arch` crate directly into core. The contents of
// `core_arch` are in a different repository: rust-lang/stdarch. // `core_arch` are in a different repository: rust-lang/stdarch.
// //
// `core_arch` depends on libcore, but the contents of this module are // `core_arch` depends on core, but the contents of this module are
// set up in such a way that directly pulling it here works such that the // set up in such a way that directly pulling it here works such that the
// crate uses the this crate as its libcore. // crate uses the this crate as its core.
#[path = "../../stdarch/crates/core_arch/src/mod.rs"] #[path = "../../stdarch/crates/core_arch/src/mod.rs"]
#[allow( #[allow(
missing_docs, missing_docs,
@ -402,12 +402,12 @@ mod core_arch;
#[stable(feature = "simd_arch", since = "1.27.0")] #[stable(feature = "simd_arch", since = "1.27.0")]
pub mod arch; pub mod arch;
// Pull in the `core_simd` crate directly into libcore. The contents of // Pull in the `core_simd` crate directly into core. The contents of
// `core_simd` are in a different repository: rust-lang/portable-simd. // `core_simd` are in a different repository: rust-lang/portable-simd.
// //
// `core_simd` depends on libcore, but the contents of this module are // `core_simd` depends on core, but the contents of this module are
// set up in such a way that directly pulling it here works such that the // set up in such a way that directly pulling it here works such that the
// crate uses this crate as its libcore. // crate uses this crate as its core.
#[path = "../../portable-simd/crates/core_simd/src/mod.rs"] #[path = "../../portable-simd/crates/core_simd/src/mod.rs"]
#[allow(missing_debug_implementations, dead_code, unsafe_op_in_unsafe_fn, unused_unsafe)] #[allow(missing_debug_implementations, dead_code, unsafe_op_in_unsafe_fn, unused_unsafe)]
#[allow(rustdoc::bare_urls)] #[allow(rustdoc::bare_urls)]

View File

@ -428,7 +428,7 @@ impl f32 {
self != self self != self
} }
// FIXME(#50145): `abs` is publicly unavailable in libcore due to // FIXME(#50145): `abs` is publicly unavailable in core due to
// concerns about portability, so this implementation is for // concerns about portability, so this implementation is for
// private use internally. // private use internally.
#[inline] #[inline]

View File

@ -427,7 +427,7 @@ impl f64 {
self != self self != self
} }
// FIXME(#50145): `abs` is publicly unavailable in libcore due to // FIXME(#50145): `abs` is publicly unavailable in core due to
// concerns about portability, so this implementation is for // concerns about portability, so this implementation is for
// private use internally. // private use internally.
#[inline] #[inline]

View File

@ -157,7 +157,7 @@ impl fmt::Display for PanicInfo<'_> {
write!(formatter, "'{}', ", payload)? write!(formatter, "'{}', ", payload)?
} }
// NOTE: we cannot use downcast_ref::<String>() here // NOTE: we cannot use downcast_ref::<String>() here
// since String is not available in libcore! // since String is not available in core!
// The payload is a String when `std::panic!` is called with multiple arguments, // The payload is a String when `std::panic!` is called with multiple arguments,
// but in that case the message is also available. // but in that case the message is also available.

View File

@ -368,7 +368,7 @@ impl str {
#[inline(always)] #[inline(always)]
pub unsafe fn as_bytes_mut(&mut self) -> &mut [u8] { pub unsafe fn as_bytes_mut(&mut self) -> &mut [u8] {
// SAFETY: the cast from `&str` to `&[u8]` is safe since `str` // SAFETY: the cast from `&str` to `&[u8]` is safe since `str`
// has the same layout as `&[u8]` (only libstd can make this guarantee). // has the same layout as `&[u8]` (only std can make this guarantee).
// The pointer dereference is safe since it comes from a mutable reference which // The pointer dereference is safe since it comes from a mutable reference which
// is guaranteed to be valid for writes. // is guaranteed to be valid for writes.
unsafe { &mut *(self as *mut str as *mut [u8]) } unsafe { &mut *(self as *mut str as *mut [u8]) }

View File

@ -17,7 +17,7 @@ mod unicode_data;
#[stable(feature = "unicode_version", since = "1.45.0")] #[stable(feature = "unicode_version", since = "1.45.0")]
pub const UNICODE_VERSION: (u8, u8, u8) = unicode_data::UNICODE_VERSION; pub const UNICODE_VERSION: (u8, u8, u8) = unicode_data::UNICODE_VERSION;
// For use in liballoc, not re-exported in libstd. // For use in alloc, not re-exported in std.
pub use unicode_data::{ pub use unicode_data::{
case_ignorable::lookup as Case_Ignorable, cased::lookup as Cased, conversions, case_ignorable::lookup as Case_Ignorable, cased::lookup as Cased, conversions,
}; };

View File

@ -807,7 +807,7 @@ fn ptr_metadata_bounds() {
} }
// "Synthetic" trait impls generated by the compiler like those of `Pointee` // "Synthetic" trait impls generated by the compiler like those of `Pointee`
// are not checked for bounds of associated type. // are not checked for bounds of associated type.
// So with a buggy libcore we could have both: // So with a buggy core we could have both:
// * `<dyn Display as Pointee>::Metadata == DynMetadata` // * `<dyn Display as Pointee>::Metadata == DynMetadata`
// * `DynMetadata: !PartialEq` // * `DynMetadata: !PartialEq`
// … and cause an ICE here: // … and cause an ICE here:

View File

@ -1 +1 @@
// All `str` tests live in liballoc/tests // All `str` tests live in alloc/tests

View File

@ -61,7 +61,7 @@ pub unsafe fn __rust_start_panic(_payload: *mut &mut dyn BoxMeUp) -> u32 {
// //
// https://docs.microsoft.com/en-us/cpp/intrinsics/fastfail // https://docs.microsoft.com/en-us/cpp/intrinsics/fastfail
// //
// Note: this is the same implementation as in libstd's `abort_internal` // Note: this is the same implementation as in std's `abort_internal`
unsafe fn abort() -> ! { unsafe fn abort() -> ! {
#[allow(unused)] #[allow(unused)]
const FAST_FAIL_FATAL_APP_EXIT: usize = 7; const FAST_FAIL_FATAL_APP_EXIT: usize = 7;
@ -89,7 +89,7 @@ pub unsafe fn __rust_start_panic(_payload: *mut &mut dyn BoxMeUp) -> u32 {
// This... is a bit of an oddity. The tl;dr; is that this is required to link // This... is a bit of an oddity. The tl;dr; is that this is required to link
// correctly, the longer explanation is below. // correctly, the longer explanation is below.
// //
// Right now the binaries of libcore/libstd that we ship are all compiled with // Right now the binaries of core/std that we ship are all compiled with
// `-C panic=unwind`. This is done to ensure that the binaries are maximally // `-C panic=unwind`. This is done to ensure that the binaries are maximally
// compatible with as many situations as possible. The compiler, however, // compatible with as many situations as possible. The compiler, however,
// requires a "personality function" for all functions compiled with `-C // requires a "personality function" for all functions compiled with `-C
@ -109,7 +109,7 @@ pub unsafe fn __rust_start_panic(_payload: *mut &mut dyn BoxMeUp) -> u32 {
// library just defines this symbol so there's at least some personality // library just defines this symbol so there's at least some personality
// somewhere. // somewhere.
// //
// Essentially this symbol is just defined to get wired up to libcore/libstd // Essentially this symbol is just defined to get wired up to core/std
// binaries, but it should never be called as we don't link in an unwinding // binaries, but it should never be called as we don't link in an unwinding
// runtime at all. // runtime at all.
pub mod personalities { pub mod personalities {

View File

@ -356,7 +356,7 @@ impl<I, O> Clone for Client<I, O> {
fn maybe_install_panic_hook(force_show_panics: bool) { fn maybe_install_panic_hook(force_show_panics: bool) {
// Hide the default panic output within `proc_macro` expansions. // Hide the default panic output within `proc_macro` expansions.
// NB. the server can't do this because it may use a different libstd. // NB. the server can't do this because it may use a different std.
static HIDE_PANICS_DURING_EXPANSION: Once = Once::new(); static HIDE_PANICS_DURING_EXPANSION: Once = Once::new();
HIDE_PANICS_DURING_EXPANSION.call_once(|| { HIDE_PANICS_DURING_EXPANSION.call_once(|| {
let prev = panic::take_hook(); let prev = panic::take_hook();

View File

@ -112,7 +112,7 @@ macro_rules! define_dispatcher_impl {
$name::$method(server, $($arg),*) $name::$method(server, $($arg),*)
}; };
// HACK(eddyb) don't use `panic::catch_unwind` in a panic. // HACK(eddyb) don't use `panic::catch_unwind` in a panic.
// If client and server happen to use the same `libstd`, // If client and server happen to use the same `std`,
// `catch_unwind` asserts that the panic counter was 0, // `catch_unwind` asserts that the panic counter was 0,
// even when the closure passed to it didn't panic. // even when the closure passed to it didn't panic.
let r = if thread::panicking() { let r = if thread::panicking() {

View File

@ -3,7 +3,7 @@
// See rustc-std-workspace-core for why this crate is needed. // See rustc-std-workspace-core for why this crate is needed.
// Rename the crate to avoid conflicting with the alloc module in liballoc. // Rename the crate to avoid conflicting with the alloc module in alloc.
extern crate alloc as foo; extern crate alloc as foo;
pub use foo::*; pub use foo::*;

View File

@ -166,7 +166,7 @@ impl Repr {
// `new_unchecked` is safe. // `new_unchecked` is safe.
let res = Self(unsafe { NonNull::new_unchecked(tagged) }, PhantomData); let res = Self(unsafe { NonNull::new_unchecked(tagged) }, PhantomData);
// quickly smoke-check we encoded the right thing (This generally will // quickly smoke-check we encoded the right thing (This generally will
// only run in libstd's tests, unless the user uses -Zbuild-std) // only run in std's tests, unless the user uses -Zbuild-std)
debug_assert!(matches!(res.data(), ErrorData::Custom(_)), "repr(custom) encoding failed"); debug_assert!(matches!(res.data(), ErrorData::Custom(_)), "repr(custom) encoding failed");
res res
} }
@ -177,7 +177,7 @@ impl Repr {
// Safety: `TAG_OS` is not zero, so the result of the `|` is not 0. // Safety: `TAG_OS` is not zero, so the result of the `|` is not 0.
let res = Self(unsafe { NonNull::new_unchecked(ptr::invalid_mut(utagged)) }, PhantomData); let res = Self(unsafe { NonNull::new_unchecked(ptr::invalid_mut(utagged)) }, PhantomData);
// quickly smoke-check we encoded the right thing (This generally will // quickly smoke-check we encoded the right thing (This generally will
// only run in libstd's tests, unless the user uses -Zbuild-std) // only run in std's tests, unless the user uses -Zbuild-std)
debug_assert!( debug_assert!(
matches!(res.data(), ErrorData::Os(c) if c == code), matches!(res.data(), ErrorData::Os(c) if c == code),
"repr(os) encoding failed for {code}" "repr(os) encoding failed for {code}"
@ -191,7 +191,7 @@ impl Repr {
// Safety: `TAG_SIMPLE` is not zero, so the result of the `|` is not 0. // Safety: `TAG_SIMPLE` is not zero, so the result of the `|` is not 0.
let res = Self(unsafe { NonNull::new_unchecked(ptr::invalid_mut(utagged)) }, PhantomData); let res = Self(unsafe { NonNull::new_unchecked(ptr::invalid_mut(utagged)) }, PhantomData);
// quickly smoke-check we encoded the right thing (This generally will // quickly smoke-check we encoded the right thing (This generally will
// only run in libstd's tests, unless the user uses -Zbuild-std) // only run in std's tests, unless the user uses -Zbuild-std)
debug_assert!( debug_assert!(
matches!(res.data(), ErrorData::Simple(k) if k == kind), matches!(res.data(), ErrorData::Simple(k) if k == kind),
"repr(simple) encoding failed {:?}", "repr(simple) encoding failed {:?}",
@ -348,7 +348,7 @@ fn kind_from_prim(ek: u32) -> Option<ErrorKind> {
// that our encoding relies on for correctness and soundness. (Some of these are // that our encoding relies on for correctness and soundness. (Some of these are
// a bit overly thorough/cautious, admittedly) // a bit overly thorough/cautious, admittedly)
// //
// If any of these are hit on a platform that libstd supports, we should likely // If any of these are hit on a platform that std supports, we should likely
// just use `repr_unpacked.rs` there instead (unless the fix is easy). // just use `repr_unpacked.rs` there instead (unless the fix is easy).
macro_rules! static_assert { macro_rules! static_assert {
($condition:expr) => { ($condition:expr) => {

View File

@ -202,7 +202,7 @@
no_global_oom_handling, no_global_oom_handling,
not(no_global_oom_handling) not(no_global_oom_handling)
))] ))]
// To run libstd tests without x.py without ending up with two copies of libstd, Miri needs to be // To run std tests without x.py without ending up with two copies of std, Miri needs to be
// able to "empty" this crate. See <https://github.com/rust-lang/miri-test-libstd/issues/4>. // able to "empty" this crate. See <https://github.com/rust-lang/miri-test-libstd/issues/4>.
// rustc itself never sets the feature, so this line has no affect there. // rustc itself never sets the feature, so this line has no affect there.
#![cfg(any(not(feature = "miri-test-libstd"), test, doctest))] #![cfg(any(not(feature = "miri-test-libstd"), test, doctest))]
@ -532,7 +532,7 @@ pub mod process;
pub mod sync; pub mod sync;
pub mod time; pub mod time;
// Pull in `std_float` crate into libstd. The contents of // Pull in `std_float` crate into std. The contents of
// `std_float` are in a different repository: rust-lang/portable-simd. // `std_float` are in a different repository: rust-lang/portable-simd.
#[path = "../../portable-simd/crates/std_float/src/lib.rs"] #[path = "../../portable-simd/crates/std_float/src/lib.rs"]
#[allow(missing_debug_implementations, dead_code, unsafe_op_in_unsafe_fn, unused_unsafe)] #[allow(missing_debug_implementations, dead_code, unsafe_op_in_unsafe_fn, unused_unsafe)]
@ -602,7 +602,7 @@ mod personality;
#[allow(dead_code, unused_attributes, fuzzy_provenance_casts)] #[allow(dead_code, unused_attributes, fuzzy_provenance_casts)]
mod backtrace_rs; mod backtrace_rs;
// Re-export macros defined in libcore. // Re-export macros defined in core.
#[stable(feature = "rust1", since = "1.0.0")] #[stable(feature = "rust1", since = "1.0.0")]
#[allow(deprecated, deprecated_in_future)] #[allow(deprecated, deprecated_in_future)]
pub use core::{ pub use core::{
@ -610,7 +610,7 @@ pub use core::{
unimplemented, unreachable, write, writeln, unimplemented, unreachable, write, writeln,
}; };
// Re-export built-in macros defined through libcore. // Re-export built-in macros defined through core.
#[stable(feature = "builtin_macro_prelude", since = "1.38.0")] #[stable(feature = "builtin_macro_prelude", since = "1.38.0")]
#[allow(deprecated)] #[allow(deprecated)]
pub use core::{ pub use core::{

View File

@ -306,7 +306,7 @@ unsafe fn u8_slice_as_os_str(s: &[u8]) -> &OsStr {
// This casts are safe as OsStr is internally a wrapper around [u8] on all // This casts are safe as OsStr is internally a wrapper around [u8] on all
// platforms. // platforms.
// //
// Note that currently this relies on the special knowledge that libstd has; // Note that currently this relies on the special knowledge that std has;
// these types are single-element structs but are not marked // these types are single-element structs but are not marked
// repr(transparent) or repr(C) which would make these casts not allowable // repr(transparent) or repr(C) which would make these casts not allowable
// outside std. // outside std.

View File

@ -139,9 +139,9 @@ fn lang_start_internal(
// mechanism itself. // mechanism itself.
// //
// There are a couple of instances where unwinding can begin. First is inside of the // There are a couple of instances where unwinding can begin. First is inside of the
// `rt::init`, `rt::cleanup` and similar functions controlled by libstd. In those instances a // `rt::init`, `rt::cleanup` and similar functions controlled by bstd. In those instances a
// panic is a libstd implementation bug. A quite likely one too, as there isn't any way to // panic is a std implementation bug. A quite likely one too, as there isn't any way to
// prevent libstd from accidentally introducing a panic to these functions. Another is from // prevent std from accidentally introducing a panic to these functions. Another is from
// user code from `main` or, more nefariously, as described in e.g. issue #86030. // user code from `main` or, more nefariously, as described in e.g. issue #86030.
// SAFETY: Only called once during runtime initialization. // SAFETY: Only called once during runtime initialization.
panic::catch_unwind(move || unsafe { init(argc, argv, sigpipe) }).map_err(rt_abort)?; panic::catch_unwind(move || unsafe { init(argc, argv, sigpipe) }).map_err(rt_abort)?;

View File

@ -164,7 +164,7 @@ pub unsafe fn init(argc: isize, argv: *const *const u8, sigpipe: u8) {
unsafe fn reset_sigpipe(#[allow(unused_variables)] sigpipe: u8) { unsafe fn reset_sigpipe(#[allow(unused_variables)] sigpipe: u8) {
#[cfg(not(any(target_os = "emscripten", target_os = "fuchsia", target_os = "horizon")))] #[cfg(not(any(target_os = "emscripten", target_os = "fuchsia", target_os = "horizon")))]
{ {
// We don't want to add this as a public type to libstd, nor do we // We don't want to add this as a public type to std, nor do we
// want to `include!` a file from the compiler (which would break // want to `include!` a file from the compiler (which would break
// Miri and xargo for example), so we choose to duplicate these // Miri and xargo for example), so we choose to duplicate these
// constants from `compiler/rustc_session/src/config/sigpipe.rs`. // constants from `compiler/rustc_session/src/config/sigpipe.rs`.

View File

@ -512,7 +512,7 @@ impl FromRawFd for Socket {
// A workaround for this bug is to call the res_init libc function, to clear // A workaround for this bug is to call the res_init libc function, to clear
// the cached configs. Unfortunately, while we believe glibc's implementation // the cached configs. Unfortunately, while we believe glibc's implementation
// of res_init is thread-safe, we know that other implementations are not // of res_init is thread-safe, we know that other implementations are not
// (https://github.com/rust-lang/rust/issues/43592). Code here in libstd could // (https://github.com/rust-lang/rust/issues/43592). Code here in std could
// try to synchronize its res_init calls with a Mutex, but that wouldn't // try to synchronize its res_init calls with a Mutex, but that wouldn't
// protect programs that call into libc in other ways. So instead of calling // protect programs that call into libc in other ways. So instead of calling
// res_init unconditionally, we call it only when we detect we're linking // res_init unconditionally, we call it only when we detect we're linking

View File

@ -20,7 +20,7 @@ pub fn lock() -> impl Drop {
/// Prints the current backtrace. /// Prints the current backtrace.
pub fn print(w: &mut dyn Write, format: PrintFmt) -> io::Result<()> { pub fn print(w: &mut dyn Write, format: PrintFmt) -> io::Result<()> {
// There are issues currently linking libbacktrace into tests, and in // There are issues currently linking libbacktrace into tests, and in
// general during libstd's own unit tests we're not testing this path. In // general during std's own unit tests we're not testing this path. In
// test mode immediately return here to optimize away any references to the // test mode immediately return here to optimize away any references to the
// libbacktrace symbols // libbacktrace symbols
if cfg!(test) { if cfg!(test) {

View File

@ -950,7 +950,7 @@ pub mod fast {
// note that this is just a publicly-callable function only for the // note that this is just a publicly-callable function only for the
// const-initialized form of thread locals, basically a way to call the // const-initialized form of thread locals, basically a way to call the
// free `register_dtor` function defined elsewhere in libstd. // free `register_dtor` function defined elsewhere in std.
pub unsafe fn register_dtor(a: *mut u8, dtor: unsafe extern "C" fn(*mut u8)) { pub unsafe fn register_dtor(a: *mut u8, dtor: unsafe extern "C" fn(*mut u8)) {
unsafe { unsafe {
register_dtor(a, dtor); register_dtor(a, dtor);

View File

@ -88,7 +88,7 @@ pub type _Unwind_Exception_Cleanup_Fn =
extern "C" fn(unwind_code: _Unwind_Reason_Code, exception: *mut _Unwind_Exception); extern "C" fn(unwind_code: _Unwind_Reason_Code, exception: *mut _Unwind_Exception);
// FIXME: The `#[link]` attributes on `extern "C"` block marks those symbols declared in // FIXME: The `#[link]` attributes on `extern "C"` block marks those symbols declared in
// the block are reexported in dylib build of libstd. This is needed when build rustc with // the block are reexported in dylib build of std. This is needed when build rustc with
// feature `llvm-libunwind', as no other cdylib will provided those _Unwind_* symbols. // feature `llvm-libunwind', as no other cdylib will provided those _Unwind_* symbols.
// However the `link` attribute is duplicated multiple times and does not just export symbol, // However the `link` attribute is duplicated multiple times and does not just export symbol,
// a better way to manually export symbol would be another attribute like `#[export]`. // a better way to manually export symbol would be another attribute like `#[export]`.