Skip to content

Commit 979f18e

Browse files
committed
Add all testable issue of parallel front end to ui tests
1 parent a6bd739 commit 979f18e

19 files changed

+624
-16
lines changed

tests/ui/parallel-rustc/SUMMARY.md

+8
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
This directory contains the robustness test for prallel front end, which means deadlocks
2+
and other ice bugs. In other words, we don't care whether the compiler output in these tests,
3+
but whether they can compile normally without deadlock or other ice bugs.
4+
5+
So when a test in this directory fails, please pay attention to whether it causes any ice problems.
6+
If so(it should do), please post your comments in the issue corresponding to each test (or create a new issue
7+
with the `wg-parallel-rustc` label). Even if it is an existing issue, please add a new comment,
8+
which will help us determine the reproducibility of the bug.
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,16 @@
1+
// Test for #111528, the ice issue cause waiting on a query that panicked
2+
//
3+
//@ parallel-front-end-robustness
14
//@ compile-flags: -Z threads=16
25
//@ build-fail
36

4-
#![crate_type="rlib"]
7+
#![crate_type = "rlib"]
58
#![allow(warnings)]
69

7-
#[export_name="fail"]
8-
pub fn a() {
9-
}
10+
#[export_name = "fail"]
11+
pub fn a() {}
1012

11-
#[export_name="fail"]
12-
pub fn b() {
13-
//~^ Error symbol `fail` is already defined
14-
}
13+
#[export_name = "fail"]
14+
pub fn b() {}
1515

1616
fn main() {}

tests/ui/parallel-rustc/cache-after-waiting-issue-111528.stderr

