Skip to content

Commit 94dade5

Browse files
committed
Add parallel front end issues to ui tests
1 parent 86d69c7 commit 94dade5

35 files changed

+1944
-6
lines changed

src/tools/compiletest/src/command-list.rs

+1
Original file line numberDiff line numberDiff line change
@@ -205,6 +205,7 @@ const KNOWN_DIRECTIVE_NAMES: &[&str] = &[
205205
"only-x86_64-pc-windows-gnu",
206206
"only-x86_64-pc-windows-msvc",
207207
"only-x86_64-unknown-linux-gnu",
208+
"parallel-front-end",
208209
"pp-exact",
209210
"pretty-compare-only",
210211
"pretty-expanded",

src/tools/compiletest/src/header.rs

+6
Original file line numberDiff line numberDiff line change
@@ -108,6 +108,9 @@ pub struct TestProps {
108108
pub force_host: bool,
109109
// Check stdout for error-pattern output as well as stderr
110110
pub check_stdout: bool,
111+
// For parallel front end test, use repeated tests to avoid randomness
112+
// in multithreaded environments
113+
pub parallel_front_end: bool,
111114
// Check stdout & stderr for output of run-pass test
112115
pub check_run_results: bool,
113116
// For UI tests, allows compiler to generate arbitrary output to stdout
@@ -213,6 +216,7 @@ mod directives {
213216
pub const CHECK_RUN_RESULTS: &'static str = "check-run-results";
214217
pub const DONT_CHECK_COMPILER_STDOUT: &'static str = "dont-check-compiler-stdout";
215218
pub const DONT_CHECK_COMPILER_STDERR: &'static str = "dont-check-compiler-stderr";
219+
pub const PARALLEL_FRONT_END: &'static str = "parallel-front-end";
216220
pub const NO_PREFER_DYNAMIC: &'static str = "no-prefer-dynamic";
217221
pub const PRETTY_EXPANDED: &'static str = "pretty-expanded";
218222
pub const PRETTY_MODE: &'static str = "pretty-mode";
@@ -273,6 +277,7 @@ impl TestProps {
273277
dont_check_compiler_stderr: false,
274278
compare_output_lines_by_subset: false,
275279
no_prefer_dynamic: false,
280+
parallel_front_end: false,
276281
pretty_expanded: false,
277282
pretty_mode: "normal".to_string(),
278283
pretty_compare_only: false,
@@ -494,6 +499,7 @@ impl TestProps {
494499
DONT_CHECK_FAILURE_STATUS,
495500
&mut self.dont_check_failure_status,
496501
);
502+
config.set_name_directive(ln, PARALLEL_FRONT_END, &mut self.parallel_front_end);
497503

498504
config.set_name_directive(ln, RUN_RUSTFIX, &mut self.run_rustfix);
499505
config.set_name_directive(

src/tools/compiletest/src/runtest.rs

+7-4
Original file line numberDiff line numberDiff line change
@@ -1349,8 +1349,10 @@ impl<'test> TestCx<'test> {
13491349
};
13501350
rustc.arg(input_file);
13511351

1352-
// Use a single thread for efficiency and a deterministic error message order
1353-
rustc.arg("-Zthreads=1");
1352+
if !self.props.parallel_front_end {
1353+
// Use a single thread for efficiency and a deterministic error message order
1354+
rustc.arg("-Zthreads=1");
1355+
}
13541356

13551357
// Hide libstd sources from ui tests to make sure we generate the stderr
13561358
// output that users will see.
@@ -2475,8 +2477,9 @@ impl<'test> TestCx<'test> {
24752477
// provide extra output on failure, for example a WebAssembly runtime
24762478
// might print the stack trace of an `unreachable` instruction by
24772479
// default.
2478-
let compare_output_by_lines =
2479-
self.props.compare_output_lines_by_subset || self.config.runner.is_some();
2480+
let compare_output_by_lines = self.props.compare_output_lines_by_subset
2481+
|| self.config.runner.is_some()
2482+
|| self.props.parallel_front_end;
24802483

24812484
let tmp;
24822485
let (expected, actual): (&str, &str) = if compare_output_by_lines {

src/tools/compiletest/src/runtest/ui.rs

+13-1
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,19 @@ impl TestCx<'_> {
2424
let pm = self.pass_mode();
2525
let should_run = self.should_run(pm);
2626
let emit_metadata = self.should_emit_metadata(pm);
27-
let proc_res = self.compile_test(should_run, emit_metadata);
27+
let mut proc_res = self.compile_test(should_run, emit_metadata);
28+
29+
if self.props.parallel_front_end {
30+
// Ensure there is no ice during parallel front end.
31+
self.check_no_compiler_crash(&proc_res, false);
32+
33+
// Repeated testing due to instability in multithreaded environments.
34+
for _ in 0..50 {
35+
proc_res = self.compile_test(should_run, emit_metadata);
36+
self.check_no_compiler_crash(&proc_res, false);
37+
}
38+
}
39+
2840
self.check_if_test_should_compile(self.props.fail_mode, pm, &proc_res);
2941
if matches!(proc_res.truncated, Truncated::Yes)
3042
&& !self.props.dont_check_compiler_stdout

tests/ui/invalid-compile-flags/fuel.rs

+1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
//@ revisions: incremental threads
22
//@ dont-check-compiler-stderr
33
//
4+
//@ parallel-front-end
45
//@ [threads] compile-flags: -Zfuel=a=1 -Zthreads=2
56
//@ [threads] error-pattern:optimization fuel is incompatible with multiple threads
67
//

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

+1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
//@ parallel-front-end
12
//@ compile-flags: -Z threads=16
23
//@ build-fail
34

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

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
error: symbol `fail` is already defined
2-
--> $DIR/cache-after-waiting-issue-111528.rs:12:1
2+
--> $DIR/cache-after-waiting-issue-111528.rs:13:1
33
|
44
LL | pub fn b() {
55
| ^^^^^^^^^^
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,74 @@
1+
//@ parallel-front-end
2+
//@ compile-flags: -Z threads=200
3+
4+
#![allow(incomplete_features)]
5+
#![feature(
6+
const_trait_impl,
7+
effects,
8+
)]
9+
10+
use std::marker::Destruct;
11+
12+
const fn cmp(a: &impl ~const PartialEq) -> bool {
13+
//~^ ERROR
14+
a == a
15+
}
16+
17+
const fn wrap(x: impl ~const PartialEq + ~const Destruct)
18+
//~^ ERROR
19+
//~| ERROR
20+
-> impl ~const PartialEq + ~const Destruct
21+
//~^ ERROR
22+
//~| ERROR
23+
//~| ERROR
24+
//~| ERROR
25+
{
26+
x
27+
}
28+
29+
#[const_trait]
30+
trait Foo {
31+
fn foo(&mut self, x: <Self as Index>::Output) -> <Self as Index>::Output;
32+
//~^ ERROR
33+
//~| ERROR
34+
}
35+
36+
impl const Foo for () {
37+
//~^ ERROR
38+
fn huh() -> impl ~const PartialEq + ~const Destruct + Copy {
39+
//~^ ERROR
40+
//~| ERROR
41+
//~| ERROR
42+
//~| ERROR
43+
//~| ERROR
44+
123
45+
}
46+
}
47+
48+
const _: () = {
49+
assert!(cmp(&0xDEADBEEFu32));
50+
assert!(cmp(&()));
51+
assert!(wrap(123) == wrap(123));
52+
assert!(wrap(123) != wrap(456));
53+
let x = <() as Foo>::huh();
54+
//~^ ERROR
55+
assert!(x == x);
56+
};
57+
58+
#[const_trait]
59+
trait T {}
60+
struct S;
61+
impl const T for S {}
62+
63+
const fn rpit() -> impl ~const T { S }
64+
65+
const fn apit(_: impl ~const T + ~const Destruct) {}
66+
//~^ ERROR
67+
//~| ERROR
68+
69+
const fn rpit_assoc_bound() -> impl IntoIterator<Item: ~const T> { Some(S) }
70+
71+
const fn apit_assoc_bound(_: impl IntoIterator<Item: ~const T> + ~From Destruct) {}
72+
//~^ ERROR
73+
74+
fn main() {}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,138 @@
1+
error: expected `const`, found `From`
2+
|
3+
LL | const fn apit_assoc_bound(_: impl IntoIterator<Item: ~const T> + ~From Destruct) {}
4+
| ^^^^ expected `const`
5+
6+
error[E0407]: method `huh` is not a member of trait `Foo`
7+
|
8+
LL | / fn huh() -> impl ~const PartialEq + ~const Destruct + Copy {
9+
LL | | 123
10+
LL | | }
11+
| |_____^ not a member of trait `Foo`
12+
13+
error[E0405]: cannot find trait `Index` in this scope
14+
|
15+
LL | fn foo(&mut self, x: <Self as Index>::Output) -> <Self as Index>::Output;
16+
| ^^^^^ not found in this scope
17+
|
18+
help: consider importing this trait
19+
|
20+
LL + use std::ops::Index;
21+
|
22+
23+
error[E0405]: cannot find trait `Index` in this scope
24+
|
25+
LL | fn foo(&mut self, x: <Self as Index>::Output) -> <Self as Index>::Output;
26+
| ^^^^^ not found in this scope
27+
|
28+
help: consider importing this trait
29+
|
30+
LL + use std::ops::Index;
31+
|
32+
33+
error[E0576]: cannot find method or associated constant `huh` in trait `Foo`
34+
|
35+
LL | fn foo(&mut self, x: <Self as Index>::Output) -> <Self as Index>::Output;
36+
| ------------------------------------------------------------------------- associated function `foo` defined here
37+
...
38+
LL | let x = <() as Foo>::huh();
39+
| ^^^
40+
| |
41+
| not found in `Foo`
42+
| help: maybe you meant this associated function: `foo`
43+
44+
|
45+
|
46+
47+
|
48+
49+
error: using `#![feature(effects)]` without enabling next trait solver globally
50+
|
51+
= note: the next trait solver must be enabled globally for the effects feature to work correctly
52+
= help: use `-Znext-solver` to enable
53+
54+
error: `~const` can only be applied to `#[const_trait]` traits
55+
|
56+
LL | fn huh() -> impl ~const PartialEq + ~const Destruct + Copy {
57+
| ^^^^^^^^^
58+
59+
error: `~const` can only be applied to `#[const_trait]` traits
60+
|
61+
LL | -> impl ~const PartialEq + ~const Destruct
62+
| ^^^^^^^^^
63+
64+
error: `~const` can only be applied to `#[const_trait]` traits
65+
|
66+
LL | const fn cmp(a: &impl ~const PartialEq) -> bool {
67+
| ^^^^^^^^^
68+
69+
error: `~const` can only be applied to `#[const_trait]` traits
70+
|
71+
LL | fn huh() -> impl ~const PartialEq + ~const Destruct + Copy {
72+
| ^^^^^^^^
73+
74+
error: `~const` can only be applied to `#[const_trait]` traits
75+
|
76+
LL | const fn apit(_: impl ~const T + ~const Destruct) {}
77+
| ^^^^^^^^
78+
79+
error: `~const` can only be applied to `#[const_trait]` traits
80+
|
81+
LL | -> impl ~const PartialEq + ~const Destruct
82+
| ^^^^^^^^
83+
84+
error: `~const` can only be applied to `#[const_trait]` traits
85+
|
86+
LL | -> impl ~const PartialEq + ~const Destruct
87+
| ^^^^^^^^^
88+
|
89+
= note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no`
90+
91+
error: `~const` can only be applied to `#[const_trait]` traits
92+
|
93+
LL | -> impl ~const PartialEq + ~const Destruct
94+
| ^^^^^^^^
95+
|
96+
= note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no`
97+
98+
error: `~const` can only be applied to `#[const_trait]` traits
99+
|
100+
LL | fn huh() -> impl ~const PartialEq + ~const Destruct + Copy {
101+
| ^^^^^^^^^
102+
|
103+
= note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no`
104+
105+
error: `~const` can only be applied to `#[const_trait]` traits
106+
|
107+
LL | fn huh() -> impl ~const PartialEq + ~const Destruct + Copy {
108+
| ^^^^^^^^
109+
|
110+
= note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no`
111+
112+
error: `~const` can only be applied to `#[const_trait]` traits
113+
|
114+
LL | const fn wrap(x: impl ~const PartialEq + ~const Destruct)
115+
| ^^^^^^^^^
116+
117+
error: `~const` can only be applied to `#[const_trait]` traits
118+
|
119+
LL | const fn wrap(x: impl ~const PartialEq + ~const Destruct)
120+
| ^^^^^^^^
121+
122+
error[E0046]: not all trait items implemented, missing: `foo`
123+
|
124+
LL | fn foo(&mut self, x: <Self as Index>::Output) -> <Self as Index>::Output;
125+
| ------------------------------------------------------------------------- `foo` from trait
126+
...
127+
LL | impl const Foo for () {
128+
| ^^^^^^^^^^^^^^^^^^^^^ missing `foo` in implementation
129+
130+
error[E0493]: destructor of `impl ~const T + ~const Destruct` cannot be evaluated at compile-time
131+
|
132+
LL | const fn apit(_: impl ~const T + ~const Destruct) {}
133+
| ^ - value is dropped here
134+
| |
135+
| the destructor for this type cannot be evaluated in constant functions
136+
137+
138+
For more information about an error, try `rustc --explain E0046`.

0 commit comments

Comments
 (0)