diff --git a/compiler/rustc_codegen_ssa/src/back/archive.rs b/compiler/rustc_codegen_ssa/src/back/archive.rs index 3f12e857391b2..9b9fa737d6d8d 100644 --- a/compiler/rustc_codegen_ssa/src/back/archive.rs +++ b/compiler/rustc_codegen_ssa/src/back/archive.rs @@ -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 { @@ -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) => { diff --git a/compiler/rustc_index/src/bit_set.rs b/compiler/rustc_index/src/bit_set.rs index 98bda252b2e75..02e5feb6c5f21 100644 --- a/compiler/rustc_index/src/bit_set.rs +++ b/compiler/rustc_index/src/bit_set.rs @@ -833,13 +833,16 @@ impl BitRelations> for ChunkedBitSet { 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, diff --git a/compiler/rustc_index/src/bit_set/tests.rs b/compiler/rustc_index/src/bit_set/tests.rs index c6d211f3039b1..eaf9c62c954f7 100644 --- a/compiler/rustc_index/src/bit_set/tests.rs +++ b/compiler/rustc_index/src/bit_set/tests.rs @@ -333,6 +333,33 @@ fn chunked_bitset() { assert_eq!(b10000.count(), 6000); b10000.assert_valid(); b10000b.assert_valid(); + + //----------------------------------------------------------------------- + + let mut b64 = ChunkedBitSet::::new_filled(64); + + let mut b64b = ChunkedBitSet::::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 { diff --git a/library/alloc/src/str.rs b/library/alloc/src/str.rs index 98120896bc9b5..1f135a48224f1 100644 --- a/library/alloc/src/str.rs +++ b/library/alloc/src/str.rs @@ -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 @@ -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![], }; @@ -168,8 +166,11 @@ 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"); @@ -177,12 +178,12 @@ where 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. diff --git a/library/alloc/src/string.rs b/library/alloc/src/string.rs index 30e52f3e1be46..4e97dfd2d561e 100644 --- a/library/alloc/src/string.rs +++ b/library/alloc/src/string.rs @@ -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); } } diff --git a/library/alloctests/tests/str.rs b/library/alloctests/tests/str.rs index 49baa53c9d3ed..f1bd5325da587 100644 --- a/library/alloctests/tests/str.rs +++ b/library/alloctests/tests/str.rs @@ -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; @@ -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; diff --git a/library/std/src/io/pipe.rs b/library/std/src/io/pipe.rs index 61b81cf074a6e..e05ccb32a122d 100644 --- a/library/std/src/io/pipe.rs +++ b/library/std/src/io/pipe.rs @@ -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; @@ -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}; @@ -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}; diff --git a/library/std/src/io/pipe/tests.rs b/library/std/src/io/pipe/tests.rs index f113b157459d3..2c2d35cc63d9e 100644 --- a/library/std/src/io/pipe/tests.rs +++ b/library/std/src/io/pipe/tests.rs @@ -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(); diff --git a/src/llvm-project b/src/llvm-project index 1cb4e3833c191..eaab4d9841b9a 160000 --- a/src/llvm-project +++ b/src/llvm-project @@ -1 +1 @@ -Subproject commit 1cb4e3833c1919c2e6fb579a23ac0e2b22587b7e +Subproject commit eaab4d9841b9a8a12783d927b2df2291c1c79269 diff --git a/tests/ui/attributes/attr-before-view-item.rs b/tests/ui/attributes/attr-before-view-item.rs index 19874052e3368..5cc80f4bf1a08 100644 --- a/tests/ui/attributes/attr-before-view-item.rs +++ b/tests/ui/attributes/attr-before-view-item.rs @@ -1,4 +1,4 @@ -//@ build-pass (FIXME(62277): could be check-pass?) +//@ check-pass #![feature(rustc_attrs)] #![feature(test)] diff --git a/tests/ui/attributes/attr-before-view-item2.rs b/tests/ui/attributes/attr-before-view-item2.rs index e58063a13ab0a..eb40b0e6903e8 100644 --- a/tests/ui/attributes/attr-before-view-item2.rs +++ b/tests/ui/attributes/attr-before-view-item2.rs @@ -1,4 +1,4 @@ -//@ build-pass (FIXME(62277): could be check-pass?) +//@ check-pass #![feature(rustc_attrs)] #![feature(test)] diff --git a/tests/ui/attributes/attr-mix-new.rs b/tests/ui/attributes/attr-mix-new.rs index 3ddb1d0d7335c..b03f3cc25ddd7 100644 --- a/tests/ui/attributes/attr-mix-new.rs +++ b/tests/ui/attributes/attr-mix-new.rs @@ -1,4 +1,4 @@ -//@ build-pass (FIXME(62277): could be check-pass?) +//@ check-pass #![feature(rustc_attrs)] diff --git a/tests/ui/attributes/class-attributes-1.rs b/tests/ui/attributes/class-attributes-1.rs deleted file mode 100644 index 0c8f5f324a3ef..0000000000000 --- a/tests/ui/attributes/class-attributes-1.rs +++ /dev/null @@ -1,19 +0,0 @@ -//@ build-pass (FIXME(62277): could be check-pass?) -//@ pp-exact - Make sure we actually print the attributes - -#![feature(rustc_attrs)] - -struct Cat { - name: String, -} - -impl Drop for Cat { - #[rustc_dummy] - fn drop(&mut self) { println!("{} landed on hir feet" , self . name); } -} - - -#[rustc_dummy] -fn cat(name: String) -> Cat { Cat{name: name,} } - -fn main() { let _kitty = cat("Spotty".to_string()); } diff --git a/tests/ui/attributes/class-attributes-2.rs b/tests/ui/attributes/class-attributes-2.rs deleted file mode 100644 index 0ec0cd225969b..0000000000000 --- a/tests/ui/attributes/class-attributes-2.rs +++ /dev/null @@ -1,31 +0,0 @@ -//@ build-pass (FIXME(62277): could be check-pass?) - -#![feature(rustc_attrs)] - -struct Cat { - name: String, -} - -impl Drop for Cat { - #[rustc_dummy] - /** - Actually, cats don't always land on their feet when you drop them. - */ - fn drop(&mut self) { - println!("{} landed on hir feet", self.name); - } -} - -#[rustc_dummy] -/** -Maybe it should technically be a kitten_maker. -*/ -fn cat(name: String) -> Cat { - Cat { - name: name - } -} - -fn main() { - let _kitty = cat("Spotty".to_string()); -} diff --git a/tests/ui/attributes/method-attributes.rs b/tests/ui/attributes/method-attributes.rs index ded72d2457b1c..3d7f6f2149882 100644 --- a/tests/ui/attributes/method-attributes.rs +++ b/tests/ui/attributes/method-attributes.rs @@ -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)] diff --git a/tests/ui/attributes/unrestricted-attribute-tokens.rs b/tests/ui/attributes/unrestricted-attribute-tokens.rs index 9f91afb59bf81..9a0bb21c79666 100644 --- a/tests/ui/attributes/unrestricted-attribute-tokens.rs +++ b/tests/ui/attributes/unrestricted-attribute-tokens.rs @@ -1,4 +1,4 @@ -//@ build-pass (FIXME(62277): could be check-pass?) +//@ check-pass #![feature(rustc_attrs)] diff --git a/tests/ui/attributes/variant-attributes.rs b/tests/ui/attributes/variant-attributes.rs index a08856aa278d3..7020bdaf2557e 100644 --- a/tests/ui/attributes/variant-attributes.rs +++ b/tests/ui/attributes/variant-attributes.rs @@ -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)] diff --git a/tests/ui/conditional-compilation/cfg-attr-multi-false.rs b/tests/ui/conditional-compilation/cfg-attr-multi-false.rs index 871c1b81acd26..b323bc6bef2ab 100644 --- a/tests/ui/conditional-compilation/cfg-attr-multi-false.rs +++ b/tests/ui/conditional-compilation/cfg-attr-multi-false.rs @@ -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)] diff --git a/tests/ui/conditional-compilation/cfg-attr-multi-true.rs b/tests/ui/conditional-compilation/cfg-attr-multi-true.rs index 24950c8d42341..f4ddc6c89bc3a 100644 --- a/tests/ui/conditional-compilation/cfg-attr-multi-true.rs +++ b/tests/ui/conditional-compilation/cfg-attr-multi-true.rs @@ -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)] diff --git a/tests/ui/consts/const-eval/static-promotion-issue-101363.rs b/tests/ui/consts/const-eval/static-promotion-issue-101363.rs new file mode 100644 index 0000000000000..ff17377757653 --- /dev/null +++ b/tests/ui/consts/const-eval/static-promotion-issue-101363.rs @@ -0,0 +1,11 @@ +//@ check-pass +// Regression test for + +const OPTIONAL_SLICE_V1: Option<&'static [u8]> = Some(&{ + let array = [1, 2, 3]; + array +}); + +fn main() { + let _ = OPTIONAL_SLICE_V1; +} diff --git a/tests/ui/range/range_traits-4.rs b/tests/ui/range/range_traits-4.rs index 4241325e1d9af..39948bebe0be6 100644 --- a/tests/ui/range/range_traits-4.rs +++ b/tests/ui/range/range_traits-4.rs @@ -1,4 +1,4 @@ -//@ build-pass (FIXME(62277): could be check-pass?) +//@ check-pass use std::ops::*; diff --git a/tests/ui/range/range_traits-5.rs b/tests/ui/range/range_traits-5.rs index a15ea6a711296..0c737c964bcde 100644 --- a/tests/ui/range/range_traits-5.rs +++ b/tests/ui/range/range_traits-5.rs @@ -1,4 +1,4 @@ -//@ build-pass (FIXME(62277): could be check-pass?) +//@ check-pass use std::ops::*; diff --git a/tests/ui/range/range_traits-7.rs b/tests/ui/range/range_traits-7.rs index 95e101b0988cf..2648a7f023deb 100644 --- a/tests/ui/range/range_traits-7.rs +++ b/tests/ui/range/range_traits-7.rs @@ -1,4 +1,4 @@ -//@ build-pass (FIXME(62277): could be check-pass?) +//@ check-pass use std::ops::*; diff --git a/tests/ui/reachable/expr_andand.rs b/tests/ui/reachable/expr_andand.rs index 40a8c72e52249..f623aa55a94b4 100644 --- a/tests/ui/reachable/expr_andand.rs +++ b/tests/ui/reachable/expr_andand.rs @@ -1,4 +1,4 @@ -//@ build-pass (FIXME(62277): could be check-pass?) +//@ check-pass #![allow(unused_variables)] #![allow(dead_code)] diff --git a/tests/ui/reachable/expr_oror.rs b/tests/ui/reachable/expr_oror.rs index 4ee4b80744285..c5426b55b002a 100644 --- a/tests/ui/reachable/expr_oror.rs +++ b/tests/ui/reachable/expr_oror.rs @@ -1,4 +1,4 @@ -//@ build-pass (FIXME(62277): could be check-pass?) +//@ check-pass #![allow(unused_variables)] #![allow(dead_code)]