Skip to content

Add more tests for the parallel rustc #145384

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions src/doc/rustc-dev-guide/src/tests/directives.md
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,7 @@ for more details.
| `forbid-output` | A pattern which must not appear in stderr/`cfail` output | `ui`, `incremental` | Regex pattern |
| `run-flags` | Flags passed to the test executable | `ui` | Arbitrary flags |
| `known-bug` | No error annotation needed due to known bug | `ui`, `crashes`, `incremental` | Issue number `#123456` |
| `compare-output-by-lines` | Compare the output by lines, rather than as a single string | All | N/A |

[^check_stdout]: presently <!-- date-check: Oct 2024 --> this has a weird quirk
where the test binary's stdout and stderr gets concatenated and then
Expand Down
1 change: 1 addition & 0 deletions src/doc/rustc-dev-guide/src/tests/ui.md
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,7 @@ will check for output files:
[Normalization](#normalization)).
- `dont-check-compiler-stderr` — Ignores stderr from the compiler.
- `dont-check-compiler-stdout` — Ignores stdout from the compiler.
- `compare-output-by-lines` — Some tests have non-deterministic orders of output, so we need to compare by lines.

UI tests run with `-Zdeduplicate-diagnostics=no` flag which disables rustc's
built-in diagnostic deduplication mechanism. This means you may see some
Expand Down
9 changes: 9 additions & 0 deletions src/tools/compiletest/src/directives.rs
Original file line number Diff line number Diff line change
Expand Up @@ -205,6 +205,8 @@ pub struct TestProps {
pub dont_require_annotations: HashSet<ErrorKind>,
/// Whether pretty printers should be disabled in gdb.
pub disable_gdb_pretty_printers: bool,
/// Compare the output by lines, rather than as a single string.
pub compare_output_by_lines: bool,
}

mod directives {
Expand Down Expand Up @@ -254,6 +256,7 @@ mod directives {
// This isn't a real directive, just one that is probably mistyped often
pub const INCORRECT_COMPILER_FLAGS: &'static str = "compiler-flags";
pub const DISABLE_GDB_PRETTY_PRINTERS: &'static str = "disable-gdb-pretty-printers";
pub const COMPARE_OUTPUT_BY_LINES: &'static str = "compare-output-by-lines";
}

impl TestProps {
Expand Down Expand Up @@ -310,6 +313,7 @@ impl TestProps {
add_core_stubs: false,
dont_require_annotations: Default::default(),
disable_gdb_pretty_printers: false,
compare_output_by_lines: false,
}
}

Expand Down Expand Up @@ -664,6 +668,11 @@ impl TestProps {
DISABLE_GDB_PRETTY_PRINTERS,
&mut self.disable_gdb_pretty_printers,
);
config.set_name_directive(
ln,
COMPARE_OUTPUT_BY_LINES,
&mut self.compare_output_by_lines,
);
},
);

