Skip to content
This repository was archived by the owner on May 28, 2025. It is now read-only.

Commit 8bcd932

Browse files
committed
Auto merge of rust-lang#139997 - matthiaskrgr:rollup-a1fe5zg, r=matthiaskrgr
Rollup of 6 pull requests Successful merges: - rust-lang#137881 (Add `copy_within` to `IndexSlice`) - rust-lang#138599 (avoid overflow when generating debuginfo for expanding recursive types) - rust-lang#139934 (Update `compiler-builtins` to 0.1.155) - rust-lang#139976 (run-make: drop `os_pipe` workaround now that `anonymous_pipe` is stable on beta) - rust-lang#139989 (tests: adjust 101082 test for LLVM 21 fix) - rust-lang#139991 (remove stray file) r? `@ghost` `@rustbot` modify labels: rollup
2 parents 1f76d21 + 1b52421 commit 8bcd932

File tree

17 files changed

+86
-97
lines changed

17 files changed

+86
-97
lines changed

Cargo.lock

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -2572,16 +2572,6 @@ version = "0.2.0"
25722572
source = "registry+https://github.com/rust-lang/crates.io-index"
25732573
checksum = "04744f49eae99ab78e0d5c0b603ab218f515ea8cfe5a456d7629ad883a3b6e7d"
25742574

2575-
[[package]]
2576-
name = "os_pipe"
2577-
version = "1.2.1"
2578-
source = "registry+https://github.com/rust-lang/crates.io-index"
2579-
checksum = "5ffd2b0a5634335b135d5728d84c5e0fd726954b87111f7506a61c502280d982"
2580-
dependencies = [
2581-
"libc",
2582-
"windows-sys 0.59.0",
2583-
]
2584-
25852575
[[package]]
25862576
name = "overload"
25872577
version = "0.1.1"
@@ -3142,7 +3132,6 @@ dependencies = [
31423132
"gimli 0.31.1",
31433133
"libc",
31443134
"object 0.36.7",
3145-
"os_pipe",
31463135
"regex",
31473136
"serde_json",
31483137
"similar",

compiler/rustc_codegen_llvm/src/debuginfo/metadata/type_map.rs

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -247,6 +247,16 @@ pub(super) fn stub<'ll, 'tcx>(
247247
StubInfo { metadata, unique_type_id }
248248
}
249249

250+
struct AdtStackPopGuard<'ll, 'tcx, 'a> {
251+
cx: &'a CodegenCx<'ll, 'tcx>,
252+
}
253+
254+
impl<'ll, 'tcx, 'a> Drop for AdtStackPopGuard<'ll, 'tcx, 'a> {
255+
fn drop(&mut self) {
256+
debug_context(self.cx).adt_stack.borrow_mut().pop();
257+
}
258+
}
259+
250260
/// This function enables creating debuginfo nodes that can recursively refer to themselves.
251261
/// It will first insert the given stub into the type map and only then execute the `members`
252262
/// 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>(
261271
) -> DINodeCreationResult<'ll> {
262272
assert_eq!(debug_context(cx).type_map.di_node_for_unique_id(stub_info.unique_type_id), None);
263273

274+
let mut _adt_stack_pop_guard = None;
275+
if let UniqueTypeId::Ty(ty, ..) = stub_info.unique_type_id
276+
&& let ty::Adt(adt_def, args) = ty.kind()
277+
{
278+
let def_id = adt_def.did();
279+
// If any sub type reference the original type definition and the sub type has a type
280+
// parameter that strictly contains the original parameter, the original type is a recursive
281+
// type that can expanding indefinitely. Example,
282+
// ```
283+
// enum Recursive<T> {
284+
// Recurse(*const Recursive<Wrap<T>>),
285+
// Item(T),
286+
// }
287+
// ```
288+
let is_expanding_recursive =
289+
debug_context(cx).adt_stack.borrow().iter().any(|(parent_def_id, parent_args)| {
290+
if def_id == *parent_def_id {
291+
args.iter().zip(parent_args.iter()).any(|(arg, parent_arg)| {
292+
if let (Some(arg), Some(parent_arg)) = (arg.as_type(), parent_arg.as_type())
293+
{
294+
arg != parent_arg && arg.contains(parent_arg)
295+
} else {
296+
false
297+
}
298+
})
299+
} else {
300+
false
301+
}
302+
});
303+
if is_expanding_recursive {
304+
// FIXME: indicate that this is an expanding recursive type in stub metadata?
305+
return DINodeCreationResult::new(stub_info.metadata, false);
306+
} else {
307+
debug_context(cx).adt_stack.borrow_mut().push((def_id, args));
308+
_adt_stack_pop_guard = Some(AdtStackPopGuard { cx });
309+
}
310+
}
311+
264312
debug_context(cx).type_map.insert(stub_info.unique_type_id, stub_info.metadata);
265313

