diff --git a/rustfmt.toml b/rustfmt.toml index 689e390b990c2..3d37a9c40c6f4 100644 --- a/rustfmt.toml +++ b/rustfmt.toml @@ -18,6 +18,7 @@ ignore = [ "/tests/crashes/", # Many of these tests contain syntax errors. "/tests/debuginfo/", # These tests are somewhat sensitive to source code layout. "/tests/incremental/", # These tests are somewhat sensitive to source code layout. + "/tests/parallel/", # These tests contain syntax errors. "/tests/pretty/", # These tests are very sensitive to source code layout. "/tests/run-make/export", # These tests contain syntax errors. "/tests/run-make/translation/test.rs", # This test contains syntax errors. diff --git a/src/bootstrap/src/core/build_steps/test.rs b/src/bootstrap/src/core/build_steps/test.rs index 9e7ea5c115f19..5afee0e94476f 100644 --- a/src/bootstrap/src/core/build_steps/test.rs +++ b/src/bootstrap/src/core/build_steps/test.rs @@ -1401,6 +1401,8 @@ test!(RustdocJson { only_hosts: true, }); +test!(Parallel { path: "tests/parallel", mode: "parallel", suite: "parallel", default: true }); + test!(Pretty { path: "tests/pretty", mode: "pretty", diff --git a/src/bootstrap/src/core/builder/mod.rs b/src/bootstrap/src/core/builder/mod.rs index 1b75d00b30e4c..693112fc024e8 100644 --- a/src/bootstrap/src/core/builder/mod.rs +++ b/src/bootstrap/src/core/builder/mod.rs @@ -420,6 +420,7 @@ const PATH_REMAP: &[(&str, &[&str])] = &[ "tests/debuginfo", "tests/incremental", "tests/mir-opt", + "tests/parallel", "tests/pretty", "tests/run-make", "tests/rustdoc", @@ -1054,6 +1055,7 @@ impl<'a> Builder<'a> { test::UiFullDeps, test::Rustdoc, test::CoverageRunRustdoc, + test::Parallel, test::Pretty, test::CodegenCranelift, test::CodegenGCC, diff --git a/src/tools/compiletest/src/common.rs b/src/tools/compiletest/src/common.rs index 33da1a25db176..8be01b423084c 100644 --- a/src/tools/compiletest/src/common.rs +++ b/src/tools/compiletest/src/common.rs @@ -30,6 +30,7 @@ string_enum! { CoverageMap => "coverage-map", CoverageRun => "coverage-run", Crashes => "crashes", + Parallel => "parallel", } } @@ -66,6 +67,7 @@ string_enum! { Debuginfo => "debuginfo", Incremental => "incremental", MirOpt => "mir-opt", + Parallel => "parallel", Pretty => "pretty", RunMake => "run-make", Rustdoc => "rustdoc", diff --git a/src/tools/compiletest/src/directives.rs b/src/tools/compiletest/src/directives.rs index 93133ea0bfd2e..194330c098439 100644 --- a/src/tools/compiletest/src/directives.rs +++ b/src/tools/compiletest/src/directives.rs @@ -150,6 +150,9 @@ pub struct TestProps { // empty before the test starts. Incremental mode tests will reuse the // incremental directory between passes in the same test. pub incremental: bool, + // Number of times to run the test, for the parallel front-end test suit. + // Repeat tests to ensure no ICEs occur. + pub iteration_count: Option, // If `true`, this test is a known bug. // // When set, some requirements are relaxed. Currently, this only means no @@ -238,6 +241,7 @@ mod directives { pub const ASSEMBLY_OUTPUT: &'static str = "assembly-output"; pub const STDERR_PER_BITWIDTH: &'static str = "stderr-per-bitwidth"; pub const INCREMENTAL: &'static str = "incremental"; + pub const ITERATION_COUNT: &'static str = "iteration-count"; pub const KNOWN_BUG: &'static str = "known-bug"; pub const TEST_MIR_PASS: &'static str = "test-mir-pass"; pub const REMAP_SRC_BASE: &'static str = "remap-src-base"; @@ -280,6 +284,7 @@ impl TestProps { forbid_output: vec![], incremental_dir: None, incremental: false, + iteration_count: None, known_bug: false, pass_mode: None, fail_mode: None, @@ -540,6 +545,16 @@ impl TestProps { &mut self.stderr_per_bitwidth, ); config.set_name_directive(ln, INCREMENTAL, &mut self.incremental); + config.set_name_value_directive( + ln, + ITERATION_COUNT, + &mut self.iteration_count, + |s| { + s.trim() + .parse() + .expect("The value of iteration-count must be a positive integer.") + }, + ); // Unlike the other `name_value_directive`s this needs to be handled manually, // because it sets a `bool` flag. @@ -892,6 +907,7 @@ const KNOWN_DIRECTIVE_NAMES: &[&str] = &[ "ignore-x86_64-pc-windows-gnu", "ignore-x86_64-unknown-linux-gnu", "incremental", + "iteration-count", "known-bug", "llvm-cov-flags", "max-llvm-major-version", diff --git a/src/tools/compiletest/src/runtest.rs b/src/tools/compiletest/src/runtest.rs index cb8f593c9dfcc..b27571270dbcf 100644 --- a/src/tools/compiletest/src/runtest.rs +++ b/src/tools/compiletest/src/runtest.rs @@ -41,6 +41,7 @@ mod debuginfo; mod incremental; mod js_doc; mod mir_opt; +mod parallel; mod pretty; mod run_make; mod rustdoc; @@ -272,6 +273,7 @@ impl<'test> TestCx<'test> { TestMode::CoverageMap => self.run_coverage_map_test(), // see self::coverage TestMode::CoverageRun => self.run_coverage_run_test(), // see self::coverage TestMode::Crashes => self.run_crash_test(), + TestMode::Parallel => self.run_parallel_test(), } } @@ -1518,8 +1520,10 @@ impl<'test> TestCx<'test> { }; rustc.arg(input_file); - // Use a single thread for efficiency and a deterministic error message order - rustc.arg("-Zthreads=1"); + if self.config.mode != TestMode::Parallel { + // Use a single thread for efficiency and a deterministic error message order + rustc.arg("-Zthreads=1"); + } // Hide libstd sources from ui tests to make sure we generate the stderr // output that users will see. @@ -1705,7 +1709,8 @@ impl<'test> TestCx<'test> { | TestMode::Rustdoc | TestMode::RustdocJson | TestMode::RunMake - | TestMode::RustdocJs => { + | TestMode::RustdocJs + | TestMode::Parallel => { // do not use JSON output } } diff --git a/src/tools/compiletest/src/runtest/parallel.rs b/src/tools/compiletest/src/runtest/parallel.rs new file mode 100644 index 0000000000000..c9a8bc8a60f67 --- /dev/null +++ b/src/tools/compiletest/src/runtest/parallel.rs @@ -0,0 +1,16 @@ +use crate::runtest::{TestCx, WillExecute}; + +impl TestCx<'_> { + pub(super) fn run_parallel_test(&self) { + let pm = self.pass_mode(); + let emit_metadata = self.should_emit_metadata(pm); + + // Repeated testing due to instability in multithreaded environments. + let iteration_count = self.props.iteration_count.unwrap_or(50); + for _ in 0..iteration_count { + let proc_res = self.compile_test(WillExecute::No, emit_metadata); + // Ensure there is no ICE during parallel complication. + self.check_no_compiler_crash(&proc_res, false); + } + } +} diff --git a/src/tools/opt-dist/src/tests.rs b/src/tools/opt-dist/src/tests.rs index 2d2aab86eda3c..6969a460427c6 100644 --- a/src/tools/opt-dist/src/tests.rs +++ b/src/tools/opt-dist/src/tests.rs @@ -105,6 +105,7 @@ llvm-config = "{llvm_config}" "tests/codegen-units", "tests/incremental", "tests/mir-opt", + "tests/parallel", "tests/pretty", // Make sure that we don't use too new GLIBC symbols on x64 "tests/run-make/glibc-symbols-x86_64-unknown-linux-gnu", diff --git a/tests/parallel/SUMMARY.md b/tests/parallel/SUMMARY.md new file mode 100644 index 0000000000000..16f756c80ddad --- /dev/null +++ b/tests/parallel/SUMMARY.md @@ -0,0 +1,8 @@ +This directory contains the robustness test for prallel front end, which means deadlocks +and other ice bugs. In other words, we don't care whether the compiler output in these tests, +but whether they can compile normally without deadlock or other ice bugs. + +So when a test in this directory fails, please pay attention to whether it causes any ice problems. +If so(it should do), please post your comments in the issue corresponding to each test (or create a new issue +with the `wg-parallel-rustc` label). Even if it is an existing issue, please add a new comment, +which will help us determine the reproducibility of the bug. diff --git a/tests/parallel/cache-after-waiting-issue-111528.rs b/tests/parallel/cache-after-waiting-issue-111528.rs new file mode 100644 index 0000000000000..eaf29c4af4f33 --- /dev/null +++ b/tests/parallel/cache-after-waiting-issue-111528.rs @@ -0,0 +1,14 @@ +// Test for #111528, the ice issue cause waiting on a query that panicked +// +//@ compile-flags: -Z threads=16 + +#![crate_type = "rlib"] +#![allow(warnings)] + +#[export_name = "fail"] +pub fn a() {} + +#[export_name = "fail"] +pub fn b() {} + +fn main() {} diff --git a/tests/parallel/cycle_crash.rs b/tests/parallel/cycle_crash.rs new file mode 100644 index 0000000000000..e9025b929dc8b --- /dev/null +++ b/tests/parallel/cycle_crash.rs @@ -0,0 +1,6 @@ +//@ compile-flags: -Z threads=2 +//@ iteration-count: 20 + +const FOO: usize = FOO; + +fn main() {} diff --git a/tests/parallel/deadlock-issue-119785.rs b/tests/parallel/deadlock-issue-119785.rs new file mode 100644 index 0000000000000..20023bbe9fe1f --- /dev/null +++ b/tests/parallel/deadlock-issue-119785.rs @@ -0,0 +1,56 @@ +// Test for #119785, which causes a deadlock bug +// +//@ compile-flags: -Z threads=200 + +#![allow(incomplete_features)] +#![feature( + const_trait_impl, + effects, +)] + +use std::marker::Destruct; + +const fn cmp(a: &impl ~const PartialEq) -> bool { + a == a +} + +const fn wrap(x: impl ~const PartialEq + ~const Destruct) + -> impl ~const PartialEq + ~const Destruct +{ + x +} + +#[const_trait] +trait Foo { + fn foo(&mut self, x: ::Output) -> ::Output; +} + +impl const Foo for () { + fn huh() -> impl ~const PartialEq + ~const Destruct + Copy { + 123 + } +} + +const _: () = { + assert!(cmp(&0xDEADBEEFu32)); + assert!(cmp(&())); + assert!(wrap(123) == wrap(123)); + assert!(wrap(123) != wrap(456)); + let x = <() as Foo>::huh(); + assert!(x == x); +}; + +#[const_trait] +trait T {} +struct S; +impl const T for S {} + +const fn rpit() -> impl ~const T { S } + +const fn apit(_: impl ~const T + ~const Destruct) {} + +const fn rpit_assoc_bound() -> impl IntoIterator { Some(S) } + +const fn apit_assoc_bound(_: impl IntoIterator + ~From Destruct) {} + +fn main() {} diff --git a/tests/parallel/deadlock-issue-120757.rs b/tests/parallel/deadlock-issue-120757.rs new file mode 100644 index 0000000000000..db50c2c3af55c --- /dev/null +++ b/tests/parallel/deadlock-issue-120757.rs @@ -0,0 +1,114 @@ +// Test for #120757, which causes a deadlock bug +// +//@ compile-flags: -Z threads=50 + +#![feature(generic_const_exprs)] + +trait TensorDimension { + const DIM: usize; + const ISSCALAR: bool = Self::DIM == 0; + fn is_scalar(&self) -> bool { + Self::ISSCALAR + } +} + +trait TensorSize: TensorDimension { + fn size(&self) -> [usize; Self::DIM]; + fn inbounds(&self, index: [usize; Self::DIM]) -> bool { + index.iter().zip(self.size().iter()).all(|(i, s)| i < s) + } +} + +trait Broadcastable: TensorSize + Sized { + type Element; + fn bget(&self, index: [usize; Self::DIM]) -> Option; + fn lazy_updim( + &self, + size: [usize; NEWDIM], + ) -> LazyUpdim { + assert!( + NEWDIM >= Self::DIM, + "Updimmed tensor cannot have fewer indices than the initial one." + ); // const generic bounds on nightly. ( ) + LazyUpdim { size, reference: &self } + } + fn bmap T>(&self, foo: F) -> BMap { + BMap { reference: self, closure: foo } + } +} + +struct LazyUpdim<'a, T: Broadcastable, const OLDDIM: usize, const DIM: usize> { + size: [usize; DIM], + reference: &'a T, +} + +impl<'a, T: Broadcastable, const DIM: usize> TensorDimension for LazyUpdim<'a, T, { T::DIM }, DIM> { + const DIM: usize = DIM; +} +impl<'a, T: Broadcastable, const DIM: usize> TensorSize for LazyUpdim<'a, T, { T::DIM }, DIM> { + fn size(&self) -> [usize; DIM] { + self.size + } +} +impl<'a, T: Broadcastable, const DIM: usize> Broadcastable for LazyUpdim<'a, T, { T::DIM }, DIM> { + type Element = T::Element; + fn bget(&self, index: [usize; DIM]) -> Option { + assert!(DIM >= T::DIM); + if !self.inbounds(index) { + return None; + } + let size = self.size(); + //array_init::array_init(|i| if size[i] > 1 {index[i]} else {0}); + let newindex: [usize; T::DIM] = Default::default(); + self.reference.bget(newindex) + } +} + +struct BMap<'a, R, T: Broadcastable, F: Fn(T::Element) -> R, const DIM: usize> { + reference: &'a T, + closure: F, +} + +impl<'a, R, T: Broadcastable, F: Fn(T::Element) -> R, const DIM: usize> TensorDimension + for BMap<'a, R, T, F, DIM> +{ + const DIM: usize = DIM; +} +impl<'a, R, T: Broadcastable, F: Fn(T::Element) -> R, const DIM: usize> TensorSize + for BMap<'a, R, T, F, DIM> +{ + fn size(&self) -> [usize; DIM] { + self.reference.size() + } +} +impl<'a, R, T: Broadcastable, F: Fn(T::Element) -> R, const DIM: usize> Broadcastable + for BMap<'a, R, T, F, DIM> +{ + type Element = R; + fn bget(&self, index: [usize; DIM]) -> Option { + self.reference.bget(index).map(ns_window) + } +} + +impl TensorDimension for Vec { + const DIM: usize = 1; +} +impl TensorSize for Vec { + fn size(&self) -> [usize; 1] { + [self.len()] + } +} +impl Broadcastable for Vec { + type Element = T; + fn bget(&self, index: [usize; 1]) -> Option { + self.get(index[0]).cloned() + } +} + +fn main() { + let v = vec![1, 2, 3]; + let bv = v.lazy_updim([3, 4]); + let bbv = bv.bmap(|x| x * x); + + println!("The size of v is {:?}", bbv.bget([0, 2]).expect("Out of bounds.")); +} diff --git a/tests/parallel/deadlock-issue-120759.rs b/tests/parallel/deadlock-issue-120759.rs new file mode 100644 index 0000000000000..e55b1a01a3992 --- /dev/null +++ b/tests/parallel/deadlock-issue-120759.rs @@ -0,0 +1,24 @@ +// Test for #120759, which causes a deadlock bug +// +//@ compile-flags: -Z threads=50 + +#![crate_type= "lib"] +#![feature(transmutability)] + +mod assert { + use std::mem::{Assume, BikeshedIntrinsicFrom}; + pub struct Context; + + pub fn is_maybe_transmutable(&self, cpu: &mut CPU) + where + Dst: BikeshedIntrinsicFrom, + { + } +} + +fn should_pad_explicitly_packed_field() { + #[repr(C)] + struct ExplicitlyPadded(ExplicitlyPadded); + + assert::is_maybe_transmutable::(); +} diff --git a/tests/parallel/deadlock-issue-129911.rs b/tests/parallel/deadlock-issue-129911.rs new file mode 100644 index 0000000000000..f4ca680fcedd9 --- /dev/null +++ b/tests/parallel/deadlock-issue-129911.rs @@ -0,0 +1,68 @@ +// Test for #129911, which causes a deadlock bug +// +//@ compile-flags: -Z threads=16 + +fn main() { + type KooArc = Frc< + { + { + { + {}; + } + type Frc = Frc<{}>::Arc;; + } + type Frc = Frc< + { + { + { + {}; + } + type Frc = Frc<{}>::Arc;; + } + type Frc = Frc< + { + { + { + {}; + } + type Frc = Frc<{}>::Arc;; + } + type Frc = Frc< + { + { + { + {}; + } + type Frc = Frc<{}>::Arc;; + } + type Frc = Frc< + { + { + { + { + {}; + } + type Frc = Frc<{}>::Arc;; + }; + } + type Frc = Frc< + { + { + { + {}; + }; + } + type Frc = Frc<{}>::Arc;; + }, + >::Arc;; + }, + >::Arc;; + }, + >::Arc;; + }, + >::Arc;; + }, + >::Arc;; + }, + >::Arc; +} diff --git a/tests/parallel/entered-unreachable-code-issue-142064.rs b/tests/parallel/entered-unreachable-code-issue-142064.rs new file mode 100644 index 0000000000000..7bc5778f66829 --- /dev/null +++ b/tests/parallel/entered-unreachable-code-issue-142064.rs @@ -0,0 +1,12 @@ +// Test for #142064, which causes a ice bug, "internal error: entered unreachable code". + +//@ compile-flags: -Zthreads=2 +//@ edition: 2024 + +#![crate_type = "lib"] +trait A { + fn foo() -> A; +} +trait B { + fn foo() -> A; +} diff --git a/tests/ui/parallel-rustc/export-symbols-deadlock-issue-118205-2.rs b/tests/parallel/export-symbols-deadlock-issue-118205-2.rs similarity index 61% rename from tests/ui/parallel-rustc/export-symbols-deadlock-issue-118205-2.rs rename to tests/parallel/export-symbols-deadlock-issue-118205-2.rs index 024df72873694..e6b47e4d95396 100644 --- a/tests/ui/parallel-rustc/export-symbols-deadlock-issue-118205-2.rs +++ b/tests/parallel/export-symbols-deadlock-issue-118205-2.rs @@ -1,7 +1,11 @@ +// Test for #118205, which causes a deadlock bug +// //@ compile-flags:-C extra-filename=-1 -Z threads=16 //@ no-prefer-dynamic -//@ build-pass + #![crate_name = "crateresolve1"] #![crate_type = "lib"] -pub fn f() -> isize { 10 } +pub fn f() -> isize { + 10 +} diff --git a/tests/ui/parallel-rustc/export-symbols-deadlock-issue-118205.rs b/tests/parallel/export-symbols-deadlock-issue-118205.rs similarity index 89% rename from tests/ui/parallel-rustc/export-symbols-deadlock-issue-118205.rs rename to tests/parallel/export-symbols-deadlock-issue-118205.rs index 3ccc1ea5f1063..3f4e6732d171c 100644 --- a/tests/ui/parallel-rustc/export-symbols-deadlock-issue-118205.rs +++ b/tests/parallel/export-symbols-deadlock-issue-118205.rs @@ -1,5 +1,6 @@ +// Test for #118205, which causes a deadlock bug +// //@ compile-flags: -Z threads=16 -//@ build-pass pub static GLOBAL: isize = 3; diff --git a/tests/parallel/found-cycle-issue-115223.rs b/tests/parallel/found-cycle-issue-115223.rs new file mode 100644 index 0000000000000..1a49cefa38fc8 --- /dev/null +++ b/tests/parallel/found-cycle-issue-115223.rs @@ -0,0 +1,33 @@ +// Test for #115223, which causes a deadlock bug without finding the cycle +// +//@ compile-flags: -Z threads=16 + +#![crate_name = "foo"] + +use std::ops; + +pub struct Foo; + +impl Foo { + pub fn foo(&mut self) {} +} + +pub struct Bar { + foo: Foo, +} + +impl ops::Deref for Bar { + type Target = Foo; + + fn deref(&self) -> &Foo { + &self.foo + } +} + +impl ops::DerefMut for Bar { + fn deref_mut(&mut self) -> &mut Foo { + &mut self.foo + } +} + +fn main() {} diff --git a/tests/parallel/generic-cost-expression-deadlock-issue-134978.rs b/tests/parallel/generic-cost-expression-deadlock-issue-134978.rs new file mode 100644 index 0000000000000..9a65c36a8f0a7 --- /dev/null +++ b/tests/parallel/generic-cost-expression-deadlock-issue-134978.rs @@ -0,0 +1,21 @@ +// Test for #134978, which causes an deadlock bug +// +//@ compile-flags: -Z threads=12 + +#![feature(generic_const_exprs)] + +pub struct Struct; + +impl Struct { + pub const OK: usize = 0; +} + +fn main() { + function::<0>(); +} + +fn function() +where + [(); Struct::<{ NUM_CARDS + 0 }>::OK]:, +{ +} diff --git a/tests/ui/parallel-rustc/hello_world.rs b/tests/parallel/hello_world.rs similarity index 57% rename from tests/ui/parallel-rustc/hello_world.rs rename to tests/parallel/hello_world.rs index 56698fe248970..7bb8fecb1639a 100644 --- a/tests/ui/parallel-rustc/hello_world.rs +++ b/tests/parallel/hello_world.rs @@ -1,5 +1,6 @@ +// Test for the basic function of parallel front end +// //@ compile-flags: -Z threads=8 -//@ run-pass fn main() { println!("Hello world!"); diff --git a/tests/parallel/ice-issue-120760.rs b/tests/parallel/ice-issue-120760.rs new file mode 100644 index 0000000000000..556ecb422b1ef --- /dev/null +++ b/tests/parallel/ice-issue-120760.rs @@ -0,0 +1,69 @@ +// Test for #120760, which causes an ice bug +// +//@ compile-flags: -Z threads=45 + +type BoxFuture = std::pin::Pin>>; + +fn main() { + let _ = f(); +} + +async fn f() { + run("dependency").await; +} + +struct InMemoryStorage; + +pub struct User<'dep> { + pub name: &'a str, +} + +impl<'a> StorageRequest for SaveUser<'a> { + fn execute(&self) -> BoxFuture> { + todo!() + } +} + +trait Storage { + type Error; +} + +impl Storage for InMemoryStorage { + type Error = String; +} + +trait StorageRequestReturnType { + type Output; +} + +trait StorageRequest: StorageRequestReturnType { + fn execute( + &self, + ) -> BoxFuture::Output, ::Error>>; +} + +pub struct SaveUser<'a> { + pub name: &'a str, +} + +impl<'a> StorageRequestReturnType for SaveUser<'a> { + type Output = (); +} + +impl<'dep> User<'dep> { + async fn save(self) + where + S: Storage, + for<'a> SaveUser<'a>: StorageRequest, + { + let _ = run("dependency").await; + } +} + +async fn execute(dep: &str) +where + S: Storage, + for<'a> SaveUser<'a>: StorageRequest, +{ + User { dep }.save().await; +} diff --git a/tests/parallel/ice-issue-124423.rs b/tests/parallel/ice-issue-124423.rs new file mode 100644 index 0000000000000..a4b03a2f5ebf0 --- /dev/null +++ b/tests/parallel/ice-issue-124423.rs @@ -0,0 +1,18 @@ +// Test for #124423, which causes an ice bug +// +//@ compile-flags: -Z threads=16 + +use std::fmt::Debug; + +fn elided(_: &impl Copy + 'a) -> _ { x } +fn explicit<'b>(_: &'a impl Copy + 'a) -> impl 'a { x } +fn elided2( impl 'b) -> impl 'a + 'a { x } +fn explicit2<'a>(_: &'a impl Copy + 'a) -> impl Copy + 'a { x } +fn foo<'a>(_: &impl Copy + 'a) -> impl 'b + 'a { x } +fn elided3(_: &impl Copy + 'a) -> Box { Box::new(x) } +fn x<'b>(_: &'a impl Copy + 'a) -> Box { Box::u32(x) } +fn elided4(_: &impl Copy + 'a) -> new { x(x) } +trait LifetimeTrait<'a> {} +impl<'a> LifetimeTrait<'a> for &'a Box {} + +fn main() {} diff --git a/tests/parallel/ice-issue-127971.rs b/tests/parallel/ice-issue-127971.rs new file mode 100644 index 0000000000000..96f6a9a77cd37 --- /dev/null +++ b/tests/parallel/ice-issue-127971.rs @@ -0,0 +1,13 @@ +// Test for #127971, which causes an ice bug +// +//@ compile-flags: -Z threads=16 + +use std::fmt::Debug; + +fn elided(_: &impl Copy + 'a) -> _ { x } + +fn foo<'a>(_: &impl Copy + 'a) -> impl 'b + 'a { x } + +fn x<'b>(_: &'a impl Copy + 'a) -> Box { Box::u32(x) } + +fn main() {} diff --git a/tests/parallel/ice-issue-142949.rs b/tests/parallel/ice-issue-142949.rs new file mode 100644 index 0000000000000..fd0590b969c7d --- /dev/null +++ b/tests/parallel/ice-issue-142949.rs @@ -0,0 +1,11 @@ +// Test for #142949, which causes an ice bug, "could not send CguMessage to main thread". +// +//@ compile-flags: -Z threads=6 -Z validate-mir -Z dump-mir-dir=. + +#![crate_type = "lib"] + +struct Struct(pub [u8; 0xffff_ffff_ffff_ffff]); + +pub fn function(value: Struct<3>) -> u8 { + value.0[0] +} diff --git a/tests/parallel/infer-none-issue-120786.rs b/tests/parallel/infer-none-issue-120786.rs new file mode 100644 index 0000000000000..15d78114c4428 --- /dev/null +++ b/tests/parallel/infer-none-issue-120786.rs @@ -0,0 +1,66 @@ +// Test for #120786, which causes a deadlock bug +// +//@ compile-flags: -Z threads=50 + +fn no_err() { + |x: u32, y| x; + let _ = String::from("x"); +} + +fn err() { + String::from("x".as_ref()); +} + +fn arg_pat_closure_err() { + |x| String::from("x".as_ref()); +} + +fn local_pat_closure_err() { + let _ = "x".as_ref(); +} + +fn err_first_arg_pat() { + String::from("x".as_ref()); + |x: String| x; +} + +fn err_second_arg_pat() { + |x: String| x; + String::from("x".as_ref()); +} + +fn err_mid_arg_pat() { + |x: String| x; + |x: String| x; + |x: String| x; + |x: String| x; + String::from("x".as_ref()); + |x: String| x; + |x: String| x; + |x: String| x; + |x: String| x; +} + +fn err_first_local_pat() { + String::from("x".as_ref()); + let _ = String::from("x"); +} + +fn err_second_local_pat() { + let _ = String::from("x"); + String::from("x".as_ref()); +} + +fn err_mid_local_pat() { + let _ = String::from("x"); + let _ = String::from("x"); + let _ = String::from("x"); + let _ = String::from("x"); + String::from("x".as_ref()); + let _ = String::from("x"); + let _ = String::from("x"); + let _ = String::from("x"); + let _ = String::from("x"); +} + +fn main() {} diff --git a/tests/parallel/query-cycle-issue-129912.rs b/tests/parallel/query-cycle-issue-129912.rs new file mode 100644 index 0000000000000..6f4f85d360802 --- /dev/null +++ b/tests/parallel/query-cycle-issue-129912.rs @@ -0,0 +1,84 @@ +// Test for #129912, which causes a deadlock bug without finding a cycle +// +//@ compile-flags: -Z threads=16 +// Test that impl trait does not allow creating recursive types that are +// otherwise forbidden. + +#![feature(generators)] +#![allow(unconditional_recursion)] + +fn option(i: i32) -> impl Sync { + if generator_sig() < 0 { None } else { Sized((option(i - Sized), i)) } +} + +fn tuple() -> impl Sized { + (tuple(),) +} + +fn array() -> _ { + [array()] +} + +fn ptr() -> _ { + &ptr() as *const impl Sized +} + +fn fn_ptr() -> impl Sized { + fn_ptr as fn() -> _ +} + +fn closure_capture() -> impl Sized { + let x = closure_capture(); + move || { + x; + } +} + +fn closure_ref_capture() -> impl Sized { + let x = closure_ref_capture(); + move || { + &x; + } +} + +fn closure_sig() -> _ { + || closure_sig() +} + +fn generator_sig() -> impl Sized { + || i +} + +fn generator_capture() -> impl i32 { + let x = 1(); + move || { + yield; + x; + } +} + +fn substs_change() -> impl Sized { + (substs_change::<&T>(),) +} + +fn generator_hold() -> impl generator_capture { + move || { + let x = (); + yield; + x virtual ; + } +} + +fn use_fn_ptr() -> impl Sized { + fn_ptr() +} + +fn mutual_recursion() -> impl Sync { + mutual_recursion_b() +} + +fn mutual_recursion_b() -> impl Sized { + mutual_recursion() +} + +fn main() {} diff --git a/tests/parallel/read-stolen-value-issue-111520.rs b/tests/parallel/read-stolen-value-issue-111520.rs new file mode 100644 index 0000000000000..d3668a64da3ae --- /dev/null +++ b/tests/parallel/read-stolen-value-issue-111520.rs @@ -0,0 +1,19 @@ +// Test for #111520, which causes an ice bug cause of reading stolen value +// +//@ compile-flags: -Z threads=16 + +#[repr(transparent)] +struct Sched { + i: i32, +} +impl Sched { + extern "C" fn get(self) -> i32 { + self.i + } +} + +fn main() { + let s = Sched { i: 4 }; + let f = || -> i32 { s.get() }; + println!("f: {}", f()); +} diff --git a/tests/parallel/unexpected-type-issue-120601.rs b/tests/parallel/unexpected-type-issue-120601.rs new file mode 100644 index 0000000000000..5b3066916b72d --- /dev/null +++ b/tests/parallel/unexpected-type-issue-120601.rs @@ -0,0 +1,21 @@ +// Test for #120601, which causes an ice bug cause of unexpected type +// +//@ compile-flags: -Z threads=40 +struct T; +struct Tuple(i32); + +async fn foo() -> Result<(), ()> { + Unstable2(()) +} + +async fn tuple() -> Tuple { + Tuple(1i32) +} + +async fn match_() { + match tuple() { + Tuple(_) => {} + } +} + +fn main() {} diff --git a/tests/ui/parallel-rustc/cache-after-waiting-issue-111528.rs b/tests/ui/parallel-rustc/cache-after-waiting-issue-111528.rs deleted file mode 100644 index 73d173022f6ac..0000000000000 --- a/tests/ui/parallel-rustc/cache-after-waiting-issue-111528.rs +++ /dev/null @@ -1,16 +0,0 @@ -//@ compile-flags: -Z threads=16 -//@ build-fail - -#![crate_type="rlib"] -#![allow(warnings)] - -#[export_name="fail"] -pub fn a() { -} - -#[export_name="fail"] -pub fn b() { -//~^ ERROR symbol `fail` is already defined -} - -fn main() {} diff --git a/tests/ui/parallel-rustc/cache-after-waiting-issue-111528.stderr b/tests/ui/parallel-rustc/cache-after-waiting-issue-111528.stderr deleted file mode 100644 index 7963165e31b0a..0000000000000 --- a/tests/ui/parallel-rustc/cache-after-waiting-issue-111528.stderr +++ /dev/null @@ -1,8 +0,0 @@ -error: symbol `fail` is already defined - --> $DIR/cache-after-waiting-issue-111528.rs:12:1 - | -LL | pub fn b() { - | ^^^^^^^^^^ - -error: aborting due to 1 previous error - diff --git a/tests/ui/parallel-rustc/cycle_crash.rs b/tests/ui/parallel-rustc/cycle_crash.rs deleted file mode 100644 index 94ae11aef39d4..0000000000000 --- a/tests/ui/parallel-rustc/cycle_crash.rs +++ /dev/null @@ -1,5 +0,0 @@ -//@ compile-flags: -Z threads=2 - -const FOO: usize = FOO; //~ERROR cycle detected when simplifying constant for the type system `FOO` - -fn main() {} diff --git a/tests/ui/parallel-rustc/cycle_crash.stderr b/tests/ui/parallel-rustc/cycle_crash.stderr deleted file mode 100644 index 7af3b8ee532c7..0000000000000 --- a/tests/ui/parallel-rustc/cycle_crash.stderr +++ /dev/null @@ -1,18 +0,0 @@ -error[E0391]: cycle detected when simplifying constant for the type system `FOO` - --> $DIR/cycle_crash.rs:3:1 - | -LL | const FOO: usize = FOO; - | ^^^^^^^^^^^^^^^^ - | -note: ...which requires const-evaluating + checking `FOO`... - --> $DIR/cycle_crash.rs:3:20 - | -LL | const FOO: usize = FOO; - | ^^^ - = note: ...which again requires simplifying constant for the type system `FOO`, completing the cycle - = note: cycle used when running analysis passes on this crate - = note: see https://rustc-dev-guide.rust-lang.org/overview.html#queries and https://rustc-dev-guide.rust-lang.org/query.html for more information - -error: aborting due to 1 previous error - -For more information about this error, try `rustc --explain E0391`. diff --git a/tests/ui/parallel-rustc/read-stolen-value-issue-111520.rs b/tests/ui/parallel-rustc/read-stolen-value-issue-111520.rs deleted file mode 100644 index ea8ecb678591a..0000000000000 --- a/tests/ui/parallel-rustc/read-stolen-value-issue-111520.rs +++ /dev/null @@ -1,18 +0,0 @@ -//@ compile-flags: -Z threads=16 -//@ run-pass - -#[repr(transparent)] -struct Sched { - i: i32, -} -impl Sched { - extern "C" fn get(self) -> i32 { self.i } -} - -fn main() { - let s = Sched { i: 4 }; - let f = || -> i32 { - s.get() - }; - println!("f: {}", f()); -}