-8
This file was deleted.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
// Test for #119785, which causes a deadlock bug
2+
//
3+
//@ parallel-front-end-robustness
4+
//@ compile-flags: -Z threads=200
5+
6+
#![allow(incomplete_features)]
7+
#![feature(
8+
const_trait_impl,
9+
effects,
10+
)]
11+
12+
use std::marker::Destruct;
13+
14+
const fn cmp(a: &impl ~const PartialEq) -> bool {
15+
a == a
16+
}
17+
18+
const fn wrap(x: impl ~const PartialEq + ~const Destruct)
19+
-> impl ~const PartialEq + ~const Destruct
20+
{
21+
x
22+
}
23+
24+
#[const_trait]
25+
trait Foo {
26+
fn foo(&mut self, x: <Self as Index>::Output) -> <Self as Index>::Output;
27+
}
28+
29+
impl const Foo for () {
30+
fn huh() -> impl ~const PartialEq + ~const Destruct + Copy {
31+
123
32+
}
33+
}
34+
35+
const _: () = {
36+
assert!(cmp(&0xDEADBEEFu32));
37+
assert!(cmp(&()));
38+
assert!(wrap(123) == wrap(123));
39+
assert!(wrap(123) != wrap(456));
40+
let x = <() as Foo>::huh();
41+
assert!(x == x);
42+
};
43+
44+
#[const_trait]
45+
trait T {}
46+
struct S;
47+
impl const T for S {}
48+
49+
const fn rpit() -> impl ~const T { S }
50+
51+
const fn apit(_: impl ~const T + ~const Destruct) {}
52+
53+
const fn rpit_assoc_bound() -> impl IntoIterator<Item: ~const T> { Some(S) }
54+
55+
const fn apit_assoc_bound(_: impl IntoIterator<Item: ~const T> + ~From Destruct) {}
56+
57+
fn main() {}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,115 @@
1+
// Test for #120757, which causes a deadlock bug
2+
//
3+
//@ parallel-front-end-robustness
4+
//@ compile-flags: -Z threads=50
5+
6+
#![feature(generic_const_exprs)]
7+
8+
trait TensorDimension {
9+
const DIM: usize;
10+
const ISSCALAR: bool = Self::DIM == 0;
11+
fn is_scalar(&self) -> bool {
12+
Self::ISSCALAR
13+
}
14+
}
15+
16+
trait TensorSize: TensorDimension {
17+
fn size(&self) -> [usize; Self::DIM];
18+
fn inbounds(&self, index: [usize; Self::DIM]) -> bool {
19+
index.iter().zip(self.size().iter()).all(|(i, s)| i < s)
20+
}
21+
}
22+
23+
trait Broadcastable: TensorSize + Sized {
24+
type Element;
25+
fn bget(&self, index: [usize; Self::DIM]) -> Option<Self::Element>;
26+
fn lazy_updim<const NEWDIM: usize>(
27+
&self,
28+
size: [usize; NEWDIM],
29+
) -> LazyUpdim<Self, { Self::DIM }, NEWDIM> {
30+
assert!(
31+
NEWDIM >= Self::DIM,
32+
"Updimmed tensor cannot have fewer indices than the initial one."
33+
); // const generic bounds on nightly. ( )
34+
LazyUpdim { size, reference: &self }
35+
}
36+
fn bmap<T, F: Fn(Self::Element) -> T>(&self, foo: F) -> BMap<T, Self, F, { Self::DIM }> {
37+
BMap { reference: self, closure: foo }
38+
}
39+
}
40+
41+
struct LazyUpdim<'a, T: Broadcastable, const OLDDIM: usize, const DIM: usize> {
42+
size: [usize; DIM],
43+
reference: &'a T,
44+
}
45+
46+
impl<'a, T: Broadcastable, const DIM: usize> TensorDimension for LazyUpdim<'a, T, { T::DIM }, DIM> {
47+
const DIM: usize = DIM;
48+
}
49+
impl<'a, T: Broadcastable, const DIM: usize> TensorSize for LazyUpdim<'a, T, { T::DIM }, DIM> {
50+
fn size(&self) -> [usize; DIM] {
51+
self.size
52+
}
53+
}
54+
impl<'a, T: Broadcastable, const DIM: usize> Broadcastable for LazyUpdim<'a, T, { T::DIM }, DIM> {
55+
type Element = T::Element;
56+
fn bget(&self, index: [usize; DIM]) -> Option<Self::Element> {
57+
assert!(DIM >= T::DIM);
58+
if !self.inbounds(index) {
59+
return None;
60+
}
61+
let size = self.size();
62+
//array_init::array_init(|i| if size[i] > 1 {index[i]} else {0});
63+
let newindex: [usize; T::DIM] = Default::default();
64+
self.reference.bget(newindex)
65+
}
66+
}
67+
68+
struct BMap<'a, R, T: Broadcastable, F: Fn(T::Element) -> R, const DIM: usize> {
69+
reference: &'a T,
70+
closure: F,
71+
}
72+
73+
impl<'a, R, T: Broadcastable, F: Fn(T::Element) -> R, const DIM: usize> TensorDimension
74+
for BMap<'a, R, T, F, DIM>
75+
{
76+
const DIM: usize = DIM;
77+
}
78+
impl<'a, R, T: Broadcastable, F: Fn(T::Element) -> R, const DIM: usize> TensorSize
79+
for BMap<'a, R, T, F, DIM>
80+
{
81+
fn size(&self) -> [usize; DIM] {
82+
self.reference.size()
83+
}
84+
}
85+
impl<'a, R, T: Broadcastable, F: Fn(T::Element) -> R, const DIM: usize> Broadcastable
86+
for BMap<'a, R, T, F, DIM>
87+
{
88+
type Element = R;
89+
fn bget(&self, index: [usize; DIM]) -> Option<Self::Element> {
90+
self.reference.bget(index).map(ns_window)
91+
}
92+
}
93+
94+
impl<T> TensorDimension for Vec<T> {
95+
const DIM: usize = 1;
96+
}
97+
impl<T> TensorSize for Vec<T> {
98+
fn size(&self) -> [usize; 1] {
99+
[self.len()]
100+
}
101+
}
102+
impl<T: Clone> Broadcastable for Vec<T> {
103+
type Element = T;
104+
fn bget(&self, index: [usize; 1]) -> Option<T> {
105+
self.get(index[0]).cloned()
106+
}
107+
}
108+
109+
fn main() {
110+
let v = vec![1, 2, 3];
111+
let bv = v.lazy_updim([3, 4]);
112+
let bbv = bv.bmap(|x| x * x);
113+
114+
println!("The size of v is {:?}", bbv.bget([0, 2]).expect("Out of bounds."));
115+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,69 @@
1+
// Test for #129911, which causes a deadlock bug
2+
//
3+
//@ parallel-front-end-robustness
4+
//@ compile-flags: -Z threads=16
5+
6+
fn main() {
7+
type KooArc = Frc<
8+
{
9+
{
10+
{
11+
{};
12+
}
13+
type Frc = Frc<{}>::Arc;;
14+
}
15+
type Frc = Frc<
16+
{
17+
{
18+
{
19+
{};
20+
}
21+
type Frc = Frc<{}>::Arc;;
22+
}
23+
type Frc = Frc<
24+
{
25+
{
26+
{
27+
{};
28+
}
29+
type Frc = Frc<{}>::Arc;;
30+
}
31+
type Frc = Frc<
32+
{
33+
{
34+
{
35+
{};
36+
}
37+
type Frc = Frc<{}>::Arc;;
38+
}
39+
type Frc = Frc<
40+
{
41+
{
42+
{
43+
{
44+
{};
45+
}
46+
type Frc = Frc<{}>::Arc;;
47+
};
48+
}
49+
type Frc = Frc<
50+
{
51+
{
52+
{
53+
{};
54+
};
55+
}
56+
type Frc = Frc<{}>::Arc;;
57+
},
58+
>::Arc;;
59+
},
60+
>::Arc;;
61+
},
62+
>::Arc;;
63+
},
64+
>::Arc;;
65+
},
66+
>::Arc;;
67+
},
68+
>::Arc;
69+
}

tests/ui/parallel-rustc/export-symbols-deadlock-issue-118205-2.rs

+3
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
1+
// Test for #118205, which causes a deadlock bug
2+
//
3+
//@ parallel-front-end-robustness
14
//@ compile-flags:-C extra-filename=-1 -Z threads=16
25
//@ no-prefer-dynamic
36
//@ build-pass

tests/ui/parallel-rustc/export-symbols-deadlock-issue-118205.rs

+3
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
1+
// Test for #118205, which causes a deadlock bug
2+
//
3+
//@ parallel-front-end-robustness
14
//@ compile-flags: -Z threads=16
25
//@ build-pass
36

Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
// Test for #115223, which causes a deadlock bug without finding the cycle
2+
//
3+
//@ parallel-front-end-robustness
4+
//@ compile-flags: -Z threads=16
5+
//@ run-pass
6+
7+
#![crate_name = "foo"]
8+
9+
use std::ops;
10+
11+
pub struct Foo;
12+
13+
impl Foo {
14+
pub fn foo(&mut self) {}
15+
}
16+
17+
pub struct Bar {
18+
foo: Foo,
19+
}
20+
21+
impl ops::Deref for Bar {
22+
type Target = Foo;
23+
24+
fn deref(&self) -> &Foo {
25+
&self.foo
26+
}
27+
}
28+
29+
impl ops::DerefMut for Bar {
30+
fn deref_mut(&mut self) -> &mut Foo {
31+
&mut self.foo
32+
}
33+
}
34+
35+
fn main() {}

tests/ui/parallel-rustc/hello_world.rs

+3
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
1+
// Test for the basic function of parallel front end
2+
//
3+
//@ parallel-front-end-robustness
14
//@ compile-flags: -Z threads=8
25
//@ run-pass
36

Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
// Test for #120759, which causes an ice bug
2+
//
3+
//@ parallel-front-end-robustness
4+
//@ compile-flags: -Z threads=50 -Zcrate-attr="feature(transmutability)"
5+
6+
mod assert {
7+
use std::mem::{Assume, BikeshedIntrinsicFrom};
8+
pub struct Context;
9+
10+
pub fn is_maybe_transmutable<Src, Dst>(&self, cpu: &mut CPU)
11+
where
12+
Dst: BikeshedIntrinsicFrom<Src, Context>,
13+
{
14+
}
15+
}
16+
17+
fn should_pad_explicitly_packed_field() {
18+
#[repr(C)]
19+
struct ExplicitlyPadded(ExplicitlyPadded);
20+
21+
assert::is_maybe_transmutable::<ExplicitlyPadded, ()>();
22+
}
23+
24+
fn main() {}

0 commit comments

Comments
 (0)