Skip to content

Commit 0bffcd3

Browse files
author
The Miri Conjob Bot
committed
Merge from rustc
2 parents c0cfa04 + a335250 commit 0bffcd3

File tree

255 files changed

+178
-164
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

255 files changed

+178
-164
lines changed

core/src/primitive_docs.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1605,9 +1605,9 @@ mod prim_ref {}
16051605
/// type in the function pointer to the type at the function declaration, and the return value is
16061606
/// [`transmute`d][mem::transmute] from the type in the declaration to the type in the
16071607
/// pointer. All the usual caveats and concerns around transmutation apply; for instance, if the
1608-
/// function expects a `NonNullI32` and the function pointer uses the ABI-compatible type
1609-
/// `Option<NonNullI32>`, and the value used for the argument is `None`, then this call is Undefined
1610-
/// Behavior since transmuting `None::<NonNullI32>` to `NonNullI32` violates the non-null
1608+
/// function expects a `NonZeroI32` and the function pointer uses the ABI-compatible type
1609+
/// `Option<NonZeroI32>`, and the value used for the argument is `None`, then this call is Undefined
1610+
/// Behavior since transmuting `None::<NonZeroI32>` to `NonZeroI32` violates the non-zero
16111611
/// requirement.
16121612
///
16131613
/// #### Requirements concerning target features

core/src/task/wake.rs

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -329,12 +329,14 @@ impl Waker {
329329
Waker { waker }
330330
}
331331