266314
let members: SmallVec<_> =

compiler/rustc_codegen_llvm/src/debuginfo/mod.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,7 @@ pub(crate) struct CodegenUnitDebugContext<'ll, 'tcx> {
6666
created_files: RefCell<UnordMap<Option<(StableSourceFileId, SourceFileHash)>, &'ll DIFile>>,
6767

6868
type_map: metadata::TypeMap<'ll, 'tcx>,
69+
adt_stack: RefCell<Vec<(DefId, GenericArgsRef<'tcx>)>>,
6970
namespace_map: RefCell<DefIdMap<&'ll DIScope>>,
7071
recursion_marker_type: OnceCell<&'ll DIType>,
7172
}
@@ -80,6 +81,7 @@ impl<'ll, 'tcx> CodegenUnitDebugContext<'ll, 'tcx> {
8081
builder,
8182
created_files: Default::default(),
8283
type_map: Default::default(),
84+
adt_stack: Default::default(),
8385
namespace_map: RefCell::new(Default::default()),
8486
recursion_marker_type: OnceCell::new(),
8587
}

compiler/rustc_index/src/slice.rs

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
use std::fmt;
22
use std::marker::PhantomData;
3-
use std::ops::{Index, IndexMut};
3+
use std::ops::{Index, IndexMut, RangeBounds};
44
use std::slice::GetDisjointMutError::*;
55
use std::slice::{self, SliceIndex};
66

@@ -104,6 +104,17 @@ impl<I: Idx, T> IndexSlice<I, T> {
104104
self.raw.swap(a.index(), b.index())
105105
}
106106

107+
#[inline]
108+
pub fn copy_within(
109+
&mut self,
110+
src: impl IntoSliceIdx<I, [T], Output: RangeBounds<usize>>,
111+
dest: I,
112+
) where
113+
T: Copy,
114+
{
115+
self.raw.copy_within(src.into_slice_idx(), dest.index());
116+
}
117+
107118
#[inline]
108119
pub fn get<R: IntoSliceIdx<I, [T]>>(
109120
&self,

diff

Whitespace-only changes.

library/Cargo.lock

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -67,9 +67,9 @@ dependencies = [
6767

6868
[[package]]
6969
name = "compiler_builtins"
70-
version = "0.1.153"
70+
version = "0.1.155"
7171
source = "registry+https://github.com/rust-lang/crates.io-index"
72-
checksum = "926ef6a360c15a911023352fd6969c51605d70495406f735beb1ca0257448e59"
72+
checksum = "341e0830ca6170a4fcf02e92e57daf4b6f10142d48da32a547023867a6c8b35e"
7373
dependencies = [
7474
"cc",
7575
"rustc-std-workspace-core",

library/alloc/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ bench = false
1616

1717
[dependencies]
1818
core = { path = "../core", public = true }
19-
compiler_builtins = { version = "=0.1.153", features = ['rustc-dep-of-std'] }
19+
compiler_builtins = { version = "=0.1.155", features = ['rustc-dep-of-std'] }
2020

2121
[features]
2222
compiler-builtins-mem = ['compiler_builtins/mem']

library/std/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ cfg-if = { version = "1.0", features = ['rustc-dep-of-std'] }
1818
panic_unwind = { path = "../panic_unwind", optional = true }
1919
panic_abort = { path = "../panic_abort" }
2020
core = { path = "../core", public = true }
21-
compiler_builtins = { version = "=0.1.153" }
21+
compiler_builtins = { version = "=0.1.155" }
2222
unwind = { path = "../unwind" }
2323
hashbrown = { version = "0.15", default-features = false, features = [
2424
'rustc-dep-of-std',

src/tools/run-make-support/Cargo.toml

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -14,9 +14,5 @@ build_helper = { path = "../../build_helper" }
1414
serde_json = "1.0"
1515
libc = "0.2"
1616

17-
# FIXME(#137532): replace `os_pipe` with `anonymous_pipe` once it stabilizes and
18-
# reaches beta.
19-
os_pipe = "1.2.1"
20-
2117
[lib]
2218
crate-type = ["lib", "dylib"]

src/tools/run-make-support/src/lib.rs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -41,8 +41,6 @@ pub use bstr;
4141
pub use gimli;
4242
pub use libc;
4343
pub use object;
44-
// FIXME(#137532): replace with std `anonymous_pipe` once it stabilizes and reaches beta.
45-
pub use os_pipe;
4644
pub use regex;
4745
pub use serde_json;
4846
pub use similar;

0 commit comments

Comments
 (0)