Skip to content
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

Rollup of 8 pull requests #133059

Merged
merged 19 commits into from
Nov 15, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
19 commits
Select commit Hold shift + click to select a range
c496af6
Add as_slice/into_slice for IoSlice/IoSliceMut.
aDotInTheVoid Nov 8, 2024
fb3edb2
[illumos] use pipe2 to create anonymous pipes
sunshowers Nov 13, 2024
0df3ef4
Fix compilation error on Solaris due to flock usage
cberner Nov 13, 2024
2cb7aea
docs: Fix missing period in methods for integer types
sorairolake Nov 14, 2024
17ed948
docs: Fix missing colon in methods for primitive types
sorairolake Nov 14, 2024
467ce26
Include the "unwind" crate to link with libunwind instead of the "lib…
xingxue-ibm Nov 11, 2024
7711ba2
use `&raw` in `{read, write}_unaligned` documentation
cyrgani Nov 14, 2024
ede8a74
tests/run-make/simd-ffi: fix test crashing on x86 targets ...
liushuyu Nov 14, 2024
b77dbbd
Pass `f16` and `f128` by value in `const_assert!`
tgross35 Nov 14, 2024
5d81891
Always inline functions signatures containing `f16` or `f128`
tgross35 Nov 14, 2024
0733ed7
tests/run-make/simd-ffi: use a generic LLVM intrinsics ...
liushuyu Nov 14, 2024
b1b56b1
Rollup merge of #132790 - aDotInTheVoid:ioslice-asslice-rides-again, …
workingjubilee Nov 15, 2024
fcc0845
Rollup merge of #132905 - xingxue-ibm:link-unwind, r=bjorn3
workingjubilee Nov 15, 2024
3f9f7c4
Rollup merge of #132977 - cberner:fix_solaris, r=tgross35
workingjubilee Nov 15, 2024
a5510a5
Rollup merge of #132984 - sunshowers:pipe2, r=tgross35
workingjubilee Nov 15, 2024
a835f2a
Rollup merge of #133019 - sorairolake:add-missing-period-and-colon, r…
workingjubilee Nov 15, 2024
60f3911
Rollup merge of #133048 - cyrgani:ptr-doc-update, r=Amanieu
workingjubilee Nov 15, 2024
cea081e
Rollup merge of #133050 - tgross35:inline-f16-f128, r=saethlin
workingjubilee Nov 15, 2024
efe2c44
Rollup merge of #133053 - liushuyu:simd-test-x86-baseline-fix, r=work…
workingjubilee Nov 15, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions compiler/rustc_mir_transform/src/cross_crate_inline.rs
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,16 @@ fn cross_crate_inlinable(tcx: TyCtxt<'_>, def_id: LocalDefId) -> bool {
_ => {}
}

let sig = tcx.fn_sig(def_id).instantiate_identity();
for ty in sig.inputs().skip_binder().iter().chain(std::iter::once(&sig.output().skip_binder()))
{
// FIXME(f16_f128): in order to avoid crashes building `core`, always inline to skip
// codegen if the function is not used.
if ty == &tcx.types.f16 || ty == &tcx.types.f128 {
return true;
}
}