332-
/// Creates a new `Waker` that does nothing when `wake` is called.
332+
/// Returns a reference to a `Waker` that does nothing when used.
333333
///
334334
/// This is mostly useful for writing tests that need a [`Context`] to poll
335335
/// some futures, but are not expecting those futures to wake the waker or
336336
/// do not need to do anything specific if it happens.
337337
///
338+
/// If an owned `Waker` is needed, `clone()` this one.
339+
///
338340
/// # Examples
339341
///
340342
/// ```
@@ -343,16 +345,20 @@ impl Waker {
343345
/// use std::future::Future;
344346
/// use std::task;
345347
///
346-
/// let waker = task::Waker::noop();
347-
/// let mut cx = task::Context::from_waker(&waker);
348+
/// let mut cx = task::Context::from_waker(task::Waker::noop());
348349
///
349350
/// let mut future = Box::pin(async { 10 });
350351
/// assert_eq!(future.as_mut().poll(&mut cx), task::Poll::Ready(10));
351352
/// ```
352353
#[inline]
353354
#[must_use]
354355
#[unstable(feature = "noop_waker", issue = "98286")]
355-
pub const fn noop() -> Waker {
356+
pub const fn noop() -> &'static Waker {
357+
// Ideally all this data would be explicitly `static` because it is used by reference and
358+
// only ever needs one copy. But `const fn`s (and `const` items) cannot refer to statics,
359+
// even though their values can be promoted to static. (That might change; see #119618.)
360+
// An alternative would be a `pub static NOOP: &Waker`, but associated static items are not
361+
// currently allowed either, and making it non-associated would be unergonomic.
356362
const VTABLE: RawWakerVTable = RawWakerVTable::new(
357363
// Cloning just returns a new no-op raw waker
358364
|_| RAW,
@@ -364,8 +370,9 @@ impl Waker {
364370
|_| {},
365371
);
366372
const RAW: RawWaker = RawWaker::new(ptr::null(), &VTABLE);
373+
const WAKER_REF: &Waker = &Waker { waker: RAW };
367374

368-
Waker { waker: RAW }
375+
WAKER_REF
369376
}
370377

371378
/// Get a reference to the underlying [`RawWaker`].

std/src/sys/mod.rs

Lines changed: 7 additions & 121 deletions
Original file line numberDiff line numberDiff line change
@@ -1,124 +1,10 @@
1-
//! Platform-dependent platform abstraction.
2-
//!
3-
//! The `std::sys` module is the abstracted interface through which
4-
//! `std` talks to the underlying operating system. It has different
5-
//! implementations for different operating system families, today
6-
//! just Unix and Windows, and initial support for Redox.
7-
//!
8-
//! The centralization of platform-specific code in this module is
9-
//! enforced by the "platform abstraction layer" tidy script in
10-
//! `tools/tidy/src/pal.rs`.
11-
//!
12-
//! This module is closely related to the platform-independent system
13-
//! integration code in `std::sys_common`. See that module's
14-
//! documentation for details.
15-
//!
16-
//! In the future it would be desirable for the independent
17-
//! implementations of this module to be extracted to their own crates
18-
//! that `std` can link to, thus enabling their implementation
19-
//! out-of-tree via crate replacement. Though due to the complex
20-
//! inter-dependencies within `std` that will be a challenging goal to
21-
//! achieve.
1+
/// The PAL (platform abstraction layer) contains platform-specific abstractions
2+
/// for implementing the features in the other submodules, e.g. UNIX file
3+
/// descriptors.
4+
mod pal;
225

23-
#![allow(missing_debug_implementations)]
24-
25-
pub mod common;
266
mod personality;
277

28-
cfg_if::cfg_if! {
29-
if #[cfg(unix)] {
30-
mod unix;
31-
pub use self::unix::*;
32-
} else if #[cfg(windows)] {
33-
mod windows;
34-
pub use self::windows::*;
35-
} else if #[cfg(target_os = "solid_asp3")] {
36-
mod solid;
37-
pub use self::solid::*;
38-
} else if #[cfg(target_os = "hermit")] {
39-
mod hermit;
40-
pub use self::hermit::*;
41-
} else if #[cfg(target_os = "wasi")] {
42-
mod wasi;
43-
pub use self::wasi::*;
44-
} else if #[cfg(target_family = "wasm")] {
45-
mod wasm;
46-
pub use self::wasm::*;
47-
} else if #[cfg(target_os = "xous")] {
48-
mod xous;
49-
pub use self::xous::*;
50-
} else if #[cfg(target_os = "uefi")] {
51-
mod uefi;
52-
pub use self::uefi::*;
53-
} else if #[cfg(all(target_vendor = "fortanix", target_env = "sgx"))] {
54-
mod sgx;
55-
pub use self::sgx::*;
56-
} else if #[cfg(target_os = "teeos")] {
57-
mod teeos;
58-
pub use self::teeos::*;
59-
} else {
60-
mod unsupported;
61-
pub use self::unsupported::*;
62-
}
63-
}
64-
65-
cfg_if::cfg_if! {
66-
// Fuchsia components default to full backtrace.
67-
if #[cfg(target_os = "fuchsia")] {
68-
pub const FULL_BACKTRACE_DEFAULT: bool = true;
69-
} else {
70-
pub const FULL_BACKTRACE_DEFAULT: bool = false;
71-
}
72-
}
73-
74-
#[cfg(not(test))]
75-
cfg_if::cfg_if! {
76-
if #[cfg(target_os = "android")] {
77-
pub use self::android::log2f32;
78-
pub use self::android::log2f64;
79-
} else {
80-
#[inline]
81-
pub fn log2f32(n: f32) -> f32 {
82-
unsafe { crate::intrinsics::log2f32(n) }
83-
}
84-
85-
#[inline]
86-
pub fn log2f64(n: f64) -> f64 {
87-
unsafe { crate::intrinsics::log2f64(n) }
88-
}
89-
}
90-
}
91-
92-
// Solaris/Illumos requires a wrapper around log, log2, and log10 functions
93-
// because of their non-standard behavior (e.g., log(-n) returns -Inf instead
94-
// of expected NaN).
95-
#[cfg(not(test))]
96-
#[cfg(any(target_os = "solaris", target_os = "illumos"))]
97-
#[inline]
98-
pub fn log_wrapper<F: Fn(f64) -> f64>(n: f64, log_fn: F) -> f64 {
99-
if n.is_finite() {
100-
if n > 0.0 {
101-
log_fn(n)
102-
} else if n == 0.0 {
103-
f64::NEG_INFINITY // log(0) = -Inf
104-
} else {
105-
f64::NAN // log(-n) = NaN
106-
}
107-
} else if n.is_nan() {
108-
n // log(NaN) = NaN
109-
} else if n > 0.0 {
110-
n // log(Inf) = Inf
111-
} else {
112-
f64::NAN // log(-Inf) = NaN
113-
}
114-
}
115-
116-
#[cfg(not(test))]
117-
#[cfg(not(any(target_os = "solaris", target_os = "illumos")))]
118-
#[inline]
119-
pub fn log_wrapper<F: Fn(f64) -> f64>(n: f64, log_fn: F) -> f64 {
120-
log_fn(n)
121-
}
122-
123-
#[cfg(not(target_os = "uefi"))]
124-
pub type RawOsError = i32;
8+
// FIXME(117276): remove this, move feature implementations into individual
9+
// submodules.
10+
pub use pal::*;
File renamed without changes.
File renamed without changes.
File renamed without changes.

0 commit comments

Comments
 (0)