Auto merge of #139997 - matthiaskrgr:rollup-a1fe5zg, r=matthiaskrgr

Rollup of 6 pull requests

Successful merges:

 - #137881 (Add `copy_within` to `IndexSlice`)
 - #138599 (avoid overflow when generating debuginfo for expanding recursive types)
 - #139934 (Update `compiler-builtins` to 0.1.155)
 - #139976 (run-make: drop `os_pipe` workaround now that `anonymous_pipe` is stable on beta)
 - #139989 (tests: adjust 101082 test for LLVM 21 fix)
 - #139991 (remove stray file)

r? `@ghost`
`@rustbot` modify labels: rollup
This commit is contained in:
bors 2025-04-18 10:37:11 +00:00
commit 6a0bd27619
17 changed files with 86 additions and 97 deletions

View file

@ -2572,16 +2572,6 @@ version = "0.2.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "04744f49eae99ab78e0d5c0b603ab218f515ea8cfe5a456d7629ad883a3b6e7d"
[[package]]
name = "os_pipe"
version = "1.2.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "5ffd2b0a5634335b135d5728d84c5e0fd726954b87111f7506a61c502280d982"
dependencies = [
"libc",
"windows-sys 0.59.0",
]
[[package]]
name = "overload"
version = "0.1.1"
@ -3142,7 +3132,6 @@ dependencies = [
"gimli 0.31.1",
"libc",
"object 0.36.7",
"os_pipe",
"regex",
"serde_json",
"similar",

View file

@ -247,6 +247,16 @@ pub(super) fn stub<'ll, 'tcx>(
StubInfo { metadata, unique_type_id }
}
struct AdtStackPopGuard<'ll, 'tcx, 'a> {
cx: &'a CodegenCx<'ll, 'tcx>,
}
impl<'ll, 'tcx, 'a> Drop for AdtStackPopGuard<'ll, 'tcx, 'a> {
fn drop(&mut self) {
debug_context(self.cx).adt_stack.borrow_mut().pop();
}
}
/// This function enables creating debuginfo nodes that can recursively refer to themselves.
/// It will first insert the given stub into the type map and only then execute the `members`
/// and `generics` closures passed in. These closures have access to the stub so they can
@ -261,6 +271,44 @@ pub(super) fn build_type_with_children<'ll, 'tcx>(
) -> DINodeCreationResult<'ll> {
assert_eq!(debug_context(cx).type_map.di_node_for_unique_id(stub_info.unique_type_id), None);
let mut _adt_stack_pop_guard = None;
if let UniqueTypeId::Ty(ty, ..) = stub_info.unique_type_id
&& let ty::Adt(adt_def, args) = ty.kind()
{
let def_id = adt_def.did();
// If any sub type reference the original type definition and the sub type has a type
// parameter that strictly contains the original parameter, the original type is a recursive
// type that can expanding indefinitely. Example,
// ```
// enum Recursive<T> {
// Recurse(*const Recursive<Wrap<T>>),
// Item(T),
// }
// ```
let is_expanding_recursive =
debug_context(cx).adt_stack.borrow().iter().any(|(parent_def_id, parent_args)| {
if def_id == *parent_def_id {
args.iter().zip(parent_args.iter()).any(|(arg, parent_arg)| {
if let (Some(arg), Some(parent_arg)) = (arg.as_type(), parent_arg.as_type())
{
arg != parent_arg && arg.contains(parent_arg)
} else {
false
}
})
} else {
false
}
});
if is_expanding_recursive {
// FIXME: indicate that this is an expanding recursive type in stub metadata?
return DINodeCreationResult::new(stub_info.metadata, false);
} else {
debug_context(cx).adt_stack.borrow_mut().push((def_id, args));
_adt_stack_pop_guard = Some(AdtStackPopGuard { cx });
}
}
debug_context(cx).type_map.insert(stub_info.unique_type_id, stub_info.metadata);
let members: SmallVec<_> =

View file