// Don't do any inference when incremental compilation is enabled; the additional inlining that
// inference permits also creates more work for small edits.
if tcx.sess.opts.incremental.is_some() {
Expand Down
5 changes: 2 additions & 3 deletions library/core/src/num/f128.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1258,9 +1258,8 @@ impl f128 {
min <= max,
"min > max, or either was NaN",
"min > max, or either was NaN. min = {min:?}, max = {max:?}",
// FIXME(f16_f128): Passed by-ref to avoid codegen crashes
min: &f128 = &min,
max: &f128 = &max,
min: f128,
max: f128,
);

if self < min {
Expand Down
5 changes: 2 additions & 3 deletions library/core/src/num/f16.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1235,9 +1235,8 @@ impl f16 {
min <= max,
"min > max, or either was NaN",
"min > max, or either was NaN. min = {min:?}, max = {max:?}",
// FIXME(f16_f128): Passed by-ref to avoid codegen crashes
min: &f16 = &min,
max: &f16 = &max,
min: f16,
max: f16,
);

if self < min {
Expand Down
8 changes: 4 additions & 4 deletions library/core/src/num/int_macros.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1300,7 +1300,7 @@ macro_rules! int_impl {
}
}

/// Unbounded shift left. Computes `self << rhs`, without bounding the value of `rhs`
/// Unbounded shift left. Computes `self << rhs`, without bounding the value of `rhs`.
///
/// If `rhs` is larger or equal to the number of bits in `self`,
/// the entire value is shifted out, and `0` is returned.
Expand Down Expand Up @@ -1423,7 +1423,7 @@ macro_rules! int_impl {
}
}

/// Unbounded shift right. Computes `self >> rhs`, without bounding the value of `rhs`
/// Unbounded shift right. Computes `self >> rhs`, without bounding the value of `rhs`.
///
/// If `rhs` is larger or equal to the number of bits in `self`,
/// the entire value is shifted out, which yields `0` for a positive number,
Expand Down Expand Up @@ -2389,7 +2389,7 @@ macro_rules! int_impl {
(res, overflowed ^ (rhs < 0))
}

/// Calculates `self` - `rhs`
/// Calculates `self` - `rhs`.
///
/// Returns a tuple of the subtraction along with a boolean indicating whether an arithmetic overflow
/// would occur. If an overflow would have occurred then the wrapped value is returned.
Expand Down Expand Up @@ -2470,7 +2470,7 @@ macro_rules! int_impl {
(c, b != d)
}

/// Calculates `self` - `rhs` with an unsigned `rhs`
/// Calculates `self` - `rhs` with an unsigned `rhs`.
///
/// Returns a tuple of the subtraction along with a boolean indicating
/// whether an arithmetic overflow would occur. If an overflow would
Expand Down
24 changes: 12 additions & 12 deletions library/core/src/num/uint_macros.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1517,7 +1517,7 @@ macro_rules! uint_impl {
}
}

/// Unbounded shift left. Computes `self << rhs`, without bounding the value of `rhs`
/// Unbounded shift left. Computes `self << rhs`, without bounding the value of `rhs`.
///
/// If `rhs` is larger or equal to the number of bits in `self`,
/// the entire value is shifted out, and `0` is returned.
Expand Down Expand Up @@ -1640,7 +1640,7 @@ macro_rules! uint_impl {
}
}

