Skip to content
/ rust Public
forked from rust-lang/rust

Commit 6a0bd27

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 6a0bd27

File tree

17 files changed

+86
-97
lines changed

17 files changed

+86
-97
lines changed

Diff for: Cargo.lock

-11
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",

Diff for: compiler/rustc_codegen_llvm/src/debuginfo/metadata/type_map.rs

+48
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<_> =

Diff for: compiler/rustc_codegen_llvm/src/debuginfo/mod.rs

+2
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
}

Diff for: compiler/rustc_index/src/slice.rs

+12-1
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 for: diff

Whitespace-only changes.

Diff for: library/Cargo.lock

+2-2
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",

Diff for: library/alloc/Cargo.toml

+1-1
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']

Diff for: library/std/Cargo.toml

+1-1
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',

Diff for: src/tools/run-make-support/Cargo.toml

-4
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"]

Diff for: src/tools/run-make-support/src/lib.rs

-2
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;

Diff for: tests/codegen/issues/issue-101082.rs

+2-10
Original file line numberDiff line numberDiff line change
@@ -12,23 +12,15 @@
1212
// at the time still sometimes fails, so only verify it for the power-of-two size
1313
// - https://github.com/llvm/llvm-project/issues/134735
1414
//@[x86-64-v3] only-x86_64
15+
//@[x86-64-v3] min-llvm-version: 21
1516
//@[x86-64-v3] compile-flags: -Ctarget-cpu=x86-64-v3
1617

1718
#![crate_type = "lib"]
1819

1920
#[no_mangle]
2021
pub fn test() -> usize {
2122
// CHECK-LABEL: @test(
22-
// host: ret {{i64|i32}} 165
23-
// x86-64: ret {{i64|i32}} 165
24-
25-
// FIXME: Now that this autovectorizes via a masked load, it doesn't actually
26-
// const-fold for certain widths. The `test_eight` case below shows that, yes,
27-
// what we're emitting *can* be const-folded, except that the way LLVM does it
28-
// for certain widths doesn't today. We should be able to put this back to
29-
// the same check after <https://github.com/llvm/llvm-project/issues/134513>
30-
// x86-64-v3: masked.load
31-
23+
// CHECK: ret {{i64|i32}} 165
3224
let values = [23, 16, 54, 3, 60, 9];
3325
let mut acc = 0;
3426
for item in values {

Diff for: tests/crashes/100618.rs

-12
This file was deleted.

Diff for: tests/crashes/115994.rs

-17
This file was deleted.

Diff for: tests/crashes/121538.rs

-30
This file was deleted.

Diff for: tests/debuginfo/recursive-enum.rs

+16-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
// gdb-command:run
55

66
// Test whether compiling a recursive enum definition crashes debug info generation. The test case
7-
// is taken from issue #11083.
7+
// is taken from issue #11083 and #135093.
88

99
#![allow(unused_variables)]
1010
#![feature(omit_gdb_pretty_printer_section)]
@@ -18,6 +18,21 @@ struct WindowCallbacks<'a> {
1818
pos_callback: Option<Box<FnMut(&Window, i32, i32) + 'a>>,
1919
}
2020

21+
enum ExpandingRecursive<T> {
22+
Recurse(Indirect<T>),
23+
Item(T),
24+
}
25+
26+
struct Indirect<U> {
27+
rec: *const ExpandingRecursive<Option<U>>,
28+
}
29+
30+
2131
fn main() {
2232
let x = WindowCallbacks { pos_callback: None };
33+
34+
// EXPANDING RECURSIVE
35+
let expanding_recursive: ExpandingRecursive<u64> = ExpandingRecursive::Recurse(Indirect {
36+
rec: &ExpandingRecursive::Item(Option::Some(42)),
37+
});
2338
}

Diff for: tests/crashes/107362.rs renamed to tests/debuginfo/recursive-type-with-gat.rs

-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
//@ known-bug: #107362
21
//@ compile-flags: -Cdebuginfo=2
32

43
pub trait Functor

Diff for: tests/run-make/broken-pipe-no-ice/rmake.rs

+2-4
Original file line numberDiff line numberDiff line change
@@ -14,9 +14,7 @@
1414
use std::io::Read;
1515
use std::process::{Command, Stdio};
1616

17-
// FIXME(#137532): replace `os_pipe` dependency with std `anonymous_pipe` once that stabilizes and
18-
// reaches beta.
19-
use run_make_support::{env_var, os_pipe};
17+
use run_make_support::env_var;
2018

2119
#[derive(Debug, PartialEq)]
2220
enum Binary {
@@ -25,7 +23,7 @@ enum Binary {
2523
}
2624

2725
fn check_broken_pipe_handled_gracefully(bin: Binary, mut cmd: Command) {
28-
let (reader, writer) = os_pipe::pipe().unwrap();
26+
let (reader, writer) = std::io::pipe().unwrap();
2927
drop(reader); // close read-end
3028
cmd.stdout(writer).stderr(Stdio::piped());
3129

0 commit comments

Comments
 (0)