@ -66,6 +66,7 @@ pub(crate) struct CodegenUnitDebugContext<'ll, 'tcx> {
created_files: RefCell<UnordMap<Option<(StableSourceFileId, SourceFileHash)>, &'ll DIFile>>,
type_map: metadata::TypeMap<'ll, 'tcx>,
adt_stack: RefCell<Vec<(DefId, GenericArgsRef<'tcx>)>>,
namespace_map: RefCell<DefIdMap<&'ll DIScope>>,
recursion_marker_type: OnceCell<&'ll DIType>,
}
@ -80,6 +81,7 @@ impl<'ll, 'tcx> CodegenUnitDebugContext<'ll, 'tcx> {
builder,
created_files: Default::default(),
type_map: Default::default(),
adt_stack: Default::default(),
namespace_map: RefCell::new(Default::default()),
recursion_marker_type: OnceCell::new(),
}

View file

@ -1,6 +1,6 @@
use std::fmt;
use std::marker::PhantomData;
use std::ops::{Index, IndexMut};
use std::ops::{Index, IndexMut, RangeBounds};
use std::slice::GetDisjointMutError::*;
use std::slice::{self, SliceIndex};
@ -104,6 +104,17 @@ impl<I: Idx, T> IndexSlice<I, T> {
self.raw.swap(a.index(), b.index())
}
#[inline]
pub fn copy_within(
&mut self,
src: impl IntoSliceIdx<I, [T], Output: RangeBounds<usize>>,
dest: I,
) where
T: Copy,
{
self.raw.copy_within(src.into_slice_idx(), dest.index());
}
#[inline]
pub fn get<R: IntoSliceIdx<I, [T]>>(
&self,

0
diff
View file

View file

@ -67,9 +67,9 @@ dependencies = [
[[package]]
name = "compiler_builtins"
version = "0.1.153"
version = "0.1.155"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "926ef6a360c15a911023352fd6969c51605d70495406f735beb1ca0257448e59"
checksum = "341e0830ca6170a4fcf02e92e57daf4b6f10142d48da32a547023867a6c8b35e"
dependencies = [
"cc",
"rustc-std-workspace-core",

View file

@ -16,7 +16,7 @@ bench = false
[dependencies]
core = { path = "../core", public = true }
compiler_builtins = { version = "=0.1.153", features = ['rustc-dep-of-std'] }
compiler_builtins = { version = "=0.1.155", features = ['rustc-dep-of-std'] }
[features]
compiler-builtins-mem = ['compiler_builtins/mem']

View file

@ -18,7 +18,7 @@ cfg-if = { version = "1.0", features = ['rustc-dep-of-std'] }
panic_unwind = { path = "../panic_unwind", optional = true }
panic_abort = { path = "../panic_abort" }
core = { path = "../core", public = true }
compiler_builtins = { version = "=0.1.153" }
compiler_builtins = { version = "=0.1.155" }
unwind = { path = "../unwind" }
hashbrown = { version = "0.15", default-features = false, features = [
'rustc-dep-of-std',

View file

@ -14,9 +14,5 @@ build_helper = { path = "../../build_helper" }
serde_json = "1.0"
libc = "0.2"
# FIXME(#137532): replace `os_pipe` with `anonymous_pipe` once it stabilizes and
# reaches beta.
os_pipe = "1.2.1"
[lib]
crate-type = ["lib", "dylib"]

View file

@ -41,8 +41,6 @@ pub use bstr;
pub use gimli;
pub use libc;
pub use object;
// FIXME(#137532): replace with std `anonymous_pipe` once it stabilizes and reaches beta.
pub use os_pipe;
pub use regex;
pub use serde_json;
pub use similar;

View file

@ -12,6 +12,7 @@
// at the time still sometimes fails, so only verify it for the power-of-two size
// - https://github.com/llvm/llvm-project/issues/134735
//@[x86-64-v3] only-x86_64
//@[x86-64-v3] min-llvm-version: 21
//@[x86-64-v3] compile-flags: -Ctarget-cpu=x86-64-v3
#![crate_type = "lib"]
@ -19,16 +20,7 @@
#[no_mangle]
pub fn test() -> usize {
// CHECK-LABEL: @test(
// host: ret {{i64|i32}} 165
// x86-64: ret {{i64|i32}} 165
// FIXME: Now that this autovectorizes via a masked load, it doesn't actually
// const-fold for certain widths. The `test_eight` case below shows that, yes,
// what we're emitting *can* be const-folded, except that the way LLVM does it
// for certain widths doesn't today. We should be able to put this back to
// the same check after <https://github.com/llvm/llvm-project/issues/134513>
// x86-64-v3: masked.load
// CHECK: ret {{i64|i32}} 165
let values = [23, 16, 54, 3, 60, 9];
let mut acc = 0;
for item in values {

View file

@ -1,12 +0,0 @@
//@ known-bug: #100618
//@ compile-flags: -Cdebuginfo=2
//@ only-x86_64
enum Foo<T: 'static> {
Value(T),
Recursive(&'static Foo<Option<T>>),
}
fn main() {
let _x = Foo::Value(());
}

View file

@ -1,17 +0,0 @@
//@ known-bug: #115994
//@ compile-flags: -Cdebuginfo=2 --crate-type lib
// To prevent "overflow while adding drop-check rules".
use std::mem::ManuallyDrop;
pub enum Foo<U> {
Leaf(U),
Branch(BoxedFoo<BoxedFoo<U>>),
}
pub type BoxedFoo<U> = ManuallyDrop<Box<Foo<U>>>;
pub fn test() -> Foo<usize> {
todo!()
}

View file

@ -1,30 +0,0 @@
//@ known-bug: #121538
//@ compile-flags: -Cdebuginfo=2
use std::marker::PhantomData;
struct Digit<T> {
elem: T
}
struct Node<T:'static> { m: PhantomData<&'static T> }
enum FingerTree<T:'static> {
Single(T),
Deep(
Digit<T>,
Node<FingerTree<Node<T>>>,
)
}
enum Wrapper<T:'static> {
Simple,
Other(FingerTree<T>),
}
fn main() {
let w =
Some(Wrapper::Simple::<u32>);
}

View file

@ -4,7 +4,7 @@
// gdb-command:run
// Test whether compiling a recursive enum definition crashes debug info generation. The test case
// is taken from issue #11083.
// is taken from issue #11083 and #135093.
#![allow(unused_variables)]
#![feature(omit_gdb_pretty_printer_section)]
@ -18,6 +18,21 @@ struct WindowCallbacks<'a> {
pos_callback: Option<Box<FnMut(&Window, i32, i32) + 'a>>,
}
enum ExpandingRecursive<T> {
Recurse(Indirect<T>),
Item(T),
}
struct Indirect<U> {
rec: *const ExpandingRecursive<Option<U>>,
}
fn main() {
let x = WindowCallbacks { pos_callback: None };
// EXPANDING RECURSIVE
let expanding_recursive: ExpandingRecursive<u64> = ExpandingRecursive::Recurse(Indirect {
rec: &ExpandingRecursive::Item(Option::Some(42)),
});
}

View file

@ -1,4 +1,3 @@
//@ known-bug: #107362
//@ compile-flags: -Cdebuginfo=2
pub trait Functor

View file

@ -14,9 +14,7 @@
use std::io::Read;
use std::process::{Command, Stdio};
// FIXME(#137532): replace `os_pipe` dependency with std `anonymous_pipe` once that stabilizes and
// reaches beta.
use run_make_support::{env_var, os_pipe};
use run_make_support::env_var;
#[derive(Debug, PartialEq)]
enum Binary {
@ -25,7 +23,7 @@ enum Binary {
}
fn check_broken_pipe_handled_gracefully(bin: Binary, mut cmd: Command) {
let (reader, writer) = os_pipe::pipe().unwrap();
let (reader, writer) = std::io::pipe().unwrap();
drop(reader); // close read-end
cmd.stdout(writer).stderr(Stdio::piped());