Expand Down
1 change: 1 addition & 0 deletions src/tools/compiletest/src/directives/directive_names.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ pub(crate) const KNOWN_DIRECTIVE_NAMES: &[&str] = &[
"check-run-results",
"check-stdout",
"check-test-line-numbers-match",
"compare-output-by-lines",
"compile-flags",
"disable-gdb-pretty-printers",
"doc-flags",
Expand Down
6 changes: 5 additions & 1 deletion src/tools/compiletest/src/runtest.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2749,7 +2749,11 @@ impl<'test> TestCx<'test> {
// Wrapper tools set by `runner` might provide extra output on failure,
// for example a WebAssembly runtime might print the stack trace of an
// `unreachable` instruction by default.
let compare_output_by_lines = self.config.runner.is_some();
//
// Also, some tests like `ui/parallel-rustc` have non-deterministic
// orders of output, so we need to compare by lines.
let compare_output_by_lines =
self.props.compare_output_by_lines || self.config.runner.is_some();

let tmp;
let (expected, actual): (&str, &str) = if compare_output_by_lines {
Expand Down
14 changes: 8 additions & 6 deletions tests/ui/parallel-rustc/cache-after-waiting-issue-111528.rs
Original file line number Diff line number Diff line change
@@ -1,16 +1,18 @@
// Test for #111528, the ice issue cause waiting on a query that panicked
//
//@ compile-flags: -Z threads=16
//@ build-fail
//@ compare-output-by-lines

#![crate_type="rlib"]
#![crate_type = "rlib"]
#![allow(warnings)]

#[export_name="fail"]
pub fn a() {
}
#[export_name = "fail"]
pub fn a() {}

#[export_name="fail"]
#[export_name = "fail"]
pub fn b() {
//~^ ERROR symbol `fail` is already defined
//~^ ERROR symbol `fail` is already defined
}

fn main() {}
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
error: symbol `fail` is already defined
--> $DIR/cache-after-waiting-issue-111528.rs:12:1
--> $DIR/cache-after-waiting-issue-111528.rs:14:1
|
LL | pub fn b() {
| ^^^^^^^^^^
Expand Down
8 changes: 8 additions & 0 deletions tests/ui/parallel-rustc/cycle_crash-issue-135870.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
// Test for #135870, which causes a deadlock bug
//
//@ compile-flags: -Z threads=2
//@ compare-output-by-lines

const FOO: usize = FOO; //~ ERROR cycle detected when simplifying constant for the type system `FOO`

fn main() {}
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
error[E0391]: cycle detected when simplifying constant for the type system `FOO`
--> $DIR/cycle_crash.rs:3:1
--> $DIR/cycle_crash-issue-135870.rs:6:1
|
LL | const FOO: usize = FOO;
| ^^^^^^^^^^^^^^^^
|
note: ...which requires const-evaluating + checking `FOO`...
--> $DIR/cycle_crash.rs:3:20
--> $DIR/cycle_crash-issue-135870.rs:6:20
|
LL | const FOO: usize = FOO;
| ^^^
Expand Down
5 changes: 0 additions & 5 deletions tests/ui/parallel-rustc/cycle_crash.rs

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
// Test for #118205, which causes a deadlock bug
//
//@ compile-flags:-C extra-filename=-1 -Z threads=16
//@ no-prefer-dynamic
//@ build-pass
//@ compare-output-by-lines

#![crate_name = "crateresolve1"]
#![crate_type = "lib"]

Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
// Test for #118205, which causes a deadlock bug
//
//@ compile-flags: -Z threads=16
//@ build-pass
//@ compare-output-by-lines

pub static GLOBAL: isize = 3;

Expand Down
3 changes: 3 additions & 0 deletions tests/ui/parallel-rustc/hello_world.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
// Test for the basic function of parallel front end
//
//@ compile-flags: -Z threads=8
//@ run-pass
//@ compare-output-by-lines

fn main() {
println!("Hello world!");
Expand Down
11 changes: 7 additions & 4 deletions tests/ui/parallel-rustc/read-stolen-value-issue-111520.rs
Original file line number Diff line number Diff line change
@@ -1,18 +1,21 @@
// Test for #111520, which causes an ice bug cause of reading stolen value
//
//@ compile-flags: -Z threads=16
//@ run-pass
//@ compare-output-by-lines

#[repr(transparent)]
struct Sched {
i: i32,
}
impl Sched {
extern "C" fn get(self) -> i32 { self.i }
extern "C" fn get(self) -> i32 {
self.i
}
}

fn main() {
let s = Sched { i: 4 };
let f = || -> i32 {
s.get()
};
let f = || -> i32 { s.get() };
println!("f: {}", f());
}
58 changes: 58 additions & 0 deletions tests/ui/parallel-rustc/ty-variance-issue-124423.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
// Test for #124423, which causes an ice bug: only `variances_of` returns `&[ty::Variance]`
//
//@ compile-flags: -Z threads=16
//@ compare-output-by-lines

use std::fmt::Debug;

fn elided(_: &impl Copy + 'a) -> _ { x }
//~^ ERROR ambiguous `+` in a type
//~| ERROR use of undeclared lifetime name `'a`
//~| ERROR the placeholder `_` is not allowed within types on item signatures for return types

fn explicit<'b>(_: &'a impl Copy + 'a) -> impl 'a { x }
//~^ ERROR ambiguous `+` in a type
//~| ERROR at least one trait must be specified
//~| ERROR use of undeclared lifetime name `'a`
//~| ERROR use of undeclared lifetime name `'a`
//~| ERROR use of undeclared lifetime name `'a`

fn elided2( impl 'b) -> impl 'a + 'a { x }
//~^ ERROR expected one of `:` or `|`, found `'b`
//~| ERROR expected identifier, found keyword `impl`
//~| ERROR at least one trait must be specified
//~| ERROR use of undeclared lifetime name `'a`
//~| ERROR use of undeclared lifetime name `'a`

fn explicit2<'a>(_: &'a impl Copy + 'a) -> impl Copy + 'a { x }
//~^ ERROR ambiguous `+` in a type

fn foo<'a>(_: &impl Copy + 'a) -> impl 'b + 'a { x }
//~^ ERROR ambiguous `+` in a type
//~| ERROR at least one trait must be specified
//~| ERROR use of undeclared lifetime name `'b`

fn elided3(_: &impl Copy + 'a) -> Box<dyn 'a> { Box::new(x) }
//~^ ERROR ambiguous `+` in a type
//~| ERROR use of undeclared lifetime name `'a`
//~| ERROR use of undeclared lifetime name `'a`
//~| ERROR at least one trait is required for an object type

fn x<'b>(_: &'a impl Copy + 'a) -> Box<dyn 'b> { Box::u32(x) }
//~^ ERROR ambiguous `+` in a type
//~| ERROR use of undeclared lifetime name `'a`
//~| ERROR use of undeclared lifetime name `'a`
//~| ERROR at least one trait is required for an object type
//~| ERROR no function or associated item named `u32` found for struct `Box<_, _>` in the current scope

fn elided4(_: &impl Copy + 'a) -> new { x(x) }
//~^ ERROR ambiguous `+` in a type
//~| ERROR use of undeclared lifetime name `'a`
//~| ERROR cannot find type `new` in this scope

trait LifetimeTrait<'a> {}

impl<'a> LifetimeTrait<'a> for &'a Box<dyn 'a> {}
//~^ ERROR at least one trait is required for an object type

fn main() {}
Loading
Loading