Skip to content

Commit

Permalink
Auto merge of rust-lang#127674 - jhpratt:rollup-0dxy3k7, r=jhpratt
Browse files Browse the repository at this point in the history
Rollup of 3 pull requests

Successful merges:

 - rust-lang#127654 (Fix incorrect NDEBUG handling in LLVM bindings)
 - rust-lang#127661 (Stabilize io_slice_advance)
 - rust-lang#127668 (Improved slice documentation)

r? `@ghost`
`@rustbot` modify labels: rollup
  • Loading branch information
bors committed Jul 13, 2024
2 parents 0065384 + f011913 commit 44fb857
Show file tree
Hide file tree
Showing 6 changed files with 64 additions and 38 deletions.
2 changes: 1 addition & 1 deletion compiler/rustc_codegen_llvm/src/llvm/ffi.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2057,7 +2057,7 @@ extern "C" {
AddrOpsCount: c_uint,
DL: &'a DILocation,
InsertAtEnd: &'a BasicBlock,
) -> &'a Value;
);

pub fn LLVMRustDIBuilderCreateEnumerator<'a>(
Builder: &DIBuilder<'a>,
Expand Down
3 changes: 1 addition & 2 deletions compiler/rustc_llvm/build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -197,9 +197,8 @@ fn main() {
cfg.define("LLVM_RUSTLLVM", None);
}

if tracked_env_var_os("LLVM_NDEBUG").is_some() {
if tracked_env_var_os("LLVM_ASSERTIONS").is_none() {
cfg.define("NDEBUG", None);
cfg.debug(false);
}

rerun_if_changed_anything_in_dir(Path::new("llvm-wrapper"));
Expand Down
17 changes: 6 additions & 11 deletions compiler/rustc_llvm/llvm-wrapper/RustWrapper.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1137,20 +1137,15 @@ LLVMRustDIBuilderGetOrCreateArray(LLVMRustDIBuilderRef Builder,
Builder->getOrCreateArray(ArrayRef<Metadata *>(DataValue, Count)).get());
}