/// Unbounded shift right. Computes `self >> rhs`, without bounding the value of `rhs`
/// Unbounded shift right. Computes `self >> rhs`, without bounding the value of `rhs`.
///
/// If `rhs` is larger or equal to the number of bits in `self`,
/// the entire value is shifted out, and `0` is returned.
Expand Down Expand Up @@ -2299,7 +2299,7 @@ macro_rules! uint_impl {
///
/// # Examples
///
/// Basic usage
/// Basic usage:
///
/// ```
#[doc = concat!("assert_eq!(5", stringify!($SelfT), ".overflowing_add(2), (7, false));")]
Expand Down Expand Up @@ -2389,15 +2389,15 @@ macro_rules! uint_impl {
(res, overflowed ^ (rhs < 0))
}

/// Calculates `self` - `rhs`
/// Calculates `self` - `rhs`.
///
/// Returns a tuple of the subtraction along with a boolean indicating
/// whether an arithmetic overflow would occur. If an overflow would
/// have occurred then the wrapped value is returned.
///
/// # Examples
///
/// Basic usage
/// Basic usage:
///
/// ```
#[doc = concat!("assert_eq!(5", stringify!($SelfT), ".overflowing_sub(2), (3, false));")]
Expand Down Expand Up @@ -2550,7 +2550,7 @@ macro_rules! uint_impl {
///
/// # Examples
///
/// Basic usage
/// Basic usage:
///
/// ```
#[doc = concat!("assert_eq!(5", stringify!($SelfT), ".overflowing_div(2), (2, false));")]
Expand Down Expand Up @@ -2581,7 +2581,7 @@ macro_rules! uint_impl {
///
/// # Examples
///
/// Basic usage
/// Basic usage:
///
/// ```
#[doc = concat!("assert_eq!(5", stringify!($SelfT), ".overflowing_div_euclid(2), (2, false));")]
Expand Down Expand Up @@ -2609,7 +2609,7 @@ macro_rules! uint_impl {
///
/// # Examples
///
/// Basic usage
/// Basic usage:
///
/// ```
#[doc = concat!("assert_eq!(5", stringify!($SelfT), ".overflowing_rem(2), (1, false));")]
Expand Down Expand Up @@ -2640,7 +2640,7 @@ macro_rules! uint_impl {
///
/// # Examples
///
/// Basic usage
/// Basic usage:
///
/// ```
#[doc = concat!("assert_eq!(5", stringify!($SelfT), ".overflowing_rem_euclid(2), (1, false));")]
Expand All @@ -2664,7 +2664,7 @@ macro_rules! uint_impl {
///
/// # Examples
///
/// Basic usage
/// Basic usage:
///
/// ```
#[doc = concat!("assert_eq!(0", stringify!($SelfT), ".overflowing_neg(), (0, false));")]
Expand All @@ -2689,7 +2689,7 @@ macro_rules! uint_impl {
///
/// # Examples
///
/// Basic usage
/// Basic usage:
///
/// ```
#[doc = concat!("assert_eq!(0x1", stringify!($SelfT), ".overflowing_shl(4), (0x10, false));")]
Expand All @@ -2715,7 +2715,7 @@ macro_rules! uint_impl {
///
/// # Examples
///
/// Basic usage
/// Basic usage:
///
/// ```
#[doc = concat!("assert_eq!(0x10", stringify!($SelfT), ".overflowing_shr(4), (0x1, false));")]
Expand Down
14 changes: 6 additions & 8 deletions library/core/src/ptr/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1407,9 +1407,8 @@ pub const unsafe fn read<T>(src: *const T) -> T {
/// As a result, using `&packed.unaligned as *const FieldType` causes immediate
/// *undefined behavior* in your program.
///
/// Instead you must use the [`ptr::addr_of!`](addr_of) macro to
/// create the pointer. You may use that returned pointer together with this
/// function.
/// Instead you must use the `&raw const` syntax to create the pointer.
/// You may use that constructed pointer together with this function.
///
/// An example of what not to do and how this relates to `read_unaligned` is:
///
Expand All @@ -1427,7 +1426,7 @@ pub const unsafe fn read<T>(src: *const T) -> T {
///
/// // Take the address of a 32-bit integer which is not aligned.
/// // In contrast to `&packed.unaligned as *const _`, this has no undefined behavior.
/// let unaligned = std::ptr::addr_of!(packed.unaligned);
/// let unaligned = &raw const packed.unaligned;
///
/// let v = unsafe { std::ptr::read_unaligned(unaligned) };
/// assert_eq!(v, 0x01020304);
Expand Down Expand Up @@ -1615,9 +1614,8 @@ pub const unsafe fn write<T>(dst: *mut T, src: T) {
/// As a result, using `&packed.unaligned as *const FieldType` causes immediate
/// *undefined behavior* in your program.
///
/// Instead, you must use the [`ptr::addr_of_mut!`](addr_of_mut)
/// macro to create the pointer. You may use that returned pointer together with
/// this function.
/// Instead, you must use the `&raw mut` syntax to create the pointer.
/// You may use that constructed pointer together with this function.
///
/// An example of how to do it and how this relates to `write_unaligned` is:
///
Expand All @@ -1632,7 +1630,7 @@ pub const unsafe fn write<T>(dst: *mut T, src: T) {
///
/// // Take the address of a 32-bit integer which is not aligned.
/// // In contrast to `&packed.unaligned as *mut _`, this has no undefined behavior.
/// let unaligned = std::ptr::addr_of_mut!(packed.unaligned);
/// let unaligned = &raw mut packed.unaligned;
///
/// unsafe { std::ptr::write_unaligned(unaligned, 42) };
///
Expand Down
2 changes: 1 addition & 1 deletion library/core/src/str/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2400,7 +2400,7 @@ impl str {
///
/// # Examples
///
/// Basic usage
/// Basic usage:
///
/// ```
/// let four: u32 = "4".parse().unwrap();
Expand Down
28 changes: 28 additions & 0 deletions library/std/src/fs/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -204,6 +204,13 @@ fn file_test_io_seek_and_write() {
}

#[test]
#[cfg(any(
windows,
target_os = "freebsd",
target_os = "linux",
target_os = "netbsd",
target_vendor = "apple",
))]
fn file_lock_multiple_shared() {
let tmpdir = tmpdir();
let filename = &tmpdir.join("file_lock_multiple_shared_test.txt");
Expand All @@ -220,6 +227,13 @@ fn file_lock_multiple_shared() {
}

#[test]
#[cfg(any(
windows,
target_os = "freebsd",
target_os = "linux",
target_os = "netbsd",
target_vendor = "apple",
))]
fn file_lock_blocking() {
let tmpdir = tmpdir();
let filename = &tmpdir.join("file_lock_blocking_test.txt");
Expand All @@ -237,6 +251,13 @@ fn file_lock_blocking() {
}

#[test]
#[cfg(any(
windows,
target_os = "freebsd",
target_os = "linux",
target_os = "netbsd",
target_vendor = "apple",
))]
fn file_lock_drop() {
let tmpdir = tmpdir();
let filename = &tmpdir.join("file_lock_dup_test.txt");
Expand All @@ -251,6 +272,13 @@ fn file_lock_drop() {
}

#[test]
#[cfg(any(
windows,
target_os = "freebsd",
target_os = "linux",
target_os = "netbsd",
target_vendor = "apple",
))]
fn file_lock_dup() {
let tmpdir = tmpdir();
let filename = &tmpdir.join("file_lock_dup_test.txt");
Expand Down
45 changes: 45 additions & 0 deletions library/std/src/io/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1340,6 +1340,25 @@ impl<'a> IoSliceMut<'a> {
bufs[0].advance(left);
}
}

/// Get the underlying bytes as a mutable slice with the original lifetime.
///
/// # Examples
///
/// ```
/// #![feature(io_slice_as_bytes)]
/// use std::io::IoSliceMut;
///
/// let mut data = *b"abcdef";
/// let io_slice = IoSliceMut::new(&mut data);
/// io_slice.into_slice()[0] = b'A';
///
/// assert_eq!(&data, b"Abcdef");
/// ```
#[unstable(feature = "io_slice_as_bytes", issue = "132818")]
pub const fn into_slice(self) -> &'a mut [u8] {
self.0.into_slice()
}
}

#[stable(feature = "iovec", since = "1.36.0")]
Expand Down Expand Up @@ -1482,6 +1501,32 @@ impl<'a> IoSlice<'a> {
bufs[0].advance(left);
}
}

/// Get the underlying bytes as a slice with the original lifetime.
///
/// This doesn't borrow from `self`, so is less restrictive than calling
/// `.deref()`, which does.
///
/// # Examples
///
/// ```
/// #![feature(io_slice_as_bytes)]
/// use std::io::IoSlice;
///
/// let data = b"abcdef";
///
/// let mut io_slice = IoSlice::new(data);
/// let tail = &io_slice.as_slice()[3..];
///
/// // This works because `tail` doesn't borrow `io_slice`
/// io_slice = IoSlice::new(tail);
///
/// assert_eq!(io_slice.as_slice(), b"def");
/// ```
#[unstable(feature = "io_slice_as_bytes", issue = "132818")]
pub const fn as_slice(self) -> &'a [u8] {
self.0.as_slice()
}
}

