Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
18 commits
Select commit Hold shift + click to select a range
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
13 changes: 6 additions & 7 deletions compiler/rustc_codegen_ssa/src/back/archive.rs
Original file line number Diff line number Diff line change
Expand Up @@ -217,12 +217,10 @@ fn create_mingw_dll_import_lib(
// able to control the *exact* spelling of each of the symbols that are being imported:
// hence we don't want `dlltool` adding leading underscores automatically.
let dlltool = find_binutils_dlltool(sess);
let temp_prefix = {
let mut path = PathBuf::from(&output_path);
path.pop();
path.push(lib_name);
path
};
// temp_prefix doesn't handle paths with spaces so
// use a relative path and set the current working directory
let cwd = output_path.parent().unwrap_or(output_path);
let temp_prefix = lib_name;
// dlltool target architecture args from:
// https://github.com/llvm/llvm-project-release-prs/blob/llvmorg-15.0.6/llvm/lib/ToolDrivers/llvm-dlltool/DlltoolDriver.cpp#L69
let (dlltool_target_arch, dlltool_target_bitness) = match &sess.target.arch {
Expand All @@ -246,7 +244,8 @@ fn create_mingw_dll_import_lib(
.arg(dlltool_target_bitness)
.arg("--no-leading-underscore")
.arg("--temp-prefix")
.arg(temp_prefix);
.arg(temp_prefix)
.current_dir(cwd);

match dlltool_cmd.output() {
Err(e) => {
Expand Down
13 changes: 8 additions & 5 deletions compiler/rustc_index/src/bit_set.rs
Original file line number Diff line number Diff line change
Expand Up @@ -833,13 +833,16 @@ impl<T: Idx> BitRelations<ChunkedBitSet<T>> for ChunkedBitSet<T> {
changed = true;
let num_words = num_words(*chunk_domain_size as usize);
debug_assert!(num_words > 0 && num_words <= CHUNK_WORDS);
let mut tail_mask =
1 << (*chunk_domain_size - ((num_words - 1) * WORD_BITS) as u16) - 1;
// Set `self_chunk_words` to `other_chunk_words`, then invert all bits and
// clear any excess bits in the final word.
let mut self_chunk_words = **other_chunk_words;
for word in self_chunk_words[0..num_words].iter_mut().rev() {
*word = !*word & tail_mask;
tail_mask = Word::MAX;
for word in self_chunk_words[0..num_words].iter_mut() {
*word = !*word;
}
clear_excess_bits_in_final_word(
*chunk_domain_size as usize,
&mut self_chunk_words[..num_words],
);
let self_chunk_ones_count = *chunk_domain_size - *other_chunk_ones_count;
debug_assert_eq!(
self_chunk_ones_count,
Expand Down
27 changes: 27 additions & 0 deletions compiler/rustc_index/src/bit_set/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -333,6 +333,33 @@ fn chunked_bitset() {
assert_eq!(b10000.count(), 6000);
b10000.assert_valid();
b10000b.assert_valid();

//-----------------------------------------------------------------------

let mut b64 = ChunkedBitSet::<usize>::new_filled(64);

let mut b64b = ChunkedBitSet::<usize>::new_empty(64);
b64b.insert(0);

b64.subtract(&b64b);
assert!(!b64.contains(0));
assert!(b64.contains(10));
assert!(b64.contains(50));
assert!(b64.contains(63));
assert_eq!(
b64.chunks(),
#[rustfmt::skip]
vec![
Mixed {
chunk_domain_size: 64,
ones_count: 63,
words: Rc::new([
0xfffffffffffffffe, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
])
},
],
);
}

fn with_elements_chunked(elements: &[usize], domain_size: usize) -> ChunkedBitSet<usize> {
Expand Down
21 changes: 11 additions & 10 deletions library/alloc/src/str.rs
Original file line number Diff line number Diff line change
Expand Up @@ -135,13 +135,9 @@ macro_rules! copy_slice_and_advance {
//
// This implementation calls `borrow()` multiple times:
// 1. To calculate `reserved_len`, all elements are borrowed once.
// 2. The first element is borrowed again when copied via `extend_from_slice`.
// 3. Subsequent elements are borrowed a second time when building the mapped iterator.
// 2. All elements, except the first, are borrowed a second time when building the mapped iterator.
//
// Risks and Mitigations:
// - If the first element GROWS on the second borrow, the length subtraction underflows.
// We mitigate this by doing a `checked_sub` to panic rather than allowing an underflow
// that fabricates a huge destination slice.
// - If elements 2..N GROW on their second borrow, the target slice bounds set by `checked_sub`
// means that `split_at_mut` inside `copy_slice_and_advance!` will correctly panic.
// - If elements SHRINK on their second borrow, the spare space is never written, and the final
Expand All @@ -157,8 +153,10 @@ where
let mut iter = slice.iter();

// the first slice is the only one without a separator preceding it
// we take care to only borrow this once during the length calculation
// to avoid inconsistent Borrow implementations from breaking our assumptions
let first = match iter.next() {
Some(first) => first,
Some(first) => first.borrow().as_ref(),
None => return vec![],
};

Expand All @@ -168,21 +166,24 @@ where
// the entire Vec pre-allocated for safety
let reserved_len = sep_len
.checked_mul(iter.len())
.and_then(|n| n.checked_add(first.len()))
.and_then(|n| {
slice.iter().map(|s| s.borrow().as_ref().len()).try_fold(n, usize::checked_add)
// iter starts from the second element as we've already taken the first
// it's cloned so we can reuse the same iterator below
iter.clone().map(|s| s.borrow().as_ref().len()).try_fold(n, usize::checked_add)
})
.expect("attempt to join into collection with len > usize::MAX");

// prepare an uninitialized buffer
let mut result = Vec::with_capacity(reserved_len);
debug_assert!(result.capacity() >= reserved_len);

result.extend_from_slice(first.borrow().as_ref());
result.extend_from_slice(first);

unsafe {
let pos = result.len();
let target_len = reserved_len.checked_sub(pos).expect("inconsistent Borrow implementation");
let target = result.spare_capacity_mut().get_unchecked_mut(..target_len);
debug_assert!(reserved_len >= pos);
let target = result.spare_capacity_mut().get_unchecked_mut(..reserved_len - pos);

// Convert the separator and slices to slices of MaybeUninit
// to simplify implementation in specialize_for_lengths.
Expand Down
2 changes: 1 addition & 1 deletion library/alloc/src/string.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1420,7 +1420,7 @@ impl String {

// SAFETY: Just reserved capacity for at least the length needed to encode `ch`.
unsafe {
core::char::encode_utf8_raw_unchecked(ch as u32, self.vec.as_mut_ptr().add(self.len()));
core::char::encode_utf8_raw_unchecked(ch as u32, self.vec.as_mut_ptr().add(len));
self.vec.set_len(len + ch_len);
}
}
Expand Down
8 changes: 4 additions & 4 deletions library/alloctests/tests/str.rs
Original file line number Diff line number Diff line change
Expand Up @@ -164,7 +164,7 @@ fn test_join_for_different_lengths_with_long_separator() {
}

#[test]
fn test_join_issue_80335() {
fn test_join_inconsistent_borrow_shrink() {
use core::borrow::Borrow;
use core::cell::Cell;

Expand All @@ -191,12 +191,12 @@ fn test_join_issue_80335() {
}

let arr: [WeirdBorrow; 3] = Default::default();
test_join!("0-0-0", arr, "-");
test_join!("123456-0-0", arr, "-");
}

#[test]
#[should_panic(expected = "inconsistent Borrow implementation")]
fn test_join_inconsistent_borrow() {
#[should_panic(expected = "mid > len")]
fn test_join_inconsistent_borrow_grow() {
use std::borrow::Borrow;
use std::cell::Cell;

Expand Down
6 changes: 0 additions & 6 deletions library/std/src/io/pipe.rs
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,6 @@ use crate::sys::{FromInner, IntoInner, pipe as imp};
/// # Example
///
/// ```no_run
/// # #[cfg(miri)] fn main() {}
/// # #[cfg(not(miri))]
/// # fn main() -> std::io::Result<()> {
/// use std::io::{Read, Write, pipe};
/// use std::process::Command;
Expand Down Expand Up @@ -126,8 +124,6 @@ impl PipeReader {
/// # Examples
///
/// ```no_run
/// # #[cfg(miri)] fn main() {}
/// # #[cfg(not(miri))]
/// # fn main() -> std::io::Result<()> {
/// use std::fs;
/// use std::io::{pipe, Write};
Expand Down Expand Up @@ -185,8 +181,6 @@ impl PipeWriter {
/// # Examples
///
/// ```no_run
/// # #[cfg(miri)] fn main() {}
/// # #[cfg(not(miri))]
/// # fn main() -> std::io::Result<()> {
/// use std::process::Command;
/// use std::io::{pipe, Read};
Expand Down
1 change: 0 additions & 1 deletion library/std/src/io/pipe/tests.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
use crate::io::{Read, Write, pipe};

#[test]
#[cfg(all(any(unix, windows), not(miri)))]
fn pipe_creation_clone_and_rw() {
let (rx, tx) = pipe().unwrap();

Expand Down
2 changes: 1 addition & 1 deletion src/llvm-project
Submodule llvm-project updated 132 files
2 changes: 1 addition & 1 deletion tests/ui/attributes/attr-before-view-item.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
//@ build-pass (FIXME(62277): could be check-pass?)
//@ check-pass

#![feature(rustc_attrs)]
#![feature(test)]
Expand Down
2 changes: 1 addition & 1 deletion tests/ui/attributes/attr-before-view-item2.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
//@ build-pass (FIXME(62277): could be check-pass?)
//@ check-pass

#![feature(rustc_attrs)]
#![feature(test)]
Expand Down
2 changes: 1 addition & 1 deletion tests/ui/attributes/attr-mix-new.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
//@ build-pass (FIXME(62277): could be check-pass?)
//@ check-pass

#![feature(rustc_attrs)]

Expand Down
19 changes: 0 additions & 19 deletions tests/ui/attributes/class-attributes-1.rs

This file was deleted.

31 changes: 0 additions & 31 deletions tests/ui/attributes/class-attributes-2.rs

This file was deleted.

2 changes: 1 addition & 1 deletion tests/ui/attributes/method-attributes.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
//@ build-pass (FIXME(62277): could be check-pass?)
//@ check-pass
//@ pp-exact - Make sure we print all the attributes

#![feature(rustc_attrs)]
Expand Down
2 changes: 1 addition & 1 deletion tests/ui/attributes/unrestricted-attribute-tokens.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
//@ build-pass (FIXME(62277): could be check-pass?)
//@ check-pass

#![feature(rustc_attrs)]

Expand Down
2 changes: 1 addition & 1 deletion tests/ui/attributes/variant-attributes.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
//@ build-pass (FIXME(62277): could be check-pass?)
//@ check-pass
//@ pp-exact - Make sure we actually print the attributes

#![allow(non_camel_case_types)]
Expand Down
2 changes: 1 addition & 1 deletion tests/ui/conditional-compilation/cfg-attr-multi-false.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// Test that cfg_attr doesn't emit any attributes when the
// configuration variable is false. This mirrors `cfg-attr-multi-true.rs`

//@ build-pass (FIXME(62277): could be check-pass?)
//@ check-pass

#![warn(unused_must_use)]

Expand Down
2 changes: 1 addition & 1 deletion tests/ui/conditional-compilation/cfg-attr-multi-true.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
// This is done by emitting two attributes that cause new warnings, and then
// triggering those warnings.

//@ build-pass (FIXME(62277): could be check-pass?)
//@ check-pass

#![warn(unused_must_use)]

Expand Down
11 changes: 11 additions & 0 deletions tests/ui/consts/const-eval/static-promotion-issue-101363.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
//@ check-pass
// Regression test for <https://github.com/rust-lang/rust/issues/101363>

const OPTIONAL_SLICE_V1: Option<&'static [u8]> = Some(&{
let array = [1, 2, 3];
array
});

fn main() {
let _ = OPTIONAL_SLICE_V1;
}
2 changes: 1 addition & 1 deletion tests/ui/range/range_traits-4.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
//@ build-pass (FIXME(62277): could be check-pass?)
//@ check-pass

use std::ops::*;

Expand Down
2 changes: 1 addition & 1 deletion tests/ui/range/range_traits-5.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
//@ build-pass (FIXME(62277): could be check-pass?)
//@ check-pass

use std::ops::*;

Expand Down
2 changes: 1 addition & 1 deletion tests/ui/range/range_traits-7.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
//@ build-pass (FIXME(62277): could be check-pass?)
//@ check-pass

use std::ops::*;

Expand Down
2 changes: 1 addition & 1 deletion tests/ui/reachable/expr_andand.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
//@ build-pass (FIXME(62277): could be check-pass?)
//@ check-pass

#![allow(unused_variables)]
#![allow(dead_code)]
Expand Down
2 changes: 1 addition & 1 deletion tests/ui/reachable/expr_oror.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
//@ build-pass (FIXME(62277): could be check-pass?)
//@ check-pass

#![allow(unused_variables)]
#![allow(dead_code)]
Expand Down
Loading