extern "C" LLVMValueRef LLVMRustDIBuilderInsertDeclareAtEnd(
extern "C" void LLVMRustDIBuilderInsertDeclareAtEnd(
LLVMRustDIBuilderRef Builder, LLVMValueRef V, LLVMMetadataRef VarInfo,
uint64_t *AddrOps, unsigned AddrOpsCount, LLVMMetadataRef DL,
LLVMBasicBlockRef InsertAtEnd) {
auto Result = Builder->insertDeclare(
unwrap(V), unwrap<DILocalVariable>(VarInfo),
Builder->createExpression(
llvm::ArrayRef<uint64_t>(AddrOps, AddrOpsCount)),
DebugLoc(cast<MDNode>(unwrap(DL))), unwrap(InsertAtEnd));
#if LLVM_VERSION_GE(19, 0)
return wrap(Result.get<llvm::Instruction *>());
#else
return wrap(Result);
#endif
Builder->insertDeclare(unwrap(V), unwrap<DILocalVariable>(VarInfo),
Builder->createExpression(
llvm::ArrayRef<uint64_t>(AddrOps, AddrOpsCount)),
DebugLoc(cast<MDNode>(unwrap(DL))),
unwrap(InsertAtEnd));
}

extern "C" LLVMMetadataRef LLVMRustDIBuilderCreateEnumerator(
Expand Down
60 changes: 50 additions & 10 deletions library/core/src/slice/iter.rs
Original file line number Diff line number Diff line change
Expand Up @@ -388,6 +388,9 @@ pub(super) trait SplitIter: DoubleEndedIterator {
/// ```
/// let slice = [10, 40, 33, 20];
/// let mut iter = slice.split(|num| num % 3 == 0);
/// assert_eq!(iter.next(), Some(&[10, 40][..]));
/// assert_eq!(iter.next(), Some(&[20][..]));
/// assert_eq!(iter.next(), None);
/// ```
///
/// [`split`]: slice::split
Expand Down Expand Up @@ -541,6 +544,9 @@ impl<T, P> FusedIterator for Split<'_, T, P> where P: FnMut(&T) -> bool {}
/// ```
/// let slice = [10, 40, 33, 20];
/// let mut iter = slice.split_inclusive(|num| num % 3 == 0);
/// assert_eq!(iter.next(), Some(&[10, 40, 33][..]));
/// assert_eq!(iter.next(), Some(&[20][..]));
/// assert_eq!(iter.next(), None);
/// ```
///
/// [`split_inclusive`]: slice::split_inclusive
Expand Down Expand Up @@ -914,7 +920,10 @@ impl<T, P> FusedIterator for SplitInclusiveMut<'_, T, P> where P: FnMut(&T) -> b
///
/// ```
/// let slice = [11, 22, 33, 0, 44, 55];
/// let iter = slice.rsplit(|num| *num == 0);
/// let mut iter = slice.rsplit(|num| *num == 0);
/// assert_eq!(iter.next(), Some(&[44, 55][..]));
/// assert_eq!(iter.next(), Some(&[11, 22, 33][..]));
/// assert_eq!(iter.next(), None);
/// ```
///
/// [`rsplit`]: slice::rsplit
Expand Down Expand Up @@ -1134,7 +1143,10 @@ impl<T, I: SplitIter<Item = T>> Iterator for GenericSplitN<I> {
///
/// ```
/// let slice = [10, 40, 30, 20, 60, 50];
/// let iter = slice.splitn(2, |num| *num % 3 == 0);
/// let mut iter = slice.splitn(2, |num| *num % 3 == 0);
/// assert_eq!(iter.next(), Some(&[10, 40][..]));
/// assert_eq!(iter.next(), Some(&[20, 60, 50][..]));
/// assert_eq!(iter.next(), None);
/// ```
///
/// [`splitn`]: slice::splitn
Expand Down Expand Up @@ -1175,7 +1187,10 @@ where
///
/// ```
/// let slice = [10, 40, 30, 20, 60, 50];
/// let iter = slice.rsplitn(2, |num| *num % 3 == 0);
/// let mut iter = slice.rsplitn(2, |num| *num % 3 == 0);
/// assert_eq!(iter.next(), Some(&[50][..]));
/// assert_eq!(iter.next(), Some(&[10, 40, 30, 20][..]));
/// assert_eq!(iter.next(), None);
/// ```
///
/// [`rsplitn`]: slice::rsplitn
Expand Down Expand Up @@ -1300,7 +1315,11 @@ forward_iterator! { RSplitNMut: T, &'a mut [T] }
///
/// ```
/// let slice = ['r', 'u', 's', 't'];
/// let iter = slice.windows(2);
/// let mut iter = slice.windows(2);
/// assert_eq!(iter.next(), Some(&['r', 'u'][..]));
/// assert_eq!(iter.next(), Some(&['u', 's'][..]));
/// assert_eq!(iter.next(), Some(&['s', 't'][..]));
/// assert_eq!(iter.next(), None);
/// ```
///
/// [`windows`]: slice::windows
Expand Down Expand Up @@ -1448,7 +1467,11 @@ unsafe impl<'a, T> TrustedRandomAccessNoCoerce for Windows<'a, T> {
///
/// ```
/// let slice = ['l', 'o', 'r', 'e', 'm'];
/// let iter = slice.chunks(2);
/// let mut iter = slice.chunks(2);
/// assert_eq!(iter.next(), Some(&['l', 'o'][..]));
/// assert_eq!(iter.next(), Some(&['r', 'e'][..]));
/// assert_eq!(iter.next(), Some(&['m'][..]));
/// assert_eq!(iter.next(), None);
/// ```
///
/// [`chunks`]: slice::chunks
Expand Down Expand Up @@ -1819,7 +1842,10 @@ unsafe impl<T> Sync for ChunksMut<'_, T> where T: Sync {}
///
/// ```
/// let slice = ['l', 'o', 'r', 'e', 'm'];
/// let iter = slice.chunks_exact(2);
/// let mut iter = slice.chunks_exact(2);
/// assert_eq!(iter.next(), Some(&['l', 'o'][..]));
/// assert_eq!(iter.next(), Some(&['r', 'e'][..]));
/// assert_eq!(iter.next(), None);
/// ```
///
/// [`chunks_exact`]: slice::chunks_exact
Expand Down Expand Up @@ -2163,7 +2189,11 @@ unsafe impl<T> Sync for ChunksExactMut<'_, T> where T: Sync {}
/// #![feature(array_windows)]
///
/// let slice = [0, 1, 2, 3];
/// let iter = slice.array_windows::<2>();
/// let mut iter = slice.array_windows::<2>();
/// assert_eq!(iter.next(), Some(&[0, 1]));
/// assert_eq!(iter.next(), Some(&[1, 2]));
/// assert_eq!(iter.next(), Some(&[2, 3]));
/// assert_eq!(iter.next(), None);
/// ```
///
/// [`array_windows`]: slice::array_windows
Expand Down Expand Up @@ -2285,7 +2315,10 @@ impl<T, const N: usize> ExactSizeIterator for ArrayWindows<'_, T, N> {
/// #![feature(array_chunks)]
///
/// let slice = ['l', 'o', 'r', 'e', 'm'];
/// let iter = slice.array_chunks::<2>();
/// let mut iter = slice.array_chunks::<2>();
/// assert_eq!(iter.next(), Some(&['l', 'o']));
/// assert_eq!(iter.next(), Some(&['r', 'e']));
/// assert_eq!(iter.next(), None);
/// ```
///
/// [`array_chunks`]: slice::array_chunks
Expand Down Expand Up @@ -2526,7 +2559,11 @@ unsafe impl<'a, T, const N: usize> TrustedRandomAccessNoCoerce for ArrayChunksMu
///
/// ```
/// let slice = ['l', 'o', 'r', 'e', 'm'];
/// let iter = slice.rchunks(2);
/// let mut iter = slice.rchunks(2);
/// assert_eq!(iter.next(), Some(&['e', 'm'][..]));
/// assert_eq!(iter.next(), Some(&['o', 'r'][..]));
/// assert_eq!(iter.next(), Some(&['l'][..]));
/// assert_eq!(iter.next(), None);
/// ```
///
/// [`rchunks`]: slice::rchunks
Expand Down Expand Up @@ -2892,7 +2929,10 @@ unsafe impl<T> Sync for RChunksMut<'_, T> where T: Sync {}
///
/// ```
/// let slice = ['l', 'o', 'r', 'e', 'm'];
/// let iter = slice.rchunks_exact(2);
/// let mut iter = slice.rchunks_exact(2);
/// assert_eq!(iter.next(), Some(&['e', 'm'][..]));
/// assert_eq!(iter.next(), Some(&['o', 'r'][..]));
/// assert_eq!(iter.next(), None);
/// ```
///
/// [`rchunks_exact`]: slice::rchunks_exact
Expand Down
16 changes: 4 additions & 12 deletions library/std/src/io/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1256,8 +1256,6 @@ impl<'a> IoSliceMut<'a> {
/// # Examples
///
/// ```
/// #![feature(io_slice_advance)]
///
/// use std::io::IoSliceMut;
/// use std::ops::Deref;
///
Expand All @@ -1268,7 +1266,7 @@ impl<'a> IoSliceMut<'a> {
/// buf.advance(3);
/// assert_eq!(buf.deref(), [1; 5].as_ref());
/// ```
#[unstable(feature = "io_slice_advance", issue = "62726")]
#[stable(feature = "io_slice_advance", since = "CURRENT_RUSTC_VERSION")]
#[inline]
pub fn advance(&mut self, n: usize) {
self.0.advance(n)
Expand All @@ -1290,8 +1288,6 @@ impl<'a> IoSliceMut<'a> {
/// # Examples
///
/// ```
/// #![feature(io_slice_advance)]
///
/// use std::io::IoSliceMut;
/// use std::ops::Deref;
///
Expand All @@ -1309,7 +1305,7 @@ impl<'a> IoSliceMut<'a> {
/// assert_eq!(bufs[0].deref(), [2; 14].as_ref());
/// assert_eq!(bufs[1].deref(), [3; 8].as_ref());
/// ```
#[unstable(feature = "io_slice_advance", issue = "62726")]
#[stable(feature = "io_slice_advance", since = "CURRENT_RUSTC_VERSION")]
#[inline]
pub fn advance_slices(bufs: &mut &mut [IoSliceMut<'a>], n: usize) {
// Number of buffers to remove.
Expand Down Expand Up @@ -1400,8 +1396,6 @@ impl<'a> IoSlice<'a> {
/// # Examples
///
/// ```
/// #![feature(io_slice_advance)]
///
/// use std::io::IoSlice;
/// use std::ops::Deref;
///
Expand All @@ -1412,7 +1406,7 @@ impl<'a> IoSlice<'a> {
/// buf.advance(3);
/// assert_eq!(buf.deref(), [1; 5].as_ref());
/// ```
#[unstable(feature = "io_slice_advance", issue = "62726")]
#[stable(feature = "io_slice_advance", since = "CURRENT_RUSTC_VERSION")]
#[inline]
pub fn advance(&mut self, n: usize) {
self.0.advance(n)
Expand All @@ -1434,8 +1428,6 @@ impl<'a> IoSlice<'a> {
/// # Examples
///
/// ```
/// #![feature(io_slice_advance)]
///
/// use std::io::IoSlice;
/// use std::ops::Deref;
///
Expand All @@ -1452,7 +1444,7 @@ impl<'a> IoSlice<'a> {
/// IoSlice::advance_slices(&mut bufs, 10);
/// assert_eq!(bufs[0].deref(), [2; 14].as_ref());
/// assert_eq!(bufs[1].deref(), [3; 8].as_ref());
#[unstable(feature = "io_slice_advance", issue = "62726")]
#[stable(feature = "io_slice_advance", since = "CURRENT_RUSTC_VERSION")]
#[inline]
pub fn advance_slices(bufs: &mut &mut [IoSlice<'a>], n: usize) {
// Number of buffers to remove.
Expand Down
4 changes: 2 additions & 2 deletions src/bootstrap/src/core/build_steps/compile.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1213,8 +1213,8 @@ fn rustc_llvm_env(builder: &Builder<'_>, cargo: &mut Cargo, target: TargetSelect
if builder.config.llvm_use_libcxx {
cargo.env("LLVM_USE_LIBCXX", "1");
}
if builder.config.llvm_optimize && !builder.config.llvm_release_debuginfo {
cargo.env("LLVM_NDEBUG", "1");
if builder.config.llvm_assertions {
cargo.env("LLVM_ASSERTIONS", "1");
}
}

Expand Down

0 comments on commit 44fb857

Please sign in to comment.