#[stable(feature = "iovec", since = "1.36.0")]
Expand Down
14 changes: 14 additions & 0 deletions library/std/src/io/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -531,6 +531,20 @@ fn io_slice_advance_slices_beyond_total_length() {
assert!(bufs.is_empty());
}

#[test]
fn io_slice_as_slice() {
let buf = [1; 8];
let slice = IoSlice::new(&buf).as_slice();
assert_eq!(slice, buf);
}

#[test]
fn io_slice_into_slice() {
let mut buf = [1; 8];
let slice = IoSliceMut::new(&mut buf).into_slice();
assert_eq!(slice, [1; 8]);
}

/// Creates a new writer that reads from at most `n_bufs` and reads
/// `per_call` bytes (in total) per call to write.
fn test_writer(n_bufs: usize, per_call: usize) -> TestWriter {
Expand Down
7 changes: 6 additions & 1 deletion library/std/src/sys/pal/hermit/io.rs
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ impl<'a> IoSlice<'a> {
}

#[inline]
pub fn as_slice(&self) -> &[u8] {
pub const fn as_slice(&self) -> &'a [u8] {
unsafe { slice::from_raw_parts(self.vec.iov_base as *mut u8, self.vec.iov_len) }
}
}
Expand Down Expand Up @@ -70,6 +70,11 @@ impl<'a> IoSliceMut<'a> {
unsafe { slice::from_raw_parts(self.vec.iov_base as *mut u8, self.vec.iov_len) }
}

#[inline]
pub const fn into_slice(self) -> &'a mut [u8] {
unsafe { slice::from_raw_parts_mut(self.vec.iov_base as *mut u8, self.vec.iov_len) }
}

#[inline]
pub fn as_mut_slice(&mut self) -> &mut [u8] {
unsafe { slice::from_raw_parts_mut(self.vec.iov_base as *mut u8, self.vec.iov_len) }
Expand Down
Loading
Loading